Example #1
0
KmlPastebufferType Kml::ParseOnePlacemarkPoint( TiXmlNode* node, wxString& name ) {
    double newLat = 0., newLon = 0.;
    dPointList coordinates;

    if( ParseCoordinates( node->ToElement(), coordinates ) ) {
        newLat = coordinates[0].y;
        newLon = coordinates[0].x;
    }

    if( newLat == 0.0 && newLon == 0.0 ) {
        wxString msg( _T("KML Parser failed to convert <Point> coordinates.") );
        wxLogMessage( msg );
        return KML_PASTE_INVALID;
    }
    wxString pointName = wxEmptyString;
	TiXmlElement* e = node->Parent()->FirstChild( "name" )->ToElement();
    if( e ) pointName = wxString( e->GetText(), wxConvUTF8 );

    wxString pointDescr = wxEmptyString;
    e = node->Parent()->FirstChildElement( "description" );

    // If the <description> is an XML element we must convert it to text,
    // otherwise it gets lost.
    if( e ) {
        TiXmlNode* n = e->FirstChild();
        if( n ) switch( n->Type() ){
            case TiXmlNode::TINYXML_TEXT:
                pointDescr = wxString( e->GetText(), wxConvUTF8 );
                break;
            case TiXmlNode::TINYXML_ELEMENT:
                TiXmlPrinter printer;
                printer.SetIndent( "\t" );
                n->Accept( &printer );
                pointDescr = wxString( printer.CStr(), wxConvUTF8 );
                break;
        }
    }

    // Extended data will override description.
    TiXmlNode* n = node->Parent()->FirstChild( "ExtendedData" );
    if( n ) {
        TiXmlPrinter printer;
        printer.SetIndent( "\t" );
        n->Accept( &printer );
        pointDescr = wxString( printer.CStr(), wxConvUTF8 );
    }

    // XXX leak ?
    parsedRoutePoint = new RoutePoint();
    parsedRoutePoint->m_lat = newLat;
    parsedRoutePoint->m_lon = newLon;
    parsedRoutePoint->m_bIsolatedMark = true;
    parsedRoutePoint->m_bPtIsSelected = false;
    parsedRoutePoint->m_MarkDescription = pointDescr;
    parsedRoutePoint->SetName( pointName );

    return KML_PASTE_WAYPOINT;
}
status_t Converter::ConvertPDoc2FreeMind()
{
	status_t		err					= B_OK;
	BMessage		*inMessage			= new BMessage();
	BMessage		*tmpMessage			= new BMessage();
	void			*id					= NULL;

 	allConnections	= new BMessage();
	selected		= new BMessage();
	allNodes		= new BMessage();


	err = inMessage->Unflatten(in);
	if (err == B_OK)
	{
		inMessage->FindMessage("PDocument::allConnections",allConnections);
		inMessage->FindMessage("PDocument::selected",selected);
		inMessage->FindMessage("PDocument::allNodes",allNodes);
		int32 i = 0;
		while(allNodes->FindMessage("node",i,tmpMessage)==B_OK)
		{
			tmpMessage->FindPointer("this",&id);
			nodes[(int32)id]=tmpMessage;
			tmpMessage = new BMessage();
-			i++;
		}
		i = 0;
		while(allConnections->FindMessage("node",i,tmpMessage)==B_OK)
		{
			tmpMessage->FindPointer("this",&id);
			connections[(int32)id]=tmpMessage;
			tmpMessage = new BMessage();
			i++;
		}

		BMessage	*node= GuessStartNode();
		TiXmlDocument	doc;
		TiXmlElement	freeMap("map");
		freeMap.SetAttribute("version","0.9.0");
		freeMap.SetAttribute("background_color","#ffffff");
		TiXmlComment	comment("this File was gernerated by ProjectConceptor! - To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net");
		freeMap.InsertEndChild(comment);

		tmpMessage=GuessStartNode();
	//	tmpMessage = nodes.begin()->second;
		freeMap.InsertEndChild(ProcessNode(tmpMessage));
		doc.InsertEndChild(freeMap);
		TiXmlPrinter	printer;
//		printer.SetStreamPrinting();
//		printer.SetLineBreak("\n");
//		printer.SetIndent("\t");
		doc.Accept( &printer );
		out->Write(printer.CStr(),strlen(printer.CStr()));
	}
	return err;
}
Example #3
0
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;
}
Example #4
0
string Versioning::upgradeFrom1To2(string content)
{
    TiXmlDocument doc;
    doc.Parse(content.c_str());
    RRNode node(doc.RootElement());
    node.gotoElement("world");
    int w = node.attrInt("width");
    int h = node.attrInt("height");
    node.setAttr("version", "2");
    for (node.gotoElement("items")->gotoChild("item"); !node.isNull(); node.gotoNext())
    {
        node.setAttr("x", floatToStr(node.attrFloat("x") / w));
        node.setAttr("y", floatToStr(node.attrFloat("y") / h));
        node.setAttr("width", floatToStr(node.attrFloat("width") / w));
        node.setAttr("height", floatToStr(node.attrFloat("height") / h));
    }

    for (node.gotoElement("rooms")->gotoChild("room"); !node.isNull(); node.gotoNext())
    {
        for (node.gotoChild("area"); !node.isNull(); node.gotoNext())
        {
            node.setAttr("x", floatToStr(node.attrFloat("x") / w));
            node.setAttr("y", floatToStr(node.attrFloat("y") / h));
            node.setAttr("width", floatToStr(node.attrFloat("width") / w));
            node.setAttr("height", floatToStr(node.attrFloat("height") / h));
        }
        node.gotoParent();
    }
    TiXmlPrinter printer;
    doc.Accept(&printer);
    return printer.CStr();
}
Example #5
0
void CALLBACK CUICommandHistory::UIAdd(TiXmlNode* pNode)
{
	TiXmlElement* pElement = pNode->ToElement();
	CStringA strParentName = pElement->Attribute("parentname");
	pElement->RemoveAttribute("parentname");
	if(strParentName.IsEmpty())
		return;

	CUIDesignerView* pUIView = g_pMainFrame->GetActiveUIView();
	CPaintManagerUI* pManager = pUIView->GetPaintManager();
	CControlUI* pParentControl = pManager->FindControl(StringConvertor::Utf8ToWide(strParentName));
	if(pParentControl == NULL)
		return;

	TiXmlDocument xmlDoc;
	TiXmlDeclaration Declaration("1.0","utf-8","yes");
	xmlDoc.InsertEndChild(Declaration);
	TiXmlElement* pRootElem = new TiXmlElement("UIAdd");
	pRootElem->InsertEndChild(*pElement);
	xmlDoc.InsertEndChild(*pRootElem);
	TiXmlPrinter printer;
	xmlDoc.Accept(&printer);
	delete pRootElem;

	CDialogBuilder builder;
	CControlUI* pRoot=builder.Create(StringConvertor::Utf8ToWide(printer.CStr()), (UINT)0, NULL, pManager);
 	if(pRoot)
		pUIView->RedoUI(pRoot, pParentControl);
}
	void BehaviorTreeLoader::
	Print() const
	{
		TiXmlPrinter printer;
		_XMLDoc.Accept(&printer);
		std::cout << printer.CStr() << std::endl;
	}
