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


C++ TiXmlDocument::LoadBuffer方法代码示例

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


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

示例1: LoadFontRes

bool KAppRes::LoadFontRes()
{
	bool retval = false;
	void* pBuffer = NULL;
	unsigned long dwBuffer = 0;
	TiXmlDocument xmlDoc;
	const TiXmlElement* pXmlChild = NULL;
	const TiXmlElement* pXmlItem = NULL;

	if (!GetRawDataFromRes("fonts.xml", &pBuffer, dwBuffer))
		goto clean0;

	if (!xmlDoc.LoadBuffer((char*)pBuffer, (long)dwBuffer, TIXML_ENCODING_UTF8))
		goto clean0;

	pXmlChild = xmlDoc.FirstChildElement("fonts");
	if (!pXmlChild)
		goto clean0;

	pXmlItem = pXmlChild->FirstChildElement("font");
	while (pXmlItem) 
	{
		std::string strId;
		std::wstring strFontface;
		int nFontSize = 11;
		int nUnderline = 0;
		int nBold = 0;
		int nItalic = 0;

		strId = pXmlItem->Attribute("id");
		strFontface = AnsiToUnicode(pXmlItem->Attribute("fontface"));
		pXmlItem->Attribute("fontsize", &nFontSize);
		pXmlItem->Attribute("underline", &nUnderline);
		pXmlItem->Attribute("bold", &nBold);
		pXmlItem->Attribute("italic", &nItalic);

		if (strId.length() && strFontface.length())
		{
			m_mapFontTable[strId] = CreateFont(
				strFontface,
				nFontSize,
				nBold ? TRUE : FALSE,
				nUnderline ? TRUE : FALSE,
				nItalic ? TRUE : FALSE
				);
		}

		pXmlItem = pXmlItem->NextSiblingElement("font");
	}

clean0:
	if (pBuffer)
	{
		FreeRawData(pBuffer);
	}

	return retval;
}
开发者ID:dreamsxin,项目名称:PcManager,代码行数:58,代码来源:kscres.cpp

示例2: LoadStringRes

bool KAppRes::LoadStringRes()
{
	bool retval = false;
	void* pBuffer = NULL;
	unsigned long dwBuffer = 0;
	TiXmlDocument xmlDoc;
	const TiXmlElement* pXmlChild = NULL;
	const TiXmlElement* pXmlItem = NULL;

	if (!GetRawDataFromRes("strings.xml", &pBuffer, dwBuffer))
		goto clean0;

	if (!xmlDoc.LoadBuffer((char*)pBuffer, (long)dwBuffer, TIXML_ENCODING_UTF8))
		goto clean0;

	pXmlChild = xmlDoc.FirstChildElement("strings");
	if (!pXmlChild)
		goto clean0;

	pXmlItem = pXmlChild->FirstChildElement("string");
	while (pXmlItem) 
	{
		std::string strId;
		std::string strValue;

		strId = pXmlItem->Attribute("id");
		strValue = pXmlItem->Attribute("value");

		if (strId.length() && strValue.length())
		{
			std::wstring strTemp = Utf8ToUnicode(strValue);
			update_string(strTemp);
			m_mapStringTable[strId] = strTemp;
		}

		pXmlItem = pXmlItem->NextSiblingElement("string");
	}

	retval = true;

clean0:
	if (pBuffer)
	{
		FreeRawData(pBuffer);
	}

	return retval;
}
开发者ID:dreamsxin,项目名称:PcManager,代码行数:48,代码来源:kscres.cpp

示例3: LoadXmlRes

