antioch-0.4.0
List of all members | Static Public Member Functions
tinyxml2::XMLUtil Class Reference

#include <tinyxml2.h>

Static Public Member Functions

static const char * SkipWhiteSpace (const char *p)
 
static char * SkipWhiteSpace (char *p)
 
static bool IsWhiteSpace (char p)
 
static bool StringEqual (const char *p, const char *q, int nChar=INT_MAX)
 
static int IsUTF8Continuation (const char p)
 
static int IsAlphaNum (unsigned char anyByte)
 
static int IsAlpha (unsigned char anyByte)
 
static const char * ReadBOM (const char *p, bool *hasBOM)
 
static const char * GetCharacterRef (const char *p, char *value, int *length)
 
static void ConvertUTF32ToUTF8 (unsigned long input, char *output, int *length)
 
static void ToStr (int v, char *buffer, int bufferSize)
 
static void ToStr (unsigned v, char *buffer, int bufferSize)
 
static void ToStr (bool v, char *buffer, int bufferSize)
 
static void ToStr (float v, char *buffer, int bufferSize)
 
static void ToStr (double v, char *buffer, int bufferSize)
 
static bool ToInt (const char *str, int *value)
 
static bool ToUnsigned (const char *str, unsigned *value)
 
static bool ToBool (const char *str, bool *value)
 
static bool ToFloat (const char *str, float *value)
 
static bool ToDouble (const char *str, double *value)
 

Detailed Description

Definition at line 375 of file tinyxml2.h.

Member Function Documentation

void XMLUtil::ConvertUTF32ToUTF8 ( unsigned long  input,
char *  output,
int *  length 
)
inlinestatic

Definition at line 303 of file tinyxml2_imp.h.

Referenced by GetCharacterRef().

304 {
305  const unsigned long BYTE_MASK = 0xBF;
306  const unsigned long BYTE_MARK = 0x80;
307  const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
308 
309  if (input < 0x80)
310  *length = 1;
311  else if ( input < 0x800 )
312  *length = 2;
313  else if ( input < 0x10000 )
314  *length = 3;
315  else if ( input < 0x200000 )
316  *length = 4;
317  else
318  { *length = 0; return; } // This code won't covert this correctly anyway.
319 
320  output += *length;
321 
322  // Scary scary fall throughs.
323  switch (*length)
324  {
325  case 4:
326  --output;
327  *output = (char)((input | BYTE_MARK) & BYTE_MASK);
328  input >>= 6;
329  case 3:
330  --output;
331  *output = (char)((input | BYTE_MARK) & BYTE_MASK);
332  input >>= 6;
333  case 2:
334  --output;
335  *output = (char)((input | BYTE_MARK) & BYTE_MASK);
336  input >>= 6;
337  case 1:
338  --output;
339  *output = (char)(input | FIRST_BYTE_MARK[*length]);
340  }
341 }
const char * XMLUtil::GetCharacterRef ( const char *  p,
char *  value,
int *  length 
)
inlinestatic

Definition at line 345 of file tinyxml2_imp.h.

References ConvertUTF32ToUTF8().

Referenced by tinyxml2::StrPair::GetStr().

346 {
347  // Presume an entity, and pull it out.
348  *length = 0;
349 
350  if ( *(p+1) == '#' && *(p+2) )
351  {
352  unsigned long ucs = 0;
353  ptrdiff_t delta = 0;
354  unsigned mult = 1;
355 
356  if ( *(p+2) == 'x' )
357  {
358  // Hexadecimal.
359  if ( !*(p+3) ) return 0;
360 
361  const char* q = p+3;
362  q = strchr( q, ';' );
363 
364  if ( !q || !*q ) return 0;
365 
366  delta = q-p;
367  --q;
368 
369  while ( *q != 'x' )
370  {
371  if ( *q >= '0' && *q <= '9' )
372  ucs += mult * (*q - '0');
373  else if ( *q >= 'a' && *q <= 'f' )
374  ucs += mult * (*q - 'a' + 10);
375  else if ( *q >= 'A' && *q <= 'F' )
376  ucs += mult * (*q - 'A' + 10 );
377  else
378  return 0;
379  mult *= 16;
380  --q;
381  }
382  }
383  else
384  {
385  // Decimal.
386  if ( !*(p+2) ) return 0;
387 
388  const char* q = p+2;
389  q = strchr( q, ';' );
390 
391  if ( !q || !*q ) return 0;
392 
393  delta = q-p;
394  --q;
395 
396  while ( *q != '#' )
397  {
398  if ( *q >= '0' && *q <= '9' )
399  ucs += mult * (*q - '0');
400  else
401  return 0;
402  mult *= 10;
403  --q;
404  }
405  }
406  // convert the UCS to UTF-8
407  ConvertUTF32ToUTF8( ucs, value, length );
408  return p + delta + 1;
409  }
410  return p+1;
411 }
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
Definition: tinyxml2_imp.h:303
static int tinyxml2::XMLUtil::IsAlpha ( unsigned char  anyByte)
inlinestatic

