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


C++ TiXmlPrinter::SetStreamPrinting方法代码示例

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


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

示例1: ModifyXml

bool CSimpleXml::ModifyXml(list<XMLNODEINFO> &lstXmlNodes)
{
    if(m_pDoc == NULL || m_pRoot == NULL)
    {
        return false;
    }
    list<XMLNODEINFO>::iterator itlist = lstXmlNodes.begin();
    int nSize = lstXmlNodes.size();
    for(int i = 0; i < nSize; ++i)
    {
        if(!AccessXmlNode((*itlist), MODIFY))
        {
            return false;
        }
        ++itlist;
    }
    TiXmlPrinter printer;
    printer.SetStreamPrinting();
    if(m_pDoc->Accept( &printer ))
    {
        m_strXml = printer.CStr();
    }
    else
    {
        return false;
    }
    return true;
}
开发者ID:huddy1985,项目名称:ChatOnline,代码行数:28,代码来源:SimpleXml.cpp

示例2: OpenXml

bool CSimpleXml::OpenXml(const string &strXml, int nXmlType)
{
	if(strXml.empty())
	{
		return false;
	}
//	m_pDoc = new TiXmlDocument(strXml.c_str());
	if(XMLFILE == nXmlType)//解析文件
	{
            m_pDoc = new TiXmlDocument(strXml.c_str());
		if(!m_pDoc->LoadFile())  
		{
			return false;
		}
	}
	else if(XMLSTR == nXmlType)//解析字符串
	{
            m_pDoc = new TiXmlDocument;
		 m_pDoc->Parse(strXml.c_str());
	}
	m_pRoot = m_pDoc->RootElement(); 
	if(NULL == m_pDoc || NULL == m_pRoot)
	{
		return false;
	}
	TiXmlPrinter printer;
	printer.SetStreamPrinting();
	if(m_pDoc->Accept(&printer))
	{
		m_strXml = printer.CStr();
		return true;
	}
	return false;
}
开发者ID:huddy1985,项目名称:ChatOnline,代码行数:34,代码来源:SimpleXml.cpp

示例3: getstr

// QC:A (discussion possible sur l'utilisation de snprintf. Les buffers statiques ne sont pas thread safe.)
char* ScriptVariable::getstr() const {
	if(isPointer()) {
		return getPointee()->getstr();
	}

	if(type == VAR_NULL) {
		return NULL;
	}

	if(type == VAR_INT) {
		static char number[32];
		snprintf(number, 32, "%d", value);
		number[31] ='\0';
		return number;
	}

	if(type == VAR_XML) {
		static TiXmlPrinter printer;
		printer = TiXmlPrinter();
		printer.SetStreamPrinting();
		TiXmlNode* node = (TiXmlNode*) data;
		node->Accept(&printer);
		return (char*)printer.CStr();
	}

	if(type == VAR_OBJ) {
		static char address[256];
		snprintf(address, 256, "(*%p:%s)", data, ((ScriptableObject*)data)->getClassName());
		address[255] ='\0';
		return address;
	}

	if(type == VAR_PAIR) {
		static char number[64];
		snprintf(number, 64, "(%ld:%ld)", (long) data, (long) params);
		number[63] ='\0';
		return number;
	}

	if(type == VAR_PACK) {
		static char info[4096]; // XXX : NOT thread safe
		snprintf(info, 4096, "(*%p => \"%s\")", data, params);
		info[4095] ='\0';
		return info;
	}

	if(type == VAR_TBL) {
		static char info[4096]; // XXX : NOT thread safe
		snprintf(info, 4096, "(tbl[%ld]:*%p)", (long)(data?(((ScriptTable*)data)->size()):0), data);
		info[4095] ='\0';
		return info;
	}

	if(type == VAR_FCT) {
		return params;
	}

	return data;
}
开发者ID:Dustpup,项目名称:aurora-game-engine,代码行数:60,代码来源:script_variable.cpp

示例4: getText

size_t XMLSource::getText(const char*& outputBuffer) {
	TiXmlPrinter printer;
	printer.SetStreamPrinting();
	xassert(doc, "No document to save.");
	doc->Accept(&printer);
	outputBuffer = printer.CStr();
	return printer.Size();
}
开发者ID:Dustpup,项目名称:aurora-game-engine,代码行数:8,代码来源:xml_source.cpp

示例5: saveAOD

// QC:?
void ScriptableObject::saveAOD(VFS::File* file)
{
	TiXmlDocument* doc = new TiXmlDocument();
	TiXmlElement* xml = aod()->Clone()->ToElement();

	cleanPtrInAOD(xml);
	doc->LinkEndChild(xml);

	TiXmlPrinter printer;
	printer.SetStreamPrinting();
	doc->Accept(&printer);

	file->truncate();
	file->write((char*)printer.CStr(), printer.Size());

	delete doc;
}
开发者ID:Dustpup,项目名称:aurora-game-engine,代码行数:18,代码来源:scriptable_object.cpp

示例6: ProcessFile

void ProcessFile(const char* fileName)
{
    TiXmlDocument doc;
    doc.LoadFile(fileName);
    if (doc.Error())
    {
        printf("Error in file %s: %s\n", fileName, doc.ErrorDesc());
        return;
    }
    TiXmlPrinter printer;
    printer.SetStreamPrinting();
    doc.Accept(&printer);

    FILE *f = fopen(fileName, "wb");
    if (!f)
        return;

    fwrite(printer.CStr(), printer.Size(), 1, f);
    fclose(f);
}
开发者ID:Distrotech,项目名称:codeblocks,代码行数:20,代码来源:scrooge.cpp

示例7: GetXMLStream

/**************************************************************************
* name       : GetXMLStream
* description: 获取xml流
* input      : NA
* output     : nXMLStreamLength
* return     : const char* xml流
* remark     : NA
**************************************************************************/
const char*  CXml::GetXMLStream(unsigned int &uiXMLStreamLength)
{
	TiXmlPrinter xmlPrinter;
	xmlPrinter.SetStreamPrinting();		

	if (NULL == m_pXMlDoc)
	{
		SAFE_NEW(m_pXMlDoc, TiXmlDocument);//lint !e774
	}

	CHECK_POINTER(m_pXMlDoc, NULL);//lint !e774
	if (!m_pXMlDoc->Accept(&xmlPrinter))
	{
		return NULL;
	}

    uiXMLStreamLength = xmlPrinter.Size();

	m_strStream = xmlPrinter.CStr();
    return m_strStream.c_str();
}
开发者ID:eSDK,项目名称:esdk_elte,代码行数:29,代码来源:eLTE_Xml.cpp

示例8: main


