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

C++ XMLText类代码示例

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

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



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

示例1: example_3

int example_3()
{
	static const char* xml =
		"<?xml version=\"1.0\"?>"
		"<!DOCTYPE PLAY SYSTEM \"play.dtd\">"
		"<PLAY>"
		"<TITLE>A Midsummer Night's Dream</TITLE>"
		"</PLAY>";

	XMLDocument doc;
	doc.Parse( xml );

	XMLElement* titleElement = doc.FirstChildElement( "PLAY" )->FirstChildElement( "TITLE" );
	const char* title = titleElement->GetText();
	printf( "Name of play (1): %s\n", title );

	XMLText* textNode = titleElement->FirstChild()->ToText();
	title = textNode->Value();
	printf( "Name of play (2): %s\n", title );

	return doc.ErrorID();
}
开发者ID:Fissuras,项目名称:videoventure,代码行数:22,代码来源:xmltest.cpp


示例2: LoadFloatArrays

void COLLADAImporter::LoadFloatArrays(XMLElement *geometryNode, boost::unordered_map<std::string, std::vector<float> >& map)
{	 
	std::vector<XMLElement *> geometries = XMLHelper::GetChildElements(geometryNode,"geometry");
	std::vector<XMLElement *> meshes;
	for(std::vector<XMLElement *>::const_iterator it = geometries.begin(); it != geometries.end(); it++) {
		XMLElement *mesh;
		if((mesh = XMLHelper::GetChildElement(*it,"mesh")) != NULL) {
			meshes.push_back(mesh);
		}
	}

	std::string id;
	for(std::vector<XMLElement *>::const_iterator mit = meshes.begin(); mit != meshes.end(); mit++){
		std::vector<XMLElement *> sources = XMLHelper::GetChildElements(*mit,"source");		
		for(std::vector<XMLElement *>::const_iterator it = sources.begin(); it != sources.end(); it++) {
			XMLElement *float_array = XMLHelper::GetChildElement(*it,"float_array");
			if(float_array != NULL) {
				if(XMLHelper::GetElementAttribute(float_array,"id",id)) {
					XMLText *innerText = float_array->FirstChild()->ToText();
					std::string farray(innerText->Value());
					std::vector<float> fvalues;
					//fvalues = StringHelper::ConvertStringToFloatArray(farray);
					fvalues = StringHelper::ConvertStringToTArray<float>(farray);
				
					int arraycount;
					if(!StringHelper::from_string<int>(arraycount,float_array->Attribute("count"))) {
						continue;					
					}

					while(fvalues.size() < arraycount) {
						fvalues.push_back(0.0f);
					}

					map[id] = fvalues;
				}
			}
		}
	}
}
开发者ID:ehsan1384,项目名称:Vrep,代码行数:39,代码来源:COLLADAImporter.cpp


示例3: main

int main() {
    XMLDocument doc;
	//bii://examples/tinyxml2/dream.xml
    doc.LoadFile( "examples/tinyxml2/dream.xml" );

    // Structure of the XML file:
    // - Element "PLAY"      the root Element, which is the 
    //                       FirstChildElement of the Document
    // - - Element "TITLE"   child of the root PLAY Element
    // - - - Text            child of the TITLE Element

    // Navigate to the title, using the convenience function,
    // with a dangerous lack of error checking.
    const char* title = doc.FirstChildElement( "PLAY" )->FirstChildElement( "TITLE" )->GetText();
    printf( "Name of play (1): %s\n", title );

    // Text is just another Node to TinyXML-2. The more
    // general way to get to the XMLText:
    XMLText* textNode = doc.FirstChildElement( "PLAY" )->FirstChildElement( "TITLE" )->FirstChild()->ToText();
    title = textNode->Value();
    printf( "Name of play (2): %s\n", title );
}
开发者ID:JeffAbrahamson,项目名称:docs,代码行数:22,代码来源:tinyxml2.cpp


示例4: Visit

bool TextVisitor::Visit(const XMLText& text)
{
	std::string t = " ";
	t = text.Value();	

	// break text strings into 57 character lengths to fit on the screen.
	for (unsigned int i = 0; i < t.length(); i += 57)
	{
		bookText.push_back(t.substr(i, 57));
	}
	
	return true;
}
开发者ID:pdapanda,项目名称:3DS_eBook_Reader,代码行数:13,代码来源:TextVisitor.cpp


