Commit 39dadccb authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Fixed parseCommandLine after refactoring the getType function

parent 5910a5e8
Loading
Loading
Loading
Loading
+15 −11
Original line number Diff line number Diff line
@@ -254,55 +254,59 @@ public:
         if( entries[ i ]->hasDefaultValue &&
             ! parameter_container.checkParameter( entry_name ) )
         {
            if( entries[ i ]->getEntryType() == "String" )
            if( entries[ i ]->getEntryType() == "TNL::String" )
            {
               ConfigEntry< String >& entry = dynamic_cast< ConfigEntry< String >& >( *entries[ i ] );
               parameter_container.addParameter< String >( entry_name, entry.defaultValue );
               continue;
            }
            if( entries[ i ]->getEntryType() == "bool" )
            else if( entries[ i ]->getEntryType() == "bool" )
            {
               ConfigEntry< bool >& entry = dynamic_cast< ConfigEntry< bool >& >( *entries[ i ] );
               parameter_container.addParameter< bool >( entry_name, entry.defaultValue );
               continue;
            }
            if( entries[ i ]->getEntryType() == "int" )
            else if( entries[ i ]->getEntryType() == "int" )
            {
               ConfigEntry< int >& entry = dynamic_cast< ConfigEntry< int >& >( *entries[ i ] );
               parameter_container.addParameter< int >( entry_name, entry.defaultValue );
               continue;
            }
            if( entries[ i ]->getEntryType() == "double" )
            else if( entries[ i ]->getEntryType() == "double" )
            {
               ConfigEntry< double >& entry = dynamic_cast< ConfigEntry< double >& >( *entries[ i ] );
               parameter_container.addParameter< double >( entry_name, entry.defaultValue );
               continue;
            }
            
            if( entries[ i ]->getEntryType() == "ConfigEntryList< String >" )
            else if( entries[ i ]->getEntryType() == "ConfigEntryList< TNL::String >" )
            {
               ConfigEntryList< String >& entry = dynamic_cast< ConfigEntryList< String >& >( *entries[ i ] );
               parameter_container.addList< String >( entry_name, entry.defaultValue );
               continue;
            }
            if( entries[ i ]->getEntryType() == "ConfigEntryList< bool >" )
            else if( entries[ i ]->getEntryType() == "ConfigEntryList< bool >" )
            {
               ConfigEntryList< bool >& entry = dynamic_cast< ConfigEntryList< bool >& >( *entries[ i ] );
               parameter_container.addList< bool >( entry_name, entry.defaultValue );
               continue;
            }
            if( entries[ i ]->getEntryType() == "ConfigEntryList< int >" )
            else if( entries[ i ]->getEntryType() == "ConfigEntryList< int >" )
            {
               ConfigEntryList< int >& entry = dynamic_cast< ConfigEntryList< int >& >( *entries[ i ] );
               parameter_container.addList< int >( entry_name, entry.defaultValue );
               continue;
            }
            if( entries[ i ]->getEntryType() == "ConfigEntryList< double >" )
            else if( entries[ i ]->getEntryType() == "ConfigEntryList< double >" )
            {
               ConfigEntryList< double >& entry = dynamic_cast< ConfigEntryList< double >& >( *entries[ i ] );
               parameter_container.addList< double >( entry_name, entry.defaultValue );
               continue;
            }
            else
            {
               throw std::runtime_error( "Method ConfigDescription::addMissingEntries encountered "
                                         "unsupported entry type: " + entries[ i ]->getEntryType() );
            }
         }
      }
   }
+20 −10
Original line number Diff line number Diff line
@@ -96,11 +96,11 @@ parseCommandLine( int argc, char* argv[],
            while( i < argc && ( ( argv[ i ] )[ 0 ] != '-' || ( atof( argv[ i ] ) < 0.0 && ( parsedEntryType[ 1 ] == "int" || parsedEntryType[ 1 ] == "double" ) ) ) )
            {
               const char* value = argv[ i ++ ];
               if( parsedEntryType[ 1 ] == "String" )
               if( parsedEntryType[ 1 ] == "TNL::String" )
               {
                  string_list.push_back( String( value ) );
               }
               if( parsedEntryType[ 1 ] == "bool" )
               else if( parsedEntryType[ 1 ] == "bool" )
               {
                  const int v = matob( value );
                  if( v == -1 )
@@ -110,14 +110,19 @@ parseCommandLine( int argc, char* argv[],
                  }
                  else bool_list.push_back( v );
               }
               if( parsedEntryType[ 1 ] == "int" )
               else if( parsedEntryType[ 1 ] == "int" )
               {
                  integer_list.push_back( atoi( value ) );
               }
               if( parsedEntryType[ 1 ] == "double" )
               else if( parsedEntryType[ 1 ] == "double" )
               {
                  real_list.push_back( atof( value ) );
               }
               else
               {
                  // this will not happen if all entry types are handled above
                  throw std::runtime_error( "Function parseCommandLine encountered unsupported entry type: " + entryType );
               }
            }
            if( string_list.size() )
               parameters.addParameter< std::vector< String > >( option, string_list );
@@ -132,14 +137,14 @@ parseCommandLine( int argc, char* argv[],
         }
         else
         {
            if( parsedEntryType[ 0 ] == "String" )
            if( parsedEntryType[ 0 ] == "TNL::String" )
            {
               if( ! ( ( ConfigEntry< String >* ) entry )->checkValue( value ) )
                  return false;
                parameters.addParameter< String >( option, value );
                continue;
            }
            if( parsedEntryType[ 0 ] == "bool" )
            else if( parsedEntryType[ 0 ] == "bool" )
            {
               const int v = matob( value );
               if( v == -1 )
@@ -150,7 +155,7 @@ parseCommandLine( int argc, char* argv[],
               else parameters.addParameter< bool >( option, v );
               continue;
            }
            if( parsedEntryType[ 0 ] == "int" )
            else if( parsedEntryType[ 0 ] == "int" )
            {
               /*if( ! std::isdigit( value ) ) //TODO: Check for real number
               {
@@ -162,7 +167,7 @@ parseCommandLine( int argc, char* argv[],
                  return false;
               parameters.addParameter< int >( option, atoi( value ) );
            }
            if( parsedEntryType[ 0 ] == "double" )
            else if( parsedEntryType[ 0 ] == "double" )
            {
               /*if( ! std::isdigit( value ) )  //TODO: Check for real number
               {
@@ -174,6 +179,11 @@ parseCommandLine( int argc, char* argv[],
                  return false;
               parameters.addParameter< double >( option, atof( value ) );
            }
            else
            {
               // this will not happen if all entry types are handled above
               throw std::runtime_error( "Function parseCommandLine encountered unsupported entry type: " + entryType );
            }
         }
      }
   }
+2 −2

File changed.

Contains only whitespace changes.