ReactOS 0.4.15-dev-7924-g5949c20
tinyxml2::StrPair Class Reference

#include <tinyxml2.h>

Collaboration diagram for tinyxml2::StrPair:

Public Types

enum  {
  NEEDS_ENTITY_PROCESSING = 0x01 , NEEDS_NEWLINE_NORMALIZATION = 0x02 , NEEDS_WHITESPACE_COLLAPSING = 0x04 , TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION ,
  TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION , ATTRIBUTE_NAME = 0 , ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION , ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION ,
  COMMENT = NEEDS_NEWLINE_NORMALIZATION
}
 

Public Member Functions

 StrPair ()
 
 ~StrPair ()
 
void Set (char *start, char *end, int flags)
 
const charGetStr ()
 
bool Empty () const
 
void SetInternedStr (const char *str)
 
void SetStr (const char *str, int flags=0)
 
charParseText (char *in, const char *endTag, int strFlags)
 
charParseName (char *in)
 
void TransferTo (StrPair *other)
 

Private Types

enum  { NEEDS_FLUSH = 0x100 , NEEDS_DELETE = 0x200 }
 

Private Member Functions

void Reset ()
 
void CollapseWhitespace ()
 
 StrPair (const StrPair &other)
 
void operator= (StrPair &other)
 

Private Attributes

int _flags
 
char_start
 
char_end
 

Detailed Description

Definition at line 116 of file tinyxml2.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
NEEDS_ENTITY_PROCESSING 
NEEDS_NEWLINE_NORMALIZATION 
NEEDS_WHITESPACE_COLLAPSING 
TEXT_ELEMENT 
TEXT_ELEMENT_LEAVE_ENTITIES 
ATTRIBUTE_NAME 
ATTRIBUTE_VALUE 
ATTRIBUTE_VALUE_LEAVE_ENTITIES 
COMMENT 

Definition at line 119 of file tinyxml2.h.

◆ anonymous enum

anonymous enum
private
Enumerator
NEEDS_FLUSH 
NEEDS_DELETE 

Definition at line 164 of file tinyxml2.h.

164 {
165 NEEDS_FLUSH = 0x100,
166 NEEDS_DELETE = 0x200
167 };

Constructor & Destructor Documentation

◆ StrPair() [1/2]

tinyxml2::StrPair::StrPair ( )
inline

Definition at line 132 of file tinyxml2.h.

132: _flags( 0 ), _start( 0 ), _end( 0 ) {}

◆ ~StrPair()

tinyxml2::StrPair::~StrPair ( )

Definition at line 138 of file tinyxml2.cpp.

139{
140 Reset();
141}

◆ StrPair() [2/2]

tinyxml2::StrPair::StrPair ( const StrPair other)
private

Member Function Documentation

◆ CollapseWhitespace()

void tinyxml2::StrPair::CollapseWhitespace ( )
private

Definition at line 231 of file tinyxml2.cpp.

232{
233 // Adjusting _start would cause undefined behavior on delete[]
234 TIXMLASSERT( ( _flags & NEEDS_DELETE ) == 0 );
235 // Trim leading space.
237
238 if ( *_start ) {
239 char* p = _start; // the read pointer
240 char* q = _start; // the write pointer
241
242 while( *p ) {
243 if ( XMLUtil::IsWhiteSpace( *p )) {
245 if ( *p == 0 ) {
246 break; // don't write to q; this trims the trailing space.
247 }
248 *q = ' ';
249 ++q;
250 }
251 *q = *p;
252 ++q;
253 ++p;
254 }
255 *q = 0;
256 }
257}
static const char * SkipWhiteSpace(const char *p)
Definition: tinyxml2.h:519
static bool IsWhiteSpace(char p)
Definition: tinyxml2.h:533
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLfloat GLfloat p
Definition: glext.h:8902
#define TIXMLASSERT(x)
Definition: tinyxml2.h:88

Referenced by GetStr().

◆ Empty()

bool tinyxml2::StrPair::Empty ( ) const
inline

Definition at line 144 of file tinyxml2.h.

144 {
145 return _start == _end;
146 }

Referenced by tinyxml2::XMLNode::ParseDeep(), and tinyxml2::XMLElement::ParseDeep().

◆ GetStr()

