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

C++ TiXmlNode类代码示例

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

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



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

示例1: docHandle

        void MeshGraph2D::ReadElements(TiXmlDocument &doc)
        {
            /// We know we have it since we made it this far.
            TiXmlHandle docHandle(&doc);
            TiXmlElement* mesh = docHandle.FirstChildElement("NEKTAR").FirstChildElement("GEOMETRY").Element();
            TiXmlElement* field = NULL;

            /// Look for elements in ELEMENT block.
            field = mesh->FirstChildElement("ELEMENT");

            ASSERTL0(field, "Unable to find ELEMENT tag in file.");

            // Set up curve map for curved elements on an embedded manifold.
            map<int, int> faceCurves;
            map<int,int>::iterator x;
            for (int i = 0; i < m_curvedFaces.size(); ++i)
            {
                faceCurves[m_curvedFaces[i]->m_curveID] = i;
            }

            int nextElementNumber = -1;

            /// All elements are of the form: "<? ID="#"> ... </?>", with
            /// ? being the element type.

            TiXmlElement *element = field->FirstChildElement();

                while (element)
                {
                    std::string elementType(element->ValueStr());

                    ASSERTL0(elementType == "Q" || elementType == "T",
                             (std::string("Unknown 2D element type: ") + elementType).c_str());

                    /// These should be ordered.
                    nextElementNumber++;

                    /// Read id attribute.
                    int indx;
                    int err = element->QueryIntAttribute("ID", &indx);
                    ASSERTL0(err == TIXML_SUCCESS, "Unable to read element attribute ID.");
//                    ASSERTL0(indx == nextElementNumber, "Element IDs must begin with zero and be sequential.");

                    /// Read text element description.
                    TiXmlNode* elementChild = element->FirstChild();
                    std::string elementStr;
                    while(elementChild)
                    {
                        if (elementChild->Type() == TiXmlNode::TEXT)
                        {
                            elementStr += elementChild->ToText()->ValueStr();
                        }
                        elementChild = elementChild->NextSibling();
                    }

                    ASSERTL0(!elementStr.empty(), "Unable to read element description body.");

                    /// Parse out the element components corresponding to type of element.
                    if (elementType == "T")
                    {
                        // Read three edge numbers
                        int edge1, edge2, edge3;
                        std::istringstream elementDataStrm(elementStr.c_str());

                        try
                        {
                            elementDataStrm >> edge1;
                            elementDataStrm >> edge2;
                            elementDataStrm >> edge3;

                            ASSERTL0(!elementDataStrm.fail(), (std::string("Unable to read element data for TRIANGLE: ") + elementStr).c_str());

                            /// Create a TriGeom to hold the new definition.
                            SegGeomSharedPtr edges[TriGeom::kNedges] =
                        {
                            GetSegGeom(edge1),
                            GetSegGeom(edge2),
                            GetSegGeom(edge3)
                        };

                            StdRegions::Orientation edgeorient[TriGeom::kNedges] =
                        {
                            SegGeom::GetEdgeOrientation(*edges[0], *edges[1]),
                            SegGeom::GetEdgeOrientation(*edges[1], *edges[2]),
                            SegGeom::GetEdgeOrientation(*edges[2], *edges[0])
                        };

                            TriGeomSharedPtr trigeom;
                            if ((x = faceCurves.find(indx)) == faceCurves.end())
                            {
                                trigeom = MemoryManager<TriGeom>
                                            ::AllocateSharedPtr(indx,
                                                    edges,
                                                    edgeorient);
                            }
                            else
                            {
                                trigeom = MemoryManager<TriGeom>
                                            ::AllocateSharedPtr(indx,
                                                    edges,
//.........这里部分代码省略.........
开发者ID:gaoak,项目名称:nektar,代码行数:101,代码来源:MeshGraph2D.cpp


示例2: GetText

void duXmlStatic::ParseTextParam()
{
	LPCTSTR lpszText = GetText();
	if (lpszText == NULL || *lpszText == 0)
		return;
	
	TiXmlDocument *pXmlDoc = new TiXmlDocument;
	pXmlDoc->Parse(lpszText, NULL);
	
	TiXmlElement *pTextElement = pXmlDoc->FirstChildElement(_T("text"));
	if (pTextElement == NULL)
	{
		delete pXmlDoc;
		return;
	}
	
	Destroy();
	
	m_nParagraphSpace = ReadXmlAttributeInt(pTextElement, _T("ParagraphSpace"));
	ReadXmlAttributeText(pTextElement, _T("Font"), m_szDefaultFont, MAX_NAME);
	m_clrDefault = ReadXmlAttributeColor(pTextElement, _T("Color"));

	TiXmlNode *pChildNode = pTextElement->FirstChild();
	while (pChildNode)
	{
		if (pChildNode->Type() == TiXmlNode::ELEMENT)
		{
			TiXmlElement *pThis = pChildNode->ToElement();
			if (lstrcmpi(pThis->Value(), _T("br")) == 0)
			{
				XMLTEXTHEAD *pBrText = ParseBrText(pThis);
				if (pBrText)
					m_vtXmlText.push_back(pBrText);
			}
			else if (lstrcmpi(pThis->Value(), _T("text")) == 0)
			{
				XMLTEXTHEAD *pFormatText = ParseFormatText(pThis);
				if (pFormatText)
					m_vtXmlText.push_back(pFormatText);
			}
		}
		else if (pChildNode->Type() == TiXmlNode::TEXT)
		{
			TiXmlText *pThis = pChildNode->ToText();
			XMLTEXTHEAD *pNormalText = ParseNormalText(pThis);
			if (pNormalText)
				m_vtXmlText.push_back(pNormalText);
		}
		
		pChildNode = pChildNode->NextSibling();
	}
	
	//////////////////////////////////////////////////////////////////
	duRect rectStatic;
	Plugin_GetRect(this, &rectStatic);
	rectStatic.OffsetRect(-rectStatic.left, -rectStatic.top);
	
	int nTextCount = (int)m_vtXmlText.size();
	int i;
	int nCurrentLineWidth = 0;
	int nMaxHeight = 0;
	
	XMLSTATICLINE *pThisLine = NULL;
	for (i = 0;i < nTextCount; i++)
	{
		XMLTEXTHEAD *pTextHead = m_vtXmlText[i];
		MeasureString(pTextHead);
		
		if (pTextHead->size.cy > nMaxHeight)
			nMaxHeight = pTextHead->size.cy;

		if (pTextHead->enType == BRTEXT)
		{
			XMLSTATICLINESEGMENT *pLineSegment = new XMLSTATICLINESEGMENT;
			pLineSegment->pTextHead = pTextHead;
			pLineSegment->lpString = g_emptyString;
			pLineSegment->nStringWidth = 0;
			pLineSegment->nStringPosInTextHead = 0;
			pLineSegment->nWidth = pTextHead->size.cx;
			pLineSegment->nHeight = pTextHead->size.cy;

			if (pThisLine == NULL)
			{
				pThisLine = new XMLSTATICLINE;
				pThisLine->nWidth = 0;
				pThisLine->nHeight = 0;
				pThisLine->vtLineSegment.clear();
				m_vtLine.push_back(pThisLine);
			}

			pThisLine->nWidth = nCurrentLineWidth;
			pThisLine->nHeight = nMaxHeight;
			pThisLine->vtLineSegment.push_back(pLineSegment);

			pThisLine = NULL;
			nCurrentLineWidth = 0;
		}
		else
		{
			nCurrentLineWidth += pTextHead->size.cx;
//.........这里部分代码省略.........
开发者ID:blueantst,项目名称:dulib,代码行数:101,代码来源:duXmlStatic.cpp


示例3: GetDocument

const wchar_t* TiXmlElement::ReadValue( const wchar_t* p, TiXmlParsingData* data, TiXmlEncoding encoding )
{
	TiXmlDocument* document = GetDocument();

	// Read in text and elements in any order.
	const wchar_t* pWithWhiteSpace = p;
	p = SkipWhiteSpace( p, encoding );

	while ( p && *p )
	{
		if ( *p != '<' )
		{
			// Take what we have, make a text element.
			TiXmlText* textNode = new TiXmlText( L"" );

			if ( !textNode )
			{
				if ( document ) document->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 );
			else
				delete textNode;
		} 
		else 
		{
			// We hit a '<'
			// Have we hit a new element or an end tag? This could also be
			// a TiXmlText in the L"CDATA" style.
			if ( StringEqual( p, L"</", false, encoding ) )
			{
				return p;
			}
			else
			{
				TiXmlNode* node = Identify( p, encoding );
				if ( node )
				{
					p = node->Parse( p, data, encoding );
					LinkEndChild( node );
				}				
				else
				{
					return 0;
				}
			}
		}
		pWithWhiteSpace = p;
		//p = SkipWhiteSpace( p, encoding );
	}

	if ( !p )
	{
		if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding );
	}	
	return p;
}
开发者ID:BigZaphod,项目名称:lime,代码行数:70,代码来源:tinyxmlparser.cpp


示例4: main

int main()
{
	//
	// We start with the 'demoStart' todo list. Process it. And
	// should hopefully end up with the todo list as illustrated.
	//
	const char* demoStart =
		"<?xml version=\"1.0\"  standalone='no' >\n"
		"<!-- Our to do list data -->"
		"<ToDo>\n"
		"<!-- Do I need a secure PDA? -->\n"
		"<Item priority=\"1\" distance='close'> Go to the <bold>Toy store!</bold></Item>"
		"<Item priority=\"2\" distance='none'> Do bills   </Item>"
		"<Item priority=\"2\" distance='far &amp; back'> Look for Evil Dinosaurs! </Item>"
		"</ToDo>";

#ifdef TIXML_USE_STL
	/*	What the todo list should look like after processing.
		In stream (no formatting) representation. */
	const char* demoEnd =
		"<?xml version=\"1.0\" standalone=\"no\" ?>"
		"<!-- Our to do list data -->"
		"<ToDo>"
		"<!-- Do I need a secure PDA? -->"
		"<Item priority=\"2\" distance=\"close\">Go to the"
		"<bold>Toy store!"
		"</bold>"
		"</Item>"
		"<Item priority=\"1\" distance=\"far\">Talk to:"
		"<Meeting where=\"School\">"
		"<Attendee name=\"Marple\" position=\"teacher\" />"
		"<Attendee name=\"Vo&#x82;\" position=\"counselor\" />"
		"</Meeting>"
		"<Meeting where=\"Lunch\" />"
		"</Item>"
		"<Item priority=\"2\" distance=\"here\">Do bills"
		"</Item>"
		"</ToDo>";
#endif

	// The example parses from the character string (above):
	#if defined( WIN32 ) && defined( TUNE )
	QueryPerformanceCounter( (LARGE_INTEGER*) (&start) );
	#endif

	{
		// Write to a file and read it back, to check file I/O.

		TiXmlDocument doc( "demotest.xml" );
		doc.Parse( demoStart );

		if ( doc.Error() )
		{
			printf( "Error in %s: %s\n", doc.Value(), doc.ErrorDesc() );
			exit( 1 );
		}
		doc.SaveFile();
	}
	ostringstream outputStream( ostringstream::out );
        {
          TiXmlDocument doc( "demotest.xml" );
          bool loadOkay = doc.LoadFile();
          
          if ( !loadOkay )
          {
            printf( "Could not load test file 'demotest.xml'. Error='%s'. Exiting.\n", doc.ErrorDesc() );
            exit( 1 );
          }

          printf( "** Demo doc read from disk: ** \n\n" );
          doc.Print( stdout );

          TiXmlNode* node = 0;
          TiXmlElement* todoElement = 0;
          TiXmlElement* itemElement = 0;


          // --------------------------------------------------------
          // An example of changing existing attributes, and removing
          // an element from the document.
          // --------------------------------------------------------
          
          // Get the "ToDo" element.
          // It is a child of the document, and can be selected by name.
          node = doc.FirstChild( "ToDo" );
          assert( node );
          todoElement = node->ToElement();
          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->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();
//.........这里部分代码省略.........
开发者ID:E-LLP,项目名称:europa,代码行数:101,代码来源:xmltest.cpp


示例5: wxLogError

KmlPastebufferType Kml::ParsePasteBuffer() {
    if( !wxTheClipboard->IsOpened() )
        if( ! wxTheClipboard->Open() ) return KML_PASTE_INVALID;

    wxTextDataObject data;
    wxTheClipboard->GetData( data );
    kmlText = data.GetText();
    wxTheClipboard->Close();

    if( kmlText.Find( _T("<kml") ) == wxNOT_FOUND ) return KML_PASTE_INVALID;

    TiXmlDocument doc;
    if( ! doc.Parse( kmlText.mb_str( wxConvUTF8 ), 0, TIXML_ENCODING_UTF8 ) ) {
		wxLogError( wxString( doc.ErrorDesc(), wxConvUTF8 ) );
		return KML_PASTE_INVALID;
	}
    if( 0 != strncmp( doc.RootElement()->Value(), "kml", 3 ) ) return KML_PASTE_INVALID;

    TiXmlHandle docHandle( doc.RootElement() );

	// We may or may not have a <document> depending on what the user copied.
    TiXmlElement* placemark = docHandle.FirstChild( "Document" ).FirstChild( "Placemark" ).ToElement();
    if( ! placemark ) {
        placemark = docHandle.FirstChild( "Placemark" ).ToElement();
	}
    if( ! placemark ) {
        wxString msg( _T("KML Parser found no <Placemark> tag in the KML.") );
        wxLogMessage( msg );
        return KML_PASTE_INVALID;
    }

    int pointCounter = 0;
    wxString name;
    for( ; placemark; placemark=placemark->NextSiblingElement() ) {
        TiXmlElement* e = placemark->FirstChildElement( "name" );
        if( e ) name = wxString( e->GetText(),wxConvUTF8 );
        pointCounter++;
    }

    if( pointCounter == 1 ) {

        // Is it a single waypoint?
        TiXmlNode* element = docHandle.FirstChild( "Document" ).FirstChild( "Placemark" ).FirstChild( "Point" ).ToNode();
        if( ! element ) element = docHandle.FirstChild( "Placemark" ).FirstChild( "Point" ).ToNode();
        if( element ) return ParseOnePlacemarkPoint( element, name );

        // Is it a dumb <LineString> track?
        element = docHandle.FirstChild( "Document" ).FirstChild( "Placemark" ).FirstChild( "LineString" ).ToNode();
        if( ! element ) element = docHandle.FirstChild( "Placemark" ).FirstChild( "LineString" ).ToNode();
        if( element ) return ParseTrack( element, name );

        // Is it a smart extended <gx:track> track?
        element = docHandle.FirstChild( "Document" ).FirstChild( "Placemark" ).FirstChild( "gx:Track" ).ToNode();
        if( ! element ) element = docHandle.FirstChild( "Placemark" ).FirstChild( "gx:Track" ).ToNode();
        if( element ) return ParseTrack( element, name );

        wxString msg( _T("KML Parser found a single <Placemark> in the KML, but no useable data in it.") );
        wxLogMessage( msg );
        return KML_PASTE_INVALID;
    }

    // Here we go with a full route.

    parsedRoute = new Route();
    bool foundPoints = false;
    bool foundTrack = false;
    TiXmlElement* element = docHandle.FirstChild( "Document" ).FirstChild( "name" ).ToElement();
    if( element )
        parsedRoute->m_RouteNameString = wxString( element->GetText(), wxConvUTF8 );

    RoutePoint* rp = NULL;
    placemark = docHandle.FirstChild( "Document" ).FirstChild( "Placemark" ).ToElement();
    for( ; placemark; placemark=placemark->NextSiblingElement() ) {

        TiXmlNode* n = placemark->FirstChild( "Point" );
        if( n ) {
            if( ParseOnePlacemarkPoint( n->ToElement(), name ) == KML_PASTE_WAYPOINT ) {
                parsedRoute->AddPoint( new RoutePoint( parsedRoutePoint ) );
                delete parsedRoutePoint;
                parsedRoutePoint = 0;
                foundPoints = true;
            }
        }

        n = placemark->FirstChild( "LineString" );
        if( n ) {
            ParseTrack( n->ToElement(), name );
            foundTrack = true;
        }
        n = placemark->FirstChild( "gx:Track" );
        if( n ) {
            ParseTrack( n->ToElement(), name );
            foundTrack = true;
        }
    }

    if( foundPoints && parsedRoute->GetnPoints() < 2 ) {
        wxString msg( _T("KML Parser did not find enough <Point>s to make a route.") );
        wxLogMessage( msg );
        foundPoints = false;
//.........这里部分代码省略.........
开发者ID:SamsonovAnton,项目名称:OpenCPN,代码行数:101,代码来源:kml.cpp


示例6: lock

bool CMediaSettings::Save(TiXmlNode *settings) const
{
  if (settings == NULL)
    return false;

  CSingleLock lock(m_critical);
  // default video settings
  TiXmlElement videoSettingsNode("defaultvideosettings");
  TiXmlNode *pNode = settings->InsertEndChild(videoSettingsNode);
  if (pNode == NULL)
    return false;

  XMLUtils::SetInt(pNode, "deinterlacemode", m_defaultVideoSettings.m_DeinterlaceMode);
  XMLUtils::SetInt(pNode, "interlacemethod", m_defaultVideoSettings.m_InterlaceMethod);
  XMLUtils::SetInt(pNode, "scalingmethod", m_defaultVideoSettings.m_ScalingMethod);
  XMLUtils::SetFloat(pNode, "noisereduction", m_defaultVideoSettings.m_NoiseReduction);
  XMLUtils::SetBoolean(pNode, "postprocess", m_defaultVideoSettings.m_PostProcess);
  XMLUtils::SetFloat(pNode, "sharpness", m_defaultVideoSettings.m_Sharpness);
  XMLUtils::SetInt(pNode, "viewmode", m_defaultVideoSettings.m_ViewMode);
  XMLUtils::SetFloat(pNode, "zoomamount", m_defaultVideoSettings.m_CustomZoomAmount);
  XMLUtils::SetFloat(pNode, "pixelratio", m_defaultVideoSettings.m_CustomPixelRatio);
  XMLUtils::SetFloat(pNode, "verticalshift", m_defaultVideoSettings.m_CustomVerticalShift);
  XMLUtils::SetFloat(pNode, "volumeamplification", m_defaultVideoSettings.m_VolumeAmplification);
  XMLUtils::SetBoolean(pNode, "outputtoallspeakers", m_defaultVideoSettings.m_OutputToAllSpeakers);
  XMLUtils::SetBoolean(pNode, "showsubtitles", m_defaultVideoSettings.m_SubtitleOn);
  XMLUtils::SetFloat(pNode, "brightness", m_defaultVideoSettings.m_Brightness);
  XMLUtils::SetFloat(pNode, "contrast", m_defaultVideoSettings.m_Contrast);
  XMLUtils::SetFloat(pNode, "gamma", m_defaultVideoSettings.m_Gamma);
  XMLUtils::SetFloat(pNode, "audiodelay", m_defaultVideoSettings.m_AudioDelay);
  XMLUtils::SetFloat(pNode, "subtitledelay", m_defaultVideoSettings.m_SubtitleDelay);
  XMLUtils::SetBoolean(pNode, "autocrop", m_defaultVideoSettings.m_Crop); 
  XMLUtils::SetBoolean(pNode, "nonlinstretch", m_defaultVideoSettings.m_CustomNonLinStretch);

  // mymusic
  pNode = settings->FirstChild("mymusic");
  if (pNode == NULL)
  {
    TiXmlElement videosNode("mymusic");
    pNode = settings->InsertEndChild(videosNode);
    if (pNode == NULL)
      return false;
  }

  TiXmlElement musicPlaylistNode("playlist");
  TiXmlNode *playlistNode = pNode->InsertEndChild(musicPlaylistNode);
  if (playlistNode == NULL)
    return false;
  XMLUtils::SetBoolean(playlistNode, "repeat", m_musicPlaylistRepeat);
  XMLUtils::SetBoolean(playlistNode, "shuffle", m_musicPlaylistShuffle);

  XMLUtils::SetInt(pNode, "needsupdate", m_musicNeedsUpdate);

  // myvideos
  pNode = settings->FirstChild("myvideos");
  if (pNode == NULL)
  {
    TiXmlElement videosNode("myvideos");
    pNode = settings->InsertEndChild(videosNode);
    if (pNode == NULL)
      return false;
  }

  XMLUtils::SetInt(pNode, "watchmodemovies", m_watchedModes.find("movies")->second);
  XMLUtils::SetInt(pNode, "watchmodetvshows", m_watchedModes.find("tvshows")->second);
  XMLUtils::SetInt(pNode, "watchmodemusicvideos", m_watchedModes.find("musicvideos")->second);

  TiXmlElement videoPlaylistNode("playlist");
  playlistNode = pNode->InsertEndChild(videoPlaylistNode);
  if (playlistNode == NULL)
    return false;
  XMLUtils::SetBoolean(playlistNode, "repeat", m_videoPlaylistRepeat);
  XMLUtils::SetBoolean(playlistNode, "shuffle", m_videoPlaylistShuffle);

  XMLUtils::SetInt(pNode, "needsupdate", m_videoNeedsUpdate);

  return true;
}
开发者ID:DJMatty,项目名称:xbmc,代码行数:77,代码来源:MediaSettings.cpp


示例7: PathRemoveFileSpec

bool AutoCompletion::setLanguage(LangType language) {
	if (_curLang == language)
		return true;
	_curLang = language;

	TCHAR path[MAX_PATH];
	::GetModuleFileName(NULL, path, MAX_PATH);
	PathRemoveFileSpec(path);
	lstrcat(path, TEXT("\\plugins\\APIs\\"));
	lstrcat(path, getApiFileName());
	lstrcat(path, TEXT(".xml"));

	if (_pXmlFile)
		delete _pXmlFile;

	_pXmlFile = new TiXmlDocument(path);
	_funcCompletionActive = _pXmlFile->LoadFile();

	TiXmlNode * pAutoNode = NULL;
	if (_funcCompletionActive) {
		_funcCompletionActive = false;	//safety
		TiXmlNode * pNode = _pXmlFile->FirstChild(TEXT("NotepadPlus"));
		if (!pNode)
			return false;
		pAutoNode = pNode = pNode->FirstChildElement(TEXT("AutoComplete"));
		if (!pNode)
			return false;
		pNode = pNode->FirstChildElement(TEXT("KeyWord"));
		if (!pNode)
			return false;
		_pXmlKeyword = reinterpret_cast<TiXmlElement *>(pNode);
		if (!_pXmlKeyword)
			return false;
		_funcCompletionActive = true;
	}

	if(_funcCompletionActive) //try setting up environment
    {
		//setup defaults
		_ignoreCase = true;
		_funcCalltip._start = '(';
		_funcCalltip._stop = ')';
		_funcCalltip._param = ',';
		_funcCalltip._terminal = ';';
		_funcCalltip._ignoreCase = true;
        _funcCalltip._additionalWordChar.clear();

		TiXmlElement * pElem = pAutoNode->FirstChildElement(TEXT("Environment"));
		if (pElem)
        {
			const TCHAR * val = 0;
			val = pElem->Attribute(TEXT("ignoreCase"));
			if (val && !lstrcmp(val, TEXT("no"))) {
				_ignoreCase = false;
				_funcCalltip._ignoreCase = false;
			}
			val = pElem->Attribute(TEXT("startFunc"));
			if (val && val[0])
				_funcCalltip._start = val[0];
			val = pElem->Attribute(TEXT("stopFunc"));
			if (val && val[0])
				_funcCalltip._stop = val[0];
			val = pElem->Attribute(TEXT("paramSeparator"));
			if (val && val[0])
				_funcCalltip._param = val[0];
			val = pElem->Attribute(TEXT("terminal"));
			if (val && val[0])
				_funcCalltip._terminal = val[0];
			val = pElem->Attribute(TEXT("additionalWordChar"));
			if (val && val[0])
                _funcCalltip._additionalWordChar = val;
		}
	}

	if (_funcCompletionActive) {
		_funcCalltip.setLanguageXML(_pXmlKeyword);
	} else {
		_funcCalltip.setLanguageXML(NULL);
	}

	_keyWords.clear();
	_keyWordArray.clear();

	if (_funcCompletionActive)
	{
		//Cache the keywords
		//Iterate through all keywords
		TiXmlElement *funcNode = _pXmlKeyword;

		for (; funcNode; funcNode = funcNode->NextSiblingElement(TEXT("KeyWord")) )
		{
			const TCHAR *name = funcNode->Attribute(TEXT("name"));
			if (name)
			{
				size_t len = lstrlen(name);
				if (len)
				{
					_keyWordArray.push_back(name);
					if (len > _keyWordMaxLen)
						_keyWordMaxLen = len;
//.........这里部分代码省略.........
开发者ID:123vipulj,项目名称:notepad-plus-plus,代码行数:101,代码来源:AutoCompletion.cpp


示例8: TiXmlText

//修改结点struNote。或返回结点struNode的值
bool CSimpleXml::AccessXmlNode( XMLNODEINFO &struNote, int nType)
{
    int nEnd = 0;
    if(m_pDoc == NULL || m_pRoot == NULL)
    {
        return false;
    }
    TiXmlText* pText = NULL; // 一个指向Text的指针
    pText = new TiXmlText(struNote.strData.c_str()) ;
    string strNodeName = struNote.strNodeName;
    nEnd = strNodeName.find("/");
    string strNode = strNodeName.substr(0, nEnd);
    strNodeName = strNodeName.substr(nEnd + 1, strNodeName.length() - nEnd);

    TiXmlNode *node = m_pRoot;
    TiXmlNode *destnode = NULL;
    while(node)
    {
        string strchildnode = node->Value();
        if(strNode != strchildnode)
        {
            node = node->NextSibling();
            continue;//此子结点非我们要的子结点,跳到下一个子结点
        }
        if((strNode == strNodeName) && (strNode == node->Value()))//Node就是我们访问的结点。
        {
            destnode = node->FirstChild();
            if(destnode && destnode->Type() == TiXmlNode::TEXT)//是叶子结点,修改为我们的值
            {
                if(nType == QUERY)
                {
                    struNote.strData = destnode->Value();//查询结点的值
                }
                else
                {
                    destnode->SetValue(struNote.strData.c_str());//修改为我们的值
                }
            }
            else if(destnode && destnode->Type() == TiXmlNode::ELEMENT)//不是叶子结点,加上我们的值
            {
                node->InsertBeforeChild(destnode, *pText);
            }
            else if(!destnode)//要写的结点原值为空,加上我们的值
            {
                node->InsertEndChild(*pText);
            }
            return true;
        }
        node = node->FirstChild();//Node不是我们访问的结点,开始遍历Node的子结点
        nEnd = strNodeName.find("/");
        strNode = strNodeName.substr(0, nEnd);
        strNodeName = strNodeName.substr(nEnd + 1, strNodeName.length() - nEnd);
        if(node && (strNode == strNodeName) && (strNode == node->Value()))//Node就是我们访问的结点
        {
            destnode = node->FirstChild();
            if(destnode && destnode->Type() == TiXmlNode::TEXT)//是叶子结点,加上我们的值
            {
                if(nType == QUERY)
                {
                    struNote.strData = destnode->Value();//查询结点的值
                }
                else
                {
                    destnode->SetValue(struNote.strData.c_str());//修改为我们的值
                }
            }
            else if(destnode && destnode->Type() == TiXmlNode::ELEMENT)//不是叶子结点,加上我们的值
            {
                node->InsertBeforeChild(destnode, *pText);
            }
            else if(!destnode)//要写的结点原值为空,加上我们的值
            {
                node->InsertEndChild(*pText);
            }
            return true;
        }
    }
    return false;
}
开发者ID:huddy1985,项目名称:ChatOnline,代码行数:80,代码来源:SimpleXml.cpp


示例9: settings

void Lagom::loadSettings()
{
	_effectVolume = defaultSoundVolume;
	_musicVolume = defaultMusicVolume;
	_xResolution = defaultXResolution;
	_yResolution = defaultYResolution;
	_FSAA = defaultFSAA;
	_SSAO = defaultSSAO;
	_fullscreen = defaultFullscreen;
	_dataFile = defaultDataFile;
	_playerColor = defaultPlayerColor;
	_challengeStage = defaultChallengeStage;
	_endless = defaultEndlessMode;
	
	TiXmlDocument	settings(sConfigFilename);
	bool loadOkay = settings.LoadFile();
	if(!loadOkay)
	{
		saveSettings();
		return;
	}
	
	if(!TryReadBool(settings,sPropFullscreen,&_fullscreen))loadOkay=false;
	if(!TryReadBool(settings,sPropEndlessMode,&_endless))loadOkay=false;
	if(!TryReadBool(settings,sPropSSAO,&_SSAO))loadOkay=false;
	if(!TryReadInt(settings,sPropFSAA,&_FSAA))loadOkay=false;
	if(!TryReadInt(settings,sPropXResolution,&_xResolution))loadOkay=false;
	if(!TryReadInt(settings,sPropYResolution,&_yResolution))loadOkay=false;
	if(!TryReadFloat(settings,sPropSoundVolume,&_effectVolume))loadOkay=false;
	if(!TryReadFloat(settings,sPropMusicVolume,&_musicVolume))loadOkay=false;
	if(!TryReadString(settings,sPropDataFile,&_dataFile))loadOkay=false;
	if(!TryReadString(settings,sPropDataFile,&_dataFile))loadOkay=false;
	if(!TryReadColourValue(settings,sPropPlayerColor,&_playerColor))loadOkay=false;
	if(!TryReadInt(settings,sPropChallengeStage,&_challengeStage))loadOkay=false;

	//load highscores
	TiXmlNode* highScoresNode = settings.RootElement()->FirstChild(sPropHighScores);

	if(!highScoresNode)
		loadOkay=false;
	else
	{
		_highScores.clear();

		TiXmlNode* highScore = highScoresNode->FirstChild(sPropHighScoresEntry);
		while(highScore && _highScores.size() < MaxNumHighScores )
		{
			TiXmlElement* highScoreElement = highScore->ToElement();
			if(highScoreElement)
			{
				bool bEntryOk = true;
				HighScoreEntry entry;
				if(!highScoreElement->Attribute(sPropHighScoresScore,&entry._score))bEntryOk=false;
				if(!highScoreElement->Attribute(sPropHighScoresStage,&entry._stage))bEntryOk=false;

				const std::string* pstr= highScoreElement->Attribute(std::string(sPropHighScoresName));

				if(pstr == nullptr)
					bEntryOk=false;
				else 
					entry._name = *pstr;

				if(bEntryOk)
					_highScores.insert(entry);
				else
					loadOkay=false;
			}
			highScore = highScore->NextSibling(sPropHighScoresEntry);
		}
	}

	_playerColor.a = 1.0f;

	if(!loadOkay)
		saveSettings();

	return;
}
开发者ID:jaschmid,项目名称:Lagom,代码行数:78,代码来源:Lagom.cpp


示例10: url

bool CDAVDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
  CFileCurl dav;
  CURL url(strPath);
  CStdString strRequest = "PROPFIND";

  dav.SetCustomRequest(strRequest);
  dav.SetMimeType("text/xml; charset=\"utf-8\"");
  dav.SetRequestHeader("depth", 1);
  dav.SetPostData(
    "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
    " <D:propfind xmlns:D=\"DAV:\">"
    "   <D:prop>"
    "     <D:resourcetype/>"
    "     <D:getcontentlength/>"
    "     <D:getlastmodified/>"
    "     <D:creationdate/>"
    "     <D:displayname/>"
    "    </D:prop>"
    "  </D:propfind>");

  if (!dav.Open(url))
  {
    CLog::Log(LOGERROR, "%s - Unable to get dav directory (%s)", __FUNCTION__, strPath.c_str());
    return false;
  }

  char buffer[MAX_PATH + 1024];
  CStdString strResponse;
  CStdString strHeader;
  while (dav.ReadString(buffer, sizeof(buffer)))
  {
    if (strstr(buffer, "<D:response") != NULL)
    {
      // The header should contain the xml version/utf encoding line
      // followed by the <multistatus> tag
      if (strHeader.IsEmpty())
        strHeader = strResponse;
      
      strResponse = strHeader;
    }
    strResponse.append(buffer, strlen(buffer));

    if (strstr(buffer, "</D:response") != NULL)
    {
      // Close the multistatus tag from the header
      if (strHeader.Find("<D:multistatus"))
        strResponse+="</D:multistatus>\n";
      
      TiXmlDocument davResponse;

      if (!davResponse.Parse(strResponse))
      {
        CLog::Log(LOGERROR, "%s - Unable to process dav directory (%s)", __FUNCTION__, strPath.c_str());
        dav.Close();
        return false;
      }

      TiXmlNode *pChild;
      // Iterate over all responses
      for (pChild = davResponse.RootElement()->FirstChild(); pChild != 0; pChild = pChild->NextSibling())
      {
        if (ValueWithoutNamespace(pChild, "response"))
        {
          CFileItem item;
          ParseResponse(pChild->ToElement(), item);
          CURL url2(strPath);
          CURL url3(item.m_strPath);

          URIUtils::AddFileToFolder(url2.GetWithoutFilename(), url3.GetFileName(), item.m_strPath);

          if (item.GetLabel().IsEmpty())
          {
            CStdString name(item.m_strPath);
            URIUtils::RemoveSlashAtEnd(name);
            CURL::Decode(name);
            item.SetLabel(URIUtils::GetFileName(name));
          }

          if (item.m_bIsFolder)
            URIUtils::AddSlashAtEnd(item.m_strPath);

          // Add back protocol options
          if (!url2.GetProtocolOptions().IsEmpty())
            item.m_strPath += "|" + url2.GetProtocolOptions();

          if (!item.m_strPath.Equals(strPath))
          {
            CFileItemPtr pItem(new CFileItem(item));
            items.Add(pItem);
          }
        }
      }
      strResponse.clear();
    }
  }

  dav.Close();

  return true;
//.........这里部分代码省略.........
开发者ID:mbolhuis,项目名称:xbmc,代码行数:101,代码来源:DAVDirectory.cpp


示例11: while

// 将指定节点下的节点装入map,strNode只支持第一层
void CSimpleXml::GetSpecifyNode(const string &strNode, map<string, string> &mapNode, TiXmlNode *begin/* = NULL*/)
{
    TiXmlNode *node = NULL;
    if (NULL == begin)
    {
        node = m_pRoot;
    }
    else
    {
        node = begin;
    }

    while(NULL != node)
    {
        if (strNode == node->Value())
        {
            TiXmlNode *destnode = node->FirstChild();
            while (NULL != destnode)
            {
                if(destnode->Type() == TiXmlNode::ELEMENT)
                {
                    string strKey = destnode->Value();
                    TiXmlNode *nodechild = destnode->FirstChild();
                    if (NULL != nodechild)
                    {
                        if (NULL != nodechild->FirstChild())
                        {
                            while (NULL != nodechild)
                            {
                                TiXmlNode *grandson = nodechild->FirstChild();
                                string strKey = nodechild->Value();
                                if (NULL != grandson)
                                {
                                    mapNode.insert(make_pair(strKey, grandson->Value()));
                                }

                                nodechild = nodechild->NextSibling();
                            }

                        }
                        else
                        {
                            mapNode.insert(make_pair(strKey, nodechild->Value()));
                        }
                    }
                }
                destnode = destnode->NextSibling();
            }
        }
        node = node->NextSibling();
    }
}
开发者ID:huddy1985,项目名称:ChatOnline,代码行数:53,代码来源:SimpleXml.cpp


示例12: initTheme

void ToolBar::initTheme(TiXmlDocument *toolIconsDocRoot)
{
    _toolIcons =  toolIconsDocRoot->FirstChild(TEXT("NotepadPlus"));
	if (_toolIcons)
	{
		_toolIcons = _toolIcons->FirstChild(TEXT("ToolBarIcons"));
		if (_toolIcons)
		{
			_toolIcons = _toolIcons->FirstChild(TEXT("Theme"));
			if (_toolIcons)
			{
				const TCHAR *themeDir = (_toolIcons->ToElement())->Attribute(TEXT("pathPrefix"));

				for (TiXmlNode *childNode = _toolIcons->FirstChildElement(TEXT("Icon"));
					 childNode ;
					 childNode = childNode->NextSibling(TEXT("Icon")))
				{
					int iIcon;
					const TCHAR *res = (childNode->ToElement())->Attribute(TEXT("id"), &iIcon);
					if (res)
					{
						TiXmlNode *grandChildNode = childNode->FirstChildElement(TEXT("normal"));
						if (grandChildNode)
						{
							TiXmlNode *valueNode = grandChildNode->FirstChild();
							//putain, enfin!!!
							if (valueNode)
							{
								generic_string locator = themeDir?themeDir:TEXT("");
								
								locator += valueNode->Value();
								_customIconVect.push_back(iconLocator(0, iIcon, locator));
							}
						}

						grandChildNode = childNode->FirstChildElement(TEXT("hover"));
						if (grandChildNode)
						{
							TiXmlNode *valueNode = grandChildNode->FirstChild();
							//putain, enfin!!!
							if (valueNode)
							{
								generic_string locator = themeDir?themeDir:TEXT("");
								
								locator += valueNode->Value();
								_customIconVect.push_back(iconLocator(1, iIcon, locator));
							}
						}

						grandChildNode = childNode->FirstChildElement(TEXT("disabled"));
						if (grandChildNode)
						{
							TiXmlNode *valueNode = grandChildNode->FirstChild();
							//putain, enfin!!!
							if (valueNode)
							{
								generic_string locator = themeDir?themeDir:TEXT("");
								
								locator += valueNode->Value();
								_customIconVect.push_back(iconLocator(2, iIcon, locator));
							}
						}
					}
				}
			}
		}
	}
}
开发者ID:nbred5,项目名称:notepad-plus-plus,代码行数:68,代码来源:ToolBar.cpp


示例13: while

bool CLastFmManager::RequestRadioTracks()
{
  unsigned int start = XbmcThreads::SystemClockMillis();
  CStdString url;
  CStdString html;
  url.Format("http://" + m_RadioBaseUrl + m_RadioBasePath + "/xspf.php?sk=%s&discovery=0&desktop=", m_RadioSession);
  {
    CFileCurl http;
    if (!http.Get(url, html))
    {
      m_RadioSession.empty();
      CLog::Log(LOGERROR, "LastFmManager: Connect to Last.fm to request tracks failed.");
      return false;
    }
  }
  //CLog::Log(LOGDEBUG, "RequestRadioTracks: %s", html.c_str());

  //parse playlist
  CXBMCTinyXML xmlDoc;

  xmlDoc.Parse(html);
  if (xmlDoc.Error())
  {
    m_RadioSession.empty();
    CLog::Log(LOGERROR, "LastFmManager: Unable to parse tracklist Error: %s", xmlDoc.ErrorDesc());
    return false;
  }

  TiXmlElement* pRootElement = xmlDoc.RootElement();
  if (!pRootElement )
  {
    CLog::Log(LOGWARNING, "LastFmManager: No more tracks received");
    m_RadioSession.empty();
    return false;
  }

  TiXmlElement* pBodyElement = pRootElement->FirstChildElement("trackList");
  if (!pBodyElement )
  {
    CLog::Log(LOGWARNING, "LastFmManager: No more tracks received, no tracklist");
    m_RadioSession.empty();
    return false;
  }

  TiXmlElement* pTrackElement = pBodyElement->FirstChildElement("track");

  if (!pTrackElement)
  {
    CLog::Log(LOGWARNING, "LastFmManager: No more tracks received, empty tracklist");
    m_RadioSession.empty();
    return false;
  }
  while (pTrackElement)
  {
    CFileItemPtr newItem(new CFileItem);

    TiXmlElement* pElement = pTrackElement->FirstChildElement("location");
    if (pElement)
    {
      TiXmlNode* child = pElement->FirstChild();
      if (child)
      {
        CStdString url = child->Value();
        url.Replace("http:", "lastfm:");
        newItem->SetPath(url);
      }
    }
    pElement = pTrackElement->FirstChildElement("title");
    if (pElement)
    {
      TiXmlNode* child = pElement->FirstChild();
      if (child)
      {
        newItem->SetLabel(child->Value());
        newItem->GetMusicInfoTag()->SetTitle(child->Value());
      }
    }
    pElement = pTrackElement->FirstChildElement("creator");
    if (pElement)
    {
      TiXmlNode* child = pElement->FirstChild();
      if (child)
      {
        newItem->GetMusicInfoTag()->SetArtist(child->Value());
      }
    }
    pElement = pTrackElement->FirstChildElement("album");
    if (pElement)
    {
      TiXmlNode* child = pElement->FirstChild();
      if (child)
      {
        newItem->GetMusicInfoTag()->SetAlbum(child->Value());
      }
    }

    pElement = pTrackElement->FirstChildElement("duration");
    if (pElement)
    {
      TiXmlNode* child = pElement->FirstChild();
//.........这里部分代码省略.........
开发者ID:Gemini88,项目名称:xbmc-1,代码行数:101,代码来源:LastFmManager.cpp


示例14: LoadDefaults

bool CSettings::Open(CString strPath, bool bCreate, bool bSave, bool bClient)
{
	// Flag we are not allowed to save the file by default
	m_bSave = false;

	// Load the default settings
	LoadDefaults(bClient);

	// Does the settings file not exist?
	bool bExists = true;

	if(!SharedUtility::Exists(strPath.Get()))
	{
		if(!bCreate)
		{
			CLogFile::Printf("ERROR: Settings file %s does not exist.", strPath.Get());
			return false;
		}
		else
		{
			CLogFile::Printf("WARNING: Settings file %s does not exist, it will now be created.", strPath.Get());

			// Attempt to open the file for write
			FILE * fFile = fopen(strPath.Get(), "w");

			// Ensure the file was opened
			if(!fFile)
			{
				CLogFile::Printf("WARNING: Failed to create settings file %s, no settings will be loaded or saved.", strPath.Get());

				// Flag the settings file as does not exist
				bExists = false;
			}
			else
			{
				// Write the default contents to the file
				fprintf(fFile, "<settings />");

				// Close the file
				fclose(fFile);
			}
		}
	}

	// Load the settings file
	if(bExists)
	{
		// Attempt to load the XML file
		if(m_XMLDocument.LoadFile(strPath.Get()))
		{
			// Flag ourselves as open
			m_bOpen = true;

			// Loop through all XML nodes
			for(TiXmlNode * pNode = m_XMLDocument.RootElement()->FirstChildElement(); pNode; pNode = pNode->NextSibling())
			{
				// Is this not an element node?
				if(pNode->Type() != TiXmlNode::ELEMENT)
					continue;

				// Get the setting and value
				CString strSetting = pNode->Value();
				CString strValue = pNode->ToElement()->GetText();

				// Does the setting not exist?
				if(!Exists(strSetting))
					CLogFile::Printf("WARNING: Log file setting %s does not exist.", strSetting.Get());
				else
					SetEx(strSetting, strValue);
			}

			// Flag if we are allowed to save the file
			m_bSave = bSave;

			// Save the XML file
			Save();
		}
		else
		{
			if(bCreate)
			{
				CLogFile::Printf("ERROR: Failed to open settings file %s.", strPath.Get());
				return false;
			}
			else
				CLogFile::Printf("WARNING: Failed to open settings file %s, no settings will be loaded or saved.", strPath.Get());
		}
	}

	return true;
}
开发者ID:Rukenshia,项目名称:IV-Network,代码行数:91,代码来源:CSettings.cpp


示例15: atoi

bool ParserMessageXML::_Parser(TiXmlDocument& xmlTiny)
{
    TiXmlElement* msg = xmlTiny.RootElement();
    std::string sRootName = msg->Value();
    if (sRootName != MsgDataObject_XML_Root)
    {
        return false;
    }
    TiXmlNode* msgNode = xmlTiny.FirstChild(MsgDataObject_XML_Root);
    if (msgNode == NULL)
    {
        return false;
    }
    for (msg = msgNode->FirstChildElement();
        msg != NULL;
        msg = msg->NextSiblingElement())
    {
        if (strcmp(msg->Value(),MsgDataObject_XML_Msg) == 0)
        {
            const char* pName = msg->Attribute(MsgDataObject_XML_Name);
            const ch 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TiXmlNodeA类代码示例发布时间:2022-05-31
下一篇:
C++ TiXmlHandle类代码示例发布时间: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