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


C++ TiXmlNode::ToText方法代码示例

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


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

示例1: Print

void TiXmlElement::Print( FILE* cfile, int depth ) const
{
	int i;
	assert( cfile );
	for ( i=0; i<depth; i++ ) {
		fprintf( cfile, "    " );
	}

	fprintf( cfile, "<%s", value.c_str() );

	const TiXmlAttribute* attrib;
	for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() )
	{
		fprintf( cfile, " " );
		attrib->Print( cfile, depth );
	}

	// There are 3 different formatting approaches:
	// 1) An element without children is printed as a <foo /> node
	// 2) An element with only a text child is printed as <foo> text </foo>
	// 3) An element with children is printed on multiple lines.
	TiXmlNode* node;
	if ( !firstChild )
	{
		fprintf( cfile, " />" );
	}
	else if ( firstChild == lastChild && firstChild->ToText() )
	{
		fprintf( cfile, ">" );
		firstChild->Print( cfile, depth + 1 );
		fprintf( cfile, "</%s>", value.c_str() );
	}
	else
	{
		fprintf( cfile, ">" );

		for ( node = firstChild; node; node=node->NextSibling() )
		{
			if ( !node->ToText() )
			{
				fprintf( cfile, "\n" );
			}
			node->Print( cfile, depth+1 );
		}
		fprintf( cfile, "\n" );
		for( i=0; i<depth; ++i ) {
			fprintf( cfile, "    " );
		}
		fprintf( cfile, "</%s>", value.c_str() );
	}
}
开发者ID:zhouxs1023,项目名称:Editor,代码行数:51,代码来源:tinyxml.cpp

示例2: GetTextElement

wxString GetTextElement(TiXmlElement* node, const char* name)
{
	wxASSERT(node);

	TiXmlElement* element = node->FirstChildElement(name);
	if (!element)
		return wxString();

	TiXmlNode* textNode = element->FirstChild();
	if (!textNode || !textNode->ToText())
		return wxString();

	return ConvLocal(textNode->Value());
}
开发者ID:Typz,项目名称:FileZilla,代码行数:14,代码来源:xmlfunctions.cpp

示例3: GetTextElement

wxString GetTextElement(TiXmlElement* node)
{
	wxASSERT(node);

	for (TiXmlNode* pChild = node->FirstChild(); pChild; pChild = pChild->NextSibling())
	{
		if (!pChild->ToText())
			continue;

		return ConvLocal(pChild->Value());
	}

	return _T("");
}
开发者ID:bartojak,项目名称:osp-filezilla,代码行数:14,代码来源:xmlfunctions.cpp

示例4: Set_Temp_Online_Project_Name

void CKSXML_Read_Project::Set_Temp_Online_Project_Name(TiXmlNode* pParent)
{
	if ( !pParent ) return;
	
	TiXmlNode* pChild = pParent->FirstChild();
	
	if ( pChild ){
		TiXmlText* pText;
		pText = pChild->ToText();
		
		msTemp_Online_Project_Name =  pText->Value();
	}
	
}
开发者ID:grimtraveller,项目名称:koblo_software,代码行数:14,代码来源:CKSXML_Read_Project.cpp

示例5: mainProcessorIni