示例5: defined

	char* XMLDocument::Identify( char* p, XMLNode** node )
	{
		XMLNode* returnNode = 0;
		char* start = p;
		p = XMLUtil::SkipWhiteSpace( p );
		if( !p || !*p ) {
			return p;
		}

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

		static const char* xmlHeader		= { "<?" };
		static const char* commentHeader	= { "<!--" };
		static const char* dtdHeader		= { "<!" };
		static const char* cdataHeader		= { "<![CDATA[" };
		static const char* elementHeader	= { "<" };	// and a header for everything else; check last.

		static const int xmlHeaderLen		= 2;
		static const int commentHeaderLen	= 4;
		static const int dtdHeaderLen		= 2;
		static const int cdataHeaderLen		= 9;
		static const int elementHeaderLen	= 1;

#if defined(_MSC_VER)
#pragma warning ( push )
#pragma warning ( disable : 4127 )
#endif
		TIXMLASSERT( sizeof( XMLComment ) == sizeof( XMLUnknown ) );		// use same memory pool
		TIXMLASSERT( sizeof( XMLComment ) == sizeof( XMLDeclaration ) );	// use same memory pool
#if defined(_MSC_VER)
#pragma warning (pop)
#endif
		if ( XMLUtil::StringEqual( p, xmlHeader, xmlHeaderLen ) ) {
			returnNode = new (_commentPool.Alloc()) XMLDeclaration( this );
			returnNode->_memPool = &_commentPool;
			p += xmlHeaderLen;
		}
		else if ( XMLUtil::StringEqual( p, commentHeader, commentHeaderLen ) ) {
			returnNode = new (_commentPool.Alloc()) XMLComment( this );
			returnNode->_memPool = &_commentPool;
			p += commentHeaderLen;
		}
		else if ( XMLUtil::StringEqual( p, cdataHeader, cdataHeaderLen ) ) {
			XMLText* text = new (_textPool.Alloc()) XMLText( this );
			returnNode = text;
			returnNode->_memPool = &_textPool;
			p += cdataHeaderLen;
			text->SetCData( true );
		}
		else if ( XMLUtil::StringEqual( p, dtdHeader, dtdHeaderLen ) ) {
			returnNode = new (_commentPool.Alloc()) XMLUnknown( this );
			returnNode->_memPool = &_commentPool;
			p += dtdHeaderLen;
		}
		else if ( XMLUtil::StringEqual( p, elementHeader, elementHeaderLen ) ) {
			returnNode = new (_elementPool.Alloc()) XMLElement( this );
			returnNode->_memPool = &_elementPool;
			p += elementHeaderLen;
		}
		else {
			returnNode = new (_textPool.Alloc()) XMLText( this );
			returnNode->_memPool = &_textPool;
			p = start;	// Back it up, all the text counts.
		}

		*node = returnNode;
		return p;
	}
开发者ID:dominik-uebele,项目名称:E1,代码行数:73,代码来源:tinyxml2.cpp


示例6: Visit

	bool XMLPrinter::Visit( const XMLText& text )
	{
		PushText( text.Value(), text.CData() );
		return true;
	}
开发者ID:dominik-uebele,项目名称:E1,代码行数:5,代码来源:tinyxml2.cpp


