Commit 50fc314d authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Removed Containers::List from the parseObjectType function

parent 32b0eb5d
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@

#include "../Benchmarks.h"

#include <TNL/Containers/List.h>
#include <TNL/Pointers/DevicePointer.h>
#include <TNL/Matrices/CSR.h>
#include <TNL/Matrices/Ellpack.h>
@@ -111,8 +110,7 @@ benchmarkSpMV( Benchmark & benchmark,
   CudaVector deviceVector, deviceVector2;

   // create benchmark group
   Containers::List< String > parsedType;
   parseObjectType( HostMatrix::getType(), parsedType );
   const std::vector< String > parsedType = parseObjectType( HostMatrix::getType() );
#ifdef HAVE_CUDA
   benchmark.createHorizontalGroup( parsedType[ 0 ], 2 );
#else
+1 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ struct ConfigEntryList : public ConfigEntryBase

   String getEntryType() const
   {
      return String("List< ") + TNL::getType< EntryType >() + " >";
      return String("ConfigEntryList< ") + TNL::getType< EntryType >() + " >";
   }

   String getUIEntryType() const
+24 −60
Original line number Diff line number Diff line
@@ -155,41 +155,27 @@ parseCommandLine( int argc, char* argv[],
            std::cerr << "Missing value for the parameter " << option << "." << std::endl;
            return false;
         }
         Containers::List< String > parsedEntryType;
         if( ! parseObjectType( entryType, parsedEntryType ) )
         std::vector< String > parsedEntryType = parseObjectType( entryType );
         if( parsedEntryType.size() == 0 )
         {
            std::cerr << "Internal error: Unknown config entry type " << entryType << "." << std::endl;
            return false;
         }
         if( parsedEntryType[ 0 ] == "Containers::List" )
         if( parsedEntryType[ 0 ] == "ConfigEntryList" )
         {
            Containers::List< String >* string_list( 0 );
            Containers::List< bool >* bool_list( 0 );
            Containers::List< int >* integer_list( 0 );
            Containers::List< double >* real_list( 0 );
            std::vector< String > string_list;
            std::vector< bool > bool_list;
            std::vector< int > integer_list;
            std::vector< double > real_list;

            if( parsedEntryType[ 1 ] == "String" )
               string_list = new Containers::List< String >;
            if( parsedEntryType[ 1 ] == "bool" )
               bool_list = new Containers::List< bool >;
            if( parsedEntryType[ 1 ] == "int" )
               integer_list = new Containers::List< int >;
            if( parsedEntryType[ 1 ] == "double" )
               real_list = new Containers::List< double >;

            while( i < argc && ( ( argv[ i ] )[ 0 ] != '-' || ( atof( argv[ i ] ) < 0.0 && ( integer_list || real_list ) ) ) )
            while( i < argc && ( ( argv[ i ] )[ 0 ] != '-' || ( atof( argv[ i ] ) < 0.0 && ( parsedEntryType[ 1 ] == "int" || parsedEntryType[ 1 ] == "double" ) ) ) )
            {
               const char* value = argv[ i ++ ];
               if( string_list )
               {
                  /*if( ! ( ( ConfigEntry< Containers::List< String > >* )  entry )->checkValue( String( value ) ) )
               if( parsedEntryType[ 1 ] == "String" )
               {
                     delete string_list;
                     return false;
                  }*/
                  string_list -> Append( String( value ) );
                  string_list.push_back( String( value ) );
               }
               if( bool_list )
               if( parsedEntryType[ 1 ] == "bool" )
               {
                  bool bool_val;
                  if( ! matob( value, bool_val ) )
@@ -197,47 +183,25 @@ parseCommandLine( int argc, char* argv[],
                     std::cerr << "Yes/true or no/false is required for the parameter " << option << "." << std::endl;
                     parse_error = true;
                  }
                  else bool_list -> Append( bool_val );
               }
               if( integer_list )
               {
                  /*if( ! ( ConfigEntry< Containers::List< int > >* ) entry->checkValue( atoi( value ) ) )
                  {
                     delete integer_list;
                     return false;
                  }*/
                  integer_list -> Append( atoi( value ) );
               }
               if( real_list )
               {
                  /*if( ! ( ConfigEntry< Containers::List< double > >* ) entry->checkValue( atof( value ) ) )
                  {
                     delete real_list;
                     return false;
                  }*/
                  real_list -> Append( atof( value ) );
                  else bool_list.push_back( bool_val );
               }
            }
            if( string_list )
            {
               parameters.addParameter< Containers::List< String > >( option, *string_list );
               delete string_list;
            }
            if( bool_list )
               if( parsedEntryType[ 1 ] == "int" )
               {
               parameters.addParameter< Containers::List< bool > >( option, *bool_list );
               delete bool_list;
                  integer_list.push_back( atoi( value ) );
               }
            if( integer_list )
               if( parsedEntryType[ 1 ] == "double" )
               {
               parameters.addParameter< Containers::List< int > >( option, *integer_list );
               delete integer_list;
                  real_list.push_back( atof( value ) );
               }
            if( real_list )
            {
               parameters.addParameter< Containers::List< double > >( option, *real_list );
               delete real_list;
            }
            if( string_list.size() )
               parameters.addParameter< std::vector< String > >( option, string_list );
            if( bool_list.size() )
               parameters.addParameter< std::vector< bool > >( option, bool_list );
            if( integer_list.size() )
               parameters.addParameter< std::vector< int > >( option, integer_list );
            if( real_list.size() )
               parameters.addParameter< std::vector< double > >( option, real_list );
            if( i < argc ) i --;
            continue;
         }
+10 −8
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@

#include <TNL/String.h>
#include <TNL/Object.h>
#include <TNL/Containers/List.h>
#include <TNL/Meshes/Readers/EntityShape.h>

namespace TNL {
@@ -34,8 +33,8 @@ public:
         return EXIT_FAILURE;
      }

      Containers::List< String > parsedMeshType;
      if( ! parseObjectType( objectType, parsedMeshType ) ) {
      const std::vector< String > parsedMeshType = parseObjectType( objectType );
      if( ! parsedMeshType.size() ) {
         std::cerr << "Unable to parse the mesh type " << meshType << "." << std::endl;
         return false;
      }
@@ -55,14 +54,17 @@ public:
            cellShape = EntityShape::Hexahedron;
      }
      else if( meshType == "Meshes::Mesh" ) {
         Containers::List< String > parsedMeshConfig;
         if( ! parseObjectType( parsedMeshType[ 1 ], parsedMeshConfig ) ) {
         const std::vector< String > parsedMeshConfig = parseObjectType( parsedMeshType[ 1 ] );
         if( ! parsedMeshConfig.size() ) {
            std::cerr << "Unable to parse the mesh config type " << parsedMeshType[ 1 ] << "." << std::endl;
            return false;
         }
         if( parsedMeshConfig.getSize() != 7 ) {
            std::cerr << "The parsed mesh config type has wrong size (expected 7 elements):" << std::endl
                      << parsedMeshConfig << std::endl;
         if( parsedMeshConfig.size() != 7 ) {
            std::cerr << "The parsed mesh config type has wrong size (expected 7 elements):" << std::endl;
            std::cerr << "[ ";
            for( std::size_t i = 0; i < parsedMeshConfig.size() - 1; i++ )
               std::cerr << parsedMeshConfig[ i ] << ", ";
            std::cerr << parsedMeshConfig.back() << " ]" << std::endl;
            return false;
         }

+15 −16
Original line number Diff line number Diff line
@@ -130,11 +130,11 @@ bool getObjectType( const String& fileName, String& type )
   return getObjectType( binaryFile, type );
}

bool parseObjectType( const String& objectType,
                      Containers::List< String >& parsedObjectType )
std::vector< String >
parseObjectType( const String& objectType )
{
   parsedObjectType.reset();
   int objectTypeLength = objectType. getLength();
   std::vector< String > parsedObjectType;
   const int objectTypeLength = objectType.getLength();
   int i = 0;
   /****
    * The object type consists of the following:
@@ -145,8 +145,7 @@ bool parseObjectType( const String& objectType,
   while( i < objectTypeLength && objectType[ i ] != '<' )
      i++;
   String objectName( objectType.getString(), 0, objectTypeLength - i );
   if( ! parsedObjectType. Append( objectName ) )
      return false;
   parsedObjectType.push_back( objectName );
   i++;

   /****
@@ -168,8 +167,7 @@ bool parseObjectType( const String& objectType,
         {
            if( buffer != "" )
            {
               if( ! parsedObjectType. Append( buffer.strip( ' ' ) ) )
                  return false;
               parsedObjectType.push_back( buffer.strip( ' ' ) );
               buffer.setString( "" );
            }
         }
@@ -180,7 +178,8 @@ bool parseObjectType( const String& objectType,
         templateBrackets--;
      i++;
   }
   return true;

   return parsedObjectType;
}

} // namespace TNL
Loading