void XMLreader::mainProcessorIni( std::vector<TiXmlNode*> pParentVect )
{
    std::map<int, TiXmlNode*> parents;
    for (unsigned iParent=0; iParent<pParentVect.size(); ++iParent) {
        EPC_ASSERT( pParentVect[iParent]->Type()==TiXmlNode::DOCUMENT ||
                          pParentVect[iParent]->Type()==TiXmlNode::ELEMENT );

        TiXmlElement* pParentElement = pParentVect[iParent]->ToElement();
        int id=0;
        if (pParentElement) {
            const char* attribute = pParentElement->Attribute("id");
            if (attribute) {
                std::stringstream attributestr(attribute);
                attributestr >> id;
            }
        }
        parents[id] = pParentVect[iParent];
    }

    std::map<int, TiXmlNode*>::iterator it = parents.begin();
    name = it->second->ValueStr();

    for (; it != parents.end(); ++it) {
        int id = it->first;

        TiXmlNode* pParent = it->second;
        Data& data = data_map[id];
        data.text="";

        typedef std::map<std::string, std::vector<TiXmlNode*> > ChildMap;
        ChildMap childMap;
        TiXmlNode* pChild;
        for ( pChild = pParent->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) 
        {
            int type = pChild->Type();
            if ( type==TiXmlNode::ELEMENT ) {
                std::string name(pChild->Value());
                childMap[name].push_back(pChild);
            }
            else if ( type==TiXmlNode::TEXT ) {
                data.text = pChild->ToText()->ValueStr();
            }
        }
        for (ChildMap::iterator it = childMap.begin(); it != childMap.end(); ++it) {
            std::vector<TiXmlNode*> pChildVect = it->second;
            data.children.push_back( new XMLreader( pChildVect ) );
        }
    }
}
开发者ID:cndesantana,项目名称:epicell,代码行数:49,代码来源:TINYXML_xmlIO.cpp

示例6: parseTileLayer

void LevelParser::parseTileLayer( TiXmlElement* pTileElement, std::vector<Layer*> *pLayers, const std::vector<Tileset> *pTilesets )
{
	TileLayer* pTileLayer = new TileLayer( m_tileSize, *pTilesets );

	// 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("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 numGids = m_width * m_height * sizeof( int );
	std::vector< unsigned > gids( m_width * m_height );
	uncompress( (Bytef*) &gids[0], &numGids, (const Bytef* ) decodedIDs.c_str(), decodedIDs.size() );

	std::vector< int > layerRow( m_width );
	
	for( int j = 0; j < m_height; j++ )
	{
		data.push_back( layerRow );
	}

	for( int rows = 0; rows < m_height; rows++ )
	{
		for( int cols = 0; cols < m_width; cols++ )
		{
			data[rows][cols] = gids[rows * m_width + cols];
		}
	}

	pTileLayer->setTileIDs( data );
	
	pLayers->push_back( pTileLayer );
}
开发者ID:rrodrig6,项目名称:BoardGame,代码行数:49,代码来源:LevelParser.cpp

示例7: GetXmlValue

bool COptions::GetXmlValue(unsigned int nID, wxString &value, TiXmlElement *settings /*=0*/)
{
	if (!settings)
	{
		if (!m_pXmlFile)
			return false;

		settings = m_pXmlFile->GetElement()->FirstChildElement("Settings");
		if (!settings)
		{
			TiXmlNode *node = m_pXmlFile->GetElement()->InsertEndChild(TiXmlElement("Settings"));
			if (!node)
				return false;
			settings = node->ToElement();
			if (!settings)
				return false;
		}
	}

	TiXmlNode *node = 0;
	while ((node = settings->IterateChildren("Setting", node)))
	{
		TiXmlElement *setting = node->ToElement();
		if (!setting)
			continue;

		const char *attribute = setting->Attribute("name");
		if (!attribute)
			continue;
		if (strcmp(attribute, options[nID].name))
			continue;

		TiXmlNode *text = setting->FirstChild();
		if (!text)
		{
			value.clear();
			return true;
		}

		if (!text->ToText())
			return false;

		value = ConvLocal(text->Value());

		return true;
	}

	return false;
}
开发者ID:ErichKrause,项目名称:filezilla,代码行数:49,代码来源:Options.cpp

示例8: Read_Branch_Object

