#include // ------------------------------------------------------------------------- typedef std::deque< std::string > TStrings; // ------------------------------------------------------------------------- int main( int argc, char* argv[] ) { // Get inputs if( argc < 3 ) { std::cerr << "Usage: " << argv[ 0 ] << " definitons_file library_name" << std::endl; return( 1 ); } // fi std::string definitions_filename = argv[ 1 ]; std::string library_name = argv[ 2 ]; // Read inputs std::string definitions_buffer; if( !( cpPlugins_bash::Read( definitions_buffer, definitions_filename ) ) ) { std::cout << argv[ 0 ] << ": Error reading definitions file \"" << definitions_filename << "\"" << std::endl; return( 1 ); } // fi // Put it in a line-by-line structure TStrings definitions_lines; cpPlugins_bash::Tokenize( definitions_lines, definitions_buffer, "\n" ); // Parse input file TCommands commands; cpPlugins_bash::Parse( commands, definitions_lines ); // Load pre-compiled definitions cpPlugins_bash::LoadDefinitions( commands ); // Expand definitions TCommands definitions; cpPlugins_bash::ExpandDefinitions( definitions, commands ); definitions[ "_export_" ].clear( ); definitions[ "_export_" ].push_back( library_name + std::string( "_EXPORT" ) ); // Get class data std::string class_name = commands[ "class" ][ 0 ]; std::string namespace_name = commands[ "namespace" ][ 0 ]; std::string superclass_name = commands[ "superclass" ][ 0 ]; std::stringstream header; header << "namespace " << namespace_name << std::endl << "{" << std::endl << " class " << class_name << std::endl << " : public " << superclass_name << std::endl << " {" << std::endl << " public:" << std::endl << " typedef " << class_name << " Self;" << std::endl << " typedef " << superclass_name << " Superclass;" << std::endl << " typedef itk::SmartPointer< Self > Pointer;" << std::endl << " typedef itk::SmartPointer< const Self > Pointer;" << std::endl << " protected:" << std::endl << " " << class_name << "( );" << std::endl << " virtual ~" << class_name << "( );" << std::endl << " virtual void _GenerateData( ) ITK_OVERRIDE;" << std::endl; auto inputs = commands.find( "input" ); std::stringstream template_args, input_args; unsigned long id = 0; for( auto iIt = inputs->second.begin( ); iIt != inputs->second.end( ); ++iIt, ++id ) { TStrings toks; cpPlugins_bash::Tokenize( toks, *iIt, "|" ); if( iIt == inputs->second.begin( ) ) { template_args << "class _T" << toks[ 2 ]; input_args << " _T" << toks[ 2 ] << "* input_" << toks[ 2 ]; } else { template_args << ", class _T" << toks[ 2 ]; input_args << ", _T" << toks[ 2 ] << "* input_" << toks[ 2 ]; } // fi header << " template< " << template_args.str( ) << " >" << std::endl << " inline void _GD_" << id << "( " << input_args.str( ) << " );" << std::endl; } // rof header << " private:" << std::endl << " " << class_name << "( const Self& );" << std::endl << " Self& operator=( const Self& );" << std::endl; header << " };" << std::endl << std::endl << "} // ecapseman" << std::endl; // Source code std::stringstream source; source << namespace_name << "::" << class_name << "::" << std::endl << class_name << "( )" << std::endl << " : Superclass( )" << std::endl << "{" << std::endl << "}" << std::endl << std::endl; source << namespace_name << "::" << class_name << "::" << std::endl << "~" << class_name << "( )" << std::endl << "{" << std::endl << "}" << std::endl << std::endl; source << "void " << namespace_name << "::" << class_name << "::" << std::endl << "_GenerateData( )" << std::endl << "{" << std::endl << " auto i = this->Get" << std::endl << "}" << std::endl << std::endl; std::cout << source.str( ) << std::endl; return( 0 ); } // eof - $RCSfile$