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

C++ TiXmlString类代码示例

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

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



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

示例1: strlen

TiXmlString operator + (const char* a, const TiXmlString & b)
{
	TiXmlString tmp;
	TiXmlString::size_type a_len = static_cast<TiXmlString::size_type>( strlen(a) );
	tmp.reserve(a_len + b.length());
	tmp.append(a, a_len);
	tmp += b;
	return tmp;
}
开发者ID:dalinhuang,项目名称:concourse,代码行数:9,代码来源:tinystr.cpp


示例2: reserve

void TiXmlString::reserve (size_type cap)
{
	if (cap > capacity())
	{
		TiXmlString tmp;
		tmp.init(length(), cap);
		std::memcpy(tmp.start(), data(), length());
		swap(tmp);
	}
}
开发者ID:HBPVIS,项目名称:Vista,代码行数:10,代码来源:tinystr.cpp


示例3: sizeof

	// TiXmlString copy constructor
	TiXmlString::TiXmlString (const TiXmlString& copy)
	{
		unsigned newlen;
		WCHAR * newstring;

		// Prevent copy to self!
		if ( &copy == this )
			return;

		if (! copy.allocated)
		{
			allocated = 0;
			cstring = NULL;
			current_length = 0;
			return;
		}
		newlen = copy.length () + 1;
		newstring = new WCHAR [newlen];

		// strcpy (newstring, copy.cstring);
		CopyMemory(newstring, copy.cstring, sizeof(WCHAR)*newlen);

		allocated = newlen;
		cstring = newstring;
		current_length = newlen - 1;
	}
开发者ID:JJMoon,项目名称:CGSF,代码行数:27,代码来源:tinystr.cpp


示例4: capacity

TiXmlString& TiXmlString::assign(const char* str, size_type len)
{
	size_type cap = capacity();
	if (len > cap || cap > 3*(len + 8))
	{
		TiXmlString tmp;
		tmp.init(len);
		std::memcpy(tmp.start(), str, len);
		swap(tmp);
	}
	else
	{
		std::memmove(start(), str, len);
		set_size(len);
	}
	return *this;
}
开发者ID:HBPVIS,项目名称:Vista,代码行数:17,代码来源:tinystr.cpp


示例5: partitionId

void XCFParser::parsePartition(TiXmlElement* partition){
    TiXmlString partitionId (partition->Attribute(XCFMapping::PARTITION_ID));
    TiXmlNode* node = partition->FirstChild();

    while (node != NULL){
        if (node->Type() == TiXmlNode::TINYXML_ELEMENT) {
            TiXmlElement* element = (TiXmlElement*)node;
            TiXmlString name(node->Value());
            if (name == XCFMapping::INSTANCE) {
                TiXmlString instanceId (element->Attribute(XCFMapping::INSTANCE_ID));
                mapStr->insert(pair<string,string>(instanceId.c_str(), partitionId.c_str()));
            }else {
                cerr << "Invalid node "<< name.c_str() << endl;
                exit(1);
            }
        }

        node = node->NextSibling();
    }
}
开发者ID:orcc,项目名称:jade,代码行数:20,代码来源:XCFParser.cpp


示例6: Auth

bool IHomeSession:: Auth(Request *req,int sock)
{

    TiXmlString user;
    TiXmlString pass;
    char passwd[33];
    if(!TinyXPath::o_xpath_string(root,"/REQUEST/USER/text()",user) || !TinyXPath::o_xpath_string(root,"/REQUEST/PASS/text()",pass))
    {
        SendResponse(req,ERR_USER_PASS,sock);
             return false;
    }
   const char *ptr = config.GetKeyValue("password");
   int len = strlen(ptr);
   MD5Encode((void *)ptr,len,passwd);
   if(strcmp(user.c_str(),config.GetKeyValue("username")) == 0 && strcmp(pass.c_str(),passwd) == 0)
    {

            authOK = true;
            SendResponse(req,RESPONSE_OK,sock);
            log.Log("SES",DEBUG,"User %s login success %d",user.c_str(),sock);
            return true;
    //发送一个成功的应答
    }
    //发送一个认证失败
   SendResponse(req,1,sock);
    log.Log("SES",DEBUG,"User %s login failed",user.c_str());
    return true;
}
开发者ID:yohoj,项目名称:ITS,代码行数:28,代码来源:ihomesession.cpp


示例7: if

bool TiXmlString::operator == (const TiXmlString & compare) const
{
	if ( allocated && compare.allocated )
	{
		assert( cstring );
		assert( compare.cstring );
		return ( strcmp( cstring, compare.cstring ) == 0 );
 	}
	else if ( length() == 0 && compare.length() == 0 )
	{
		return true;
	}
	return false;
}
开发者ID:tantaishan,项目名称:MyEcho,代码行数:14,代码来源:tinystr.cpp