void CKSXML_Read_Project::Read_Branch_Object(TiXmlElement* pElement)
{
	if ( !pElement ) return ;
	
	// branch uuid
	TiXmlAttribute* pAttrib	=	pElement->FirstAttribute();
	if(pAttrib)
		gpApplication->Set_Branch_UUID( pAttrib->Value() );
	
	TiXmlNode* pChild;
	TiXmlText* pText;
	
	for ( pChild = pElement->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) {
		
		if(pChild->Type() == TiXmlNode::ELEMENT){
			
			if (stricmp("name", pChild->Value()) == 0) {
				
				TiXmlNode* pName = pChild->FirstChild();
				if(pName) {
					pText = pName->ToText();
					if(pText)
						gpApplication->Set_Branch_Name(pText->Value());
				}
			}
			
			else if (stricmp("description", pChild->Value()) == 0) {
				
				
				TiXmlNode* pSet_Branch_Description = pChild->FirstChild();
				if(pSet_Branch_Description) {
					pText = pSet_Branch_Description->ToText();
					if(pText)
						gpApplication->Set_Branch_Description(pText->Value());
				}
			}
			
			else if (stricmp("revision", pChild->Value()) == 0){
				
				TiXmlNode* pSet_Branch_Revision = pChild->FirstChild();
				if(pSet_Branch_Revision) {
					std::string sBranch_Revision = pSet_Branch_Revision->Value();
					gpApplication->Branch_Revision(atoi(sBranch_Revision.c_str()));
				}
			}
		}
	}
}
开发者ID:grimtraveller,项目名称:koblo_software,代码行数:48,代码来源:CKSXML_Read_Project.cpp

示例9: toStream

void TiXmlElement::toStream( std::ostream& stream, int depth ) const
{
	int i;
	for ( i=0; i<depth; i++ )
		stream << "    ";

	stream << "<" << value;

	const TiXmlAttribute* attrib;
	for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() )
	{
		stream << " ";
		attrib->toStream( stream, depth );
	}

	// There are 3 different formatting approaches:
	// 1) An element without children is printed as a <foo /> node
	// 2) An element with only a text child is printed as <foo> text </foo>
	// 3) An element with children is printed on multiple lines.
	TiXmlNode* node;
	if ( !firstChild )
	{
		stream << " />";
	}
	else if ( firstChild == lastChild && firstChild->ToText() )
	{
		stream << ">";
		firstChild->toStream( stream, depth + 1 );
		stream << "</" << value << ">";
	}
	else
	{
		stream << ">";

		for ( node = firstChild; node; node=node->NextSibling() )
		{
			if ( !node->ToText() )
			{
				stream << "\n";
			}
			node->toStream( stream, depth+1 );
		}
		stream << "\n";
		for( i=0; i<depth; ++i )
			stream << "    ";
		stream << "</" << value << ">";
	}
}
开发者ID:GreyGhost,项目名称:OpenAnno-Archive,代码行数:48,代码来源:tinyxml.cpp

示例10: addNode

void XMLNode::addNode(TiXmlNode* n){
  if (!n) throw CasadiException("Error in XMLNode::addNode: Node is 0");

  // Save name
  setName(n->Value());
  
  // Save attributes
  int type = n->Type();  
  if(type == TiXmlNode::ELEMENT){
    if(n->ToElement()!=0){
      for(TiXmlAttribute* pAttrib=n->ToElement()->FirstAttribute(); pAttrib; pAttrib=pAttrib->Next()){
          setAttribute(pAttrib->Name(),pAttrib->Value());
      }
    }
  } else if(type == TiXmlNode::DOCUMENT) {
    // do nothing
  } else {
    throw CasadiException("XMLNode::addNode");
  }

  // Count the number of children
  int num_children = 0;
  for( TiXmlNode* child = n->FirstChild(); child != 0; child= child->NextSibling()){
    num_children++;
  }
  children_.reserve(num_children);
  
  // add children
  int ch = 0;
  for ( TiXmlNode* child = n->FirstChild(); child != 0; child= child->NextSibling(), ++ch){ 
      int childtype = child->Type();  

      if(childtype == TiXmlNode::ELEMENT){
        XMLNode newnode;
        newnode.addNode(child);
        children_.push_back(newnode);
        child_indices_[newnode.getName()] = ch;
      } else if(childtype == TiXmlNode::COMMENT){
        comment_ = child->Value();
      } else if(childtype == TiXmlNode::TEXT){
        text_ = child->ToText()->Value();
      } else if (childtype == TiXmlNode::DECLARATION){
        cout << "Warning: Skipped TiXmlNode::DECLARATION" << endl;
      } else {
        throw CasadiException("Error in XMLNode::addNode: Unknown node type");
      }
  }
}
开发者ID:Snkrnryn,项目名称:casadi,代码行数:48,代码来源:xml_node.cpp

