Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
tinystr.cc
Go to the documentation of this file.
1/*
2www.sourceforge.net/projects/tinyxml
3
4This software is provided 'as-is', without any express or implied
5warranty. In no event will the authors be held liable for any
6damages arising from the use of this software.
7
8Permission is granted to anyone to use this software for any
9purpose, including commercial applications, and to alter it and
10redistribute it freely, subject to the following restrictions:
11
121. The origin of this software must not be misrepresented; you must
13not claim that you wrote the original software. If you use this
14software in a product, an acknowledgment in the product documentation
15would be appreciated but is not required.
16
172. Altered source versions must be plainly marked as such, and
18must not be misrepresented as being the original software.
19
203. This notice may not be removed or altered from any source
21distribution.
22*/
23
24
25#ifndef TIXML_USE_STL
26
27#include "Xml/tinystr.h" // Altered path
28
29namespace pandora // Added namespace
30{
31
32// Error value for find primitive
34
35
36// Null rep.
37TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } };
38
39
41{
42 if (cap > capacity())
43 {
44 TiXmlString tmp;
45 tmp.init(length(), cap);
46 memcpy(tmp.start(), data(), length());
47 swap(tmp);
48 }
49}
50
51
53{
54 size_type cap = capacity();
55 if (len > cap || cap > 3*(len + 8))
56 {
57 TiXmlString tmp;
58 tmp.init(len);
59 memcpy(tmp.start(), str, len);
60 swap(tmp);
61 }
62 else
63 {
64 memmove(start(), str, len);
65 set_size(len);
66 }
67 return *this;
68}
69
70
72{
73 size_type newsize = length() + len;
74 if (newsize > capacity())
75 {
76 reserve (newsize + capacity());
77 }
78 memmove(finish(), str, len);
79 set_size(newsize);
80 return *this;
81}
82
83
85{
86 TiXmlString tmp;
87 tmp.reserve(a.length() + b.length());
88 tmp += a;
89 tmp += b;
90 return tmp;
91}
92
93TiXmlString operator + (const TiXmlString & a, const char* b)
94{
95 TiXmlString tmp;
96 TiXmlString::size_type b_len = static_cast<TiXmlString::size_type>( strlen(b) );
97 tmp.reserve(a.length() + b_len);
98 tmp += a;
99 tmp.append(b, b_len);
100 return tmp;
101}
102
103TiXmlString operator + (const char* a, const TiXmlString & b)
104{
105 TiXmlString tmp;
106 TiXmlString::size_type a_len = static_cast<TiXmlString::size_type>( strlen(a) );
107 tmp.reserve(a_len + b.length());
108 tmp.append(a, a_len);
109 tmp += b;
110 return tmp;
111}
112
113} // Added namespace pandora
114
115#endif // TIXML_USE_STL
char * start() const
Definition tinystr.h:210
void set_size(size_type sz)
Definition tinystr.h:209
TiXmlString & append(const char *str, size_type len)
Definition tinystr.cc:71
static Rep nullrep_
Definition tinystr.h:252
void reserve(size_type cap)
Definition tinystr.cc:40
char * finish() const
Definition tinystr.h:211
void swap(TiXmlString &other)
Definition tinystr.h:199
static const size_type npos
Definition tinystr.h:64
TiXmlString & assign(const char *str, size_type len)
Definition tinystr.cc:52
size_type capacity() const
Definition tinystr.h:145
const char * data() const
Definition tinystr.h:133
void init(size_type sz)
Definition tinystr.h:208
size_type length() const
Definition tinystr.h:136
CartesianVector operator+(const CartesianVector &lhs, const CartesianVector &rhs)
Cartesian vector addition operator.