Example #1
0
void GenerateServerMethods::generate_CPP_USER(const std::string &destdir, const std::string &name)
{
  const std::string h_name = theClass.getBaseName() + "_ulxr_server.h";
  std::string cpp_name = destdir + theClass.getBaseName() + "_ulxr_server_user.cpp";

  struct stat statbuf;
  if (stat(cpp_name.c_str(), &statbuf) >= 0)
  {
    std::cout << "User file already exists: " << cpp_name << std::endl;
    cpp_name += ".new";
    std::cout << "New template will be created: " << cpp_name << std::endl;
  }

  std::ofstream cpp_file(cpp_name.c_str());
  std::cout << "User file will be created: " << cpp_name << std::endl;

  generateUserSourceHead(cpp_file, h_name);

  cpp_file << "#include <ulxmlrpcpp/ulxr_response.h>\n";
  cpp_file << "#include <ulxmlrpcpp/ulxr_method_adder.h>\n";
  cpp_file << "#include <ulxmlrpcpp/ulxr_signature.h>\n\n";

  cpp_file << "#include \"" << theClass.getSource() << "\"\n";
  cpp_file << "#include \"" << name + "_ulxr_names.h" << "\"\n\n";

  cpp_file <<
    "\nvoid " << name << "Server::setupServerMethods()\n"
    "{\n";

  for (unsigned i = 0; i < theClass.numMethods(); ++i)
  {
    if (i != 0)
      cpp_file << "\n";

    Method method = theClass.getMethod(i);
    method.extractNamespace();

    cpp_file << "  // mapped to: " << method.getCppString(0, false, "");

    if (method.getName() != method.getOverloadName())
       cpp_file << "   (there are overloaded methods)";

    cpp_file <<
      "\n"
      "  method_adder.addMethod(ulxr::make_method(*this, &" << method.getOverloadName(true, "Server") << "),\n"
      "                         " << method.getType().getRpcName() << "::getValueName(),\n"
      "                         ULXR_CALLTO_" << method.getOverloadName(true, "", "_") << ",\n"
      "                         ulxr::Signature()";

    for (unsigned p = 0; p < method.numArgs(); ++p)
      cpp_file << "\n                           << " << method.getArg(p).getType().getRpcName() << "::getValueName()";

    cpp_file <<
      ",\n"
      "                         ulxr_i18n(ULXR_PCHAR(\"Some descriptive comment about '" << method.getCppString(0, true, "") << "'.\"))); // TODO adjust comment\n";
  }

  cpp_file <<
    "}\n\n";
}
void api_generator::generate_rpc_client_files(const fc::path& rpc_client_output_dir, const std::string& generated_filename_suffix)
{
  std::string client_classname = _api_classname + "_rpc_client";

  fc::path client_header_path = rpc_client_output_dir / "include" / "bts" / "rpc_stubs";
  fc::create_directories(client_header_path); // creates dirs for both header and cpp
  fc::path client_header_filename = client_header_path / (client_classname + ".hpp");
  fc::path client_cpp_filename = rpc_client_output_dir / (client_classname + ".cpp");
  fc::path method_overrides_filename = client_header_path / (_api_classname + "_overrides.ipp");
  std::ofstream header_file(client_header_filename.string() + generated_filename_suffix);
  std::ofstream cpp_file(client_cpp_filename.string() + generated_filename_suffix);
  std::ofstream method_overrides_file(method_overrides_filename.string() + generated_filename_suffix);

  write_generated_file_header(header_file);
  write_generated_file_header(method_overrides_file);
  header_file << "#pragma once\n\n";
  header_file << "#include <fc/rpc/json_connection.hpp>\n";
  header_file << "#include <bts/api/" << _api_classname << ".hpp>\n\n";
  header_file << "namespace bts { namespace rpc_stubs {\n\n";
  header_file << "  class " << client_classname << " : public bts::api::" << _api_classname << "\n";
  header_file << "  {\n";
  header_file << "  public:\n";
  header_file << "    virtual fc::rpc::json_connection_ptr get_json_connection() const = 0;\n\n";
  for (const method_description& method : _methods)
  {
    header_file << "    " << generate_signature_for_method(method, "", true) << " override;\n";
    method_overrides_file << "    " << generate_signature_for_method(method, "", true) << " override;\n";
  }

  header_file << "  };\n\n";
  header_file << "} } // end namespace bts::rpc_stubs\n";

  write_generated_file_header(cpp_file);
  cpp_file << "#include <bts/rpc_stubs/" << client_classname << ".hpp>\n";
  cpp_file << "#include <bts/api/conversion_functions.hpp>\n\n";
  cpp_file << "namespace bts { namespace rpc_stubs {\n\n";

  for (const method_description& method : _methods)
  {
    cpp_file << generate_signature_for_method(method, client_classname, false) << "\n";
    cpp_file << "{\n";

    cpp_file << "  fc::variant result = get_json_connection()->async_call(\"" << method.name << "\"";
    for (const parameter_description& parameter : method.parameters)
      cpp_file << ", " << parameter.type->convert_object_of_type_to_variant(parameter.name);
    cpp_file << ").wait();\n";

    if (!std::dynamic_pointer_cast<void_type_mapping>(method.return_type))
      cpp_file << "  return " << method.return_type->convert_variant_to_object_of_type("result") << ";\n";
    cpp_file << "}\n";
  }
  cpp_file << "\n";
  cpp_file << "} } // end namespace bts::rpc_stubs\n";
}
Example #3
0
void GenerateServerMethods::generate_CPP(const std::string &destdir, const std::string &name)
{
  const std::string h_name = theClass.getBaseName() + "_ulxr_server.h";
  const std::string cpp_name = destdir + theClass.getBaseName() + "_ulxr_server.cpp";
  std::ofstream cpp_file(cpp_name.c_str());
  std::cout << "Source file will be created: " << cpp_name << std::endl;

  generateSourceHead(cpp_file, h_name);
  generateSourceCtors(cpp_file, name);
  generateSourceMethods(cpp_file);
}
Example #4
0
inline std::string file_to_string(std::string const& filename)
{
    std::string result;

    std::ifstream cpp_file(filename.c_str());
    if (cpp_file.is_open())
    {
        while (! cpp_file.eof() )
        {
            std::string line;
            std::getline(cpp_file, line);
            result += line + "\n";
        }
    }
    return result;
}
inline void read_wkt(std::string const& filename, std::vector<Geometry>& geometries, Box& box)
{
    std::ifstream cpp_file(filename.c_str());
    if (cpp_file.is_open())
    {
        while (! cpp_file.eof() )
        {
            std::string line;
            std::getline(cpp_file, line);
            if (! line.empty())
            {
                Geometry geometry;
                boost::geometry::read_wkt(line, geometry);
                geometries.push_back(geometry);
                boost::geometry::expand(box, boost::geometry::return_envelope<Box>(geometry));
            }
        }
    }
}
Example #6
0
void compile(void) {
    int i;
    char buf[256];
    if ( cpp_file_cnt() > 0 ) {
        FILE *fp = response( RESPONSE );
        int sys = get_dosex();
      fprintf( fp, " /W%c %s%ci %ce %cl %cA %s \"/I%s\"", 
            ( sys == OPT_W32CON || sys == OPT_W32GUI || sys == OPT_W32DLL ? 
                 'c' : 'a'), // we aren't being too specific on the /W switch
                            // since the compiler isn't spawning the linker directly
            ( get_option( OPT_C99) ? "/9 " : "" ),
            ( get_option( OPT_CPPFILE) ? '+' : '-' ),
            ( get_option( OPT_ERRFILE) ? '+' : '-' ),
            ( get_option( OPT_LSTFILE) ? '+' : '-' ),
            ( get_option( OPT_EXTEND) ? '+' : '-' ),
            //( get_option( OPT_EXCEPTION) ? '+' : '-' ),
            get_cc_opt(),
            get_inc_path()
        );
        for ( i = 0; i < cpp_file_cnt(); i++ )
            fprintf( fp, " %s", cpp_file(i) );
        fclose( fp );
        // this is being done the hard way because of a vagary in the compiler:
        // it cannot handle /S in a response file.  I'll fix it later...
        if ( get_assembler() == OPT_NASM )
            sprintf( buf, " /S ");
        else if ( get_assembler() == OPT_WASM ||
            get_assembler() == OPT_LASM ||
            get_assembler() == OPT_MASM ||
            get_assembler() == OPT_ML )
            sprintf( buf, " -C+M ");
        else
            sprintf( buf, " /c ");
        strcat(buf, "@" RESPONSE);
        exec( "occ", buf );
        if (! get_option(OPT_KEEPRSP) )
            unlink( RESPONSE );
    }
}
void read_wkt(std::string const& filename, std::vector<Tuple>& tuples, Box& box)
{
    std::ifstream cpp_file(filename.c_str());
    if (cpp_file.is_open())
    {
        while (! cpp_file.eof() )
        {
            std::string line;
            std::getline(cpp_file, line);
            Geometry geometry;
            boost::trim(line);
            if (! line.empty() && ! boost::starts_with(line, "#"))
            {
                std::string name;

                // Split at ';', if any
                std::string::size_type pos = line.find(";");
                if (pos != std::string::npos)
                {
                    name = line.substr(pos + 1);
                    line.erase(pos);

                    boost::trim(line);
                    boost::trim(name);
                }

                Geometry geometry;
                boost::geometry::read_wkt(line, geometry);

                Tuple tuple(geometry, name);

                tuples.push_back(tuple);
                boost::geometry::combine(box, boost::geometry::make_envelope<Box>(geometry));
            }
        }
    }
}
void level_converter::generate_level_cpp_file()
{
    fstream cpp_file( output_prefix() + string(".thumb.cpp"),
                      ios_base::out );

    cpp_file << "#include \"" << output_basename << ".hpp\"\n\n\n";

    //for ( tiled_sublevel& the_tiled_sublevel : tiled_sublevel_vec )
    for ( u32 i=0; i<tiled_sublevel_vec.size(); ++i )
    {
        tiled_sublevel& the_tiled_sublevel = tiled_sublevel_vec[i];

        cpp_file << "// " << the_tiled_sublevel.sublevel_file_name << "\n";

        cpp_file << "const sublevel< "
                 << the_tiled_sublevel.the_sublevel.compressed_block_data_vec
                 .size() << ", "
                 << the_tiled_sublevel.the_sublevel.real_size_2d.x << ", "
                 << the_tiled_sublevel.the_sublevel.real_size_2d.y << ", "
                 << the_tiled_sublevel.the_sublevel.sprite_ipg_vec.size() << ", "
                 << the_tiled_sublevel.the_sublevel.sublevel_entrance_vec.size()
                 << " > " << output_basename << "_"
                 << the_tiled_sublevel.output_basename << "\n" << "= {\n";


        // Build the array of compressed block data
        cpp_file << "\t{\n";

        u32 counter = 0;

        for ( u32& the_u32
                : the_tiled_sublevel.the_sublevel.compressed_block_data_vec )
        {
            ////cpp_file << hex << "\t\t0x" << *iter << dec << ",\n";
            //cpp_file << hex << "\t\t0x" << the_u32 << dec << ",\n";
            if ( counter % 4 == 0 )
            {
                cpp_file << "\t\t";
            }

            //cpp_file << hex << "0x" << *iter << dec;
            cpp_file << hex << "0x" << the_u32 << dec;

            if ( counter % 4 == 3 )
            {
                cpp_file << ",\n";
            }
            else
            {
                cpp_file << ", ";
            }

            ++counter;
        }

        if ( counter % 4 != 0 )
        {
            cpp_file << "\n";
        }
        cpp_file << "\t},\n\t\n";


        // Build the array of sprite_init_param_group's
        cpp_file << "\t{\n";

        for ( sprite_init_param_group& sprite_ipg
                : the_tiled_sublevel.the_sublevel.sprite_ipg_vec )
        {
            cpp_file << "\t\t{ ";

            if ( sprite_ipg.type < sprite_type_helper::st_name_vec.size() )
            {
                cpp_file << sprite_type_helper::get_st_name
                         (sprite_ipg.type);
            }
            else
            {
                // Print out a number if the_sprite_type doesn't have a
                // corresponding string in sprite_type_helper::st_name_vec.
                cpp_file << sprite_ipg.type;
            }

            cpp_file << ", " << sprite_ipg.initial_block_grid_x_coord
                     << ", " << sprite_ipg.initial_block_grid_y_coord << ", "
                     << ( sprite_ipg.facing_right ? "true" : "false" );


            // This had to be changed to make the Sherwin's Adventure code
            // compile with the OUTDATED version of arm-none-eabi- prefixed
            // GCC and Binutils that are included in devkitARM
            //// Don't clutter the sprite_init_param_group's that have only
            //// zeroes as extra parameters.
            //if ( !( sprite_ipg.extra_param_0 == 0
            //	&& sprite_ipg.extra_param_1 == 0
            //	&& sprite_ipg.extra_param_2 == 0
            //	&& sprite_ipg.extra_param_3 == 0 ) )
            //{
            //	cpp_file << ", " << sprite_ipg.extra_param_0 << ", "
            //		<< sprite_ipg.extra_param_1 << ", "
            //		<< sprite_ipg.extra_param_2 << ", "
            //		<< sprite_ipg.extra_param_3;
            //}

            //cpp_file << ", " << sprite_ipg.extra_param_0 << ", "
            //	<< sprite_ipg.extra_param_1 << ", "
            //	<< sprite_ipg.extra_param_2 << ", "
            //	<< sprite_ipg.extra_param_3;

            if ( sprite_ipg.type >= sprite_type_helper::lowest_warp_id_st
                    && sprite_ipg.type
                    <= sprite_type_helper::highest_warp_id_st )
            {
                cpp_file << ", " << sprite_ipg.extra_param_0 << ", ";

                //if ( sprite_ipg
                //	<< sprite_ipg.extra_param_1 << ", ";
                if ( sprite_ipg.extra_param_1 == (u32)-1 )
                {
                    //cout << "Found a sprite_init_param_group with -1 for "
                    //	<< "its extra_param_1!\n";
                    cpp_file << i;
                }
                else
                {
                    cpp_file << sprite_ipg.extra_param_1;
                }


                cpp_file << ", " << sprite_ipg.extra_param_2 << ", "
                         << sprite_ipg.extra_param_3;
            }
            else
            {
                cpp_file << ", " << sprite_ipg.extra_param_0 << ", "
                         << sprite_ipg.extra_param_1 << ", "
                         << sprite_ipg.extra_param_2 << ", "
                         << sprite_ipg.extra_param_3;
            }

            cpp_file << " },\n";
        }

        cpp_file << "\t},\n\t\n";

        // Build the array of sublevel_entrance's
        cpp_file << "\t{\n";

        for ( sublevel_entrance& the_sle
                : the_tiled_sublevel.the_sublevel.sublevel_entrance_vec )
        {
            cpp_file << "\t\t{ " << get_sle_name_debug(the_sle.type)
                     << hex << ", vec2_f24p8( {0x"
                     << the_sle.in_sublevel_pos.x.data << "}, {0x"
                     << the_sle.in_sublevel_pos.y.data << "} ) },\n" << dec;
        }

        cpp_file << "\t},\n";


        cpp_file << "};\n\n\n";
    }


    cpp_file << "const level " << output_basename << " = level\n\t"
             << "( sublevel_pointer(" << output_basename << "_"
             << tiled_sublevel_vec[0].output_basename << ")";

    if ( tiled_sublevel_vec.size() == 1 )
    {
        cpp_file << " );\n";
    }
    else
    {
        cpp_file << ",\n";

        //for ( tiled_sublevel& the_tiled_sublevel : tiled_sublevel_vec )
        for ( size_t i=1; i<tiled_sublevel_vec.size(); ++i )
        {
            cpp_file << "\tsublevel_pointer(" << output_basename << "_"
                     << tiled_sublevel_vec[i].output_basename << ")";

            if ( i == tiled_sublevel_vec.size() - 1 )
            {
                cpp_file << " );";
            }
            else
            {
                cpp_file << ",";
            }

            cpp_file << "\n";
        }
    }

    cpp_file << "\n\n\n";


}
Example #9
0
/** @brief Renders the code in proper format in the output C++ file
 *
 *  @param NIL
 *  @return NIL
 */
void source_code::render_code()
{
	int s=strlen(file_name);
	char *file_to_write=(char *)malloc(s+5);
	*file_to_write='\0';
	strcat(file_to_write,file_name);
	strcat(file_to_write,".cpp\0");
	

	std::ofstream cpp_file(file_to_write);

	
	std::string decl;
	decl.append("#include \"supporting_libs.h\"\n\n");

	std::vector< std::pair< std::string,function_declaration > >::iterator itr = generated_cpp_code.begin();



//code for rendering the cpp classes

  for(std::vector<std::pair <std::string,class_declaration > >
   			::iterator class_itr=generated_cpp_classes.begin();
   			 class_itr!=generated_cpp_classes.end()-1;
   			 class_itr++)
   {
   		decl.append("class ");
   		decl.append((class_itr->second).name);
   		//attach the inherited functions here
   		if((class_itr->second).num_base_func >0)
   		{
   			decl.append(": ");
   			std::vector< std::string >::iterator base_functions_itr = (class_itr->second).base_functions.begin();
   			for(int k=0;k<(class_itr->second).num_base_func;k++)
   			{
   				decl.append("public ");
   				decl.append(*(base_functions_itr));
   				base_functions_itr++;


   			}
   		}
   		decl.append("\n{");
   		decl.append("\n public: \n");
   		decl.append(class_itr->first);
   		decl.append("\n};\n");
   }


// For remaining functions iterate over the generated_cpp_code vec	tor
	for(std::vector< std::pair< std::string,function_declaration > >::iterator itr=generated_cpp_code.begin()+1;itr!=generated_cpp_code.end();++itr)
		{
			 decl.append(itr->second.return_type);
			 decl.append(" ");
			 decl.append(itr->second.name);
			 decl.append("(");
			 for(std::vector< string_pair >::iterator i=itr->second.args.begin();i!=itr->second.args.end();++i)
			 {
			 	decl.append(i->second);
			 	decl.append(" ");
			 	decl.append(i->first);
			 	decl.append(",");
			 }
			 if(*(decl.end()-1) == ',')
			 	*(decl.end()-1)=')';
			 else  decl.append(")");
			 
			decl.append("\n{\n");
			decl.append(itr->first);
			decl.append("\n}\n\n");

		}

			// For main function 
		    	decl.append(itr->second.return_type);
			 decl.append(" ");
			 decl.append(itr->second.name);
			 decl.append("(");
			 for(std::vector< string_pair >::iterator i=itr->second.args.begin();i!=itr->second.args.end();++i)
			 {
			 	decl.append(i->second);
			 	decl.append(" ");
			 	decl.append(i->first);
			 	decl.append(",");
			 }
			 if(*(decl.end()-1) == ',')
			 	*(decl.end()-1)=')';
			 else  decl.append(")");
			 
			decl.append("\n{\n");
			decl.append(itr->first);
			decl.append("\n}\n\n");


		cpp_file<<decl;
}
Example #10
0
void NewFilterDialog::createFiles()
{
  QString class_name     = m_Ui.class_edit->text();
  QString h_file_name    = "new_filters/" + class_name.lower() + ".h";
  QString cpp_file_name  = "new_filters/" + class_name.lower() + ".cpp";
  QFile h_file(h_file_name);
  QFile cpp_file(cpp_file_name);
  h_file.open(QIODevice::WriteOnly);
  cpp_file.open(QIODevice::WriteOnly);
  {
    QTextStream h(&h_file);
    QTextStream cpp(&cpp_file);
    h << "//                                                                         \n";
    h << "// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
    h << "// +                                                                      +\n";
    h << "// + This file is part of enVisu.                                         +\n";
    h << "// +                                                                      +\n";
    h << "// + Copyright 2013 O. Gloth, enGits GmbH                                 +\n";
    h << "// +                                                                      +\n";
    h << "// + enGrid is free software: you can redistribute it and/or modify       +\n";
    h << "// + it under the terms of the GNU General Public License as published by +\n";
    h << "// + the Free Software Foundation, either version 3 of the License, or    +\n";
    h << "// + (at your option) any later version.                                  +\n";
    h << "// +                                                                      +\n";
    h << "// + enGrid is distributed in the hope that it will be useful,            +\n";
    h << "// + but WITHOUT ANY WARRANTY; without even the implied warranty of       +\n";
    h << "// + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        +\n";
    h << "// + GNU General Public License for more details.                         +\n";
    h << "// +                                                                      +\n";
    h << "// + You should have received a copy of the GNU General Public License    +\n";
    h << "// + along with enVisu. If not, see <http://www.gnu.org/licenses/>.       +\n";
    h << "// +                                                                      +\n";
    h << "// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
    h << "//                                                                         \n";

    h << "#ifndef " << m_Ui.class_edit->text().lower() << "_H\n";
    h << "#define " << m_Ui.class_edit->text().lower() << "_H\n";
    h << "\n";
    h << "class " << class_name << ";\n";
    h << "\n";
    h << "#include \"mpwsitem.h\"\n";
    h << "#include \"" << class_name.lower() << "config.h\"\n";
    h << "\n";
    h << "#include <" << m_Ui.vtk_edit->text() << ".h>\n";
    h << "\n";
    h << "class " << class_name << " : public MpWsItem\n";
    h << "{\n";
    h << "\n";
    h << "    Q_OBJECT\n";
    h << "\n";
    h << "private:\n";
    h << "\n";
    h << "    " << class_name << "Config dlg;\n";
    h << "    " << m_Ui.vtk_edit->text() << " *vtk;\n";
    h << "\n";
    h << "public:\n";
    h << "\n";
    h << "    " << class_name << " (MpWorkSpace *mws);\n";
    h << "    ~" << class_name << "();\n";
    h << "\n";
    if (m_Ui.polydata_rb->isChecked()) {
      h << "    virtual vtkPolyData* getPolyData();\n";
    } else if (m_Ui.dataset_rb->isChecked()) {
      h << "    virtual vtkDataSet* getDataSet();\n";
    } else if (m_Ui.function_rb->isChecked()) {
      h << "    virtual vtkImplicitFunction* getImplicitFunction();\n";
    };
    h << "\n";
    h << "    virtual void setPolyData        (int i, vtkPolyData         *poly_data);\n";
    h << "    virtual void setDataSet         (int i, vtkDataSet          *data_set);\n";
    h << "    virtual void setImplicitFunction(int i, vtkImplicitFunction *implicit_function);\n";
    h << "    virtual void connectInput       (int i);\n";
    h << "    virtual void disconnectInput    (int i);\n";
    h << "    virtual void connectOutput      (int i);\n";
    h << "    virtual void disconnectOutput   (int i);\n";
    h << "\n";
    h << "public slots:\n";
    h << "\n";
    h << "    virtual void apply ();\n";
    h << "    virtual void config();\n";
    h << "    virtual void help  ();\n";
    h << "    virtual void load  (istream &s);\n";
    h << "    virtual void save  (ostream &s);\n";
    h << "\n";
    h << "};\n";
    h << "\n";
    h << "#endif\n";
    cpp << "#include \"" << m_Ui.class_edit->text().lower() << ".h\"\n";
    cpp << "\n";
    cpp << class_name << "::" << class_name << "(MpWorkSpace *mws) :\n";
    cpp << "        MpWsItem(mws)\n";
    cpp << "{\n";
    cpp << "    loadIcon(\"" << class_name.lower() << ".png\");\n";
    cpp << "    ws->addItem(this);\n";
    cpp << "    setName(\"" << class_name << "\");\n";
    cpp << "    vtk = " << m_Ui.vtk_edit->text() << "::New();\n";
    for (int i = 0; i < m_Ui.inputs_lb->count(); ++i) {
      QString text = m_Ui.inputs_lb->text(i);
      QString type = text.left(19).stripWhiteSpace();
      QString name = text.right(text.length()-22).stripWhiteSpace();
      cpp << "    addInput(\"" << name << "\",\"" << type << "\");\n";
    }
    cpp << "    connect(dlg.apply_pb,SIGNAL(clicked()),this,SLOT(apply()));\n";
    cpp << "    connect(dlg.help_pb,SIGNAL(clicked()),this,SLOT(help()));\n";
    cpp << "    dlg.name_edit->setText(name());\n";
    if (m_Ui.polydata_rb->isChecked()) {
      cpp << "    has_output = true;\n";
      cpp << "    output_type = \"vtkPolyData\";\n";
    } else if (m_Ui.dataset_rb->isChecked()) {
      cpp << "    has_output = true;\n";
      cpp << "    output_type = \"vtkDataSet\";\n";
    } else if (m_Ui.function_rb->isChecked()) {
      cpp << "    has_output = true;\n";
      cpp << "    output_type = \"vtkImplicitFunction\";\n";
    } else {
      cpp << "    has_output = false;\n";
    };
    cpp << "    apply();\n";
    cpp << "};\n";
    cpp << "\n";
    cpp << class_name << "::~" << class_name << "()\n";
    cpp << "{\n";
    cpp << "    vtk->Delete();\n";
    cpp << "};\n";
    cpp << "\n";
    cpp << "void " << class_name << "::apply()\n";
    cpp << "{\n";
    cpp << "    changeName(dlg.name_edit->text());\n";
    cpp << "    ws->render();\n";
    cpp << "};\n";
    cpp << "\n";
    cpp << "void " << class_name << "::config()\n";
    cpp << "{\n";
    cpp << "    if (dlg.exec()) apply();\n";
    cpp << "};\n";
    cpp << "\n";
    cpp << "void " << class_name << "::save(ostream &s)\n";
    cpp << "{\n";
    cpp << "    MpWsItem::save(s);\n";
    cpp << "};\n";
    cpp << "\n";
    cpp << "void " << class_name << "::load(istream &s)\n";
    cpp << "{\n";
    cpp << "    MpWsItem::load(s);\n";
    cpp << "    apply();\n";
    cpp << "};\n";
    cpp << "\n";

    if (m_Ui.polydata_rb->isChecked()) {
      cpp << "vtkPolyData* " << class_name;
      cpp << "::getPolyData()\n";
      cpp << "{\n";
      cpp << "    return vtk->GetOutput();\n";
      cpp << "};\n";
    } else if (m_Ui.dataset_rb->isChecked()) {
      cpp << "vtkDataSet* " << class_name;
      cpp << "::getDataSet()\n";
      cpp << "{\n";
      cpp << "    return vtk->GetOutput();\n";
      cpp << "};\n";
    } else if (m_Ui.function_rb->isChecked()) {
      cpp << "vtkImplicitFunction* " << class_name;
      cpp << "::getImplicitFunction()\n";
      cpp << "{\n";
      cpp << "    return vtk;\n";
      cpp << "};\n";
    };
    cpp << "\n";
    cpp << "void " << class_name << "::setPolyData(int i, vtkPolyData *poly_data)\n";
    cpp << "{\n";
    cpp << "};\n";
    cpp << "\n";
    cpp << "void " << class_name << "::setDataSet(int i, vtkDataSet *data_set)\n";
    cpp << "{\n";
    cpp << "};\n";
    cpp << "\n";
    cpp << "void " << class_name << "::setImplicitFunction(int i, vtkImplicitFunction *function)\n";
    cpp << "{\n";
    cpp << "};\n";
    cpp << "\n";
    cpp << "void " << class_name << "::connectInput(int i)\n";
    cpp << "{\n";
    cpp << "};\n";
    cpp << "\n";
    cpp << "void " << class_name << "::disconnectInput(int i)\n";
    cpp << "{\n";
    cpp << "};\n";
    cpp << "\n";
    cpp << "void " << class_name << "::connectOutput(int i)\n";
    cpp << "{\n";
    cpp << "};\n";
    cpp << "\n";
    cpp << "void " << class_name << "::disconnectOutput(int i)\n";
    cpp << "{\n";
    cpp << "};\n";
    cpp << "\n";
    cpp << "void " << class_name << "::help()\n";
    cpp << "{\n";
    cpp << "};\n";
    cpp << "\n";
  }
}
Example #11
0
void main (int argc, char *argv[])
{      
   WIN32_FIND_DATAA ffd;
   HANDLE h_find;
   char file_pattern[MAX_PATH];

   if (argc != 3)
   {
      printf("patmake.exe <mol-root> <cpp-output>");
      return;
   }

   if (argv[1][strlen(argv[1]) - 1] == '\\')
      argv[1][strlen(argv[1]) - 1] = 0;

   sprintf_s(file_pattern, "%s\\*.mol", argv[1]);

   h_find = FindFirstFileA(file_pattern, &ffd);

   if (h_find == INVALID_HANDLE_VALUE) 
   {
      printf ("FindFirstFile failed (%d)\n", GetLastError());
      return;
   } 
   else 
   {
      try
      {
         FileOutput cpp_file(true, argv[2]);
         SYSTEMTIME st;

         GetSystemTime(&st);

         char buf[200];

         sprintf_s(buf, " * Added %02d/%02d/%02d %02d:%02d:%02d", st.wDay, st.wMonth, st.wYear, st.wHour, st.wMinute, st.wSecond);

         cpp_file.writeStringCR("/*");
         cpp_file.writeStringCR(buf);
         cpp_file.writeStringCR(" */");

         do 
         {
            try
            {
               convertMolfile(argv[1], ffd.cFileName, cpp_file);
            }
            catch (Exception &e)
            {
               printf("Error: %s\n", e.message()); 
            }
         } while (FindNextFileA(h_find, &ffd) != 0);

         printf("Done.\n"); 
      }
      catch (Exception &e)
      {
         printf("Error: %s\n", e.message()); 
      }

      FindClose(h_find);
   }

}