示例7: main


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

		const char* cStr = ele->Attribute( "str" );
		ele->QueryIntAttribute( "int", &iVal );
		ele->QueryDoubleAttribute( "double", &dVal );

		ele->QueryAttribute( "int", &iVal2 );
		ele->QueryAttribute( "double", &dVal2 );

		XMLTest( "Attribute match test", ele->Attribute( "str", "strValue" ), "strValue" );
		XMLTest( "Attribute round trip. c-string.", "strValue", cStr );
		XMLTest( "Attribute round trip. int.", 1, iVal );
		XMLTest( "Attribute round trip. double.", -1, (int)dVal );
		XMLTest( "Alternate query", true, iVal == iVal2 );
		XMLTest( "Alternate query", true, dVal == dVal2 );
	}

	{
		XMLDocument doc;
		doc.LoadFile( "resources/utf8test.xml" );

		// Get the attribute "value" from the "Russian" element and check it.
		XMLElement* element = doc.FirstChildElement( "document" )->FirstChildElement( "Russian" );
		const unsigned char correctValue[] = {	0xd1U, 0x86U, 0xd0U, 0xb5U, 0xd0U, 0xbdU, 0xd0U, 0xbdU,
												0xd0U, 0xbeU, 0xd1U, 0x81U, 0xd1U, 0x82U, 0xd1U, 0x8cU, 0 };

		XMLTest( "UTF-8: Russian value.", (const char*)correctValue, element->Attribute( "value" ) );

		const unsigned char russianElementName[] = {	0xd0U, 0xa0U, 0xd1U, 0x83U,
														0xd1U, 0x81U, 0xd1U, 0x81U,
														0xd0U, 0xbaU, 0xd0U, 0xb8U,
														0xd0U, 0xb9U, 0 };
		const char russianText[] = "<\xD0\xB8\xD0\xBC\xD0\xB5\xD0\xB5\xD1\x82>";

		XMLText* text = doc.FirstChildElement( "document" )->FirstChildElement( (const char*) russianElementName )->FirstChild()->ToText();
		XMLTest( "UTF-8: Browsing russian element name.",
				 russianText,
				 text->Value() );

		// Now try for a round trip.
		doc.SaveFile( "resources/out/utf8testout.xml" );

		// Check the round trip.
		int okay = 0;

		FILE* saved  = fopen( "resources/out/utf8testout.xml", "r" );
		FILE* verify = fopen( "resources/utf8testverify.xml", "r" );

		if ( saved && verify )
		{
			okay = 1;
			char verifyBuf[256];
			while ( fgets( verifyBuf, 256, verify ) )
			{
				char savedBuf[256];
				fgets( savedBuf, 256, saved );
				NullLineEndings( verifyBuf );
				NullLineEndings( savedBuf );

				if ( strcmp( verifyBuf, savedBuf ) )
				{
					printf( "verify:%s<\n", verifyBuf );
					printf( "saved :%s<\n", savedBuf );
					okay = 0;
					break;
				}
			}
开发者ID:AlejandorLazaro,项目名称:tinyxml2,代码行数:67,代码来源:xmltest.cpp


示例8: main

int main( int /*argc*/, const char ** /*argv*/ )
{
	#if defined( _MSC_VER ) && defined( DEBUG )
		_CrtMemCheckpoint( &startMemState );
	#endif	

	#if defined(_MSC_VER)
	#pragma warning ( push )
	#pragma warning ( disable : 4996 )		// Fail to see a compelling reason why this should be deprecated.
	#endif

	FILE* fp = fopen( "dream.xml", "r" );
	if ( !fp ) {
		printf( "Error opening test file 'dream.xml'.\n"
				"Is your working directory the same as where \n"
				"the xmltest.cpp and dream.xml file are?\n\n"
	#if defined( _MSC_VER )
				"In windows Visual Studio you may need to set\n"
				"Properties->Debugging->Working Directory to '..'\n"
	#endif
			  );
		exit( 1 );
	}
	fclose( fp );

	#if defined(_MSC_VER)
	#pragma warning ( pop )
	#endif

	/* ------ Example 1: Load and parse an XML file. ---- */	
	{
		XMLDocument doc;
		doc.LoadFile( "dream.xml" );
	}
	
	/* ------ Example 2: Lookup information. ---- */	
	{
		XMLDocument doc;
		doc.LoadFile( "dream.xml" );

		// Structure of the XML file:
		// - Element "PLAY"			the root Element
		// - - Element "TITLE"		child of the root PLAY Element
		// - - - Text				child of the TITLE Element
		
		// Navigate to the title, using the convenience function, with a dangerous lack of error checking.
		const char* title = doc.FirstChildElement( "PLAY" )->FirstChildElement( "TITLE" )->GetText();
		printf( "Name of play (1): %s\n", title );
		
		// Text is just another Node to TinyXML-2. The more general way to get to the XMLText:
		XMLText* textNode = doc.FirstChildElement( "PLAY" )->FirstChildElement( "TITLE" )->FirstChild()->ToText();
		title = textNode->Value();
		printf( "Name of play (2): %s\n", title );
	}

	{
		static const char* test[] = {	"<element />",
									    "<element></element>",
										"<element><subelement/></element>",
									    "<element><subelement></subelement></element>",
									    "<element><subelement><subsub/></subelement></element>",
									    "<!--comment beside elements--><element><subelement></subelement></element>",
									    "<!--comment beside elements, this time with spaces-->  \n <element>  <subelement> \n </subelement> </element>",
									    "<element attrib1='foo' attrib2=\"bar\" ></element>",
									    "<element attrib1='foo' attrib2=\"bar\" ><subelement attrib3='yeehaa' /></element>",
										"<element>Text inside element.</element>",
										"<element><b></b></element>",
										"<element>Text inside and <b>bolded</b> in the element.</element>",
										"<outer><element>Text inside and <b>bolded</b> in the element.</element></outer>",
										"<element>This &amp; That.</element>",
										"<element attrib='This&lt;That' />",
										0
		};
		for( int i=0; test[i]; ++i ) {
			XMLDocument doc;
			doc.Parse( test[i] );
			doc.Print();
			printf( "----------------------------------------------\n" );
		}
	}
#if 1
	{
		static const char* test = "<!--hello world\n"
			                      "          line 2\r"
			                      "          line 3\r\n"
			                      "          line 4\n\r"
			                      "          line 5\r-->";

		XMLDocument doc;
		doc.Parse( test );
		doc.Print();
	}

	{
		static const char* test = "<element>Text before.</element>";
		XMLDocument doc;
		doc.Parse( test );
		XMLElement* root = doc.FirstChildElement();
		XMLElement* newElement = doc.NewElement( "Subelement" );
		root->InsertEndChild( newElement );
//.........这里部分代码省略.........
开发者ID:qaisjp,项目名称:green-candy,代码行数:101,代码来源:xmltest.cpp


示例9: parse

        bool parse(const char *buffer) {

            // TODO: Restructure parse code so all checks occur in beginning
            // before any values are changed

            // TODO: catch lexical_cast exception

            doc.Parse( buffer );
            XMLHandle docHandle( &doc );

            XMLText *nodeval = docHandle.FirstChildElement( "ExternalData" )
                        .FirstChildElement( "TString" )
                        .FirstChild()   // this is a text, not an element
                        .ToText();

            if( nodeval ) {
                if ( nodeval->Value() ) {
                    estr = nodeval->Value();
                }
                else {  // something wrong with xml
                    malformedXMLError("TString Value");
                    return false;
                }
            }
            else {  // something wrong with xml
                malformedXMLError("TString");
                return false;
            }

            nodeval = docHandle.FirstChildElement( "ExternalData" )
                        .FirstChildElement( "Position" )
                        .FirstChildElement("XPos")   // this is a text, not an element
                        .FirstChild()
                        .ToText();

            if( nodeval ) {
                if ( nodeval->Value() ) {
                    xPos = boost::lexical_cast<double>(nodeval->Value());
                }
                else {  // something wrong with xml
                    malformedXMLError("XPos Value");
                    return false;
                }
            }
            else {  // something wrong with xml
                malformedXMLError("XPos");
                return false;
            }

            nodeval = docHandle.FirstChildElement( "ExternalData" )
                        .FirstChildElement( "Position" )
                        .FirstChildElement("YPos")   // this is a text, not an element
                        .FirstChild()
                        .ToText();

            if( nodeval ) {
                if ( nodeval->Value() ) {
                    yPos = boost::lexical_cast<double>(nodeval->Value());
                }
                else {  // something wrong with xml
                    malformedXMLError("YPos Value");
                    return false;
                }
            }
            else {  // something wrong with xml
                malformedXMLError("YPos");
                return false;
            }

            nodeval = docHandle.FirstChildElement( "ExternalData" )
                        .FirstChildElement( "Position" )
                        .FirstChildElement("ZPos")   // this is a text, not an element
                        .FirstChild()
                        .ToText();

            if( nodeval ) {
                if ( nodeval->Value() ) {
                    zPos = boost::lexical_cast<double>(nodeval->Value());
                }
                else {  // something wrong with xml
                    malformedXMLError("ZPos Value");
                    return false;
                }
            }
            else {  // something wrong with xml
                malformedXMLError("ZPos");
                return false;
            }

            nodeval = docHandle.FirstChildElement( "ExternalData" )
                        .FirstChildElement( "Temperature" )
                        .FirstChildElement("Cpu")   // this is a text, not an element
                        .FirstChild()
                        .ToText();

            if( nodeval ) {
                if ( nodeval->Value() ) {
                    cpu = boost::lexical_cast<double>(nodeval->Value());
                }
                else {  // something wrong with xml
//.........这里部分代码省略.........
开发者ID:mateuszherczka,项目名称:mhkxml,代码行数:101,代码来源:KukaParseXMLExample.hpp


示例10: v


//.........这里部分代码省略.........
				return false;
			temp = temp.substr(1);
			if(temp != verticesid)		// verify source is the same as vertices id loaded above in current mesh
				return false;
			if(!XMLHelper::GetElementAttribute(verticesInput,"offset",temp))		// get vertices offset in <p> element
				return false;
			if(!StringHelper::from_string(vertices_offset,temp))
				return false;

			std::string normalid;
			int normal_offset;						
			bool hasNormals;

			// get normals <input>
			XMLElement* normalInput = XMLHelper::GetChildElement(triangles,"input","semantic","NORMAL");
			if(!XMLHelper::GetElementAttribute(normalInput,"source",normalid))
				hasNormals = false;
			else {
				normalid = normalid.substr(1);
				hasNormals = true;
			}
											
			if(hasNormals && !XMLHelper::GetElementAttribute(normalInput,"offset",temp))	// get offset for normals in <p> element
				return false;
			else {
				if(!StringHelper::from_string<int>(normal_offset,temp))
					return false;
			}

			XMLElement *pelement = XMLHelper::GetChildElement(triangles,"p");
			if(pelement == NULL)
				return false;

			XMLText *innerText = pelement->FirstChild()->ToText();
			if(innerText == NULL)
				return false;
			std::string tarray(innerText->Value());
			std::vector<int> IndexArray = StringHelper::ConvertStringToTArray<int>(tarray);
							
			int indexcount = IndexArray.size();
			if((indexcount % (3*tricount)) != 0)
				return false;
			int indexstride = indexcount/(3*tricount);																				

			TriangleGroup trigroup;
			trigroup.setMaterialSymbol(materialsymbol);

			// TODO: add check for positionid & normalid			

			if(hasNormals) {
				Source& vertices = sources[normalid];
				ucount = vertices.getUnitCount();
				if(ucount < 3)
					return false;
				int vcount = vertices.getArrayValues().size() / ucount;
				for(int i=0;i<vcount;i++) {
					int idx = ucount*i;
					vec3 v(vertices.getArrayValues()[idx],vertices.getArrayValues()[idx+1],vertices.getArrayValues()[idx+2]);
					trigroup.getNormals().push_back(v);
				}
			}

			for(int i=0;i<tricount*3;i++) {
				int vpos = i*indexstride + vertices_offset;
				trigroup.getTriangleIndices().push_back(IndexArray[vpos]);
				if(hasNormals) {
开发者ID:ehsan1384,项目名称:Vrep,代码行数:67,代码来源:COLLADAImporter.cpp


示例11: vec3

bool COLLADAImporter::LoadMaterial(XMLElement* colladaRootNode,const std::string& id)
{
	if(m_Materials.find(id) != m_Materials.end())			// material already loaded
		return true;

	XMLElement *materials = XMLHelper::GetChildElement(colladaRootNode,"library_materials");
	if(materials == NULL)
		return false;
	XMLElement *material = XMLHelper::GetChildElement(materials,"material","id",id);
	if(material == NULL)
		return false;
	XMLElement *effect = XMLHelper::GetChildElement(material,"instance_effect");
	if(effect == NULL)
		return false;
	std::string effectid;
	if(!XMLHelper::GetElementAttribute(effect,"url",effectid))
		return false;
	effectid = effectid.substr(1);		// remove leading "#"

	XMLElement *effects = XMLHelper::GetChildElement(colladaRootNode,"library_effects");
	if(effects == NULL)
		return false;
	effect = XMLHelper::GetChildElement(effects,"id",effectid);
	if(effect == NULL)
		return false;
	XMLElement *profile = XMLHelper::GetChildElement(effect,"profile_COMMON");
	if(profile == NULL)
		return false;
	XMLElement *technique = XMLHelper::GetChildElement(profile,"technique");
	if(technique == NULL)
		return false;

	XMLElement *bp = XMLHelper::GetChildElement(technique,"blinn");
	if(bp == NULL) {
		bp = XMLHelper::GetChildElement(technique,"phong");
		if(bp == NULL) {
			bp = XMLHelper::GetChildElement(technique,"lambert");
			if(bp == NULL)
				return false;
		}
			
	}

	Material mat;
	// ambient
	XMLElement *ambient = XMLHelper::GetChildElement(bp,"ambient");
	if(ambient != NULL) {	
		XMLElement *color = XMLHelper::GetChildElement(ambient,"color");
		if(color != NULL) {
			XMLText *value = color->FirstChild()->ToText();
			if(value != NULL) {		
				std::vector<float> c = StringHelper::ConvertStringToTArray<float>(value->Value());
				if(c.size() >= 3 )			
					mat.m_Ambient = vec3(c[0],c[1],c[2]);
			}
		}
	}

	//diffuse
	XMLElement *diffuse = XMLHelper::GetChildElement(bp,"diffuse");
	if(diffuse != NULL) {		
		XMLElement* color = XMLHelper::GetChildElement(diffuse,"color");
		if(color != NULL) {		
			XMLText* value = color->FirstChild()->ToText();
			if(value != NULL) {				
				std::vector<float> c = StringHelper::ConvertStringToTArray<float>(value->Value());
				if(c.size() >= 3 )					
					mat.m_Diffuse = vec3(c[0],c[1],c[2]);
			}
		}
	}

	//specular
	XMLElement *specular = XMLHelper::GetChildElement(bp,"specular");
	if(specular != NULL) {		
		XMLElement* color = XMLHelper::GetChildElement(specular,"color");
		if(color != NULL) {		
			XMLText* value = color->FirstChild()->ToText();
			if(value != NULL) {
				std::vector<float> c = StringHelper::ConvertStringToTArray<float>(value->Value());
				if(c.size() >= 3 )		
					mat.m_Specular = vec3(c[0],c[1],c[2]);
			}
		}
	}

	//emission
	XMLElement *emission = XMLHelper::GetChildElement(bp,"emission");
	if(emission != NULL) {
		XMLElement* color = XMLHelper::GetChildElement(emission,"color");
		if(color != NULL) {			
			XMLText* value = color->FirstChild()->ToText();
			if(value != NULL) {			
				std::vector<float> c = StringHelper::ConvertStringToTArray<float>(value->Value());
				if(c.size() >= 3 )
					mat.m_Emmission = vec3(c[0],c[1],c[2]);
			}
		}
	}
	m_Materials[id] = mat;
//.........这里部分代码省略.........
开发者ID:ehsan1384,项目名称:Vrep,代码行数:101,代码来源:COLLADAImporter.cpp


示例12: iterate

bool FractalConfiguration::save(string filename)
{
	if(invalidID())
		return true;

	// Check filename and append .xml
	if(!endsWith(filename, ".xml"))
		filename += ".xml";

	// Create document
	XMLDocument doc;

	// Root element
	XMLElement *root = doc.NewElement("fractal");
	root->SetAttribute("id", m_id.c_str());
	doc.InsertEndChild(root);

	// Add properties
	iterate();

	while(true)
	{
		if(!next())
			break;
		
		XMLElement *prop = doc.NewElement("property");
		prop->SetAttribute("name", getName().c_str());

		XMLText *text = doc.NewText("");

		if(isString())
		{
			prop->SetAttribute("type", "string");

			text->SetValue(getString().c_str());
		}
		else if(isInt())
		{
			prop->SetAttribute("type", "int");

			stringstream ss;
			ss << getInt();
			text->SetValue(ss.str().c_str());
		}
		else if(isDouble())
		{
			prop->SetAttribute("type", "double");

			stringstream ss;
			ss << getDouble();
			text->SetValue(ss.str().c_str());
		}
		else if(isBool())
		{
			prop->SetAttribute("type", "bool");

			if(getBool())
				text->SetValue("1");
			else
				text->SetValue("0");
		}

		prop->InsertEndChild(text);
		root->InsertEndChild(prop);
	}

	// Save to file
	if(doc.SaveFile(filename.c_str()) != XML_NO_ERROR)
	{
		m_last_error = doc.GetErrorStr1();
		return true;
	}

	resetDirty();

	return false;
}
开发者ID:svenhertle,项目名称:fractalimages,代码行数:77,代码来源:FractalConfiguration.cpp


示例13: strlen


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

		for (unsigned int normalIndex = 0; normalIndex < normals->GetSize(); ++normalIndex)
		{
			normals->At(normalIndex).z *= -1.0f;
		}

        //read the textures
        OVR::Array<Vector3f> *diffuseUVs = new OVR::Array<Vector3f>();
        OVR::Array<Vector3f> *lightmapUVs = new OVR::Array<Vector3f>();
        int         diffuseTextureIndex = -1;
        int         lightmapTextureIndex = -1;
        XMLElement* pXmlCurMaterial = pXmlModel->FirstChildElement("material");

        while(pXmlCurMaterial != NULL)
        {
            if(pXmlCurMaterial->Attribute("name", "diffuse"))
            {
                pXmlCurMaterial->FirstChildElement("texture")->
					             QueryIntAttribute("index", &diffuseTextureIndex);
                if(diffuseTextureIndex > -1)
                {
                    ParseVectorString(pXmlCurMaterial->FirstChildElement("texture")->
						              FirstChild()->ToText()->Value(), diffuseUVs, true);
                }
            }
            else if(pXmlCurMaterial->Attribute("name", "lightmap"))
            {
                pXmlCurMaterial->FirstChildElement("texture")->
					                               QueryIntAttribute("index", &lightmapTextureIndex);
                if(lightmapTextureIndex > -1)
                {
                    XMLElement* firstChildElement = pXmlCurMaterial->FirstChildElement("texture");
                    XMLNode* firstChild = firstChildElement->FirstChild();
                    XMLText* text = firstChild->ToText();
                    const char* value = text->Value();
                    ParseVectorString(value, lightmapUVs, true);
                }
            }

            pXmlCurMaterial = pXmlCurMaterial->NextSiblingElement("material");
        }

        //set up the shader
        Ptr<ShaderFill> shader = *new ShaderFill(*pRender->CreateShaderSet());
        shader->GetShaders()->SetShader(pRender->LoadBuiltinShader(Shader_Vertex, VShader_MVP));
        if(diffuseTextureIndex > -1)
        {
            shader->SetTexture(0, Textures[diffuseTextureIndex]);
            if(lightmapTextureIndex > -1)
            {
                shader->GetShaders()->SetShader(pRender->LoadBuiltinShader(Shader_Fragment, FShader_MultiTexture));
                shader->SetTexture(1, Textures[lightmapTextureIndex]);
            }
            else
            {
                shader->GetShaders()->SetShader(pRender->LoadBuiltinShader(Shader_Fragment, FShader_Texture));
            }
        }
        else
        {
            shader->GetShaders()->SetShader(pRender->LoadBuiltinShader(Shader_Fragment, FShader_LitGouraud));
        }
        Models[i]->Fill = shader;

        //add all the vertices to the model
        const size_t numVerts = vertices->GetSize();
开发者ID:AugmentedRealityCenter,项目名称:CardSortingV2,代码行数:67,代码来源:Render_XmlSceneLoader.cpp


示例14: TEST

TEST(XMLNodeTest, prependText) {
	XMLElement root("root");
	root.prepend(util::make_unique<XMLText>("first string"));
	EXPECT_EQ(number_of_children(root), 1);
	XMLText *firstChild = root.firstChild()->toText();
	ASSERT_NE(firstChild, nullptr);
	EXPECT_EQ(firstChild->getText(), "first string");
	EXPECT_EQ(firstChild->parent(), &root);
	EXPECT_EQ(firstChild->prev(), nullptr);
	EXPECT_EQ(firstChild->next(), nullptr);

	root.prepend(util::make_unique<XMLText>("second string,"));
	EXPECT_EQ(number_of_children(root), 1);
	firstChild = root.firstChild()->toText();
	ASSERT_NE(firstChild, nullptr);
	EXPECT_EQ(firstChild->getText(), "second string,first string");
	EXPECT_EQ(firstChild->parent(), &root);
	EXPECT_EQ(firstChild->prev(), nullptr);
	EXPECT_EQ(firstChild->next(), nullptr);

	root.prepend(util::make_unique<XMLElement>("separator"));
	root.prepend(util::make_unique<XMLText>("third string,"));
	EXPECT_EQ(number_of_children(root), 3);
	firstChild = root.firstChild()->toText();
	ASSERT_NE(firstChild, nullptr);
	EXPECT_EQ(firstChild->getText(), "third string,");
	EXPECT_EQ(firstChild->parent(), &root);
	EXPECT_EQ(firstChild->prev(), nullptr);
	EXPECT_EQ(firstChild->next()->next(), root.lastChild());
	EXPECT_EQ(root.lastChild()->prev()->prev(), root.firstChild());
}
开发者ID:mgieseki,项目名称:dvisvgm,代码行数:31,代码来源:XMLNodeTest.cpp


示例15: TileLayer

void LevelParser::parseTileLayer(XMLElement* pTileElement, Level *pLevel)
{
	// New TileLayer instance 
	TileLayer* pTileLayer = new TileLayer(m_tileSize, m_width, m_height, TheGame::Instance().getTilesets());

	// local temporary variable
	bool collidable = false;

	// A multidimensional array of int values to hold our final decoded and uncompressed tile data
	std::vector<std::vector<int>> data;

	// xml data node
	XMLElement* pDataNode = nullptr;
	// to store base64 decoded information
	std::string decodedIDs;	

	// We search for the node we need
	for (XMLElement* e = pTileElement->FirstChildElement(); e != NULL; e = e->NextSiblingElement())
	{
		// check if layer has properties
		if (e->Value() == std::string("properties"))
		{
			for (XMLElement* property = e->FirstChildElement(); property != NULL; property = property->NextSiblingElement())
			{
				if (property->Value() == std::string("property"))
				{
					// Check if it is a collision layer
					if (property->Attribute("name") == std::string("collidable"))
					{
						collidable = true;
					}
				}
			}
		}

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

	// Tile information not encoded nor compressed
	if (pDataNode->Attribute("encoding") == nullptr)
	{
		std::vector<int> layerRow(m_width);
		for (int rows = 0; rows < m_height; rows++)
		{
			data.push_back(layerRow);
		}

		XMLElement* tile = pDataNode->FirstChildElement();
		int id;
		for (int rows = 0; rows < m_height; rows++)
		{
			for (int cols = 0; cols < m_width ; cols++)
			{
				tile->QueryAttribute("gid", &data[rows][cols]);
				tile = tile->NextSiblingElement();
			}
		}
	}
	else
	{
		// We get the text (our encoded/compressed data) from the data node and use the base64 decoder to decode it
		for (XMLNode* e = pDataNode->FirstChild(); e != NULL; e = e->NextSibling())
		{
			XMLText* text = e->ToText();
			std::string t = text->Value();
			decodedIDs = base64_decode(t);
		}

		// We use the zlib library to decompress our data once again
		uLongf sizeofids = m_width * m_height * sizeof(int);
		std::vector<unsigned> gids(sizeofids);
		uncompress((Bytef*)&gids[0], &sizeofids, (const Bytef*)decodedIDs.c_str(), decodedIDs.size());

		// gids now contains all of our tile IDs, so we fill our data array with the correct values

		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);
	pTileLayer->setMapWidth(m_width);

	// push into collision array and mark the layer as collidable if necessary
	if (collidable)
	{
//.........这里部分代码省略.........
开发者ID:afrosistema,项目名称:S2PEditor,代码行数:101,代码来源:LevelParser.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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