• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TiXmlText类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _tfopen

int CCrashInfoReader::ParseCrashDescription(CString sFileName, BOOL bParseFileItems, CErrorReportInfo& eri)
{
    strconv_t strconv;
    FILE* f = NULL; 

#if _MSC_VER<1400
    f = _tfopen(sFileName, _T("rb"));
#else
    _tfopen_s(&f, sFileName, _T("rb"));
#endif

    if(f==NULL)
        return 1;

    TiXmlDocument doc;
    bool bOpen = doc.LoadFile(f);
    if(!bOpen)
        return 1;

    TiXmlHandle hRoot = doc.FirstChild("CrashRpt");
    if(hRoot.ToElement()==NULL)
    {
        fclose(f);
        return 1;
    }

    {
        TiXmlHandle hCrashGUID = hRoot.FirstChild("CrashGUID");
        if(hCrashGUID.ToElement()!=NULL)
        {
            if(hCrashGUID.FirstChild().ToText()!=NULL)
            {
                const char* szCrashGUID = hCrashGUID.FirstChild().ToText()->Value();
                if(szCrashGUID!=NULL)
                    eri.m_sCrashGUID = strconv.utf82t(szCrashGUID);
            }
        }
    }

    {
        TiXmlHandle hAppName = hRoot.FirstChild("AppName");
        if(hAppName.ToElement()!=NULL)
        {
            const char* szAppName = hAppName.FirstChild().ToText()->Value();
            if(szAppName!=NULL)
                eri.m_sAppName = strconv.utf82t(szAppName);
        }
    }

    {
        TiXmlHandle hAppVersion = hRoot.FirstChild("AppVersion");
        if(hAppVersion.ToElement()!=NULL)
        {
            TiXmlText* pText = hAppVersion.FirstChild().ToText();
            if(pText!=NULL)
            {
                const char* szAppVersion = pText->Value();
                if(szAppVersion!=NULL)
                    eri.m_sAppVersion = strconv.utf82t(szAppVersion);
            }
        }
    }

    {
        TiXmlHandle hImageName = hRoot.FirstChild("ImageName");
        if(hImageName.ToElement()!=NULL)
        {
            TiXmlText* pText = hImageName.FirstChild().ToText();
            if(pText!=NULL)
            {
                const char* szImageName = pText->Value();
                if(szImageName!=NULL)
                    eri.m_sImageName = strconv.utf82t(szImageName);
            }
        }
    }

    {
        TiXmlHandle hSystemTimeUTC = hRoot.FirstChild("SystemTimeUTC");
        if(hSystemTimeUTC.ToElement()!=NULL)
        {
            TiXmlText* pText = hSystemTimeUTC.FirstChild().ToText();
            if(pText!=NULL)
            {
                const char* szSystemTimeUTC = pText->Value();
                if(szSystemTimeUTC!=NULL)
                    eri.m_sSystemTimeUTC = strconv.utf82t(szSystemTimeUTC);
            }
        }
    }

    if(bParseFileItems)
    {
        // Get directory name
        CString sReportDir = sFileName;
        int pos = sFileName.ReverseFind('\\');
        if(pos>=0)
            sReportDir = sFileName.Left(pos);
        if(sReportDir.Right(1)!=_T("\\"))
            sReportDir += _T("\\");
//.........这里部分代码省略.........
开发者ID:tmadar,项目名称:crashrpt,代码行数:101,代码来源:CrashInfoReader.cpp


示例2: main


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

	// Going to the toy store is now our second priority...
	// So set the "priority" attribute of the first item in the list.
	node = todoElement->FirstChildElement();	// This skips the "PDA" comment.
	assert( node );
	itemElement = node->ToElement();
	assert( itemElement  );
	itemElement->SetAttribute( "priority", 2 );

	// Change the distance to "doing bills" from
	// "none" to "here". It's the next sibling element.
	itemElement = itemElement->NextSiblingElement();
	assert( itemElement );
	itemElement->SetAttribute( "distance", "here" );

	// Remove the "Look for Evil Dinosaurs!" item.
	// It is 1 more sibling away. We ask the parent to remove
	// a particular child.
	itemElement = itemElement->NextSiblingElement();
	todoElement->RemoveChild( itemElement );

	itemElement = 0;

	// --------------------------------------------------------
	// What follows is an example of created elements and text
	// nodes and adding them to the document.
	// --------------------------------------------------------

	// Add some meetings.
	TiXmlElement item( "Item" );
	item.SetAttribute( "priority", "1" );
	item.SetAttribute( "distance", "far" );

	TiXmlText text( "Talk to:" );

	TiXmlElement meeting1( "Meeting" );
	meeting1.SetAttribute( "where", "School" );

	TiXmlElement meeting2( "Meeting" );
	meeting2.SetAttribute( "where", "Lunch" );

	TiXmlElement attendee1( "Attendee" );
	attendee1.SetAttribute( "name", "Marple" );
	attendee1.SetAttribute( "position", "teacher" );

	TiXmlElement attendee2( "Attendee" );
	attendee2.SetAttribute( "name", "Voel" );
	attendee2.SetAttribute( "position", "counselor" );

	// Assemble the nodes we've created:
	meeting1.InsertEndChild( attendee1 );
	meeting1.InsertEndChild( attendee2 );

	item.InsertEndChild( text );
	item.InsertEndChild( meeting1 );
	item.InsertEndChild( meeting2 );

	// And add the node to the existing list after the first child.
	node = todoElement->FirstChild( "Item" );
	assert( node );
	itemElement = node->ToElement();
	assert( itemElement );

	todoElement->InsertAfterChild( itemElement, item );

	printf( "\n** Demo doc processed: ** \n\n" );
开发者ID:soulsheng,项目名称:osgART,代码行数:67,代码来源:xmltest.cpp


示例3: SkipWhiteSpace

TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding )
{
	TiXmlNode* returnNode = 0;

	p = SkipWhiteSpace( p, encoding );
	if( !p || !*p || *p != '<' )
	{
		return 0;
	}

	TiXmlDocument* doc = GetDocument();
	p = SkipWhiteSpace( p, encoding );

	if ( !p || !*p )
	{
		return 0;
	}

	// What is this thing? 
	// - Elements start with a letter or underscore, but xml is reserved.
	// - Comments: <!--
	// - Decleration: <?xml
	// - Everthing else is unknown to tinyxml.
	//

	const char* xmlHeader = { "<?xml" };
	const char* commentHeader = { "<!--" };
	const char* dtdHeader = { "<!" };
	const char* cdataHeader = { "<![CDATA[" };

	if ( StringEqual( p, xmlHeader, true, encoding ) )
	{
		#ifdef DEBUG_PARSER
			TIXML_LOG( "XML parsing Declaration\n" );
		#endif
		returnNode = XNEW(TiXmlDeclaration)(); //new TiXmlDeclaration();
	}
	else if ( StringEqual( p, commentHeader, false, encoding ) )
	{
		#ifdef DEBUG_PARSER
			TIXML_LOG( "XML parsing Comment\n" );
		#endif
		returnNode = XNEW(TiXmlComment)(); //new TiXmlComment();
	}
	else if ( StringEqual( p, cdataHeader, false, encoding ) )
	{
		#ifdef DEBUG_PARSER
			TIXML_LOG( "XML parsing CDATA\n" );
		#endif
		TiXmlText* text = XNEW(TiXmlText)(""); //new TiXmlText( "" );
		text->SetCDATA( true );
		returnNode = text;
	}
	else if ( StringEqual( p, dtdHeader, false, encoding ) )
	{
		#ifdef DEBUG_PARSER
			TIXML_LOG( "XML parsing Unknown(1)\n" );
		#endif
		returnNode = XNEW(TiXmlUnknown)(); //new TiXmlUnknown();
	}
	else if (    IsAlpha( *(p+1), encoding )
			  || *(p+1) == '_' )
	{
		#ifdef DEBUG_PARSER
			TIXML_LOG( "XML parsing Element\n" );
		#endif
		returnNode = XNEW(TiXmlElement)(""); //new TiXmlElement( "" );
	}
	else
	{
		#ifdef DEBUG_PARSER
			TIXML_LOG( "XML parsing Unknown(2)\n" );
		#endif
		returnNode = XNEW(TiXmlUnknown)(); //new TiXmlUnknown();
	}

	if ( returnNode )
	{
		// Set the parent, so it can report errors
		returnNode->parent = this;
	}
	else
	{
		if ( doc )
			doc->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
	}
	return returnNode;
}
开发者ID:wsygzyr,项目名称:libinet,代码行数:88,代码来源:TinyXmlParser.cpp


示例4: main


//.........这里部分代码省略.........
	assert( todoElement  );

	// Going to the toy store is now our second priority...
	// So set the "priority" attribute of the first item in the list.
	node = todoElement->FirstChild();
	assert( node );
	itemElement = node->ToElement();
	assert( itemElement  );
	itemElement->SetAttribute( "priority", 2 );

	// Change the distance to "doing bills" from
	// "none" to "here". It's the next sibling element.
	itemElement = itemElement->NextSiblingElement();
	itemElement->SetAttribute( "distance", "here" );

	// Remove the "Look for Evil Dinosours!" item.
	// It is 1 more sibling away. We ask the parent to remove
	// a particular child.
	itemElement = itemElement->NextSiblingElement();
	todoElement->RemoveChild( itemElement );

	itemElement = 0;

	// --------------------------------------------------------
	// What follows is an example of created elements and text
	// nodes and adding them to the document.
	// --------------------------------------------------------

	// Add some meetings.
	TiXmlElement item( "Item" );
	item.SetAttribute( "priority", "1" );
	item.SetAttribute( "distance", "far" );

	TiXmlText text;
	text.SetValue( "Talk to:" );

	TiXmlElement meeting1( "Meeting" );
	meeting1.SetAttribute( "where", "School" );

	TiXmlElement meeting2( "Meeting" );
	meeting2.SetAttribute( "where", "Lunch" );

	TiXmlElement attendee1( "Attendee" );
	attendee1.SetAttribute( "name", "Marple" );
	attendee1.SetAttribute( "position", "teacher" );

	TiXmlElement attendee2( "Attendee" );
	attendee2.SetAttribute( "name", "Voo" );
	attendee2.SetAttribute( "position", "counselor" );

	// Assemble the nodes we've created:
	meeting1.InsertEndChild( attendee1 );
	meeting1.InsertEndChild( attendee2 );

	item.InsertEndChild( text );
	item.InsertEndChild( meeting1 );
	item.InsertEndChild( meeting2 );

	// And add the node to the existing list after the first child.
	node = todoElement->FirstChild( "Item" );
	assert( node );
	itemElement = node->ToElement();
	assert( itemElement );

	todoElement->InsertAfterChild( itemElement, item );
开发者ID:krunt,项目名称:projects,代码行数:66,代码来源:xmltest.cpp


示例5: while

OsStatus ForwardRules::parseRouteMatchContainer(const Url& requestUri,
                                              const SipMessage& request,
                                              UtlString& routeToString,
                                              UtlString& mappingType,
                                              bool& authRequired,
                                              TiXmlNode* routesNode,
                                              TiXmlNode* previousRouteMatchNode)
{
   UtlString testHost;
   requestUri.getHostAddress(testHost);
   int testPort = requestUri.getHostPort();
   if(testPort == SIP_PORT)
   {
      testPort = PORT_NONE;
   }
   
   UtlBoolean routeMatchFound = false;
   OsStatus methodMatchFound = OS_FAILED;
   
  	TiXmlElement* routesElement = routesNode->ToElement();

   TiXmlNode* routeMatchNode = previousRouteMatchNode;
   // Iterate through routes container children looking for 
   // route tags
   while ( (routeMatchNode = routesElement->IterateChildren(routeMatchNode)) 
      && methodMatchFound != OS_SUCCESS)
   {
      // Skip non-elements
      if(routeMatchNode && routeMatchNode->Type() != TiXmlNode::ELEMENT)
      {
         continue;
      }

      // Skip non-route elements
      TiXmlElement* routeMatchElement = routeMatchNode->ToElement();
      UtlString tagValue =  routeMatchElement->Value();
      if(tagValue.compareTo(XML_TAG_ROUTEMATCH) != 0 )
      {
         continue;
      }

      mappingType.remove(0);
      routeToString.remove(0);
      const char* mappingTypePtr = 
          routeMatchElement->Attribute(XML_ATT_MAPPINGTYPE);

      //get the mapping Type attribute
      mappingType.append(mappingTypePtr ? mappingTypePtr : "");

      // Iterate through the route container's children looking
      // for routeFrom, routeIPv4subnet, or routeDnsWildcard elements
      TiXmlNode* routeFromPatternNode = NULL;
      for( routeFromPatternNode = routeMatchElement->FirstChildElement();
         routeFromPatternNode;
         routeFromPatternNode = routeFromPatternNode->NextSiblingElement() )
      {
         // Skip elements that aren't of the "domainMatches" family 
         enum {ret_from, ret_ip, ret_dns} routeElementType ;

         const char *name = routeFromPatternNode->Value() ;
         if (strcmp(name, XML_TAG_ROUTEFROM) == 0)
         {
            routeElementType = ret_from;
         }
         else if (strcmp(name, XML_TAG_ROUTEIPV4SUBNET) == 0)
         {
            routeElementType = ret_ip;
         }
         else if (strcmp(name, XML_TAG_ROUTEDNSWILDCARD) == 0)
         {
            routeElementType = ret_dns;
         }
         else
         {
            continue ;
         }


         //found "domainMatches" pattern tag
         TiXmlElement* routeFromPatternElement = routeFromPatternNode->ToElement();
         //get the text value from it
         TiXmlNode* routeFromPatternText = routeFromPatternElement->FirstChild();
         if(routeFromPatternText && routeFromPatternText->Type() == TiXmlNode::TEXT)
         {
            TiXmlText* Xmlpattern = routeFromPatternText->ToText();
            if (Xmlpattern)
            {
               UtlString pattern = Xmlpattern->Value();

               switch(routeElementType)
               {
                  case ret_from: // a routeFrom element matches host and port
                  {
                     Url xmlUrl(pattern.data());
                     UtlString xmlHost;
                     xmlUrl.getHostAddress(xmlHost);
                     int xmlPort = xmlUrl.getHostPort();

                     // See if the host and port of the routeFrom elelment
                     // match that of the URI
//.........这里部分代码省略.........
开发者ID:ClydeFroq,项目名称:sipxecs,代码行数:101,代码来源:ForwardRules.cpp


示例6: ClearError

const char* TiXmlDocument::Parse
  ( const char* p, TiXmlParsingData* prevData, TiXmlEncoding encoding )
{
    ClearError();

    // Parse away, at the document level. Since a document
    // contains nothing but other tags, most of what happens
    // here is skipping white space.
    // sherm 100319: I changed this so that untagged top-level text is
    // parsed as a Text node rather than a parsing error. CDATA text was
    // already allowed at the top level so this seems more consistent.
    if ( !p || !*p )
    {
        SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
        return 0;
    }

    // Note that, for a document, this needs to come
    // before the while space skip, so that parsing
    // starts from the pointer we are given.
    location.Clear();
    if ( prevData )
    {
        location.row = prevData->cursor.row;
        location.col = prevData->cursor.col;
    }
    else
    {
        location.row = 0;
        location.col = 0;
    }
    TiXmlParsingData data( p, TabSize(), location.row, location.col );
    location = data.Cursor();

    if ( encoding == TIXML_ENCODING_UNKNOWN )
    {
        // Check for the Microsoft UTF-8 lead bytes.
        const unsigned char* pU = (const unsigned char*)p;
        if (    *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0
             && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1
             && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 )
        {
            encoding = TIXML_ENCODING_UTF8;
            useMicrosoftBOM = true;
        }
    }

    // Remember the start of white space in case we end up reading a text
    // element in a "keep white space" mode.
    const char* pWithWhiteSpace = p;
    p = SkipWhiteSpace( p, encoding );
    if ( !p )
    {
        SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
        return 0;
    }

    // sherm 100319: ignore all but the first Declaration
    bool haveSeenDeclaration = false;
    while ( p && *p )
    {
        TiXmlNode* node = 0;
        if ( *p != '<' )
        {   // sherm 100319: I added this case by stealing the code from
            // Element parsing; see above comment.
            // Take what we have, make a text element.
            TiXmlText* textNode = new TiXmlText( "" );

            if ( !textNode )
            {
                SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, encoding );
                return 0;
            }

            if ( TiXmlBase::IsWhiteSpaceCondensed() )
            {
                p = textNode->Parse( p, &data, encoding );
            }
            else
            {
                // Special case: we want to keep the white space
                // so that leading spaces aren't removed.
                p = textNode->Parse( pWithWhiteSpace, &data, encoding );
            }

            if ( !textNode->Blank() ) {
                LinkEndChild( textNode );
                node = textNode;
            }
            else
                delete textNode;
        }
        else // We saw a '<', now identify what kind of tag it is.
        {
            TiXmlNode* node = Identify( p, encoding );
            if ( node )
            {
                p = node->Parse( p, &data, encoding );
                if (node->ToDeclaration()) {
                    if (haveSeenDeclaration) {
//.........这里部分代码省略.........
开发者ID:thomasklau,项目名称:simbody,代码行数:101,代码来源:tinyxmlparser.cpp


示例7: CapaTile

void NivelParser::parseCapaTile(TiXmlElement* pTileElement, std::vector<Capa*> *pCapas, const std::vector<ConjuntoTiles>* pConjuntoTiles, std::vector<CapaTile*> *pCapasDeColision)
{
    CapaTile* pCapaTile = new CapaTile(magnitudTile, *pConjuntoTiles);

    bool collidable = false;

    // tile data
    std::vector<std::vector<int>> data;

    std::string decodedIDs;
    TiXmlElement* pDataNode;

    for(TiXmlElement* e = pTileElement->FirstChildElement(); e != NULL; e = e->NextSiblingElement())
    {
        if(e->Value() == std::string("properties"))
        {
            for(TiXmlElement* property = e->FirstChildElement(); property != NULL; property = property->NextSiblingElement())
            {
                if(property->Value() == std::string("property"))
                {
                    if(property->Attribute("name") == std::string("collidable"))
                    {
                        collidable = true;
                    }
                }
            }
        }

        if(e->Value() == std::string("data"))
        {
            pDataNode = e;
        }
    }

    for(TiXmlNode* e = pDataNode->FirstChild(); e != NULL; e = e->NextSibling())
    {
        TiXmlText* text = e->ToText();
        std::string t = text->Value();
        decodedIDs = base64_decode(t);
    }

    // uncompress zlib compression
    uLongf sizeofids = ancho * altura * sizeof(int);
    std::vector<int> ids(ancho * altura);
    uncompress((Bytef*)&ids[0], &sizeofids,(const Bytef*)decodedIDs.c_str(), decodedIDs.size());

    std::vector<int> filaCapa(ancho);

    for(int j = 0; j < altura; j++)
    {
        data.push_back(filaCapa);
    }

    for(int rows = 0; rows < altura; rows++)
    {
        for(int cols = 0; cols < ancho; cols++)
        {
            data[rows][cols] = ids[rows * ancho + cols];
        }
    }

    pCapaTile->setTileIDs(data);

    //imprimir para corroborar errores
    //cout<<data.size();
    for ( int i = 0; i < data.size(); i++ )
    {
       for ( int j = 0; j < data[i].size(); j++ )
       {
          std::cout << data[i][j] << ' ';
       }
       std::cout << std::endl;
    }

    pCapaTile->setAnchoMapa(ancho);

    if(collidable)
    {
        pCapasDeColision->push_back(pCapaTile);
    }

    pCapas->push_back(pCapaTile);
}
开发者ID:JairFrancesco,项目名称:PacmanSDL2-C-,代码行数:83,代码来源:NivelParser.cpp


示例8: wxASSERT

bool CSiteManager::Load(TiXmlElement *pElement, CSiteManagerXmlHandler* pHandler)
{
	wxASSERT(pElement);
	wxASSERT(pHandler);

	for (TiXmlElement* pChild = pElement->FirstChildElement(); pChild; pChild = pChild->NextSiblingElement())
	{
		if (!strcmp(pChild->Value(), "Folder"))
		{
			wxString name = GetTextElement_Trimmed(pChild);
			if (name.empty())
				continue;

			const bool expand = GetTextAttribute(pChild, "expanded") != _T("0");
			if (!pHandler->AddFolder(name, expand))
				return false;
			Load(pChild, pHandler);
			if (!pHandler->LevelUp())
				return false;
		}
		else if (!strcmp(pChild->Value(), "Server"))
		{
			CSiteManagerItemData_Site* data = ReadServerElement(pChild);

			if (data)
			{
				pHandler->AddSite(data);

				// Bookmarks
				for (TiXmlElement* pBookmark = pChild->FirstChildElement("Bookmark"); pBookmark; pBookmark = pBookmark->NextSiblingElement("Bookmark"))
				{
					TiXmlHandle handle(pBookmark);

					wxString name = GetTextElement_Trimmed(pBookmark, "Name");
					if (name.empty())
						continue;

					CSiteManagerItemData* data = new CSiteManagerItemData(CSiteManagerItemData::BOOKMARK);

					TiXmlText* localDir = handle.FirstChildElement("LocalDir").FirstChild().Text();
					if (localDir)
						data->m_localDir = GetTextElement(pBookmark, "LocalDir");

					TiXmlText* remoteDir = handle.FirstChildElement("RemoteDir").FirstChild().Text();
					if (remoteDir)
						data->m_remoteDir.SetSafePath(ConvLocal(remoteDir->Value()));

					if (data->m_localDir.empty() && data->m_remoteDir.IsEmpty())
					{
						delete data;
						continue;
					}

					if (!data->m_localDir.empty() && !data->m_remoteDir.IsEmpty())
						data->m_sync = GetTextElementBool(pBookmark, "SyncBrowsing", false);

					pHandler->AddBookmark(name, data);
				}

				if (!pHandler->LevelUp())
					return false;
			}
		}
	}

	return true;
}
开发者ID:AbelTian,项目名称:filezilla,代码行数:67,代码来源:sitemanager.cpp


示例9: wxMessageBox

CSiteManagerItemData_Site* CSiteManager::GetSiteByPath(wxString sitePath)
{
	wxChar c = sitePath[0];
	if (c != '0' && c != '1')
	{
		wxMessageBox(_("Site path has to begin with 0 or 1."), _("Invalid site path"));
		return 0;
	}

	sitePath = sitePath.Mid(1);

	// We have to synchronize access to sitemanager.xml so that multiple processed don't write
	// to the same file or one is reading while the other one writes.
	CInterProcessMutex mutex(MUTEX_SITEMANAGER);

	CXmlFile file;
	TiXmlElement* pDocument = 0;

	if (c == '0')
		pDocument = file.Load(_T("sitemanager"));
	else
	{
		const wxString& defaultsDir = wxGetApp().GetDefaultsDir();
		if (defaultsDir == _T(""))
		{
			wxMessageBox(_("Site does not exist."), _("Invalid site path"));
			return 0;
		}
		wxFileName name(defaultsDir, _T("fzdefaults.xml"));
		pDocument = file.Load(name);
	}

	if (!pDocument)
	{
		wxMessageBox(file.GetError(), _("Error loading xml file"), wxICON_ERROR);

		return 0;
	}

	TiXmlElement* pElement = pDocument->FirstChildElement("Servers");
	if (!pElement)
	{
		wxMessageBox(_("Site does not exist."), _("Invalid site path"));
		return 0;
	}

	std::list<wxString> segments;
	if (!UnescapeSitePath(sitePath, segments))
	{
		wxMessageBox(_("Site path is malformed."), _("Invalid site path"));
		return 0;
	}

	TiXmlElement* pChild = GetElementByPath(pElement, segments);
	if (!pChild)
	{
		wxMessageBox(_("Site does not exist."), _("Invalid site path"));
		return 0;
	}

	TiXmlElement* pBookmark;
	if (!strcmp(pChild->Value(), "Bookmark"))
	{
		pBookmark = pChild;
		pChild = pChild->Parent()->ToElement();
	}
	else
		pBookmark = 0;

	CSiteManagerItemData_Site* data = ReadServerElement(pChild);

	if (!data)
	{
		wxMessageBox(_("Could not read server item."), _("Invalid site path"));
		return 0;
	}

	if (pBookmark)
	{
		TiXmlHandle handle(pBookmark);

		wxString localPath;
		CServerPath remotePath;
		TiXmlText* localDir = handle.FirstChildElement("LocalDir").FirstChild().Text();
		if (localDir)
			localPath = ConvLocal(localDir->Value());
		TiXmlText* remoteDir = handle.FirstChildElement("RemoteDir").FirstChild().Text();
		if (remoteDir)
			remotePath.SetSafePath(ConvLocal(remoteDir->Value()));
		if (!localPath.empty() && !remotePath.IsEmpty())
		{
			data->m_sync = GetTextElementBool(pBookmark, "SyncBrowsing", false);
		}
		else
			data->m_sync = false;

		data->m_localDir = localPath;
		data->m_remoteDir = remotePath;
	}

//.........这里部分代码省略.........
开发者ID:AbelTian,项目名称:filezilla,代码行数:101,代码来源:sitemanager.cpp


示例10: TiXmlElement

bool ETHEntityProperties::WriteToXMLFile(TiXmlElement *pHeadRoot) const
{
	TiXmlElement *pRoot = new TiXmlElement(GS_L("Entity"));
	pHeadRoot->LinkEndChild(pRoot); 

	TiXmlElement *pElement;

	if (emissiveColor != ETH_DEFAULT_EMISSIVE_COLOR)
	{
		pElement = new TiXmlElement(GS_L("EmissiveColor"));
		pRoot->LinkEndChild(pElement); 
		pElement->SetDoubleAttribute(GS_L("r"), emissiveColor.x);
		pElement->SetDoubleAttribute(GS_L("g"), emissiveColor.y);
		pElement->SetDoubleAttribute(GS_L("b"), emissiveColor.z);
		pElement->SetDoubleAttribute(GS_L("a"), emissiveColor.w);
	}

	if (spriteCut != ETH_DEFAULT_SPRITE_CUT)
	{
		pElement = new TiXmlElement(GS_L("SpriteCut"));
		pRoot->LinkEndChild(pElement);
		pElement->SetDoubleAttribute(GS_L("x"), spriteCut.x);
		pElement->SetDoubleAttribute(GS_L("y"), spriteCut.y);
	}

	if (scale != ETH_DEFAULT_SCALE)
	{
		pElement = new TiXmlElement(GS_L("Scale"));
		pRoot->LinkEndChild(pElement);
		pElement->SetDoubleAttribute(GS_L("x"), scale.x);
		pElement->SetDoubleAttribute(GS_L("y"), scale.y);
	}

	if (pivotAdjust != ETH_DEFAULT_PIVOT_ADJUST)
	{
		pElement = new TiXmlElement(GS_L("PivotAdjust"));
		pRoot->LinkEndChild(pElement);
		pElement->SetDoubleAttribute(GS_L("x"), pivotAdjust.x);
		pElement->SetDoubleAttribute(GS_L("y"), pivotAdjust.y);
	}

	if (spriteFile != GS_L(""))
	{
		pElement = new TiXmlElement(GS_L("Sprite"));
		pElement->LinkEndChild(new TiXmlText(spriteFile));
		pRoot->LinkEndChild(pElement);
	}

	if (normalFile != GS_L(""))
	{
		pElement = new TiXmlElement(GS_L("Normal"));
		pElement->LinkEndChild(new TiXmlText(normalFile));
		pRoot->LinkEndChild(pElement);
	}

	if (glossFile != GS_L(""))
	{
		pElement = new TiXmlElement(GS_L("Gloss"));
		pElement->LinkEndChild(new TiXmlText(glossFile));
		pRoot->LinkEndChild(pElement);
	}

	if (!particleSystems.empty())
	{
		TiXmlElement *pParticles = new TiXmlElement(GS_L("Particles"));
		pRoot->LinkEndChild(pParticles);
		for (unsigned int t=0; t<particleSystems.size(); t++)
		{
			if (particleSystems[t]->nParticles > 0)
				particleSystems[t]->WriteToXMLFile(pParticles);
		}
	}

	if (light)
	{
		light->WriteToXMLFile(pRoot);
	}

	if (collision)
	{
		TiXmlElement *pCollisionRoot = collision->WriteToXMLFile(pRoot);
		if (pCollisionRoot)
		{
			// Write polygon data
			if (polygon)
			{
				pElement = new TiXmlElement(GS_L("Polygon"));
				TiXmlText* text = new TiXmlText(polygon->GetENMLDeclaration());
				text->SetCDATA(true);
				pElement->LinkEndChild(text);
				pCollisionRoot->LinkEndChild(pElement);
			}
			else if (shape == BS_POLYGON) // it the polygon data is empty, write sample data into it
			{
				pElement = new TiXmlElement(GS_L("Polygon"));
				TiXmlText* text = new TiXmlText(POLYGON_ENML_SAMPLE);
				text->SetCDATA(true);
				pElement->LinkEndChild(text);
				pCollisionRoot->LinkEndChild(pElement);
			}
//.........这里部分代码省略.........
开发者ID:skaflux,项目名称:ethanon,代码行数:101,代码来源:ETHEntityProperties.cpp


示例11: final_xml_file

bool final_xml_file(const char* xml_name, cat_items_mgr& mgr)
{
	if(xml_name == NULL)return false;
	TiXmlDocument* pdoc = new TiXmlDocument;

	TiXmlElement* root = new TiXmlElement("Items");
	pdoc->LinkEndChild(root);
	
	std::map<int, cat_items>::iterator pItr = mgr.cat_items_map.begin();
	for(; pItr != mgr.cat_items_map.end(); ++pItr)
	{
		cat_items* p_cat = &(pItr->second);
		TiXmlElement* pCat = new TiXmlElement("Cat");
		pCat->SetAttribute("ID",  p_cat->cat_id);
		pCat->SetAttribute("DbCatID", p_cat->db_cat_id);
		pCat->SetAttribute("Name", p_cat->name);
		pCat->SetAttribute("Max", p_cat->max);
		
		map<int, item_attire_data>::iterator pItr2 = p_cat->item_map.begin();
		for(; pItr2 != p_cat->item_map.end(); ++pItr2)
		{
			item_attire_data* p_data= &(pItr2->second);
			TiXmlElement* pData = new TiXmlElement("Item");	
			pData->SetAttribute("ID", p_data->id);
			pData->SetAttribute("Name", p_data->name);
			pData->SetAttribute("DropLv", p_data->droplv);
			pData->SetAttribute("QualityLevel", p_data->quality_level);
			pData->SetAttribute("EquipPart", p_data->equip_part);
			pData->SetAttribute("Price", p_data->price);
			pData->SetAttribute("SellPrice", p_data->sell_price);
			pData->SetAttribute("RepairPrice", p_data->repair_price);
			pData->SetAttribute("UseLv", p_data->uselv);
			pData->SetAttribute("Strength", p_data->strength);
			pData->SetAttribute("Agility", p_data->agility);
			pData->SetAttribute("BodyQuality", p_data->body_quality);
			pData->SetAttribute("Stamina", p_data->stamina);
			if(strlen(p_data->atk) > 0)
			{
				pData->SetAttribute("Atk", p_data->atk);
			}
			pData->SetAttribute("Def", p_data->def);
			pData->SetAttribute("Duration", p_data->duration);
			pData->SetAttribute("Hit", p_data->hit);
			pData->SetAttribute("Dodge", p_data->dodge);
			pData->SetAttribute("Crit", p_data->crit);
			pData->SetAttribute("Hp", p_data->hp);
			pData->SetAttribute("Mp", p_data->mp);
			pData->SetAttribute("AddHp", p_data->add_hp);
			pData->SetAttribute("AddMp", p_data->add_mp);
			pData->SetAttribute("Slot",  p_data->slot);
			pData->SetAttribute("Tradability", p_data->trade_ability);
			pData->SetAttribute("VipTradability", p_data->vip_trade_ability);
			pData->SetAttribute("Tradable", p_data->trade_able);
			pData->SetAttribute("ExploitValue", p_data->exploit_value);
			pData->SetAttribute("SetID", p_data->setid);
			pData->SetAttribute("honorLevel", p_data->honor_level);
			pData->SetAttribute("LifeTime", p_data->life_time);
			pData->SetAttribute("VipOnly", p_data->vip_only);
			pData->SetAttribute("DailyId", p_data->dailyid);
			pData->SetAttribute("decompose", p_data->decompose);
			pData->SetAttribute("Shop", p_data->shop);
			pData->SetAttribute("UnStorage", p_data->un_storage);
			pData->SetAttribute("resID", p_data->res_id);
			if(strlen(p_data->descipt) > 0)
			{
				TiXmlElement* pdescipt = new TiXmlElement("descript");
				TiXmlText *pText = new TiXmlText(p_data->descipt);
				pText->SetCDATA(true);
				pdescipt->InsertEndChild(*pText);
				pData->InsertEndChild(*pdescipt);
			}
	
			pCat->InsertEndChild(*pData);	
		}
		root->InsertEndChild(*pCat);
	}
	return pdoc->SaveFile(xml_name);
}
开发者ID:Zhanyin,项目名称:taomee,代码行数:78,代码来源:item_attire.cpp


示例12: hplNew

	bool cLanguageFile::LoadFromFile(const tString asFile)
	{
		TiXmlDocument *pDoc = hplNew(TiXmlDocument,(asFile.c_str()) );
		if(pDoc->LoadFile()==false)
		{
			hplDelete(pDoc);
			Error("Couldn't find language file '%s'\n",asFile.c_str());
			return false;
		}

		TiXmlElement *pRootElem = pDoc->FirstChildElement();

		///////////////////////////
		//Iterate the resources
		TiXmlElement *pResourceElem = pRootElem->FirstChildElement("RESOURCES");
		if(pResourceElem)
		{
			TiXmlElement *pDirElem = pResourceElem->FirstChildElement("Directory");
			for(; pDirElem != NULL; pDirElem = pDirElem->NextSiblingElement("Directory"))
			{
					tString sPath = pDirElem->Attribute("Path");
					mpResources->AddResourceDir(sPath);
			}
		}
		else
		{
			Warning("No resources element found in '%s'\n",asFile.c_str());
		}


		///////////////////////////
		//Iterate the categories
		TiXmlElement *pCatElem = pRootElem->FirstChildElement("CATEGORY");
		for(; pCatElem != NULL; pCatElem = pCatElem->NextSiblingElement("CATEGORY"))
		{
			cLanguageCategory *pCategory = hplNew( cLanguageCategory, () );
			tString sCatName = pCatElem->Attribute("Name");

			m_mapCategories.insert(tLanguageCategoryMap::value_type(sCatName, pCategory));

			///////////////////////////
			//Iterate the entries
			TiXmlElement *pEntryElem = pCatElem->FirstChildElement("Entry");
			for(; pEntryElem != NULL; pEntryElem = pEntryElem->NextSiblingElement("Entry"))
			{
				cLanguageEntry *pEntry = hplNew( cLanguageEntry, () );
				tString sEntryName = pEntryElem->Attribute("Name");

				if(pEntryElem->FirstChild()==NULL)
				{
					pEntry->mwsText = _W("");
				}
				else
				{
					TiXmlText *pTextNode = pEntryElem->FirstChild()->ToText();
					if(pTextNode)
					{
						//pEntry->msText = pTextNode->Value();
						//pEntry->msText = cString::ReplaceStringTo(pEntry->msText,"[br]","\n");

						tString sString = pTextNode->Value();
						pEntry->mwsText = _W("");

						//if(sCatName == "TEST") Log("String: '%s' %d\n",sString.c_str(),sString.size());

						for(size_t i=0; i< sString.length(); ++i)
						{
							unsigned char c = sString[i];
							if(c=='[')
							{
								bool bFoundCommand = true;
								tString sCommand = "";
								int lCount =1;

								while(sString[i+lCount] != ']' && i+lCount<sString.length() && lCount < 16)
								{
									sCommand += sString[i+lCount];
									lCount++;
								}

								if(sCommand=="br")
								{
									pEntry->mwsText += _W('\n');
								}
								else if(sCommand[0]=='u')
								{
									int lNum = cString::ToInt(sCommand.substr(1).c_str(),0);
									pEntry->mwsText += (wchar_t)lNum;
								}
								else
								{
									bFoundCommand = false;
								}

								//Go forward or add [ to string
								if(bFoundCommand)
								{
									i += lCount;
								}
								else
//.........这里部分代码省略.........
开发者ID:FrictionalGames,项目名称:HPL1Engine,代码行数:101,代码来源:LanguageFile.cpp


示例13: _tfopen

int CCrashDescReader::Load(CString sFileName)
{
    TiXmlDocument doc;
    FILE* f = NULL;
    strconv_t strconv;

    if(m_bLoaded)
        return 1; // already loaded

    // Check that the file exists
#if _MSC_VER<1400
    f = _tfopen(sFileName, _T("rb"));
#else
    _tfopen_s(&f, sFileName, _T("rb"));
#endif

    if(f==NULL)
        return -1; // File can't be opened

    // Open XML document  
    bool bLoaded = doc.LoadFile(f);
    if(!bLoaded)
    {
        fclose(f);
        return -2; // XML is corrupted
    }

    TiXmlHandle hDoc(&doc);

    TiXmlHandle hRoot = hDoc.FirstChild("CrashRpt").ToElement();
    if(hRoot.ToElement()==NULL)
    {
        if(LoadXmlv10(hDoc)==0)
        {
            fclose(f);
            return 0;
        }  

        return -3; // Invalid XML structure
    }

    // Get generator version

    const char* szCrashRptVersion = hRoot.ToElement()->Attribute("version");
    if(szCrashRptVersion!=NULL)
    {
        m_dwGeneratorVersion = atoi(szCrashRptVersion);
    }

    // Get CrashGUID
    TiXmlHandle hCrashGUID = hRoot.ToElement()->FirstChild("CrashGUID");
    if(hCrashGUID.ToElement())
    {    
        TiXmlText* pTextElem = hCrashGUID.FirstChild().Text();     
        if(pTextElem)
        {
            const char* text = pTextElem->Value();
            if(text)
                m_sCrashGUID = strconv.utf82t(text);    
        }    
    }

    // Get AppName
    TiXmlHandle hAppName = hRoot.ToElement()->FirstChild("AppName");
    if(hAppName.ToElement())
    {    
        TiXmlText* pTextElem = hAppName.FirstChild().Text();     
        if(pTextElem)
        {
            const char* text = pTextElem->Value();
            if(text)
                m_sAppName = strconv.utf82t(text);        
        }
    }

    // Get AppVersion
    TiXmlHandle hAppVersion = hRoot.ToElement()->FirstChild("AppVersion");
    if(hAppVersion.ToElement())
    {    
        TiXmlText* pTextElem = hAppVersion.FirstChild().Text();     
        if(pTextElem)
        {
            const char* text = pTextElem->Value();
            if(text)
                m_sAppVersion = strconv.utf82t(text);    
        }
    }

    // Get ImageName
    TiXmlHandle hImageName = hRoot.ToElement()->FirstChild("ImageName");
    if(hImageName.ToElement())
    {    
        TiXmlText* pTextElem = hImageName.FirstChild().Text();     
        if(pTextElem)
        {
            const char* text = pTextElem->Value();
            if(text)
                m_sImageName = strconv.utf82t(text);        
        }
    }
//.........这里部分代码省略.........
开发者ID:doo,项目名称:CrashRpt,代码行数:101,代码来源:CrashDescReader.cpp


示例14: while

void CVar::serializeCVar(TiXmlNode* rootNode, bool oldDeveloper)
{
    if (rootNode == NULL)
        return;

    TiXmlElement* cvarNode = rootNode->FirstChildElement("CVar");

    while (cvarNode != NULL)
    {
        if (!std::string(cvarNode->Attribute("name")).compare(name()))
            break;
        cvarNode = cvarNode->NextSiblingElement("CVar");
    }

    TiXmlText* text = NULL;
    TiXmlText* oldText = NULL;


    if (!cvarNode)
    {
        cvarNode = new TiXmlElement("CVar");
        cvarNode->SetAttribute("name", name());
        rootNode->LinkEndChild(cvarNode);
    }
    else
    {
        if (cvarNode->FirstChild())
        {
            oldText = cvarNode->FirstChild()->ToText();
        }
    }

    switch(type())
    {
        case CVar::Boolean:
        {
            cvarNode->SetAttribute("type", "boolean");
            std::string val;
            if (com_developer == this)
                val = (oldDeveloper ? "true" : "false");
            else
                val = (toBoolean() ? "true" : "false");

            text = new TiXmlText(val);
            break;
        }
        case CVar::Integer:
            cvarNode->SetAttribute("type", "integer");
            break;
        case CVar::Float:
            cvarNode->SetAttribute("type", "float");
            break;
        case CVar::Literal:
        {
            cvarNode->SetAttribute("type", "literal");
            text = new TiXmlText(toLiteral());
            text->SetCDATA(true);
            break;
        }
        case CVar::Color:
        {
            Colori col = toColori();
            cvarNode->SetAttribute("type", "color");
            cvarNode->SetAttribute("r", (col.r & 255));
            cvarNode->SetAttribute("g", (col.g & 255));
            cvarNode->SetAttribute("b", (col.b & 255));
            cvarNode->SetAttribute("a", (col.a & 255));
        }
            break;
        default: break;
    }

    if (!text && type() != Color)
        text = new TiXmlText(toLiteral());

    if (oldText && type() != Color)
    {
        cvarNode->RemoveChild(oldText);
    }

    if (text && type() != Color)
        cvarNode->LinkEndChild(text);
}
开发者ID:Antidote,项目名称:Orion,代码行数:83,代码来源:CVar.cpp


示例15: mutex

bool CSiteManager::GetBookmarks(wxString sitePath, std::list<wxString> &bookmarks)
{
	wxChar c = sitePath[0];
	if (c != '0' && c != '1')
		return false;

	sitePath = sitePath.Mid(1);

	// We have to synchronize access to sitemanager.xml so that multiple processed don't write
	// to the same file or one is reading while the other one writes.
	CInterProcessMutex mutex(MUTEX_SITEMANAGER);

	CXmlFile file;
	TiXmlElement* pDocument = 0;

	if (c == '0')
		pDocument = file.Load(_T("sitemanager"));
	else
	{
		const wxString& defaultsDir = wxGetApp().GetDefaultsDir();
		if (defaultsDir == _T(""))
			return false;
		pDocument = file.Load(wxFileName(defaultsDir, _T("fzdefaults.xml")));
	}

	if (!pDocument)
	{
		wxMessageBox(file.GetError(), _("Error loading xml file"), wxICON_ERROR);

		return false;
	}

	TiXmlElement* pElement = pDocument->FirstChildElement("Servers");
	if (!pElement)
		return false;

	std::list<wxString> segments;
	if (!UnescapeSitePath(sitePath, segments))
	{
		wxMessageBox(_("Site path is malformed."), _("Invalid site path"));
		return 0;
	}

	TiXmlElement* pChild = GetElementByPath(pElement, segments);
	if (!pChild || strcmp(pChild->Value(), "Server"))
		return 0;

	// Bookmarks
	for (TiXmlElement* pBookmark = pChild->FirstChildElement("Bookmark"); pBookmark; pBookmark = pBookmark->NextSiblingElement("Bookmark"))
	{
		TiXmlHandle handle(pBookmark);

		wxString name = GetTextElement_Trimmed(pBookmark, "Name");
		if (name.empty())
			continue;

		wxString localPath;
		CServerPath remotePath;
		TiXmlText* localDir = handle.FirstChildElement("LocalDir").FirstChild().Text();
		if (localDir)
			localPath = ConvLocal(localDir->Value());
		TiXmlText* remoteDir = handle.FirstChildElement("RemoteDir").FirstChild().Text();
		if (remoteDir)
			remotePath.SetSafePath(ConvLocal(remoteDir->Value()));

		if (localPath.empty() && remotePath.IsEmpty())
			continue;

		bookmarks.push_back(name);		
	}

	return true;
}
开发者ID:AbelTian,项目名称:filezilla,代码行数:73,代码来源:sitemanager.cpp


示例16: wxT

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TibrvMsg类代码示例发布时间:2022-05-31
下一篇:
C++ TiXmlString类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap