Loading src/TNL/Meshes/Readers/TNLReader.h +1 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ public: String objectType; try { getObjectType( fileName, objectType ); objectType = getObjectType( fileName ); } catch( ... ) { Loading src/TNL/Object.h +17 −5 Original line number Diff line number Diff line Loading @@ -135,14 +135,26 @@ class Object /** * \brief Extracts object type from a binary file. * * @param file * @param type * @return * @param file is file where the object is stored * @return string with the object type */ void getObjectType( File& file, String& type ); String getObjectType( File& file ); void getObjectType( const String& file_name, String& type ); /** * \brief Does the same as \ref getObjectType but with \e fileName parameter instead of file. * * @param fileName name of file where the object is stored * @param type string with the object type */ String getObjectType( const String& fileName ); /** * \brief Parses the object type * * @param objectType is a string with the object type * @return list of strings where the first one is the object type and the next * strings are the template parameters */ std::vector< String > parseObjectType( const String& objectType ); Loading src/TNL/Object.hpp +6 −5 Original line number Diff line number Diff line Loading @@ -51,8 +51,7 @@ inline bool Object::save( File& file ) const inline bool Object::load( File& file ) { String objectType; getObjectType( file, objectType ); String objectType = getObjectType( file ); if( objectType != this->getSerializationTypeVirtual() ) { std::cerr << "Given file contains instance of " << objectType << " but " << getSerializationTypeVirtual() << " is expected." << std::endl; Loading Loading @@ -99,20 +98,22 @@ inline bool Object::boundLoad( const String& fileName ) return this->boundLoad( file ); } inline void getObjectType( File& file, String& type ) inline String getObjectType( File& file ) { char mn[ 10 ]; String type; file.read( mn, strlen( magic_number ) ); if( strncmp( mn, magic_number, 5 ) != 0 ) throw Exceptions::NotTNLFile(); file >> type; return type; } inline void getObjectType( const String& fileName, String& type ) inline String getObjectType( const String& fileName ) { File binaryFile; binaryFile.open( fileName, IOMode::read ); getObjectType( binaryFile, type ); return getObjectType( binaryFile ); } inline std::vector< String > Loading src/Tools/tnl-diff.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ int main( int argc, char* argv[] ) String meshType; try { getObjectType( meshFile, meshType ); meshType = getObjectType( meshFile ); } catch(...) { Loading src/Tools/tnl-diff.h +1 −1 Original line number Diff line number Diff line Loading @@ -625,7 +625,7 @@ bool processFiles( const Config::ParameterContainer& parameters ) String objectType; try { getObjectType( inputFiles[ 0 ], objectType ); objectType = getObjectType( inputFiles[ 0 ] ); } catch( std::ios_base::failure exception ) { Loading Loading
src/TNL/Meshes/Readers/TNLReader.h +1 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ public: String objectType; try { getObjectType( fileName, objectType ); objectType = getObjectType( fileName ); } catch( ... ) { Loading
src/TNL/Object.h +17 −5 Original line number Diff line number Diff line Loading @@ -135,14 +135,26 @@ class Object /** * \brief Extracts object type from a binary file. * * @param file * @param type * @return * @param file is file where the object is stored * @return string with the object type */ void getObjectType( File& file, String& type ); String getObjectType( File& file ); void getObjectType( const String& file_name, String& type ); /** * \brief Does the same as \ref getObjectType but with \e fileName parameter instead of file. * * @param fileName name of file where the object is stored * @param type string with the object type */ String getObjectType( const String& fileName ); /** * \brief Parses the object type * * @param objectType is a string with the object type * @return list of strings where the first one is the object type and the next * strings are the template parameters */ std::vector< String > parseObjectType( const String& objectType ); Loading
src/TNL/Object.hpp +6 −5 Original line number Diff line number Diff line Loading @@ -51,8 +51,7 @@ inline bool Object::save( File& file ) const inline bool Object::load( File& file ) { String objectType; getObjectType( file, objectType ); String objectType = getObjectType( file ); if( objectType != this->getSerializationTypeVirtual() ) { std::cerr << "Given file contains instance of " << objectType << " but " << getSerializationTypeVirtual() << " is expected." << std::endl; Loading Loading @@ -99,20 +98,22 @@ inline bool Object::boundLoad( const String& fileName ) return this->boundLoad( file ); } inline void getObjectType( File& file, String& type ) inline String getObjectType( File& file ) { char mn[ 10 ]; String type; file.read( mn, strlen( magic_number ) ); if( strncmp( mn, magic_number, 5 ) != 0 ) throw Exceptions::NotTNLFile(); file >> type; return type; } inline void getObjectType( const String& fileName, String& type ) inline String getObjectType( const String& fileName ) { File binaryFile; binaryFile.open( fileName, IOMode::read ); getObjectType( binaryFile, type ); return getObjectType( binaryFile ); } inline std::vector< String > Loading
src/Tools/tnl-diff.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ int main( int argc, char* argv[] ) String meshType; try { getObjectType( meshFile, meshType ); meshType = getObjectType( meshFile ); } catch(...) { Loading
src/Tools/tnl-diff.h +1 −1 Original line number Diff line number Diff line Loading @@ -625,7 +625,7 @@ bool processFiles( const Config::ParameterContainer& parameters ) String objectType; try { getObjectType( inputFiles[ 0 ], objectType ); objectType = getObjectType( inputFiles[ 0 ] ); } catch( std::ios_base::failure exception ) { Loading