Ignore:
Timestamp:
27 Oct 2015, 11:33:16 (9 years ago)
Author:
tech
Message:

Merged 15.1-dev0-NICT@1355.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TAppCommon/program_options_lite.cpp

    r1313 r1356  
    111111    }
    112112
     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
    113116    static void setOptions(Options::NamesPtrList& opt_list, const string& value, ErrorReporter& error_reporter)
     117#endif
    114118    {
    115119      /* multiple options may be registered for the same name:
     
    117121      for (Options::NamesPtrList::iterator it = opt_list.begin(); it != opt_list.end(); ++it)
    118122      {
     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
    119131        (*it)->opt->parse(value, error_reporter);
     132        #endif
    120133      }
    121134    }
     
    277290    bool OptionWriter::storePair(bool allow_long, bool allow_short, const string& name, const string& value)
    278291    {
     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
    279317      bool found = false;
    280318      Options::NamesMap::iterator opt_it;
     
    286324          found = true;
    287325        }
     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
    288339      }
    289340
     
    296347          found = true;
    297348        }
    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
    300370      if (!found)
    301371      {
     372#if NH_MV_SEI
     373        if (error_reporter.output_on_unknow_parameter )
     374        {       
     375#endif
     376
    302377        error_reporter.error(where())
    303378          << "Unknown option `" << name << "' (value:`" << value << "')\n";
     379#if NH_MV_SEI
     380        }
     381#endif
    304382        return false;
    305383      }
    306384
     385#if NH_MV_SEI
     386      setOptions((*opt_it).second, idcs, value, error_reporter);
     387#else
    307388      setOptions((*opt_it).second, value, error_reporter);
     389#endif
    308390      return true;
    309391    }
Note: See TracChangeset for help on using the changeset viewer.