Changeset 1356 in 3DVCSoftware for trunk/source/Lib/TAppCommon/program_options_lite.cpp
- Timestamp:
- 27 Oct 2015, 11:33:16 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TAppCommon/program_options_lite.cpp
r1313 r1356 111 111 } 112 112 113 #if NH_MV_SEI 114 static void setOptions(Options::NamesPtrList& opt_list, const std::vector<int> idcs, const string& value, ErrorReporter& error_reporter) 115 #else 113 116 static void setOptions(Options::NamesPtrList& opt_list, const string& value, ErrorReporter& error_reporter) 117 #endif 114 118 { 115 119 /* multiple options may be registered for the same name: … … 117 121 for (Options::NamesPtrList::iterator it = opt_list.begin(); it != opt_list.end(); ++it) 118 122 { 123 #if NH_MV_SEI 124 Bool doParsing = (*it)->opt->checkDim( idcs, error_reporter ); 125 if ( doParsing ) 126 { 127 (*it)->opt->parse(value, idcs, error_reporter); 128 } 129 130 #else 119 131 (*it)->opt->parse(value, error_reporter); 132 #endif 120 133 } 121 134 } … … 277 290 bool OptionWriter::storePair(bool allow_long, bool allow_short, const string& name, const string& value) 278 291 { 292 #if NH_MV_SEI 293 std::vector<int> idcs; 294 295 std::size_t pos_underscore = name.find("_" ); 296 std::size_t pos_last_underscore_plus1 = pos_underscore+1; 297 std::size_t pos_first_underscore = pos_underscore; 298 299 while ( pos_underscore != string::npos ) 300 { 301 pos_underscore = name.find("_", pos_last_underscore_plus1 ); 302 size_t subStrlen = ( pos_underscore == string::npos ) ? string::npos : ( pos_underscore - pos_last_underscore_plus1 ); 303 string idx_str = name.substr( pos_last_underscore_plus1, subStrlen ); 304 idcs.push_back( atoi( idx_str.c_str())); 305 pos_last_underscore_plus1 = pos_underscore + 1; 306 } 307 308 string name_idcs = name.substr(0, pos_first_underscore ); 309 for (size_t i = 0; i < idcs.size(); i++ ) 310 { 311 name_idcs += "_%d"; 312 } 313 314 bool found_idcs = false; 315 Options::NamesMap::iterator opt_it_idcs; 316 #endif 279 317 bool found = false; 280 318 Options::NamesMap::iterator opt_it; … … 286 324 found = true; 287 325 } 326 #if NH_MV_SEI 327 if ( idcs.size() > 0 ) 328 { 329 opt_it_idcs = opts.opt_long_map.find(name_idcs); 330 if (opt_it_idcs != opts.opt_long_map.end() ) 331 { 332 assert( !found ); 333 found = true; 334 found_idcs = true; 335 opt_it = opt_it_idcs; 336 } 337 } 338 #endif 288 339 } 289 340 … … 296 347 found = true; 297 348 } 298 } 299 349 #if NH_MV_SEI 350 if ( idcs.size() > 0 ) 351 { 352 opt_it = opts.opt_short_map.find(name); 353 if (opt_it != opts.opt_short_map.end()) 354 { 355 assert( !found ); 356 found = true; 357 found_idcs = true; 358 opt_it = opt_it_idcs; 359 } 360 } 361 #endif 362 } 363 364 #if NH_MV_SEI 365 if ( !found_idcs ) 366 { 367 idcs.clear(); 368 } 369 #endif 300 370 if (!found) 301 371 { 372 #if NH_MV_SEI 373 if (error_reporter.output_on_unknow_parameter ) 374 { 375 #endif 376 302 377 error_reporter.error(where()) 303 378 << "Unknown option `" << name << "' (value:`" << value << "')\n"; 379 #if NH_MV_SEI 380 } 381 #endif 304 382 return false; 305 383 } 306 384 385 #if NH_MV_SEI 386 setOptions((*opt_it).second, idcs, value, error_reporter); 387 #else 307 388 setOptions((*opt_it).second, value, error_reporter); 389 #endif 308 390 return true; 309 391 }
Note: See TracChangeset for help on using the changeset viewer.