Example #7
0
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;
}
Example #8
0
void CCardProcess::CreateResponXML(int nID, const char *szResult, char *RetXML)
{
	TiXmlDocument *XmlDoc;
	TiXmlElement *RootElement;
	TiXmlElement *Segment;
	TiXmlDeclaration HeadDec;
	TiXmlPrinter Printer;

	// 创建XML文档
	XmlDoc = new TiXmlDocument();

	// 增加XML的头部说明
	HeadDec.Parse("<?xml version=\"1.0\" encoding=\"gb2312\" ?>", 0, TIXML_ENCODING_UNKNOWN);
	XmlDoc->LinkEndChild(&HeadDec);

	RootElement = new TiXmlElement("CardProcess");
	Segment = new TiXmlElement("ReturnInfo");
	Segment->SetAttribute("ID", nID);
	Segment->SetAttribute("Desc", szResult);

	RootElement->LinkEndChild(Segment);
	XmlDoc->LinkEndChild(RootElement);

	XmlDoc->Accept(&Printer);
	strcpy(RetXML, Printer.CStr());

}
Example #9
0
HRESULT CombineMasterSlaveXmlParam(
    const char* szXmlParamMaster,
    const char* szXmlParamSlave,
    char* szXmlParamAll,
    DWORD32& dwLen
)
{
    TiXmlElement* pMasterRootElement = NULL;
    TiXmlDocument cXmlDocMaster;
    if ( szXmlParamMaster && cXmlDocMaster.Parse(szXmlParamMaster) )
    {
        pMasterRootElement = cXmlDocMaster.RootElement();
    }

    TiXmlElement* pSlaveRootElement = NULL;
    TiXmlDocument cXmlDocSlave;
    if ( szXmlParamSlave && cXmlDocSlave.Parse(szXmlParamSlave) )
    {
        pSlaveRootElement = cXmlDocSlave.RootElement();
    }

    if ( NULL == pMasterRootElement || NULL == pSlaveRootElement )
    {
        dwLen = 0;
        return E_FAIL;
    }
    else
    {
        // 将主CPU参数内的所有Section结点插入到从CPU参数内的HvParam结点下。
        TiXmlElement* pMasterHvParamElement = NULL;
        TiXmlElement* pSlaveHvParamElement = NULL;
        pMasterHvParamElement = pMasterRootElement->FirstChildElement("HvParam");
        pSlaveHvParamElement = pSlaveRootElement->FirstChildElement("HvParam");
        if ( pMasterHvParamElement && pSlaveHvParamElement)
        {
            TiXmlElement* pMasterSectionElement = NULL;
            pMasterSectionElement = pMasterHvParamElement->FirstChildElement();
            while (pMasterSectionElement)
            {
                pSlaveHvParamElement->LinkEndChild(pMasterSectionElement->Clone());
                pMasterSectionElement = pMasterSectionElement->NextSiblingElement();
            }
        }

        TiXmlPrinter cTxPr;
        cXmlDocSlave.Accept(&cTxPr);
        DWORD32 dwXmlLen = (DWORD32)cTxPr.Size();
        if ( dwLen > dwXmlLen )
        {
            dwLen = dwXmlLen;
            memcpy(szXmlParamAll, cTxPr.CStr(), dwXmlLen);
            return S_OK;
        }
        else
        {
            dwLen = 0;
            return E_FAIL;
        }
    }
}
//---------------------------------------------------------
void ofxXmlSettings::copyXmlToString(string & str)
{
	TiXmlPrinter printer;
	doc.Accept(&printer);

	str = printer.CStr();
}
Example #11
0
HRESULT GetParamXml(
    CParamStore* pParamStore,
    char* szBuf,
    int nBufLen,
    DWORD32 dwFlag /*=0*/
)
{
    if (!szBuf) return E_INVALIDARG;
    szBuf[nBufLen-1] = '\0';

    CFastMemAlloc cStack;
    BYTE8* pBuf = (BYTE8*)cStack.StackAlloc(PARAM_BUF_LEN, FALSE);
    if (pBuf == NULL) return E_OUTOFMEMORY;

    CMemStorage cMemStg;
    cMemStg.Initialize(pBuf, PARAM_BUF_LEN);

    pParamStore->SaveTo(&cMemStg, FALSE);

    int nExportParamRank = 1; //= g_HvDspParam.nExportParamRank;
    bool nExportRankInfo = true; //= g_HvDspParam.nExportRankInfo;

    TiXmlDocument cDoc;
    ConvertParam2Xml(pBuf, PARAM_BUF_LEN, &cDoc, nExportParamRank, TRUE, nExportRankInfo);

    TiXmlPrinter cPrinter;
    cDoc.Accept(&cPrinter);

    strncpy(szBuf, cPrinter.CStr(), nBufLen - 1);

    return S_OK;
}
Example #12
0
void wxsCustomWidget::RebuildXmlData()
{
    TiXmlPrinter Printer;
    Printer.SetIndent("\t");
    m_XmlDataDoc.Accept(&Printer);
    m_XmlData = cbC2U(Printer.CStr());
}
Example #13
0
std::tr1::shared_ptr<std::string> APIServiceManager::_GetXMLDocumentString()
{
    TiXmlPrinter xmlPrinter;
    _XmlDoc.Accept( &xmlPrinter );

    return std::tr1::shared_ptr<std::string>(new std::string(xmlPrinter.CStr()));
}
Example #14
0
bool CSimpleXml::ModifyXmlAttri(list<XMLNODEINFO> &lstNode)
{
    if(m_pDoc == NULL || m_pRoot == NULL)
    {
        return false;
    }

    list<XMLNODEINFO>::iterator itlst = lstNode.begin();
    for(; itlst != lstNode.end(); ++itlst)
    {
        if(!ModifyOneAttri(*itlst))
        {
            return false;
        }
    }

    TiXmlPrinter printer;

    char szBuf[32];
    memset(szBuf, 0, 32);
    szBuf[0] = 0x9;
    printer.SetIndent(szBuf);
    szBuf[0] = 0x0a;
    printer.SetLineBreak(szBuf);
    if(m_pDoc->Accept(&printer))
    {
        m_strXml = printer.CStr();
    }
    else
    {
        return false;
    }
    return true;
}
Example #15
0
void CUIDesignerView::OnEditCopy()
{
	ASSERT(m_cfUI != NULL);

	TiXmlDocument xmlDoc;
	TiXmlDeclaration Declaration("1.0","utf-8","yes");
	xmlDoc.InsertEndChild(Declaration);
	TiXmlElement* pCopyElm = new TiXmlElement("UICopy");
	CopyUI(pCopyElm);
	xmlDoc.InsertEndChild(*pCopyElm);
	TiXmlPrinter printer;
	xmlDoc.Accept(&printer);
	delete pCopyElm;
	CSharedFile file(GMEM_MOVEABLE, printer.Size() + 1);
	file.Write(printer.CStr(), printer.Size());
	file.Write("\0", 1);
	COleDataSource* pDataSource = NULL;
	TRY
	{
		pDataSource = new COleDataSource;
		pDataSource->CacheGlobalData(m_cfUI, file.Detach());
		pDataSource->SetClipboard();
	}
	CATCH_ALL(e)
	{
		delete pDataSource;
		THROW_LAST();
	}
	END_CATCH_ALL
}
// 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;
}
Example #17
0
std::string em::EmXml::GetText()
{
	std::string strResult;
	TiXmlPrinter docPrinter;
	m_pDoc->Accept(&docPrinter);
	strResult = docPrinter.CStr();
	return strResult;
}
Example #18
0
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();
}
Example #19
0
void CXmlDocument::ToString(CDataBuffer& buffer)
{
	TiXmlPrinter printer;
	printer.SetLineBreak("\r\n");
	printer.SetIndent("\t");
	_doc->Accept(&printer);
	buffer.Add(printer.CStr());
}
Example #20
0
std::string SerializeBase::nodeToString(const TxElement& node) {
    try {
        TiXmlPrinter printer;
        printer.SetIndent("    ");
        node.Accept(&printer);
        return printer.CStr();
    } catch (TxException&) {
        return "No valid root node";
    }
}
Example #21
0
bool Order::SendAux(const DiplomatPtr &diplomat, const char *command_id) {

	TiXmlPrinter printer;
	_order.Accept(&printer);

	int size = strlen(printer.CStr());
	string header;
	if ( command_id )
		header = s_header.BuildHeader(size, command_id);
	else
		header = s_header.BuildHeader(size, PROTOCOL_NOT_SET);

	header += printer.CStr();

	int ret = diplomat->Speek(reinterpret_cast<const BYTE*>(header.c_str()), header.size());
	if(ret < 0)
		return false;
	return true;
}
Example #22
0
void readXml(string filename)
{
	//获取当前的工作目录 
    getcwd(buffer, MAX_PATH);   
    string seperator = "\\";
    string fullPath = buffer+seperator+filename;
    //判断文件是否存在
	if(access(fullPath.c_str(),0)==-1)
	{
		//文件不存在,下面直接略过
		cerr<<"配置文件"+fullPath+"不存在"<<endl; 
		return; 
	} 
	
    //读取配置文件xml 
    TiXmlDocument doc(fullPath.c_str());
    bool loadOk = doc.LoadFile();
    if (!loadOk)
    {
            cout << "could load:" << doc.ErrorDesc() << endl;
    }
    
    //输出整个配置文件的内容 
    TiXmlPrinter printer;//提供的工具类,目的是将xml的数据按格式输出
    doc.Accept(&printer);
    cout  << printer.CStr() << endl;//输出
    
    //获得根元素<Configuration> 
	TiXmlElement* rootElement =doc.RootElement();

	//循环处理<property>节点
	TiXmlElement* nextElement=rootElement->FirstChildElement();
    while(nextElement!=NULL)
    {
  		//获取其中<name>节点 
	    TiXmlElement* nameElement=nextElement->FirstChildElement();
	    //获取其中<value>节点 
	    TiXmlElement* valueElement=nameElement->NextSiblingElement();
	    //获取上述节点的值 
	    //cout<<nextElement->Value()<<endl;
	   // cout<<nameElement->FirstChild()->Value()<<endl;
	    parameter[nameElement->FirstChild()->Value()]=valueElement->FirstChild()->Value();
	    //cout<<valueElement->FirstChild()->Value()<<endl;
	    nextElement=nextElement->NextSiblingElement(); 
    }
    
    //循环遍历parameter中的参数,进行输出 
	map<string, string>::iterator  iter;
    for(iter = parameter.begin(); iter != parameter.end(); iter++)
	{
 		cout<<iter->first<<"  "<<iter->second<<endl;
	} 
		
} 
Example #23
0
bool CXBMCTinyXML::SaveFile(const std::string& filename) const
{
  XFILE::CFile file;
  if (file.OpenForWrite(filename, true))
  {
    TiXmlPrinter printer;
    Accept(&printer);
    return file.Write(printer.CStr(), printer.Size()) == static_cast<ssize_t>(printer.Size());
  }
  return false;
}
Example #24
0
void Export_DAE(std::ostream &s, Mesh * aMesh, Options &aOptions) {
  // Create the XML document
  TiXmlDocument doc("model");
  Export_DAE(doc, aMesh, aOptions);

  // Write the document to the stream.
  TiXmlPrinter printer;
  printer.SetIndent("    ");
  doc.Accept(&printer);
  s << printer.CStr();
}
bool TinyXML::SaveDocument(const wxString& filename, TiXmlDocument* doc)
{
    if (!doc)
        return false;

    TiXmlPrinter printer;
    printer.SetIndent("\t");
    doc->Accept(&printer);

    return Manager::Get()->GetFileManager()->SaveUTF8(filename, printer.CStr(), printer.Size());
}
Example #26
0
string& Message::GenerateMessage()
{
    mStrMessage = "";
    if(null != mXmlDoc)
    {
        TiXmlPrinter printer;
        mXmlDoc->Accept(&printer);
        mStrMessage = printer.CStr();
    }
    return mStrMessage;
}
Example #27
0
bool CXBMCTinyXML::SaveFile(const CStdString &filename) const
{
  XFILE::CFile file;
  if (file.OpenForWrite(filename, true))
  {
    TiXmlPrinter printer;
    Accept(&printer);
    file.Write(printer.CStr(), printer.Size());
    return true;
  }
  return false;
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void XmlDocumentImpl::getAsRawData(cvf::UByteArray* buffer) const
{
	TiXmlPrinter printer;

	// Use tab as indent marker
	printer.SetIndent( "\t" );

	// Link document to printer
	Accept(&printer);

    buffer->assign((cvf::ubyte*)printer.CStr(), (size_t)printer.Size());
}
Example #29
0
    bool TreeVisitor::visitLeave(Solution& solution)
    {
        TiXmlPrinter printer;
        printer.SetIndent(nullptr);
        printer.SetLineBreak(nullptr);

        m_document.Accept(&printer);

        m_serialized = printer.CStr();

        return true;
    }
Example #30
0
bool CSimpleXml::AddNodes(const string &strPath, list<XMLNODEINFO> &lstaddnode)
{
    if(m_pDoc == NULL || m_pRoot == NULL)
    {
        return false;
    }
    TiXmlElement *pCurrNode = m_pRoot;

    list<string> lstNode;
    SeperateString(lstNode, strPath, "/");

    list<string>::iterator itlstNode = lstNode.begin();

    while (NULL != pCurrNode)
    {
        if (itlstNode != lstNode.end() && *itlstNode == pCurrNode->Value())
        {
            string strShow = pCurrNode->Value();
            if (++itlstNode == lstNode.end())
            {
                AddOneNode(&pCurrNode, lstaddnode);
                goto SIMXML;
            }
            pCurrNode = pCurrNode->FirstChildElement();
        }
        else
        {
            pCurrNode = pCurrNode->NextSiblingElement();
        }
    }
    return false;

    SIMXML:

    TiXmlPrinter printer;

    char szBuf[32];
    memset(szBuf, 0, 32);
    szBuf[0] = 0x9;
    printer.SetIndent(szBuf);
    szBuf[0] = 0x0a;
    printer.SetLineBreak(szBuf);
    if(m_pDoc->Accept(&printer))
    {
        m_strXml = printer.CStr();
    }
    else
    {
        return false;
    }
    return true;
}