bool KAppRes::LoadXmlRes()
{
	bool retval = false;
	void* pBuffer = NULL;
	unsigned long dwBuffer = 0;
	TiXmlDocument xmlDoc;
	const TiXmlElement* pXmlChild = NULL;
	const TiXmlElement* pXmlItem = NULL;

	if (!GetRawDataFromRes("xmls.xml", &pBuffer, dwBuffer))
		goto clean0;

	if (!xmlDoc.LoadBuffer((char*)pBuffer, (long)dwBuffer, TIXML_ENCODING_UTF8))
		goto clean0;

	pXmlChild = xmlDoc.FirstChildElement("xmls");
	if (!pXmlChild)
		goto clean0;

	pXmlItem = pXmlChild->FirstChildElement("xml");
	while (pXmlItem) 
	{
		std::string strId;
		std::string strPath;

		strId = pXmlItem->Attribute("id");
		strPath = pXmlItem->Attribute("path");

		if (strId.length() && strPath.length())
		{
			m_mapXmlTable[strId] = strPath;
		}

		pXmlItem = pXmlItem->NextSiblingElement("xml");
	}

    retval = true;

clean0:
	if (pBuffer)
	{
		FreeRawData(pBuffer);
	}

	return retval;
}
开发者ID:dreamsxin,项目名称:PcManager,代码行数:46,代码来源:kscres.cpp

示例4: LoadColorRes

bool KAppRes::LoadColorRes()
{
	bool retval = false;
	void* pBuffer = NULL;
	unsigned long dwBuffer = 0;
	TiXmlDocument xmlDoc;
	const TiXmlElement* pXmlChild = NULL;
	const TiXmlElement* pXmlItem = NULL;

	if (!GetRawDataFromRes("colors.xml", &pBuffer, dwBuffer))
		goto clean0;

	if (!xmlDoc.LoadBuffer((char*)pBuffer, (long)dwBuffer, TIXML_ENCODING_UTF8))
		goto clean0;

	pXmlChild = xmlDoc.FirstChildElement("colors");
	if (!pXmlChild)
		goto clean0;

	pXmlItem = pXmlChild->FirstChildElement("color");
	while (pXmlItem) 
	{
		std::string strId;
		std::string strColor;

		strId = pXmlItem->Attribute("id");
		strColor = pXmlItem->Attribute("value");

		if (strId.length() && strColor.length())
		{
			m_mapColorTable[strId] = HexStringToColor(strColor.c_str());
		}

		pXmlItem = pXmlItem->NextSiblingElement("color");
	}

clean0:
	if (pBuffer)
	{
		FreeRawData(pBuffer);
	}

	return retval;
}
开发者ID:dreamsxin,项目名称:PcManager,代码行数:44,代码来源:kscres.cpp

示例5: parseXml

void MCF::parseXml(char* buff, uint32 buffLen)
{
	if (m_bStopped)
		return;

	TiXmlDocument doc;
	
	doc.SetCondenseWhiteSpace(false);
	doc.LoadBuffer(buff, buffLen);

	TiXmlNode *fNode = doc.FirstChild("files");

	if (!fNode)
		throw gcException(ERR_XML_NOPRIMENODE);

	TiXmlElement* pChild = fNode->FirstChildElement();

	while (pChild)
	{
		if (m_bStopped)
			return;

		MCFCore::MCFFile* temp = new MCFCore::MCFFile();

		try
		{
			temp->loadXmlData(pChild);
			m_pFileList.push_back( temp );
		}
		catch (gcException &)
		{
			safe_delete(temp);
		}

		pChild = pChild->NextSiblingElement();
	}
}
开发者ID:boskee,项目名称:Desurium-1,代码行数:37,代码来源:MCF.cpp

示例6: UploadDump

