From 0f50590753cd420a0e4758e70a39beab3e49129e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= <klinkjak@fjfi.cvut.cz> Date: Sat, 17 Nov 2018 13:53:39 +0100 Subject: [PATCH] Moved stuff from Object.cpp to Object_impl.h --- src/TNL/CMakeLists.txt | 2 +- src/TNL/Object.h | 2 ++ src/TNL/{Object.cpp => Object_impl.h} | 36 ++++++++++++++------------- 3 files changed, 22 insertions(+), 18 deletions(-) rename src/TNL/{Object.cpp => Object_impl.h} (84%) diff --git a/src/TNL/CMakeLists.txt b/src/TNL/CMakeLists.txt index fdf140c50d..da996f1968 100644 --- a/src/TNL/CMakeLists.txt +++ b/src/TNL/CMakeLists.txt @@ -26,6 +26,7 @@ set( headers FileName.h FileName.hpp Object.h + Object_impl.h Logger.h Logger_impl.h Math.h @@ -38,7 +39,6 @@ set( headers set( common_SOURCES FileName.cpp - Object.cpp String.cpp Timer.cpp ) diff --git a/src/TNL/Object.h b/src/TNL/Object.h index e4fd274f89..04fc841130 100644 --- a/src/TNL/Object.h +++ b/src/TNL/Object.h @@ -113,3 +113,5 @@ std::vector< String > parseObjectType( const String& objectType ); } // namespace TNL + +#include <TNL/Object_impl.h> diff --git a/src/TNL/Object.cpp b/src/TNL/Object_impl.h similarity index 84% rename from src/TNL/Object.cpp rename to src/TNL/Object_impl.h index c0cc9a446c..51075d85a9 100644 --- a/src/TNL/Object.cpp +++ b/src/TNL/Object_impl.h @@ -1,5 +1,5 @@ /*************************************************************************** - Object.cpp - description + Object_impl.h - description ------------------- begin : 2005/10/15 copyright : (C) 2005 by Tomas Oberhuber @@ -8,37 +8,39 @@ /* See Copyright Notice in tnl/Copyright */ -#include <TNL/Object.h> -#include <TNL/Assert.h> +#pragma once + #include <iostream> #include <fstream> #include <cstring> +#include <TNL/Object.h> + namespace TNL { -const char magic_number[] = "TNLMN"; +static constexpr char magic_number[] = "TNLMN"; -String Object :: getType() +inline String Object :: getType() { return String( "Object" ); } -String Object :: getTypeVirtual() const +inline String Object :: getTypeVirtual() const { return this->getType(); } -String Object :: getSerializationType() +inline String Object :: getSerializationType() { return String( "Object" ); } -String Object :: getSerializationTypeVirtual() const +inline String Object :: getSerializationTypeVirtual() const { return this->getSerializationType(); } -bool Object :: save( File& file ) const +inline bool Object :: save( File& file ) const { if( ! file. write( magic_number, strlen( magic_number ) ) ) return false; @@ -46,7 +48,7 @@ bool Object :: save( File& file ) const return true; } -bool Object :: load( File& file ) +inline bool Object :: load( File& file ) { String objectType; if( ! getObjectType( file, objectType ) ) @@ -59,12 +61,12 @@ bool Object :: load( File& file ) return true; } -bool Object :: boundLoad( File& file ) +inline bool Object :: boundLoad( File& file ) { return load( file ); } -bool Object :: save( const String& fileName ) const +inline bool Object :: save( const String& fileName ) const { File file; if( ! file. open( fileName, IOMode::write ) ) @@ -75,7 +77,7 @@ bool Object :: save( const String& fileName ) const return this->save( file ); } -bool Object :: load( const String& fileName ) +inline bool Object :: load( const String& fileName ) { File file; if( ! file. open( fileName, IOMode::read ) ) @@ -86,7 +88,7 @@ bool Object :: load( const String& fileName ) return this->load( file ); } -bool Object :: boundLoad( const String& fileName ) +inline bool Object :: boundLoad( const String& fileName ) { File file; if( ! file. open( fileName, IOMode::read ) ) @@ -98,7 +100,7 @@ bool Object :: boundLoad( const String& fileName ) } -bool getObjectType( File& file, String& type ) +inline bool getObjectType( File& file, String& type ) { char mn[ 10 ]; if( ! file. read( mn, strlen( magic_number ) ) ) @@ -119,7 +121,7 @@ bool getObjectType( File& file, String& type ) return true; } -bool getObjectType( const String& fileName, String& type ) +inline bool getObjectType( const String& fileName, String& type ) { File binaryFile; if( ! binaryFile. open( fileName, IOMode::read ) ) @@ -130,7 +132,7 @@ bool getObjectType( const String& fileName, String& type ) return getObjectType( binaryFile, type ); } -std::vector< String > +inline std::vector< String > parseObjectType( const String& objectType ) { std::vector< String > parsedObjectType; -- GitLab