示例11: AddTextElementRaw

void AddTextElementRaw(TiXmlElement* node, const char* value)
{
	wxASSERT(node);
	wxASSERT(value && *value);

	for (TiXmlNode* pChild = node->FirstChild(); pChild; pChild = pChild->NextSibling())
	{
		if (!pChild->ToText())
			continue;

		node->RemoveChild(pChild);
		break;
	}

    node->LinkEndChild(new TiXmlText(value));
}
开发者ID:ErichKrause,项目名称:filezilla,代码行数:16,代码来源:xmlfunctions.cpp

示例12: LoadOptionFromElement

void COptions::LoadOptionFromElement(TiXmlElement* pOption, std::map<std::string, unsigned int> const& nameOptionMap, bool allowDefault)
{
	const char* name = pOption->Attribute("name");
	if (!name)
		return;

	auto const iter = nameOptionMap.find(name);
	if (iter != nameOptionMap.end()) {
		if (!allowDefault && options[iter->second].flags == default_only)
			return;
		wxString value;

		TiXmlNode *text = pOption->FirstChild();
		if (text) {
			if (!text->ToText())
				return;

			value = ConvLocal(text->Value());
		}

		if (options[iter->second].flags == default_priority) {
			if (allowDefault) {
				scoped_lock l(m_sync_);
				m_optionsCache[iter->second].from_default = true;
			}
			else {
				scoped_lock l(m_sync_);
				if (m_optionsCache[iter->second].from_default)
					return;
			}
		}

		if (options[iter->second].type == number) {
			long numValue = 0;
			value.ToLong(&numValue);
			numValue = Validate(iter->second, numValue);
			scoped_lock l(m_sync_);
			m_optionsCache[iter->second] = numValue;
		}
		else {
			value = Validate(iter->second, value);
			scoped_lock l(m_sync_);
			m_optionsCache[iter->second] = value;
		}
	}
}
开发者ID:Typz,项目名称:FileZilla,代码行数:46,代码来源:Options.cpp

示例13: GetElementText

dustring duXmlStatic::GetElementText(TiXmlElement *pElement)
{
	dustring strText = _T("");
	TiXmlNode *pChildNode = pElement->FirstChild();
	while (pChildNode)
	{
		if (pChildNode->Type() == TiXmlNode::TEXT)
		{
			TiXmlText *pXmlText = pChildNode->ToText();
			strText += pXmlText->Value();
		}
		
		pChildNode = pChildNode->NextSibling();
	}
	
	return strText;
}
开发者ID:blueantst,项目名称:dulib,代码行数:17,代码来源:duXmlStatic.cpp

示例14: getTree

void BulletMLParserTinyXML::getTree(TiXmlNode* node) {
    if (node->ToComment() != 0) return;
    translateNode(node);

    TiXmlNode* child;
    for (child = node->FirstChild(); child; child = child->NextSibling()) {
        TiXmlText* text;
        if ((text = child->ToText()) != 0) {
            curNode_->setValue(text->Value());
            break;
        }

        getTree(child);
    }

    curNode_ = curNode_->getParent();
}
开发者ID:KT1138,项目名称:p47_cpp,代码行数:17,代码来源:bulletmlparser-tinyxml.cpp

示例15: handle

void SE_UnitHeightHandler::handle(SE_Element* parent, TiXmlElement* xmlElement, unsigned int indent)
{
    SE_TextureCoordAnimation* anim = (SE_TextureCoordAnimation*)parent->getAnimation();
    if(anim == NULL)
        return;
    TiXmlNode* pChild;
    TiXmlNode* currNode = xmlElement;
    for(pChild = currNode->FirstChild() ; pChild != NULL ; pChild = pChild->NextSibling())
    {
        int t = pChild->Type();
        if(t != TiXmlNode::TINYXML_TEXT)
            return;
        TiXmlText* pText = pChild->ToText();
        const char* value = pText->Value();
        int h = atoi(value);
        anim->setUnitHeight(h);
    }
}
开发者ID:26597925,项目名称:3DHome,代码行数:18,代码来源:SE_ElementManager.cpp


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