bool UploadDump(const char* file, const char* user, int build, int branch, DelegateI<Prog_s>* progress)
{
	Logger log;
	log.write("---------------------------------------\r\n");

	time_t ltime; /* calendar time */
	ltime=time(NULL); /* get current cal time */

	
#ifdef WIN32
	char buff[255] = {0};

	struct tm t;
	localtime_s(&t, &ltime);
	asctime_s(buff, 255, &t);
#else
	struct tm *t = localtime(&ltime);
	char* buff = asctime(t);
#endif

	log.write("%s\r\n", buff);
	log.write("---------------------------------------\r\n");

	log.write("Uploaded crash dump: [%s]\r\n", file);


	gcString dump(file);

	if (PrepDumpForUpload(dump) == false)
	{
		log.write("Failed to prepare crash dump.\r\n");
		return false;
	}
	else
	{
		log.write("Prepared crash dump to: [%s]\r\n", dump.c_str());
	}

	std::string os = UTIL::OS::getOSString();

	HttpHandle hh(DUMP_UPLOAD_URL);

	if (progress)
		hh->getProgressEvent() += progress;

	hh->setUserAgent(DUMP_UPLOAD_AGENT);

	hh->cleanUp();
	hh->addPostText("os", os.c_str());
	hh->addPostText("build", build);
	hh->addPostText("appid", branch);

	if (user)
		hh->addPostText("user", user);

	hh->addPostFile("crashfile", dump.c_str());

	try
	{
		hh->postWeb();
	}
	catch (gcException &except)
	{
		log.write("Failed to upload crash: %s [%d.%d].\r\n", except.getErrMsg(), except.getErrId(), except.getSecErrId());
		return false;
	}

	TiXmlDocument doc;
	doc.LoadBuffer(const_cast<char*>(hh->getData()), hh->getDataSize());
	
	try
	{
		XML::processStatus(doc, "crashupload");
		log.write("Uploaded dump\r\n");
		UTIL::FS::delFile(UTIL::FS::Path(dump, "", true));		
	}
	catch (gcException &)
	{
		log.write("Bad status returned from upload crash dump.\r\n");

		gcString res;
		res.assign(hh->getData(), hh->getDataSize());

		log.write("Result: \r\n\r\n%s\r\n\r\n", res.c_str());
		
		return false;	
	}

	return true;
}
开发者ID:boskee,项目名称:Desurium-1,代码行数:90,代码来源:CrashuploaderMain.cpp

示例7: _LoadFromFile

BOOL CStubbornFiles::_LoadFromFile()
{
    BOOL retval = FALSE;
    CDataFileLoader dataLoader;
    TiXmlDocument xmlDoc;
    const TiXmlElement* pXmlItems = NULL;
    const TiXmlElement* pXmlItem = NULL;
    const TiXmlElement* pXmlTime = NULL;
    TCHAR szConfPath[MAX_PATH] = { 0 };
    CStringA strXmlAnsi;
    CStringW strPathUtf16;
    CStringA strPathAnsi;
    SYSTEMTIME sysTime = { 0 };
    CStringA strTime;

    GetLocalTime(&sysTime);
    strTime.Format("%d.%d.%d", sysTime.wYear, sysTime.wMonth, sysTime.wDay);

    GetModuleFileName(NULL, szConfPath, MAX_PATH);
    PathRemoveFileSpec(szConfPath);
    PathAppend(szConfPath, _T("data\\strash.dat"));


    if (!dataLoader.LoadFile(szConfPath, strXmlAnsi))
        goto clean0;

    if (!xmlDoc.LoadBuffer((LPSTR)(LPCSTR)strXmlAnsi, strXmlAnsi.GetLength(), TIXML_ENCODING_UTF8))
        goto clean0;

    pXmlTime = xmlDoc.FirstChildElement("time");
    if (!pXmlTime)
        goto clean0;

    if (strTime.Compare(pXmlTime->GetText()))
        goto clean0;

    pXmlItems = xmlDoc.FirstChildElement("items");
    if (!pXmlItems)
        goto clean0;

    pXmlItem = pXmlItems->FirstChildElement("item");
    while (pXmlItem)
    {
        strPathAnsi = pXmlItem->GetText();
        if (strPathAnsi.GetLength())
        {
            strPathUtf16 = KUTF8_To_UTF16(strPathAnsi);

            if (GetFileAttributes(strPathUtf16) != INVALID_FILE_ATTRIBUTES)
            {
                m_fileList.AddTail(strPathUtf16);
                m_fileMap[strPathUtf16] = TRUE;
            }
        }

        pXmlItem = pXmlItem->NextSiblingElement("item");
    }

    retval = TRUE;

clean0:
    return retval;
}
开发者ID:dudor,项目名称:pcmanager,代码行数:63,代码来源:stubbornfiles.cpp


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