//.........这里部分代码省略.........
		doc.Clear();

		istringstream parse0( str );
		parse0 >> doc;
		//cout << doc << '\n';

		XmlTest( "CDATA stream.", doc.FirstChildElement()->FirstChild()->Value(), 
								 "I am > the rules!\n...since I make symbolic puns",
								 true );
		#endif

		TiXmlDocument doc1 = doc;
		//doc.Print();

		XmlTest( "CDATA copy.", doc1.FirstChildElement()->FirstChild()->Value(), 
								 "I am > the rules!\n...since I make symbolic puns",
								 true );
	}
	{
		// [ 1482728 ] Wrong wide char parsing
		char buf[256];
		buf[255] = 0;
		for( int i=0; i<255; ++i ) {
			buf[i] = (char)((i>=32) ? i : 32);
		}
		TIXML_STRING str( "<xmlElement><![CDATA[" );
		str += buf;
		str += "]]></xmlElement>";

		TiXmlDocument doc;
		doc.Parse( str.c_str() );

		TiXmlPrinter printer;
		printer.SetStreamPrinting();
		doc.Accept( &printer );

		XmlTest( "CDATA with all bytes #1.", str.c_str(), printer.CStr(), true );

		#ifdef TIXML_USE_STL
		doc.Clear();
		istringstream iss( printer.Str() );
		iss >> doc;
		std::string out;
		out << doc;
		XmlTest( "CDATA with all bytes #2.", out.c_str(), printer.CStr(), true );
		#endif
	}
	{
		// [ 1480107 ] Bug-fix for STL-streaming of CDATA that contains tags
		// CDATA streaming had a couple of bugs, that this tests for.
		const char* str =	"<xmlElement>"
								"<![CDATA["
									"<b>I am > the rules!</b>\n"
									"...since I make symbolic puns"
								"]]>"
							"</xmlElement>";
		TiXmlDocument doc;
		doc.Parse( str );
		doc.Print();

		XmlTest( "CDATA parse. [ 1480107 ]", doc.FirstChildElement()->FirstChild()->Value(), 
								 "<b>I am > the rules!</b>\n...since I make symbolic puns",
								 true );

		#ifdef TIXML_USE_STL
开发者ID:huntriver,项目名称:TankVSBugs-CSE380-,代码行数:66,代码来源:xmltest.cpp

示例9: BuildPlateString


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

        //如果输出附加信息
        if (m_cModuleParams.cResultSenderParam.fOutputAppendInfo)
        {
            if (m_cModuleParams.cResultSenderParam.fOutputObservedFrames)
            {
                //有效帧数
                pValue = new TiXmlElement("ObservedFrames");
                if (pValue)
                {
                    pValue->SetAttribute("value", "1");
                    pValue->SetAttribute("chnname", "有效帧数");
                    pResult->LinkEndChild(pValue);
                }
            }

            //可信度
            pValue = new TiXmlElement("Confidence");
            if (pValue)
            {
                sprintf(szConf, "%.3f", exp(log(pCarLeftInfo->cCoreResult.fltAverageConfidence) * 0.143));
                pValue->SetAttribute("value", szConf);
                pValue->SetAttribute("chnname", "平均可信度");
                pResult->LinkEndChild(pValue);
            }

            //首字符可信度
            pValue = new TiXmlElement("FirstCharConf");
            if (pValue)
            {
                sprintf(szConf, "%.3f", pCarLeftInfo->cCoreResult.fltFirstAverageConfidence);
                pValue->SetAttribute("value", szConf);
                pValue->SetAttribute("chnname", "首字可信度");
                pResult->LinkEndChild(pValue);
            }

            //车身颜色
            if (m_cModuleParams.cTrackerCfgParam.fEnableRecgCarColor)
            {
                pValue = new TiXmlElement("CarColor");
                if (pValue)
                {
                    GetCarColor(pCarLeftInfo, szConf);
                    pValue->SetAttribute("value", szConf);
                    pValue->SetAttribute("chnname", "车身颜色");
                    pResult->LinkEndChild(pValue);
                }
            }

            //车牌HSL值
            if(m_cModuleParams.cTrackerCfgParam.fProcessPlate_BlackPlate_Enable) //黑牌参数使能
            {
                pValue = new TiXmlElement("HSL");
                if (pValue)
                {
                    HV_Trace(5,"---AppendInfo:H:%d\tS:%d\tL:%d\n", pCarLeftInfo->cCoreResult.iH, pCarLeftInfo->cCoreResult.iS, pCarLeftInfo->cCoreResult.iL);
                    sprintf(szConf, "H:%d\tS:%d\tL:%d", pCarLeftInfo->cCoreResult.iH, pCarLeftInfo->cCoreResult.iS, pCarLeftInfo->cCoreResult.iL);
                    pValue->SetAttribute("value", szConf);
                    pValue->SetAttribute("chnname", "车牌HSL值");
                    pResult->LinkEndChild(pValue);
                }
            }


            //处理时间
            DWORD32 dwProcTime = GetSystemTick() - pCarLeftInfo->cCoreResult.cResultImg.pimgBestSnapShot->GetRefTime();
            if (dwProcTime > 180)
            {
                dwProcTime = 180 - DWORD32(1 + (54.0 * rand() / (RAND_MAX + 1.0)) - 27);
            }
            pValue = new TiXmlElement("ProcTime");
            if (pValue)
            {
                sprintf(szConf, "%d", dwProcTime);
                pValue->SetAttribute("value", szConf);
                pValue->SetAttribute("chnname", "处理时间");
                pResult->LinkEndChild(pValue);
            }

        } // end of if (m_cModuleParams.cResultSenderParam.fOutputAppendInfo)
    } // end of if (pResult)

    TiXmlPrinter cTxPr;
    if (m_pXmlDoc)
    {
        cTxPr.SetStreamPrinting();
        m_pXmlDoc->Accept(&cTxPr);

        int nCpyLen = MIN_INT(*piPlateStringSize, (int)cTxPr.Size() + 1);
        HV_memcpy( pszPlateString, cTxPr.CStr(), nCpyLen );
        pszPlateString[nCpyLen - 1] = '\0';
        *piPlateStringSize = nCpyLen;
    }
    else
    {
        *piPlateStringSize = 0;
    }

    return S_OK;
}
开发者ID:fangbaolei,项目名称:EC700IR,代码行数:101,代码来源:DataCtrl.cpp

