MCPcopy Create free account
hub / github.com/DFHack/dfhack / TiXmlString

Class TiXmlString

depends/tinyxml/tinystr.h:55–252  ·  view source on GitHub ↗

TiXmlString is an emulation of a subset of the std::string template. Its purpose is to allow compiling TinyXML on compilers with no or poor STL support. Only the member functions relevant to the TinyXML project have been implemented. The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase a string and there's no more room, we allocate a buffer twice as

Source from the content-addressed store, hash-verified

53 a string and there's no more room, we allocate a buffer twice as big as we need.
54*/
55class TiXmlString
56{
57 public :
58 // The size type used
59 typedef size_t size_type;
60
61 // Error value for find primitive
62 static const size_type npos; // = -1;
63
64
65 // TiXmlString empty constructor
66 TiXmlString () : rep_(&nullrep_)
67 {
68 }
69
70 // TiXmlString copy constructor
71 TiXmlString ( const TiXmlString & copy) : rep_(0)
72 {
73 init(copy.length());
74 memcpy(start(), copy.data(), length());
75 }
76
77 // TiXmlString constructor, based on a string
78 TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0)
79 {
80 init( static_cast<size_type>( strlen(copy) ));
81 memcpy(start(), copy, length());
82 }
83
84 // TiXmlString constructor, based on a string
85 TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0)
86 {
87 init(len);
88 memcpy(start(), str, len);
89 }
90
91 // TiXmlString destructor
92 ~TiXmlString ()
93 {
94 quit();
95 }
96
97 TiXmlString& operator = (const char * copy)
98 {
99 return assign( copy, (size_type)strlen(copy));
100 }
101
102 TiXmlString& operator = (const TiXmlString & copy)
103 {
104 return assign(copy.start(), copy.length());
105 }
106
107
108 // += operator. Maps to append
109 TiXmlString& operator += (const char * suffix)
110 {
111 return append(suffix, static_cast<size_type>( strlen(suffix) ));
112 }

Callers

nothing calls this directly

Calls 4

appendFunction · 0.85
lengthMethod · 0.80
startMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected