7 // -------------------------------------------------------------------------
8 std::string GetFileName( const std::string& path )
11 char* buffer = new char[ path.size( ) + 1 ];
12 std::memcpy( buffer, path.c_str( ), path.size( ) );
13 buffer[ path.size( ) ] = '\0';
14 char* tok = std::strtok( buffer, "/\\" );
15 char* ptr_fname = tok;
19 tok = std::strtok( NULL, "/\\" );
22 std::string fname( ptr_fname );
26 std::size_t pos = fname.find_last_of( "." );
27 if( pos != std::string::npos )
28 fname = fname.substr( 0, pos );
33 // -------------------------------------------------------------------------
34 int main( int argc, char* argv[] )
40 << "Usage: " << argv[ 0 ]
41 << " output_code namespace filter1 filter2 ..."
46 std::ofstream output_code( argv[ 1 ] );
50 << "Could not open file \"" << argv[ 1 ] << "\" for writing"
56 output_code << "#include <Pluma/Connector.hpp>" << std::endl;
58 << "#include <cpPlugins/Interface/ProcessObjectProvider.h>"
60 for( int i = 3; i < argc; ++i )
61 output_code << "#include \"" << argv[ i ] << "\"" << std::endl;
62 output_code << std::endl;
64 std::istringstream nspaces( argv[ 2 ] );
66 unsigned int number_of_nspaces = 0;
67 while( std::getline( nspaces, nspace, ':' ) )
71 output_code << "namespace " << nspace << std::endl << "{" << std::endl;
78 for( int i = 3; i < argc; ++i )
80 << "CPPLUGINS_INHERIT_PROVIDER( "
81 << GetFileName( argv[ i ] ) << " );" << std::endl;
83 for( unsigned int i = 0; i < number_of_nspaces; ++i )
84 output_code << "}" << std::endl;
85 output_code << std::endl;
89 << "PLUMA_CONNECTOR" << std::endl
90 << "bool connect( pluma::Host& host )" << std::endl
93 for( int i = 3; i < argc; ++i )
97 << GetFileName( argv[ i ] )
102 << " return( true );" << std::endl
105 output_code << std::endl << "// eof - $RCSfile$" << std::endl << std::endl;
108 output_code.close( );