Definition at line 399 of file tinyxml2.h.

Referenced by tinyxml2::XMLElement::ParseAttributes().

399 { return ( anyByte < 128 ) ? isalpha( anyByte ) : 1; }
static int tinyxml2::XMLUtil::IsAlphaNum ( unsigned char  anyByte)
inlinestatic

Definition at line 398 of file tinyxml2.h.

Referenced by tinyxml2::StrPair::ParseName().

398 { return ( anyByte < 128 ) ? isalnum( anyByte ) : 1; }
static int tinyxml2::XMLUtil::IsUTF8Continuation ( const char  p)
inlinestatic

Definition at line 397 of file tinyxml2.h.

Referenced by IsWhiteSpace(), and SkipWhiteSpace().

397 { return p & 0x80; }
static bool tinyxml2::XMLUtil::IsWhiteSpace ( char  p)
inlinestatic

Definition at line 382 of file tinyxml2.h.

References IsUTF8Continuation().

Referenced by tinyxml2::StrPair::CollapseWhitespace().

382 { return !IsUTF8Continuation(p) && isspace( static_cast<unsigned char>(p) ); }
static int IsUTF8Continuation(const char p)
Definition: tinyxml2.h:397
const char * XMLUtil::ReadBOM ( const char *  p,
bool *  hasBOM 
)
inlinestatic

Definition at line 286 of file tinyxml2_imp.h.

Referenced by tinyxml2::XMLDocument::LoadFile(), and tinyxml2::XMLDocument::Parse().

287 {
288  *bom = false;
289  const unsigned char* pu = reinterpret_cast<const unsigned char*>(p);
290  // Check for BOM:
291  if ( *(pu+0) == TIXML_UTF_LEAD_0
292  && *(pu+1) == TIXML_UTF_LEAD_1
293  && *(pu+2) == TIXML_UTF_LEAD_2 )
294  {
295  *bom = true;
296  p += 3;
297  }
298  return p;
299 }
static const char* tinyxml2::XMLUtil::SkipWhiteSpace ( const char *  p)
inlinestatic

Definition at line 380 of file tinyxml2.h.

References IsUTF8Continuation().

Referenced by tinyxml2::StrPair::CollapseWhitespace(), tinyxml2::XMLDocument::Identify(), tinyxml2::XMLDocument::LoadFile(), tinyxml2::XMLDocument::Parse(), tinyxml2::XMLElement::ParseAttributes(), tinyxml2::XMLAttribute::ParseDeep(), and tinyxml2::XMLElement::ParseDeep().

380 { while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<const unsigned char*>(p) ) ) { ++p; } return p; }
static int IsUTF8Continuation(const char p)
Definition: tinyxml2.h:397
static char* tinyxml2::XMLUtil::SkipWhiteSpace ( char *  p)
inlinestatic

Definition at line 381 of file tinyxml2.h.

References IsUTF8Continuation().

381 { while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<unsigned char*>(p) ) ) { ++p; } return p; }
static int IsUTF8Continuation(const char p)
Definition: tinyxml2.h:397
static bool tinyxml2::XMLUtil::StringEqual ( const char *  p,
const char *  q,
int  nChar = INT_MAX 
)
inlinestatic
bool XMLUtil::ToBool ( const char *  str,
bool *  value 
)
inlinestatic

Definition at line 466 of file tinyxml2_imp.h.

References StringEqual(), and ToInt().

Referenced by tinyxml2::XMLElement::QueryBoolText(), and tinyxml2::XMLAttribute::QueryBoolValue().

467 {
468  int ival = 0;
469  if ( ToInt( str, &ival )) {
470  *value = (ival==0) ? false : true;
471  return true;
472  }
473  if ( StringEqual( str, "true" ) ) {
474  *value = true;
475  return true;
476  }
477  else if ( StringEqual( str, "false" ) ) {
478  *value = false;
479  return true;
480  }
481  return false;
482 }
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:384
static bool ToInt(const char *str, int *value)
Definition: tinyxml2_imp.h:450
bool XMLUtil::ToDouble ( const char *  str,
double *  value 
)
inlinestatic

