CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
tinystr.cc
Go to the documentation of this file.
1 /*
2 www.sourceforge.net/projects/tinyxml
3 Original file by Yves Berquin.
4 
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any
7 damages arising from the use of this software.
8 
9 Permission is granted to anyone to use this software for any
10 purpose, including commercial applications, and to alter it and
11 redistribute it freely, subject to the following restrictions:
12 
13 1. The origin of this software must not be misrepresented; you must
14 not claim that you wrote the original software. If you use this
15 software in a product, an acknowledgment in the product documentation
16 would be appreciated but is not required.
17 
18 2. Altered source versions must be plainly marked as such, and
19 must not be misrepresented as being the original software.
20 
21 3. This notice may not be removed or altered from any source
22 distribution.
23 */
24 
25 /*
26  * THIS FILE WAS ALTERED BY Tyge Løvset, 7. April 2005.
27  */
28 /*
29  * THIS FILE WAS ALTERED BY Eric Vaandering, 25 August 2009.
30  */
31 
32 #define TIXML_USE_STL
33 
34 #ifndef TIXML_USE_STL
35 
37 
38 // Error value for find primitive
39 const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1);
40 
41 
42 // Null rep.
43 TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } };
44 
45 
46 void TiXmlString::reserve (size_type cap)
47 {
48  if (cap > capacity())
49  {
50  TiXmlString tmp;
51  tmp.init(length(), cap);
52  memcpy(tmp.start(), data(), length());
53  swap(tmp);
54  }
55 }
56 
57 
58 TiXmlString& TiXmlString::assign(const char* str, size_type len)
59 {
60  size_type cap = capacity();
61  if (len > cap || cap > 3*(len + 8))
62  {
63  TiXmlString tmp;
64  tmp.init(len);
65  memcpy(tmp.start(), str, len);
66  swap(tmp);
67  }
68  else
69  {
70  memmove(start(), str, len);
71  set_size(len);
72  }
73  return *this;
74 }
75 
76 
77 TiXmlString& TiXmlString::append(const char* str, size_type len)
78 {
79  size_type newsize = length() + len;
80  if (newsize > capacity())
81  {
82  reserve (newsize + capacity());
83  }
84  memmove(finish(), str, len);
85  set_size(newsize);
86  return *this;
87 }
88 
89 
90 TiXmlString operator + (const TiXmlString & a, const TiXmlString & b)
91 {
92  TiXmlString tmp;
93  tmp.reserve(a.length() + b.length());
94  tmp += a;
95  tmp += b;
96  return tmp;
97 }
98 
99 TiXmlString operator + (const TiXmlString & a, const char* b)
100 {
101  TiXmlString tmp;
102  TiXmlString::size_type b_len = static_cast<TiXmlString::size_type>( strlen(b) );
103  tmp.reserve(a.length() + b_len);
104  tmp += a;
105  tmp.append(b, b_len);
106  return tmp;
107 }
108 
109 TiXmlString operator + (const char* a, const TiXmlString & b)
110 {
111  TiXmlString tmp;
112  TiXmlString::size_type a_len = static_cast<TiXmlString::size_type>( strlen(a) );
113  tmp.reserve(a_len + b.length());
114  tmp.append(a, a_len);
115  tmp += b;
116  return tmp;
117 }
118 
119 
120 #endif // TIXML_USE_STL
void swap(ora::Record &rh, ora::Record &lh)
Definition: Record.h:70
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
MatrixMeschach operator+(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
#define assign
Definition: vmac.h:53
uint16_t size_type
double b
Definition: hdecay.h:120
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
double a
Definition: hdecay.h:121