const char * tinyxml2::StrPair::GetStr ( )

Definition at line 260 of file tinyxml2.cpp.

261{
263 TIXMLASSERT( _end );
264 if ( _flags & NEEDS_FLUSH ) {
265 *_end = 0;
267
268 if ( _flags ) {
269 char* p = _start; // the read pointer
270 char* q = _start; // the write pointer
271
272 while( p < _end ) {
273 if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == CR ) {
274 // CR-LF pair becomes LF
275 // CR alone becomes LF
276 // LF-CR becomes LF
277 if ( *(p+1) == LF ) {
278 p += 2;
279 }
280 else {
281 ++p;
282 }
283 *q++ = LF;
284 }
285 else if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == LF ) {
286 if ( *(p+1) == CR ) {
287 p += 2;
288 }
289 else {
290 ++p;
291 }
292 *q++ = LF;
293 }
294 else if ( (_flags & NEEDS_ENTITY_PROCESSING) && *p == '&' ) {
295 // Entities handled by tinyXML2:
296 // - special entities in the entity table [in/out]
297 // - numeric character reference [in]
298 // &#20013; or &#x4e2d;
299
300 if ( *(p+1) == '#' ) {
301 const int buflen = 10;
302 char buf[buflen] = { 0 };
303 int len = 0;
304 char* adjusted = const_cast<char*>( XMLUtil::GetCharacterRef( p, buf, &len ) );
305 if ( adjusted == 0 ) {
306 *q = *p;
307 ++p;
308 ++q;
309 }
310 else {
311 TIXMLASSERT( 0 <= len && len <= buflen );
312 TIXMLASSERT( q + len <= adjusted );
313 p = adjusted;
314 memcpy( q, buf, len );
315 q += len;
316 }
317 }
318 else {
319 bool entityFound = false;
320 for( int i = 0; i < NUM_ENTITIES; ++i ) {
321 const Entity& entity = entities[i];
322 if ( strncmp( p + 1, entity.pattern, entity.length ) == 0
323 && *( p + entity.length + 1 ) == ';' ) {
324 // Found an entity - convert.
325 *q = entity.value;
326 ++q;
327 p += entity.length + 2;
328 entityFound = true;
329 break;
330 }
331 }
332 if ( !entityFound ) {
333 // fixme: treat as error?
334 ++p;
335 ++q;
336 }
337 }
338 }
339 else {
340 *q = *p;
341 ++p;
342 ++q;
343 }
344 }
345 *q = 0;
346 }
347 // The loop below has plenty going on, and this
348 // is a less useful mode. Break it out.
351 }
353 }
355 return _start;
356}
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
void CollapseWhitespace()
Definition: tinyxml2.cpp:231
static const char * GetCharacterRef(const char *p, char *value, int *length)
Definition: tinyxml2.cpp:430
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static const Entity entities[NUM_ENTITIES]
Definition: tinyxml2.cpp:129
static const int NUM_ENTITIES
Definition: tinyxml2.cpp:128
Definition: actctx.c:388
WCHAR * value
Definition: actctx.c:438
#define LF
Definition: telnetd.h:24
#define CR
Definition: telnetd.h:23

Referenced by tinyxml2::XMLAttribute::Name(), tinyxml2::XMLNode::ParseDeep(), tinyxml2::XMLNode::Value(), and tinyxml2::XMLAttribute::Value().

◆ operator=()

void tinyxml2::StrPair::operator= ( StrPair other)
private

◆ ParseName()

char * tinyxml2::StrPair::ParseName ( char in)

Definition at line 211 of file tinyxml2.cpp.

212{
213 if ( !p || !(*p) ) {
214 return 0;
215 }
216 if ( !XMLUtil::IsNameStartChar( *p ) ) {
217 return 0;
218 }
219
220 char* const start = p;
221 ++p;
222 while ( *p && XMLUtil::IsNameChar( *p ) ) {
223 ++p;
224 }
225
226 Set( start, p, 0 );
227 return p;
228}
static bool IsNameChar(unsigned char ch)
Definition: tinyxml2.h:548
static bool IsNameStartChar(unsigned char ch)
Definition: tinyxml2.h:537
GLuint start
Definition: gl.h:1545
static BOOL Set
Definition: pageheap.c:10