Definition at line 495 of file tinyxml2_imp.h.

References TIXML_SSCANF.

Referenced by tinyxml2::XMLElement::QueryDoubleText(), and tinyxml2::XMLAttribute::QueryDoubleValue().

496 {
497  if ( TIXML_SSCANF( str, "%lf", value ) == 1 ) {
498  return true;
499  }
500  return false;
501 }
#define TIXML_SSCANF
Definition: tinyxml2.h:93
bool XMLUtil::ToFloat ( const char *  str,
float *  value 
)
inlinestatic

Definition at line 486 of file tinyxml2_imp.h.

References TIXML_SSCANF.

Referenced by tinyxml2::XMLElement::QueryFloatText(), and tinyxml2::XMLAttribute::QueryFloatValue().

487 {
488  if ( TIXML_SSCANF( str, "%f", value ) == 1 ) {
489  return true;
490  }
491  return false;
492 }
#define TIXML_SSCANF
Definition: tinyxml2.h:93
bool XMLUtil::ToInt ( const char *  str,
int *  value 
)
inlinestatic

Definition at line 450 of file tinyxml2_imp.h.

References TIXML_SSCANF.

Referenced by tinyxml2::XMLElement::QueryIntText(), tinyxml2::XMLAttribute::QueryIntValue(), and ToBool().

451 {
452  if ( TIXML_SSCANF( str, "%d", value ) == 1 )
453  return true;
454  return false;
455 }
#define TIXML_SSCANF
Definition: tinyxml2.h:93
void XMLUtil::ToStr ( int  v,
char *  buffer,
int  bufferSize 
)
inlinestatic

Definition at line 415 of file tinyxml2_imp.h.

References TIXML_SNPRINTF.

Referenced by tinyxml2::XMLPrinter::PushAttribute(), tinyxml2::XMLPrinter::PushText(), and tinyxml2::XMLAttribute::SetAttribute().

416 {
417  TIXML_SNPRINTF( buffer, bufferSize, "%d", v );
418 }
#define TIXML_SNPRINTF
Definition: tinyxml2.h:92
void XMLUtil::ToStr ( unsigned  v,
char *  buffer,
int  bufferSize 
)
inlinestatic

Definition at line 422 of file tinyxml2_imp.h.

References TIXML_SNPRINTF.

423 {
424  TIXML_SNPRINTF( buffer, bufferSize, "%u", v );
425 }
#define TIXML_SNPRINTF
Definition: tinyxml2.h:92
void XMLUtil::ToStr ( bool  v,
char *  buffer,
int  bufferSize 
)
inlinestatic

Definition at line 429 of file tinyxml2_imp.h.

References TIXML_SNPRINTF.

430 {
431  TIXML_SNPRINTF( buffer, bufferSize, "%d", v ? 1 : 0 );
432 }
#define TIXML_SNPRINTF
Definition: tinyxml2.h:92
void XMLUtil::ToStr ( float  v,
char *  buffer,
int  bufferSize 
)
inlinestatic

Definition at line 436 of file tinyxml2_imp.h.

References TIXML_SNPRINTF.

437 {
438  TIXML_SNPRINTF( buffer, bufferSize, "%g", v );
439 }
#define TIXML_SNPRINTF
Definition: tinyxml2.h:92
void XMLUtil::ToStr ( double  v,
char *  buffer,
int  bufferSize 
)
inlinestatic

Definition at line 443 of file tinyxml2_imp.h.

References TIXML_SNPRINTF.

444 {
445  TIXML_SNPRINTF( buffer, bufferSize, "%g", v );
446 }
#define TIXML_SNPRINTF
Definition: tinyxml2.h:92
bool XMLUtil::ToUnsigned ( const char *  str,
unsigned *  value 
)
inlinestatic

Definition at line 458 of file tinyxml2_imp.h.

References TIXML_SSCANF.

Referenced by tinyxml2::XMLElement::QueryUnsignedText(), and tinyxml2::XMLAttribute::QueryUnsignedValue().

459 {
460  if ( TIXML_SSCANF( str, "%u", value ) == 1 )
461  return true;
462  return false;
463 }
#define TIXML_SSCANF
Definition: tinyxml2.h:93

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

Generated on Thu Jul 7 2016 11:09:53 for antioch-0.4.0 by  doxygen 1.8.8