示例10: returnValue

Atlas::Message::MapType EntityRecipe::createEntity(Eris::TypeService& typeService)
{
	S_LOG_VERBOSE("Creating entity.");

	ScriptingService& scriptingService = EmberServices::getSingleton().getScriptingService();
	// Loading script code
	scriptingService.executeCode(mScript, "LuaScriptingProvider");

	// Walking through adapter bindings
	for (BindingsStore::iterator I = mBindings.begin(); I != mBindings.end(); ++I) {
		const std::string& func = I->second->getFunc();

		S_LOG_VERBOSE(" binding: " << I->first << " to func " << func);

		if (func.empty()) {
			std::vector<std::string>& adapters = I->second->getAdapters();

			if (adapters.size() == 1) {
				std::string adapterName = adapters[0];
				Atlas::Message::Element val = mGUIAdapters[adapterName]->getValue();
				I->second->setValue(val);
			} else {
				S_LOG_WARNING("Should be only one adapter without calling function.");
			}
		} else {
			Lua::LuaScriptingCallContext callContext;

			lua_State* L = static_cast<Lua::LuaScriptingProvider*> (scriptingService.getProviderFor("LuaScriptingProvider"))->getLuaState();

			// Pushing function params
			std::vector<std::string>& adapters = I->second->getAdapters();
			for (std::vector<std::string>::iterator J = adapters.begin(); J != adapters.end(); J++) {
				std::string adapterName = *J;
				Atlas::Message::Element* val = new Atlas::Message::Element(mGUIAdapters[adapterName]->getValue());
				tolua_pushusertype_and_takeownership(L, val, "Atlas::Message::Element");
			}

			// Calling test function
			scriptingService.callFunction(func, adapters.size(), "LuaScriptingProvider", &callContext);

			LuaRef returnValue(callContext.getReturnValue());

			Atlas::Message::Element returnObj;
			returnObj = returnValue.asObject<Atlas::Message::Element> ("Atlas::Message::Element");
			I->second->setValue(returnObj);
		}
	}
	//Inject all default attributes that aren't yet added.
	// 	TiXmlElement *elem = mEntitySpec->FirstChildElement("atlas");
	// 	if (elem)
	// 	{
	// 		Eris::TypeInfo* erisType = mConn->getTypeService()->getTypeByName(getEntityType());
	// 		if (erisType) {
	// 			const Atlas::Message::MapType& defaultAttributes = erisType->getAttributes();
	// 			for (Atlas::Message::MapType::const_iterator I = defaultAttributes.begin(); I != defaultAttributes.end(); ++I) {
	// 				bool hasAttribute = false;
	// 				TiXmlNode* child(0);
	// 				while(child = elem->IterateChildren(child)) {
	// 					if (child->ToElement()) {
	// 						if (std::string(child->ToElement()->Attribute("name")) == I->first) {
	// 							hasAttribute = true;
	// 							break;
	// 						}
	// 					}
	// 				}
	//
	// 				if (!hasAttribute) {
	// 					//The attribute isn't present, we'll inject it
	// 					//This a bit contrived, since we'll now first convert the atlas into xml and inject it into the TiXmlElement (which will convert the xml strings into TiXml structures). And then later on we'll parse the xml again and create the final atlas data from it. However, the main reason for doing it this way is that in the future we would want to have nested child elements, which could be repeated. And in those cases we'll want to work directly with xml.
	// 				}
	// 			}
	// 		}
	// 	}
	/*
	 std::stringstream str;

	 Atlas::Message::Element element(message);

	 Atlas::Message::QueuedDecoder decoder;

	 Atlas::Codecs::XML codec(str, decoder);
	 Atlas::Formatter formatter(str, codec);
	 Atlas::Message::Encoder encoder(formatter);
	 formatter.streamBegin();
	 encoder.streamMessageElement(message);
	 formatter.streamEnd();
	 */
	if (mEntitySpec) {
		// Print entity into string
		TiXmlPrinter printer;
		printer.SetStreamPrinting();
		mEntitySpec->Accept(&printer);

		S_LOG_VERBOSE("Composed entity: " << printer.Str());

		std::stringstream strStream(printer.CStr(), std::ios::in);

		// Create objects
		Atlas::Message::QueuedDecoder decoder;
		Atlas::Codecs::XML codec(strStream, decoder);
//.........这里部分代码省略.........
开发者ID:angkorcn,项目名称:ember,代码行数:101,代码来源:EntityRecipe.cpp

示例11: Trace

    int ServiceLogicFacade::Trace(struct soap* soap, _ns2__Trace* request, _ns2__TraceResponse* response) const {
        
        RasterImage* rasterImage = NULL;
        VectorImage* vectorImage = NULL;
        TiXmlDocument* svgXmlDocument = NULL;

        try {
        
            if (!securityModule->CheckSystemID(request->authToken)) {
                response->statusCode = StatusCodes::FORBIDDEN;
                logger->LogMessage("Authentication token {" + request->authToken + "} is invalid. Access denied.");
                return SOAP_OK;
            }

            //decode image data from base64
            string decodedImgData;

            bool encodingSuccessful = Base64::Decode(request->imageData, decodedImgData);

            if (!encodingSuccessful) {
                response->statusCode = StatusCodes::DECODING_ERROR;
                goto CLEANUP;
            }

            istringstream sourceImageStream(decodedImgData);

            //create RasterImage instance

            try {
                rasterImage = WinBMP::FromStream(sourceImageStream);
            }
            catch (const ImTrcr::Imaging::InvalidBmpStreamException& ex) {
                response->statusCode = StatusCodes::WRONG_FORMAT_ERROR;
                logger->LogMessage("Wrong format of received image. Vectorization failed. Authentication token of external system is {" + request->authToken + "}.");
                goto CLEANUP;
            }
            catch (...) {
                response->statusCode = StatusCodes::WRONG_FORMAT_ERROR;
                logger->LogMessage("Wrong format of received image. Vectorization failed. Authentication token of external system is {" + request->authToken + "}.");
                goto CLEANUP;
            }

            TracingOptions opts;
            if (!StringUtils::TryParseInt(request->despecklingPixels, opts.despecklingPixels)) {
                response->statusCode = StatusCodes::WRONG_FORMAT_ERROR;
                goto CLEANUP;
            }
            if (!StringUtils::TryParseInt(request->angularity, opts.angularity)) {
                response->statusCode = StatusCodes::WRONG_FORMAT_ERROR;
                goto CLEANUP;
            }

            //trace RasterImage instance to VectorImage instance
            try {
                vectorImage = tracer->Trace(*rasterImage, opts);
            }
            catch (...) {
                response->statusCode = StatusCodes::TRACING_ERROR;
                goto CLEANUP;
            }

            //serialize VectorImage to SVG XML and put it into response object
            svgXmlDocument = svgSerializer->Serialize(*vectorImage);

            TiXmlPrinter printer;
            printer.SetStreamPrinting();
            svgXmlDocument->Accept(&printer);
            response->svgXml = printer.CStr();
            response->statusCode = StatusCodes::OK;
            goto CLEANUP;
        }
        catch (...) {
            response->statusCode = StatusCodes::UNKNOWN_ERROR;
            goto CLEANUP;
        }

    CLEANUP:
        MemoryUtils::SafeFree(&rasterImage);
        MemoryUtils::SafeFree(&vectorImage);
        MemoryUtils::SafeFree(&svgXmlDocument);

        return SOAP_OK;
    }
开发者ID:maxtyutmanov,项目名称:imtrcr,代码行数:83,代码来源:ServiceLogicFacade.cpp


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