当前位置: 首页>>代码示例>>C++>>正文


C++ TiXmlElement::Accept方法代码示例

本文整理汇总了C++中TiXmlElement::Accept方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlElement::Accept方法的具体用法?C++ TiXmlElement::Accept怎么用?C++ TiXmlElement::Accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TiXmlElement的用法示例。


在下文中一共展示了TiXmlElement::Accept方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: associateBindings

void EntityRecipe::associateBindings()
{
	S_LOG_VERBOSE("Associating bindings.");
	if (mEntitySpec) {
		// Iterate over all entity spec XML nodes
		EntityRecipe::SpecIterator iter(this);
		TiXmlElement *elem = mEntitySpec->FirstChildElement("atlas");
		if (elem) {
			elem->Accept(&iter);
		}
	}
}
开发者ID:angkorcn,项目名称:ember,代码行数:12,代码来源:EntityRecipe.cpp

示例2: _Encode

	/*** XmlForLua ***/
	int XmlForLua::_Encode(lua_State* L){
		// prepare name
		if((lua_gettop(L)<1) || (!lua_istable(L, 1))){
			lua_pushnil(L);
			lua_pushstring(L, "invalid arg");
			return 2;
		}
		// parse
		TiXmlPrinter printer;
		printer.SetIndent("\t");
		TiXmlElement* ele =lua_to_xml(L, "root");
		if(ele->Accept(&printer) && printer.CStr()){
			lua_pushstring(L, printer.CStr());
			delete ele;
			return 1;
		}
		else{
			lua_pushnil(L);
			lua_pushstring(L, "tinyxml unknown error");
			delete ele;
			return 2;
		}
	}
开发者ID:AllenWangxiao,项目名称:winner,代码行数:24,代码来源:XmlForLua.cpp

示例3: start


