Loading src/Examples/CMakeLists.txt +4 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,9 @@ ADD_CUSTOM_COMMAND( COMMAND ObjectExample_getType > ObjectExample_getType.out OU ADD_EXECUTABLE( ParameterContainerExample ParameterContainerExample.cpp ) ADD_EXECUTABLE( ParseObjectTypeExample ParseObjectTypeExample.cpp ) ADD_CUSTOM_COMMAND( COMMAND ParseObjectTypeExample > ParseObjectTypeExample.out OUTPUT ParseObjectTypeExample.out ) ADD_EXECUTABLE( StringExample StringExample.cpp ) ADD_CUSTOM_COMMAND( COMMAND StringExample > StringExample.out OUTPUT StringExample.out ) Loading Loading @@ -59,6 +62,7 @@ ADD_EXECUTABLE( VectorExample VectorExample.cpp ) ADD_CUSTOM_TARGET( run ALL DEPENDS ObjectExample_getType.out ParseObjectTypeExample.out StringExample.out StringExampleGetAllocatedSize.out StringExampleReplace.out Loading src/Examples/ParseObjectTypeExample.cpp 0 → 100644 +16 −0 Original line number Diff line number Diff line #include <iostream> #include <TNL/Object.h> #include <unistd.h> using namespace TNL; using namespace std; int main() { auto parsedObjectType = parseObjectType( String( "MyObject< Value, Device, Index >" ) ); for( auto &token : parsedObjectType ) { cout << token << endl; } } src/TNL/Object.h +18 −6 Original line number Diff line number Diff line Loading @@ -30,6 +30,13 @@ namespace TNL { * * Since the virtual destructor is not defined as \ref __cuda_callable__, * objects inherited from Object should not be created in CUDA kernels. * * In addition to methods of this class, see the following related functions: * * \ref getObjectType * * \ref parseObjectType * */ class Object { Loading Loading @@ -141,19 +148,24 @@ class Object String getObjectType( File& file ); /** * \brief Does the same as \ref getObjectType but with \e fileName parameter instead of file. * \brief Does the same as \ref getObjectType but with a \e fileName parameter instead of file. * * @param fileName name of file where the object is stored * @param type string with the object type * @param fileName name of a file where the object is stored * @return 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 * @param objectType is a string with the object type to be parsed. * @return vector of strings where the first one is the object type and the next * strings are the template parameters. * * \par Example * \include ParseObjectTypeExample.cpp * \par Output * \include ParseObjectTypeExample.out */ std::vector< String > parseObjectType( const String& objectType ); Loading Loading
src/Examples/CMakeLists.txt +4 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,9 @@ ADD_CUSTOM_COMMAND( COMMAND ObjectExample_getType > ObjectExample_getType.out OU ADD_EXECUTABLE( ParameterContainerExample ParameterContainerExample.cpp ) ADD_EXECUTABLE( ParseObjectTypeExample ParseObjectTypeExample.cpp ) ADD_CUSTOM_COMMAND( COMMAND ParseObjectTypeExample > ParseObjectTypeExample.out OUTPUT ParseObjectTypeExample.out ) ADD_EXECUTABLE( StringExample StringExample.cpp ) ADD_CUSTOM_COMMAND( COMMAND StringExample > StringExample.out OUTPUT StringExample.out ) Loading Loading @@ -59,6 +62,7 @@ ADD_EXECUTABLE( VectorExample VectorExample.cpp ) ADD_CUSTOM_TARGET( run ALL DEPENDS ObjectExample_getType.out ParseObjectTypeExample.out StringExample.out StringExampleGetAllocatedSize.out StringExampleReplace.out Loading
src/Examples/ParseObjectTypeExample.cpp 0 → 100644 +16 −0 Original line number Diff line number Diff line #include <iostream> #include <TNL/Object.h> #include <unistd.h> using namespace TNL; using namespace std; int main() { auto parsedObjectType = parseObjectType( String( "MyObject< Value, Device, Index >" ) ); for( auto &token : parsedObjectType ) { cout << token << endl; } }
src/TNL/Object.h +18 −6 Original line number Diff line number Diff line Loading @@ -30,6 +30,13 @@ namespace TNL { * * Since the virtual destructor is not defined as \ref __cuda_callable__, * objects inherited from Object should not be created in CUDA kernels. * * In addition to methods of this class, see the following related functions: * * \ref getObjectType * * \ref parseObjectType * */ class Object { Loading Loading @@ -141,19 +148,24 @@ class Object String getObjectType( File& file ); /** * \brief Does the same as \ref getObjectType but with \e fileName parameter instead of file. * \brief Does the same as \ref getObjectType but with a \e fileName parameter instead of file. * * @param fileName name of file where the object is stored * @param type string with the object type * @param fileName name of a file where the object is stored * @return 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 * @param objectType is a string with the object type to be parsed. * @return vector of strings where the first one is the object type and the next * strings are the template parameters. * * \par Example * \include ParseObjectTypeExample.cpp * \par Output * \include ParseObjectTypeExample.out */ std::vector< String > parseObjectType( const String& objectType ); Loading