示例8: length

	// = operator. Safe when assign own content
	void TiXmlString ::operator = (const TiXmlString & copy)
	{
		unsigned newlen;
		WCHAR * newstring;

		if (! copy . length ())
		{
			empty_it ();
			return;
		}
		newlen = copy . length () + 1;
		newstring = new WCHAR [newlen];
		// strcpy (newstring, copy.c_str ());
		CopyMemory(newstring, copy.c_str (), sizeof(WCHAR)*newlen);
		empty_it ();
		allocated = newlen;
		cstring = newstring;
		current_length = newlen - 1;
	}
开发者ID:JJMoon,项目名称:CGSF,代码行数:20,代码来源:tinystr.cpp


示例9: main


//.........这里部分代码省略.........
		TiXmlElement childText0( "childText0" );
		TiXmlElement childText1( "childText1" );
		TiXmlNode* childNode0 = parent.InsertEndChild( childText0 );
		TiXmlNode* childNode1 = parent.InsertBeforeChild( childNode0, childText1 );

		XmlTest( "Test InsertBeforeChild on empty node.", ( childNode1 == parent.FirstChild() ), true );
	}

	{
		// InsertBeforeChild and InsertAfterChild causes crash.
		TiXmlElement parent( "Parent" );
		TiXmlElement childText0( "childText0" );
		TiXmlElement childText1( "childText1" );
		TiXmlNode* childNode0 = parent.InsertEndChild( childText0 );
		TiXmlNode* childNode1 = parent.InsertAfterChild( childNode0, childText1 );

		XmlTest( "Test InsertAfterChild on empty node. ", ( childNode1 == parent.LastChild() ), true );
	}

	// Reports of missing constructors, irregular string problems.
	{
		// Missing constructor implementation. No test -- just compiles.
		TiXmlText text( "Missing" );

		#ifdef TIXML_USE_STL
			// Missing implementation:
			TiXmlDocument doc;
			string name = "missing";
			doc.LoadFile( name );

			TiXmlText textSTL( name );
		#else
			// verifying some basic string functions:
			TiXmlString a;
			TiXmlString b( "Hello" );
			TiXmlString c( "ooga" );

			c = " World!";
			a = b;
			a += c;
			a = a;

			XmlTest( "Basic TiXmlString test. ", "Hello World!", a.c_str() );
		#endif
 	}

	// Long filenames crashing STL version
	{
		TiXmlDocument doc( "midsummerNightsDreamWithAVeryLongFilenameToConfuseTheStringHandlingRoutines.xml" );
		bool loadOkay = doc.LoadFile();
		loadOkay = true;	// get rid of compiler warning.
		// Won't pass on non-dev systems. Just a "no crash" check.
		//XmlTest( "Long filename. ", true, loadOkay );
	}

	{
		// Entities not being written correctly.
		// From Lynn Allen

		const char* passages =
			"<?xml version=\"1.0\" standalone=\"no\" ?>"
			"<passages count=\"006\" formatversion=\"20020620\">"
				"<psg context=\"Line 5 has &quot;quotation marks&quot; and &apos;apostrophe marks&apos;."
				" It also has &lt;, &gt;, and &amp;, as well as a fake copyright &#xA9;.\"> </psg>"
			"</passages>";
开发者ID:huntriver,项目名称:TankVSBugs-CSE380-,代码行数:66,代码来源:xmltest.cpp


示例10: TiXmlString

	// TiXmlString copy constructor
	TiXmlString ( const TiXmlString & copy) : rep_(0)
	{
		init(copy.length());
		memcpy(start(), copy.data(), length());
	}
开发者ID:CodeAsm,项目名称:open-sauce,代码行数:6,代码来源:tinystr.hpp


示例11: strcmp

inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; }
开发者ID:CodeAsm,项目名称:open-sauce,代码行数:1,代码来源:tinystr.hpp


示例12: main


//.........这里部分代码省略.........
		TiXmlElement childText0( "childText0" );
		TiXmlElement childText1( "childText1" );
		TiXmlNode* childNode0 = parent.InsertEndChild( childText0 );
		TiXmlNode* childNode1 = parent.InsertBeforeChild( childNode0, childText1 );

		XmlTest( "Test InsertBeforeChild on empty node.", ( childNode1 == parent.FirstChild() ), true );
	}

	{
		// InsertBeforeChild and InsertAfterChild causes crash.
		TiXmlElement parent( "Parent" );
		TiXmlElement childText0( "childText0" );
		TiXmlElement childText1( "childText1" );
		TiXmlNode* childNode0 = parent.InsertEndChild( childText0 );
		TiXmlNode* childNode1 = parent.InsertAfterChild( childNode0, childText1 );

		XmlTest( "Test InsertAfterChild on empty node. ", ( childNode1 == parent.LastChild() ), true );
	}

	// Reports of missing constructors, irregular string problems.
	{
		// Missing constructor implementation. No test -- just compiles.
		TiXmlText text( "Missing" );

		#ifdef TIXML_USE_STL
			// Missing implementation:
			TiXmlDocument doc;
			string name = "missing";
			doc.LoadFile( name );

			TiXmlText textSTL( name );
		#else
			// verifing some basic string functions:
			TiXmlString a;
			TiXmlString b( "Hello" );
			TiXmlString c( "ooga" );

			c = " World!";
			a = b;
			a += c;
			a = a;

			XmlTest( "Basic TiXmlString test. ", "Hello World!", a.c_str() );
		#endif
 	}

	// Long filenames crashing STL version
	{
		TiXmlDocument doc( "midsummerNightsDreamWithAVeryLongFilenameToConfuseTheStringHandlingRoutines.xml" );
		bool loadOkay = doc.LoadFile();
		loadOkay = true;	// get rid of compiler warning.
		// Won't pass on non-dev systems. Just a "no crash" check.
		//XmlTest( "Long filename. ", true, loadOkay );
	}

	{
		// Entities not being written correctly.
		// From Lynn Allen

		const char* passages =
			"<?xml version=\"1.0\" standalone=\"no\" ?>"
			"<passages count=\"006\" formatversion=\"20020620\">"
				"<psg context=\"Line 5 has &quot;quotation marks&quot; and &apos;apostrophe marks&apos;."
				" It also has &lt;, &gt;, and &amp;, as well as a fake copyright &#xA9;.\"> </psg>"
			"</passages>";
开发者ID:bsmr-worldforge,项目名称:libwfut,代码行数:66,代码来源:xmltest.cpp


示例13: main


//.........这里部分代码省略.........
		TiXmlElement childText0( "childText0" );
		TiXmlElement childText1( "childText1" );
		TiXmlNode* childNode0 = parent.InsertEndChild( childText0 );
		TiXmlNode* childNode1 = parent.InsertBeforeChild( childNode0, childText1 );

		XmlTest( "Test InsertBeforeChild on empty node.", ( childNode1 == parent.FirstChild() ), true );
	}

	{
		// InsertBeforeChild and InsertAfterChild causes crash.
		TiXmlElement parent( "Parent" );
		TiXmlElement childText0( "childText0" );
		TiXmlElement childText1( "childText1" );
		TiXmlNode* childNode0 = parent.InsertEndChild( childText0 );
		TiXmlNode* childNode1 = parent.InsertAfterChild( childNode0, childText1 );

		XmlTest( "Test InsertAfterChild on empty node. ", ( childNode1 == parent.LastChild() ), true );
	}

	// Reports of missing constructors, irregular string problems.
	{
		// Missing constructor implementation. No test -- just compiles.
		TiXmlText text( "Missing" );

		#ifdef TIXML_USE_STL
			// Missing implementation:
			TiXmlDocument doc;
			string name = "missing";
			doc.LoadFile( name );

			TiXmlText textSTL( name );
		#else
			// verifing some basic string functions:
			TiXmlString a;
			TiXmlString b = "Hello";
			TiXmlString c = "ooga";

			c = " World!";
			a = b;
			a += c;
			a = a;

			XmlTest( "Basic TiXmlString test. ", "Hello World!", a.c_str() );
		#endif
 	}

	// Long filenames crashing STL version
	{
		TiXmlDocument doc( "midsummerNightsDreamWithAVeryLongFilenameToConfuseTheStringHandlingRoutines.xml" );
		doc.LoadFile();
		// Won't pass on non-dev systems. Just a "no crash" check.
		//XmlTest( "Long filename. ", true, loadOkay );
	}

	{
		// Entities not being written correctly.
		// From Lynn Allen

		const char* passages =
			"<?xml version=\"1.0\" standalone=\"no\" ?>"
			"<passages count=\"006\" formatversion=\"20020620\">"
				"<psg context=\"Line 5 has &quot;quotation marks&quot; and &apos;apostrophe marks&apos;."
				" It also has &lt;, &gt;, and &amp;, as well as a fake &#xA9;.\"> </psg>"
			"</passages>";

		TiXmlDocument doc( "passages.xml" );
开发者ID:E-LLP,项目名称:europa,代码行数:67,代码来源:xmltest.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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