Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8316 in orxonox.OLD for trunk/src/lib/parser


Ignore:
Timestamp:
Jun 11, 2006, 1:57:27 PM (19 years ago)
Author:
bensch
Message:

trunk: fixed most -Wall warnings… but there are still many missing :/

Location:
trunk/src/lib/parser
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/parser/cmdline_parser/cmdline_parser.cc

    r7319 r8316  
    5252  else
    5353    argTable.push_front( entry );
     54  return true;
    5455}
    5556
     
    7071      if ( s.length() > 2 && s[0] == '-' && s[1] != '-' )
    7172      {
    72         for ( int j = 1; j < s.length(); j++ )
     73        for (unsigned int j = 1; j < s.length(); j++ )
    7374        {
    7475          std::string t = "-";
     
    9596  }
    9697
    97   int i = 0;
     98  unsigned int i = 0;
    9899
    99100  ArgTable::iterator it;
     
    110111        found = true;
    111112
    112         int posArgs = 1;
     113        unsigned int posArgs = 1;
    113114
    114115        while ( i + posArgs < args.size() )
     
    130131        std::vector<MultiType> argArgs;
    131132
    132         for ( int j = 1; j <= it->numArgs; j++ )
     133        for (unsigned int j = 1; j <= it->numArgs; j++ )
    133134          argArgs.push_back( args[i+j] );
    134135
     
    219220    assert( it->numArgs == substr.size() );
    220221
    221     for ( int i = 0; i<it->numArgs; i++ )
     222    for (unsigned int i = 0; i<it->numArgs; i++ )
    222223    {
    223224      args += " [" + substr[i] + "]";
     
    251252  output.reverse();
    252253
    253   int maxShort = 0;
    254   int maxLong = 0;
     254  unsigned int maxShort = 0;
     255  unsigned int maxLong = 0;
    255256
    256257  std::list<std::vector<std::string> >::const_iterator it;
     
    269270    printf("%s ", (*it)[0].c_str());
    270271
    271     for ( int i = 0; i<maxShort-(*it)[0].length(); i++ )
     272    for (unsigned int i = 0; i<maxShort-(*it)[0].length(); i++ )
    272273      printf(" ");
    273274
    274275    printf("%s ", (*it)[1].c_str());
    275276
    276     for ( int i = 0; i<maxLong-(*it)[1].length(); i++ )
     277    for (unsigned int i = 0; i<maxLong-(*it)[1].length(); i++ )
    277278      printf(" ");
    278279
  • trunk/src/lib/parser/cmdline_parser/cmdline_parser.h

    r7256 r8316  
    1717struct ArgTableEntry
    1818{
    19   int         id;
    20   std::string longOption;
    21   char        shortOption;
    22   int         numArgs;
    23   std::string argNames;
    24   std::string help;
     19  unsigned int    id;
     20  std::string     longOption;
     21  char            shortOption;
     22  unsigned int    numArgs;
     23  std::string     argNames;
     24  std::string     help;
    2525};
    2626
     
    3636    CmdLineParser();
    3737    virtual ~CmdLineParser();
    38    
     38
    3939    bool add( int id, const std::string& longOption, char shortOption, int numArgs, const std::string & argNames, const std::string& help, bool back=false );
    4040
    4141    bool parse( ArgParserCallback cb, void* data, int argc, char** argv );
    42    
     42
    4343    void showHelp();
    44    
     44
    4545  private:
    4646    ArgTable argTable;
    4747    std::string exeName;
    48    
     48
    4949    inline bool matches( ArgTableEntry entry, std::string arg, bool & finish );
    5050
  • trunk/src/lib/parser/preferences/cmd_line_prefs_reader.cc

    r7261 r8316  
    4343{
    4444  CallbackData * cbd = (CallbackData *)data;
    45  
     45
    4646  switch ( entry.id )
    4747  {
     
    5454      key.erase( 0, key.find(".")+1 );
    5555      //PRINTF(0)("SECTION '%s', KEY '%s'\n", section.c_str(), key.c_str());
    56      
     56
    5757      if ( key == "" || section == "" || argArgs.size() != 1 )
    5858      {
     
    6060        return false;
    6161      }
    62      
     62
    6363      //Preferences::getInstance()->setMultiType( section, key, argArgs[0], true );
    6464      cbd->iniEntries.push_back( IniEntry() );
     
    7272      return true;
    7373  }
    74  
    75   if ( entry.id >= ID_PREFS && entry.id - ID_PREFS < regArgs.size() )
     74
     75  if ( entry.id >= ID_PREFS && entry.id  < regArgs.size() + ID_PREFS)
    7676  {
    7777    if ( regArgs[entry.id - ID_PREFS].value == "%arg%" )
    7878    {
    7979      assert( argArgs.size() == 1 );
    80      
     80
    8181      cbd->iniEntries.push_back( IniEntry() );
    8282      cbd->iniEntries.back().section = regArgs[entry.id - ID_PREFS].section;
     
    9696    assert(false);
    9797  }
    98  
     98
    9999  return true;
    100100}
     
    104104{
    105105  CmdLineParser parser;
    106  
     106
    107107  parser.add( ID_HELP, "help", 'h', 0, "", "Shows this help and exits");
    108  
    109   for ( int i = 0; i<regArgs.size(); i++ )
     108
     109  for (unsigned int i = 0; i<regArgs.size(); i++ )
    110110  {
    111111    if ( regArgs[i].value == "%arg%" )
     
    118118    }
    119119  }
    120  
     120
    121121  parser.add( ID_SET_INI, "set-%", '\0', 1, "value", "Override a configuration element." );
    122  
     122
    123123  CallbackData cbd;
    124  
     124
    125125  cbd.parser = &parser;
    126  
     126
    127127  if ( parser.parse( &callBack, &cbd, argc, argv ) )
    128128  {
     
    137137    exit(EXIT_FAILURE);
    138138  }
    139  
     139
    140140  return true;
    141141}
     
    144144{
    145145  RegistredArgument arg;
    146  
     146
    147147  arg.longOption = longOption;
    148148  while ( arg.longOption.find("_") != std::string::npos )
     
    158158  arg.section = section;
    159159  arg.key = key;
    160  
     160
    161161  regArgs.push_back( arg );
     162  return true;
    162163}
    163164
Note: See TracChangeset for help on using the changeset viewer.