//.........这里部分代码省略.........

            //if want to dump all will be taken care of from finishEvaluations now for all gens
            //cout << "DUMPING ALL INDIVIDUALS FROM FINAL GENERATION\n";
            //population->getGeneration()->setIDs();
            //population->dump(outputFileName/*+string(".backup.xml")*/,true,true);
            //cout << "DONE DUMPING\n";

            cout << "Experiment finished\n";

            //cout << "Saving Dump...";
            //population->dump(outputFileName,true,false);
            //cout << "Done!\n";


            if(true) {//NEAT::Globals::getSingleton()->getParameterValue("MultiObjective") > 0.5) {
                //need to combine files into one
                //TiXmlDocument doc();
                TiXmlElement *root = new TiXmlElement("Genetics");
                NEAT::Globals::getSingleton()->dump(root);


                /*
                stringstream ss;
                //root->Print(ss,0);


                ss << root;
                string s = ss.str();

                */
                cout << "Merging Output Files...";

                TiXmlPrinter rootPrinter;
                root->Accept( &rootPrinter );
                string s = rootPrinter.CStr();

                ofstream out( outputFileName.c_str() );
                string lastGenFileName = outputFileName + string(".lastgen.xml");
                ofstream out2( lastGenFileName.c_str() );

                out << s.substr(0, s.length() - 3) << ">" <<endl;
                out2 << s.substr(0, s.length() - 3) << ">" <<endl;

                int maxGenerations = int(NEAT::Globals::getSingleton()->getParameterValue("MaxGenerations"));
                for(int i=0; i<maxGenerations; i++) {
                    stringstream ss;
                    ss << i;
                    TiXmlDocument doc( outputFileName + string("-") + ss.str() + string(".backup.xml.gz") );
                    doc.LoadFileGZ();
                    TiXmlPrinter printer;
                    doc.Accept(&printer);
                    out << printer.CStr() << endl;
                    if( i == (maxGenerations - 1))
                        out2 << printer.CStr() << endl;
                }
                out << "</Genetics>" << endl;
                out2 << "</Genetics>" << endl;
                out.close();
                out2.close();
                cout << "Done!\n";
                cout << "Compressing Merged File...";
                stringstream ss;
                ss << "gzip " << outputFileName;
                std::system(ss.str().c_str());
                stringstream ssLastGen;
                ssLastGen << "gzip " << lastGenFileName;
开发者ID:catInMud,项目名称:CPPN_Trimesh,代码行数:67,代码来源:HCUBE_ExperimentRun.cpp

示例4: finishEvaluations

    void ExperimentRun::finishEvaluations()
    {
        cout << "Cleaning up...\n";
        //int generationDumpModulo = int(NEAT::Globals::getSingleton()->getParameterValue("GenerationDumpModulo"));
        if (cleanup)
            population->cleanupOld(INT_MAX/2);

        cout << "Adjusting fitness...\n";
        population->adjustFitness();

        population->getGeneration()->setIDs();
        if((NEAT::Globals::getSingleton()->getParameterValue("DumpAll",0.0) > 0.5) || (population->getGenerationCount() % 50 == 0) ) {
            cout << "Dumping individuals...\n";
            population->dump(outputFileName/*+string(".backup.xml")*/,true,true);
            
            TiXmlElement *root = new TiXmlElement("Genetics");
		    NEAT::Globals::getSingleton()->dump(root);
		    TiXmlPrinter rootPrinter;
			root->Accept( &rootPrinter );
		    string s = rootPrinter.CStr();
		    string rootFileName = outputFileName + string("-root.backup.xml");
		    ofstream out( rootFileName.c_str() );
		    out << s.substr(0, s.length() - 3) << ">" <<endl;
		    out.close();

        } else {
            cout << "Dumping best individuals...\n";
            //population->dumpBest(outputFileName+string(".backup.xml"),true,true);
            population->dumpBest(outputFileName/*+string(".backup.xml")*/,true,true);

            //population->cleanupOld(25);
            //population->dumpBest("out/dumpBestWithGenes(backup).xml",true);
        }
        cout << "Done Dumping\n";

#ifndef HCUBE_NOGUI
        if (frame)
        {
            frame->updateNumGenerations(population->getGenerationCount());
        }
#endif

        cout << "Resetting generation data...\n";
        shared_ptr<NEAT::GeneticGeneration> generation = population->getGeneration();
        experiments[0]->resetGenerationData(generation);

        for (int a=0;a<population->getIndividualCount();a++)
        {
            //cout << __FILE__ << ":" << __LINE__ << endl;
            experiments[0]->addGenerationData(generation,population->getIndividual(a));
        }

        /*
        if(experimentType == EXPERIMENT_TIC_TAC_TOE_GAME)
        {
        //Take the best individual and run him a lot

        ((TicTacToeGameExperiment*)experiment)->setNumGames(20000);
        ((TicTacToeGameExperiment*)experiment)->setNumGames(100);
        }
        */
        
    }
开发者ID:catInMud,项目名称:CPPN_Trimesh,代码行数:63,代码来源:HCUBE_ExperimentRun.cpp

示例5: RunFromMem

int CProxyParse::RunFromMem( wxString content )
{
	char *pBuffer;
	//http://www.51proxied.com/http_non_anonymous.html
	//wxString path = wxT("f:/work/windows/wxUrlRefresh/data/最新透明HTTP代理服务器.htm");
	//wxString path1 = wxT("f:/work/windows/wxUrlRefresh/data/result.xml");

	wxString data_path = wxGetCwd() + "/data/";
	wxString path1 = data_path + "_tmp.xml";

	if (!wxDirExists(data_path))
		wxMkdir(data_path);

	pBuffer = (char*)calloc(content.Length()+1, 1);
	wxStrncpy(pBuffer, content, content.Len()+1);


	wxLogMessage("Run Tidy!");
	TidyBuffer output;
	TidyBuffer errbuf;
	int rc = -1;
	Bool ok;
	TidyDoc tdoc = tidyCreate();                     // Initialize "document"
	tidyBufInit( &output );
	tidyBufInit( &errbuf );
	//printf( "Tidying:\t\%s\\n", input );
	tidySetCharEncoding(tdoc, "utf8");
	ok = tidyOptSetBool( tdoc, TidyXhtmlOut, yes );  // Convert to XHTML
	if ( ok )
		rc = tidySetErrorBuffer( tdoc, &errbuf );      // Capture diagnostics
	if ( rc >= 0 )
		rc = tidyParseString( tdoc, pBuffer );           // Parse the input
	if ( rc >= 0 )
		rc = tidyCleanAndRepair( tdoc );               // Tidy it up!
	if ( rc >= 0 )
		rc = tidyRunDiagnostics( tdoc );               // Kvetch
	if ( rc > 1 )                                    // If error, force output.
		rc = ( tidyOptSetBool(tdoc, TidyForceOutput, yes) ? rc : -1 );
	if ( rc >= 0 )
		rc = tidySaveBuffer( tdoc, &output );          // Pretty Print
	if ( rc >= 0 )
	{
#ifdef _DEBUG
		//if ( rc > 0 )
		//	WriteAllToFile("f:/work/windows/wxUrlRefresh/data/error.xml", (char*)errbuf.bp, errbuf.size);
		WriteAllToFile(path1, (char*)output.bp, output.size);
#endif

	}
	else
		wxLogError("tidyFail");

	tidyBufFree( &output );
	tidyBufFree( &errbuf );
	tidyRelease( tdoc );
	if (pBuffer) free(pBuffer);


	wxLogMessage("Fetch data!");
	// 解析数据
	TiXmlDocument doc(path1);
	if (doc.LoadFile()) 
	{
		// root
		CTiXmlProxyVistor vistor(&m_array);
		TiXmlElement *pRoot = doc.RootElement();
		pRoot->Accept(&vistor);
	}
	else
	{
		wxLogMessage("shit");
		return -2;
	}
	return 0;
}
开发者ID:caicry,项目名称:wxUrlRefresh,代码行数:75,代码来源:url_api.cpp


注:本文中的TiXmlElement::Accept方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。