MCPcopy Create free account
hub / github.com/MaxBelkov/visualsyslog / XMLUtil

Class XMLUtil

sourcecommon/tinyxml2.h:514–584  ·  view source on GitHub ↗

Utility functionality. */

Source from the content-addressed store, hash-verified

512 Utility functionality.
513*/
514class XMLUtil
515{
516public:
517 // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
518 // correct, but simple, and usually works.
519 static const char* SkipWhiteSpace( const char* p ) {
520 while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<const unsigned char*>(p) ) ) {
521 ++p;
522 }
523 return p;
524 }
525 static char* SkipWhiteSpace( char* p ) {
526 return const_cast<char*>( SkipWhiteSpace( const_cast<const char*>(p) ) );
527 }
528 static bool IsWhiteSpace( char p ) {
529 return !IsUTF8Continuation(p) && isspace( static_cast<unsigned char>(p) );
530 }
531
532 inline static bool IsNameStartChar( unsigned char ch ) {
533 return ( ( ch < 128 ) ? isalpha( ch ) : 1 )
534 || ch == ':'
535 || ch == '_';
536 }
537
538 inline static bool IsNameChar( unsigned char ch ) {
539 return IsNameStartChar( ch )
540 || isdigit( ch )
541 || ch == '.'
542 || ch == '-';
543 }
544
545 inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) {
546 int n = 0;
547 if ( p == q ) {
548 return true;
549 }
550 while( *p && *q && *p == *q && n<nChar ) {
551 ++p;
552 ++q;
553 ++n;
554 }
555 if ( (n == nChar) || ( *p == 0 && *q == 0 ) ) {
556 return true;
557 }
558 return false;
559 }
560
561 inline static bool IsUTF8Continuation( const char p ) {
562 return ( p & 0x80 ) != 0;
563 }
564
565 static const char* ReadBOM( const char* p, bool* hasBOM );
566 // p is the starting location,
567 // the UTF-8 value of the entity will be placed in value, and length filled in.
568 static const char* GetCharacterRef( const char* p, char* value, int* length );
569 static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
570
571 // converts primitive types to strings

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected