本文整理汇总了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;
}
示例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);
}
}
示例3: sizeof
// TiXmlString copy constructor
TiXmlString::TiXmlString (const TiXmlString& copy)
{
unsigned newlen;
WCHAR * newstring;
// Prevent copy to self!
if ( © == 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;
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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 "quotation marks" and 'apostrophe marks'."
" It also has <, >, and &, as well as a fake copyright ©.\"> </psg>"
"</passages>";
示例10: TiXmlString
// TiXmlString copy constructor
TiXmlString ( const TiXmlString & copy) : rep_(0)
{
init(copy.length());
memcpy(start(), copy.data(), length());
}
示例11: strcmp
inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; }
示例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 "quotation marks" and 'apostrophe marks'."
" It also has <, >, and &, as well as a fake copyright ©.\"> </psg>"
"</passages>";
示例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 "quotation marks" and 'apostrophe marks'."
" It also has <, >, and &, as well as a fake ©.\"> </psg>"
"</passages>";
TiXmlDocument doc( "passages.xml" );