Referenced by tinyxml2::XMLAttribute::ParseDeep(), and tinyxml2::XMLElement::ParseDeep().

◆ ParseText()

char * tinyxml2::StrPair::ParseText ( char in,
const char endTag,
int  strFlags 
)

Definition at line 191 of file tinyxml2.cpp.

192{
193 TIXMLASSERT( endTag && *endTag );
194
195 char* start = p;
196 char endChar = *endTag;
197 size_t length = strlen( endTag );
198
199 // Inner loop of text parsing.
200 while ( *p ) {
201 if ( *p == endChar && strncmp( p, endTag, length ) == 0 ) {
202 Set( start, p, strFlags );
203 return p + length;
204 }
205 ++p;
206 }
207 return 0;
208}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLuint GLsizei GLsizei * length
Definition: glext.h:6040

Referenced by tinyxml2::XMLText::ParseDeep(), tinyxml2::XMLComment::ParseDeep(), tinyxml2::XMLDeclaration::ParseDeep(), tinyxml2::XMLUnknown::ParseDeep(), and tinyxml2::XMLAttribute::ParseDeep().

◆ Reset()

void tinyxml2::StrPair::Reset ( )
private

Definition at line 167 of file tinyxml2.cpp.

168{
169 if ( _flags & NEEDS_DELETE ) {
170 delete [] _start;
171 }
172 _flags = 0;
173 _start = 0;
174 _end = 0;
175}

Referenced by Set(), SetInternedStr(), SetStr(), and ~StrPair().

◆ Set()

void tinyxml2::StrPair::Set ( char start,
char end,
int  flags 
)
inline

Definition at line 135 of file tinyxml2.h.

135 {
136 Reset();
137 _start = start;
138 _end = end;
140 }
GLuint GLuint end
Definition: gl.h:1545
GLbitfield flags
Definition: glext.h:7161

◆ SetInternedStr()

void tinyxml2::StrPair::SetInternedStr ( const char str)
inline

Definition at line 148 of file tinyxml2.h.

148 {
149 Reset();
150 _start = const_cast<char*>(str);
151 }
const WCHAR * str

Referenced by tinyxml2::XMLNode::SetValue().

◆ SetStr()

void tinyxml2::StrPair::SetStr ( const char str,
int  flags = 0 
)

Definition at line 178 of file tinyxml2.cpp.

179{
180 TIXMLASSERT( str );
181 Reset();
182 size_t len = strlen( str );
183 TIXMLASSERT( _start == 0 );
184 _start = new char[ len+1 ];
185 memcpy( _start, str, len+1 );
186 _end = _start + len;
188}

Referenced by tinyxml2::XMLAttribute::SetAttribute(), tinyxml2::XMLAttribute::SetName(), and tinyxml2::XMLNode::SetValue().

◆ TransferTo()

void tinyxml2::StrPair::TransferTo ( StrPair other)

Definition at line 144 of file tinyxml2.cpp.

145{
146 if ( this == other ) {
147 return;
148 }
149 // This in effect implements the assignment operator by "moving"
150 // ownership (as in auto_ptr).
151
152 TIXMLASSERT( other->_flags == 0 );
153 TIXMLASSERT( other->_start == 0 );
154 TIXMLASSERT( other->_end == 0 );
155
156 other->Reset();
157
158 other->_flags = _flags;
159 other->_start = _start;
160 other->_end = _end;
161
162 _flags = 0;
163 _start = 0;
164 _end = 0;
165}
int other
Definition: msacm.c:1376

Referenced by tinyxml2::XMLNode::ParseDeep().

Member Data Documentation

◆ _end

char* tinyxml2::StrPair::_end
private

Definition at line 171 of file tinyxml2.h.

Referenced by Empty(), GetStr(), Reset(), Set(), SetStr(), and TransferTo().

◆ _flags

int tinyxml2::StrPair::_flags
private

Definition at line 169 of file tinyxml2.h.

Referenced by CollapseWhitespace(), GetStr(), Reset(), Set(), SetStr(), and TransferTo().

◆ _start

char* tinyxml2::StrPair::_start
private

Definition at line 170 of file tinyxml2.h.

Referenced by CollapseWhitespace(), Empty(), GetStr(), Reset(), Set(), SetInternedStr(), SetStr(), and TransferTo().


The documentation for this class was generated from the following files: