Skip to content

Commit ab6e5a9

Browse files
committed
worked on const correctness
1 parent 2c2f4a1 commit ab6e5a9

12 files changed

+45
-43
lines changed

src/FoLiA-2text.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ UnicodeString handle_token_tag( const folia::FoliaElement *d,
6969
return tmp_result;
7070
}
7171

72-
int main( int argc, char *argv[] ){
72+
int main( int argc, const char *argv[] ){
7373
TiCC::CL_Options opts( "hVvpe:t:o:c:",
7474
"class:,help,version,retaintok,threads:,"
7575
"restore-formatting,"

src/FoLiA-abby.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ UnicodeString get_line( xmlNode *line ){
244244
}
245245

246246
void update_formatting_info( formatting_info& line_font,
247-
xmlNode *node,
247+
const xmlNode *node,
248248
const map<string,formatting_info>& font_styles ){
249249
auto att_vals = TiCC::getAttributes( node );
250250
string style = att_vals["style"];
@@ -707,7 +707,7 @@ map<string,formatting_info> extract_formatting_info( xmlNode *root ){
707707
main_font_styles[pid] = mf_id;
708708
list<xmlNode*> font_styles =
709709
TiCC::FindNodes( ps, ".//*:fontStyle" );
710-
for ( const auto& fst : font_styles ){
710+
for ( const auto *fst : font_styles ){
711711
auto att_vals = TiCC::getAttributes( fst );
712712
string lang_val = att_vals["lang"];
713713
string id_val = att_vals["id"];
@@ -786,7 +786,7 @@ bool convert_abbyxml( const string& fileName,
786786
args["xml:id"] = docid + ".text";
787787
folia::Text *text = doc.setTextRoot( args );
788788
args.extract("xml:id");
789-
folia::processor *proc = add_provenance( doc, processor_name, command );
789+
const folia::processor *proc = add_provenance( doc, processor_name, command );
790790
processor_id = proc->id();
791791
args["processor"] = processor_id;
792792
doc.declare( folia::AnnotationType::PARAGRAPH, setname, args );
@@ -860,7 +860,7 @@ void usage(){
860860
cerr << "\t-V or --version\t show version " << endl;
861861
}
862862

863-
int main( int argc, char *argv[] ){
863+
int main( int argc, const char *argv[] ){
864864
TiCC::CL_Options opts( "vVt:O:hC:S:",
865865
"compress:,class:,setname:,help,version,prefix:,"
866866
"addbreaks,addmetrics,keephyphens,threads:" );

src/FoLiA-alto.cxx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void docCache::add( const string& dir, const string& f ){
111111
}
112112

113113
void docCache::fill( const string& alto_cache, const list<xmlNode*>& blocks ){
114-
for ( const auto& it : blocks ){
114+
for ( const auto *it : blocks ){
115115
string alt = TiCC::getAttribute( it, "alto" );
116116
if ( !alt.empty() ){
117117
add( alto_cache, alt );
@@ -267,14 +267,14 @@ void addStr( folia::Paragraph *par, UnicodeString& txt,
267267
}
268268

269269
void createFile( folia::FoliaElement *text,
270-
xmlDoc *alt_doc,
270+
const xmlDoc *alt_doc,
271271
const string& altoFile,
272272
const list<xmlNode*>& textblocks,
273273
bool do_strings ){
274-
xmlNode *root = xmlDocGetRootElement( alt_doc );
275-
xmlNode *keepPart1 = 0;
274+
const xmlNode *root = xmlDocGetRootElement( alt_doc );
275+
const xmlNode *keepPart1 = 0;
276276
set<string> ids;
277-
for ( const auto& block : textblocks ){
277+
for ( const auto *block : textblocks ){
278278
string id = TiCC::getAttribute( block, "ID" );
279279
if ( ids.find(id) != ids.end() ){
280280
if ( verbose ){
@@ -415,7 +415,7 @@ void processBlocks( folia::FoliaElement *text,
415415
bool do_strings ){
416416
for ( const auto& it : blocks ){
417417
string alt = TiCC::getAttribute( it, "alto" );
418-
xmlDoc *alt_doc = cache.find( alt );
418+
const xmlDoc *alt_doc = cache.find( alt );
419419
if ( alt_doc ){
420420
list<xmlNode*> texts = TiCC::FindNodes( it, "dcx:TextBlock" );
421421
createFile( text, alt_doc, alt, texts, do_strings );
@@ -464,7 +464,7 @@ void processArticle( const string& f,
464464
}
465465
outName += docid + ".folia.xml";
466466
folia::Document doc( "xml:id='" + docid + "'" );
467-
folia::processor *proc = add_provenance( doc, "FoLiA-alto", command );
467+
const folia::processor *proc = add_provenance( doc, "FoLiA-alto", command );
468468
processor_id = proc->id();
469469
folia::KWargs args;
470470
args["processor"] = processor_id;
@@ -572,7 +572,7 @@ bool download( const string& alto_cache,
572572
}
573573
}
574574
unordered_map<string,string> ref_file_map;
575-
for ( const auto& res : resources ){
575+
for ( const auto *res : resources ){
576576
string ref = TiCC::getAttribute( res, "ref" );
577577
if ( ref.find( ":alto" ) != string::npos ){
578578
string id;
@@ -832,7 +832,7 @@ void solveArtAlto( const string& alto_cache,
832832
}
833833
else {
834834
unordered_set<string> article_names;
835-
for ( const auto& it : items ){
835+
for ( const auto *it : items ){
836836
string art_id = TiCC::getAttribute( it, "article_id" );
837837
if ( art_id.empty() ){
838838
#pragma omp critical
@@ -964,7 +964,7 @@ void solveBook( const string& altoFile,
964964
docid = prefix + docid;
965965
string outName = outDir + docid + ".folia.xml";
966966
folia::Document doc( "xml:id='" + docid + "'" );
967-
folia::processor *proc = add_provenance( doc, "FoLiA-alto", command );
967+
const folia::processor *proc = add_provenance( doc, "FoLiA-alto", command );
968968
processor_id = proc->id();
969969
folia::KWargs proc_args;
970970
proc_args["processor"] = processor_id;
@@ -987,9 +987,9 @@ void solveBook( const string& altoFile,
987987
xmlFreeDoc( xmldoc );
988988
return;
989989
}
990-
xmlNode *keepPart1 = 0;
990+
const xmlNode *keepPart1 = 0;
991991
set<string> ids;
992-
for ( auto const& block : textblocks ){
992+
for ( auto const *block : textblocks ){
993993
string id = TiCC::getAttribute( block, "ID" );
994994
if ( ids.find(id) != ids.end() ){
995995
if ( verbose ){
@@ -1184,7 +1184,7 @@ void solveBookAlto( const string& alto_cache,
11841184
else {
11851185
cout << "Downloaded files " << endl;
11861186
list<xmlNode*> meta = TiCC::FindNodes( didl, "//didl:Item/didl:Component" );
1187-
for ( const auto& m : meta ){
1187+
for ( const auto *m : meta ){
11881188
string id = TiCC::getAttribute( m, "identifier");
11891189
if ( !id.empty() ){
11901190
const auto it = downloaded_files.find( id );
@@ -1256,7 +1256,7 @@ void solveDirectAlto( const string& full_file,
12561256
string outName = outDir + docid + ".folia.xml";
12571257
list<xmlNode*> texts = TiCC::FindNodes( xmldoc, "//*:TextBlock" );
12581258
folia::Document doc( "xml:id='" + docid + "'" );
1259-
folia::processor *proc = add_provenance( doc, "FoLiA-alto", command );
1259+
const folia::processor *proc = add_provenance( doc, "FoLiA-alto", command );
12601260
processor_id = proc->id();
12611261
folia::KWargs args;
12621262
args["processor"] = processor_id;
@@ -1322,7 +1322,7 @@ void usage(){
13221322
cerr << "\t-V or --version\t show version " << endl;
13231323
}
13241324

1325-
int main( int argc, char *argv[] ){
1325+
int main( int argc, const char *argv[] ){
13261326
TiCC::CL_Options opts;
13271327
try {
13281328
opts.add_short_options( "vVt:O:h" );

src/FoLiA-benchmark.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ void usage( const string& name ){
226226
cerr << "\t-V or --version \t show version " << endl;
227227
}
228228

229-
int main( int argc, char *argv[] ){
229+
int main( int argc, const char *argv[] ){
230230
TiCC::CL_Options opts( "hVt:i:", "help,version" );
231231
try {
232232
opts.init(argc,argv);

src/FoLiA-clean.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ namespace std
6464

6565
int debug = 0;
6666

67-
void clean_text( FoliaElement *node,
67+
void clean_text( const FoliaElement *node,
6868
const string& textclass,
6969
bool current ){
7070
if ( node->xmltag() == "w" ){
@@ -131,7 +131,7 @@ void clean_text( FoliaElement *node,
131131
}
132132
}
133133

134-
void clean_anno( FoliaElement *node,
134+
void clean_anno( const FoliaElement *node,
135135
const AnnotationType anno_type,
136136
const string& setname ){
137137
for ( size_t i=0; i < node->size(); ++i ){
@@ -323,7 +323,7 @@ void usage( const string& name ){
323323
cerr << "\t-O\t\t name of the output dir." << endl;
324324
}
325325

326-
int main( int argc, char *argv[] ){
326+
int main( int argc, const char *argv[] ){
327327
TiCC::CL_Options opts( "hVvpe:t:O:", "textclass:,current,cleanannoset:,help,version,fixtext,debug,threads:" );
328328
try {
329329
opts.init(argc,argv);

src/FoLiA-collect.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ void usage(){
253253
cerr << "\t-v\t verbosity " << endl;
254254
}
255255

256-
int main( int argc, char *argv[] ){
256+
int main( int argc, const char *argv[] ){
257257
TiCC::CL_Options opts( "vVhO:t:R", "hapax,ngram:,help,version,threads:" );
258258
try {
259259
opts.init( argc, argv );

src/FoLiA-correct.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ bool gram_r::has_space( ){
177177
return true;
178178
}
179179
else {
180-
FoliaElement *w = _words.back();
180+
const FoliaElement *w = _words.back();
181181
if ( w->space() ){
182182
if ( verbose > 2 ){
183183
}
@@ -1077,7 +1077,7 @@ void correctNgrams( FoliaElement *root,
10771077
const unordered_set<string>& unknowns,
10781078
const unordered_map<string,string>& puncts,
10791079
unordered_map<string,size_t>& counts,
1080-
processor *proc ){
1080+
const processor *proc ){
10811081
KWargs correction_args;
10821082
string original_set;
10831083
correction_args["processor"] = proc->id();
@@ -1280,7 +1280,7 @@ bool correctDoc( Document *doc,
12801280
unordered_map<string,size_t>& counts,
12811281
const string& command,
12821282
const string& outName ){
1283-
processor *proc = add_provenance( *doc, "FoLiA-correct", command );
1283+
const processor *proc = add_provenance( *doc, "FoLiA-correct", command );
12841284
KWargs args;
12851285
args["processor"] = proc->id();
12861286
doc->declare( folia::AnnotationType::CORRECTION, setname, args );
@@ -1322,7 +1322,7 @@ bool correctDoc( Document *doc,
13221322
return true;
13231323
}
13241324

1325-
void rebase_text( Document *doc,
1325+
void rebase_text( const Document *doc,
13261326
const string& inputclass,
13271327
const string& rebase_input ){
13281328

src/FoLiA-hocr.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ void convert_hocr( const string& fileName,
219219
docid = prefix + docid;
220220
folia::Document doc( "xml:id='" + docid + "'" );
221221
doc.set_metadata( "filename", title );
222-
folia::processor *proc = add_provenance( doc, "FoLiA-hocr", command );
222+
const folia::processor *proc = add_provenance( doc, "FoLiA-hocr", command );
223223
processor_id = proc->id();
224224
folia::KWargs args;
225225
args["processor"] = processor_id;
@@ -280,7 +280,7 @@ void usage(){
280280
cerr << "\t-V or --version\t show version " << endl;
281281
}
282282

283-
int main( int argc, char *argv[] ){
283+
int main( int argc, const char *argv[] ){
284284
TiCC::CL_Options opts( "vVt:O:h",
285285
"compress:,class:,setname:,help,version,prefix:,threads:" );
286286
try {

src/FoLiA-idf.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ void usage(){
221221
exit(EXIT_SUCCESS);
222222
}
223223

224-
int main( int argc, char *argv[] ){
224+
int main( int argc, const char *argv[] ){
225225
TiCC::CL_Options opts( "vVt:O:Rhe:",
226226
"class:,clip:,lower,help,strings,version,threads:" );
227227
try {

src/FoLiA-langcat.cxx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ void addLang( const TextContent *t,
9393
}
9494
}
9595

96-
vector<FoliaElement*> gather_nodes( Document *doc, const string& docName,
96+
vector<FoliaElement*> gather_nodes( const Document *doc,
97+
const string& docName,
9798
const set<string>& tags ){
9899
vector<FoliaElement*> result;
99100
for ( const auto& tag : tags ){
@@ -144,7 +145,7 @@ void procesFile( const TextCat& tc,
144145
return;
145146
}
146147
doc->set_metadata( "language", default_lang );
147-
processor *proc = add_provenance( *doc, "FoLiA-langcat", command );
148+
const processor *proc = add_provenance( *doc, "FoLiA-langcat", command );
148149
if ( !doc->declared( AnnotationType::LANG, ISO_SET ) ){
149150
KWargs args;
150151
args["processor"] = proc->id();
@@ -234,7 +235,7 @@ void usage(){
234235
cerr << "\t-h or --help\t this messages." << endl;
235236
}
236237

237-
int main( int argc, char *argv[] ){
238+
int main( int argc, const char *argv[] ){
238239
TiCC::CL_Options opts( "svVhO:t:", "all,lang:,class:,config:,help,version,tags:,threads:" );
239240
try {
240241
opts.init( argc, argv );

0 commit comments

Comments
 (0)