MRPT  1.9.9
xmlParser.cpp File Reference
#include "xmlParser.h"
#include <Windows.h>
#include <memory.h>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
Include dependency graph for xmlParser.cpp:

Go to the source code of this file.

Classes

struct  ALLXMLClearTag
 
struct  XMLCharacterEntity
 
struct  XML
 
struct  NextToken
 

Macros

#define _CRT_SECURE_NO_DEPRECATE
 
#define WIN32_LEAN_AND_MEAN
 
#define INDENTCHAR   _CXML('\t')
 
#define XML_isSPACECHAR(ch)
 
#define MEMORYINCREASE   50
 
#define LENSTR(lpsz)   (lpsz ? xstrlen(lpsz) : 0)
 
#define BASE64DECODE_READ_NEXT_CHAR(c)
 

Typedefs

typedef enum XMLTokenTypeTag XMLTokenType
 
typedef struct XML XML
 
using Attrib = enum Attrib { eAttribName=0, eAttribEquals, eAttribValue }
 
using Status = enum Status { eInsideTag=0, eOutsideTag }
 

Enumerations

enum  XMLTokenTypeTag {
  eTokenText = 0, eTokenQuotedText, eTokenTagStart, eTokenTagEnd,
  eTokenCloseTag, eTokenEquals, eTokenDeclaration, eTokenShortHandClose,
  eTokenClear, eTokenError
}
 

Functions

void freeXMLString (XMLSTR t)
 to free the string allocated inside the "stringDup" function or the "createXMLString" function. More...
 
int mmin (const int t1, const int t2)
 
char myIsTextWideChar (const void *b, int l)
 
char * myWideCharToMultiByte (const wchar_t *s)
 
static FILE * xfopen (XMLCSTR filename, XMLCSTR mode)
 
static int xstrlen (XMLCSTR c)
 
static int xstrnicmp (XMLCSTR c1, XMLCSTR c2, int l)
 
static int xstricmp (XMLCSTR c1, XMLCSTR c2)
 
static int xstrncmp (XMLCSTR c1, XMLCSTR c2, int l)
 
static XMLSTR xstrstr (XMLCSTR c1, XMLCSTR c2)
 
static XMLSTR xstrcpy (XMLSTR c1, XMLCSTR c2)
 
char xmltob (XMLCSTR t, char v)
 
int xmltoi (XMLCSTR t, int v)
 
long xmltol (XMLCSTR t, long v)
 
double xmltof (XMLCSTR t, double v)
 
XMLCSTR xmltoa (XMLCSTR t, XMLCSTR v)
 
XMLCHAR xmltoc (XMLCSTR t, XMLCHAR v)
 
XMLSTR stringDup (XMLCSTR lpszData, int cbData)
 Duplicate (copy in a new allocated buffer) the source string. More...
 
XMLSTR fromXMLString (XMLCSTR s, int lo, XML *pXML)
 
char myTagCompare (XMLCSTR cclose, XMLCSTR copen)
 
static XMLCHAR getNextChar (XML *pXML)
 
static NextToken GetNextToken (XML *pXML, int *pcbToken, enum XMLTokenTypeTag *pType)
 
static void myFree (void *p)
 
static voidmyRealloc (void *p, int newsize, int memInc, int sizeofElem)
 
static void CountLinesAndColumns (XMLCSTR lpXML, int nUpto, XMLResults *pResults)
 
static void charmemset (XMLSTR dest, XMLCHAR c, int l)
 

Variables

static XMLNode::XMLCharEncoding characterEncoding = XMLNode::char_encoding_UTF8
 
static char guessWideCharChars = 1
 
static char dropWhiteSpace = 1
 
static char removeCommentsInMiddleOfText = 1
 
static ALLXMLClearTag XMLClearTags []
 
static XMLCharacterEntity XMLEntities []
 
static const char XML_utf8ByteTable [256]
 
static const char XML_legacyByteTable [256]
 
static const char XML_sjisByteTable [256]
 
static const char XML_gb2312ByteTable [256]
 
static const char XML_gbk_big5_ByteTable [256]
 
static const char * XML_ByteTable
 
static const char base64Fillchar
 
XMLCSTR base64EncodeTable
 
const unsigned char base64DecodeTable []
 

Macro Definition Documentation

◆ _CRT_SECURE_NO_DEPRECATE

#define _CRT_SECURE_NO_DEPRECATE

Definition at line 11 of file xmlParser.cpp.

◆ BASE64DECODE_READ_NEXT_CHAR

#define BASE64DECODE_READ_NEXT_CHAR (   c)
Value:
do \
{ \
c = base64DecodeTable[(unsigned char)data[i++]]; \
} while (c == 97); \
if (c == 98) \
{ \
return 0; \
}
const GLubyte * c
Definition: glext.h:6406
const unsigned char base64DecodeTable[]
Definition: xmlParser.cpp:3648
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:3550

Referenced by XMLParserBase64Tool::decode().

◆ INDENTCHAR

#define INDENTCHAR   _CXML('\t')

Definition at line 78 of file xmlParser.cpp.

Referenced by XMLNode::CreateXMLStringR().

◆ LENSTR

#define LENSTR (   lpsz)    (lpsz ? xstrlen(lpsz) : 0)

◆ MEMORYINCREASE

#define MEMORYINCREASE   50

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 16 of file xmlParser.cpp.

◆ XML_isSPACECHAR

#define XML_isSPACECHAR (   ch)
Value:
((ch == _CXML('\n')) || (ch == _CXML(' ')) || (ch == _CXML('\t')) || \
(ch == _CXML('\r')))
#define _CXML(c)
Definition: xmlParser.h:224

Definition at line 1148 of file xmlParser.cpp.

Referenced by GetNextToken(), XMLNode::guessCharEncoding(), XMLNode::maybeAddTxT(), and myTagCompare().

Typedef Documentation

◆ Attrib

using Attrib = enum Attrib { eAttribName = 0, eAttribEquals, eAttribValue }

Definition at line 801 of file xmlParser.cpp.

◆ Status

using Status = enum Status { eInsideTag = 0, eOutsideTag }

Definition at line 805 of file xmlParser.cpp.

◆ XML

typedef struct XML XML

◆ XMLTokenType

Enumeration Type Documentation

◆ XMLTokenTypeTag

Enumerator
eTokenText 
eTokenQuotedText 
eTokenTagStart 
eTokenTagEnd 
eTokenCloseTag 
eTokenEquals 
eTokenDeclaration 
eTokenShortHandClose 
eTokenClear 
eTokenError 

Definition at line 766 of file xmlParser.cpp.

Function Documentation

◆ charmemset()

static void charmemset ( XMLSTR  dest,
XMLCHAR  c,
int  l 
)
inlinestatic

Definition at line 2368 of file xmlParser.cpp.

Referenced by XMLNode::CreateXMLStringR().

Here is the caller graph for this function:

◆ CountLinesAndColumns()

static void CountLinesAndColumns ( XMLCSTR  lpXML,
int  nUpto,
XMLResults pResults 
)
static

Definition at line 2193 of file xmlParser.cpp.

References _CXML, eXMLErrorNone, getNextChar(), XML::lpXML, XMLResults::nColumn, XML::nIndex, XMLResults::nLine, TRUE, and XMLCHAR.

Referenced by XMLNode::parseString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fromXMLString()

XMLSTR fromXMLString ( XMLCSTR  s,
int  lo,
XML pXML 
)

Definition at line 971 of file xmlParser.cpp.

References _CXML, XMLCharacterEntity::c, XML::error, eXMLErrorCharacterCodeAbove255, eXMLErrorUnknownCharacterEntity, XMLCharacterEntity::l, XMLCharacterEntity::s, XML_ByteTable, XMLCHAR, XMLCSTR, XMLEntities, XMLSTR, and xstrnicmp().

Referenced by XMLNode::maybeAddTxT(), and XMLNode::ParseXMLElement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNextChar()

static XMLCHAR getNextChar ( XML pXML)
inlinestatic

Definition at line 1169 of file xmlParser.cpp.

References XML::lpXML, XML::nIndex, XML_ByteTable, and XMLCHAR.

Referenced by CountLinesAndColumns(), and GetNextToken().

Here is the caller graph for this function:

◆ GetNextToken()

static NextToken GetNextToken ( XML pXML,
int *  pcbToken,
enum XMLTokenTypeTag pType 
)
static

Definition at line 1182 of file xmlParser.cpp.

References _CXML, eTokenClear, eTokenCloseTag, eTokenDeclaration, eTokenEquals, eTokenError, eTokenQuotedText, eTokenShortHandClose, eTokenTagEnd, eTokenTagStart, eTokenText, FALSE, getNextChar(), ALLXMLClearTag::lpszOpen, XML::lpXML, XML::nIndex, ALLXMLClearTag::openTagLen, NextToken::pClr, NextToken::pStr, TRUE, XML_isSPACECHAR, XMLCHAR, XMLClearTags, and xstrncmp().

Referenced by XMLNode::ParseXMLElement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mmin()

int mmin ( const int  t1,
const int  t2 
)
inline

Definition at line 37 of file xmlParser.cpp.

Referenced by mrpt::nav::CHolonomicFullEval::evalSingleTarget(), and XMLNode::guessCharEncoding().

Here is the caller graph for this function:

◆ myFree()

static void myFree ( void p)
inlinestatic

Definition at line 1422 of file xmlParser.cpp.

Referenced by XMLNode::addAttribute_priv(), XMLNode::addClear_priv(), XMLNode::addText_priv(), and XMLNode::emptyTheNode().

Here is the caller graph for this function:

◆ myIsTextWideChar()

char myIsTextWideChar ( const void b,
int  l 
)

Definition at line 193 of file xmlParser.cpp.

Referenced by XMLNode::guessCharEncoding(), and XMLNode::parseFile().

Here is the caller graph for this function:

◆ myRealloc()

static void* myRealloc ( void p,
int  newsize,
int  memInc,
int  sizeofElem 
)
inlinestatic

Definition at line 1426 of file xmlParser.cpp.

Referenced by XMLNode::addAttribute_priv(), and XMLNode::addToOrder().

Here is the caller graph for this function:

◆ myTagCompare()

char myTagCompare ( XMLCSTR  cclose,
XMLCSTR  copen 
)

Definition at line 1153 of file xmlParser.cpp.

References _CXML, XML_isSPACECHAR, XMLCHAR, xstrlen(), and xstrnicmp().

Referenced by XMLNode::ParseXMLElement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ myWideCharToMultiByte()

char* myWideCharToMultiByte ( const wchar_t *  s)

Definition at line 243 of file xmlParser.cpp.

References XMLNode::char_encoding_UTF8, and characterEncoding.

Referenced by XMLNode::parseFile().

Here is the caller graph for this function:

◆ xfopen()

static FILE* xfopen ( XMLCSTR  filename,
XMLCSTR  mode 
)
inlinestatic

Definition at line 272 of file xmlParser.cpp.

References mrpt::system::os::fopen().

Referenced by XMLNode::openFileHelper(), XMLNode::parseFile(), and XMLNode::writeToFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xstrcpy()

static XMLSTR xstrcpy ( XMLSTR  c1,
XMLCSTR  c2 
)
inlinestatic

Definition at line 298 of file xmlParser.cpp.

References mrpt::system::os::strcpy(), and XMLSTR.

Referenced by XMLNode::CreateXMLStringR(), and ToXMLStringTool::toXMLUnSafe().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xstricmp()

static int xstricmp ( XMLCSTR  c1,
XMLCSTR  c2 
)
inlinestatic

Definition at line 288 of file xmlParser.cpp.

Referenced by XMLNode::getAttribute(), XMLNode::getChildNode(), XMLNode::getChildNodeWithAttribute(), XMLNode::isAttributeSet(), XMLNode::nChildNode(), and XMLNode::parseString().

Here is the caller graph for this function:

◆ xstrlen()

static int xstrlen ( XMLCSTR  c)
inlinestatic

Definition at line 276 of file xmlParser.cpp.

Referenced by XMLNode::maybeAddTxT(), myTagCompare(), XMLNode::parseClearTag(), and stringDup().

Here is the caller graph for this function:

◆ xstrncmp()

static int xstrncmp ( XMLCSTR  c1,
XMLCSTR  c2,
int  l 
)
inlinestatic

Definition at line 290 of file xmlParser.cpp.

Referenced by GetNextToken().

Here is the caller graph for this function:

◆ xstrnicmp()

static int xstrnicmp ( XMLCSTR  c1,
XMLCSTR  c2,
int  l 
)
inlinestatic

Definition at line 284 of file xmlParser.cpp.

References mrpt::system::os::_strnicmp().

Referenced by fromXMLString(), XMLNode::guessCharEncoding(), and myTagCompare().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xstrstr()

static XMLSTR xstrstr ( XMLCSTR  c1,
XMLCSTR  c2 
)
inlinestatic

Definition at line 294 of file xmlParser.cpp.

References XMLSTR.

Referenced by XMLNode::getChildNodeByPath(), and XMLNode::parseClearTag().

Here is the caller graph for this function:

Variable Documentation

◆ base64DecodeTable

const unsigned char base64DecodeTable[]
Initial value:
= {
99, 98, 98, 98, 98, 98, 98, 98, 98, 97, 97, 98, 98, 97, 98, 98,
98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
98, 98, 97, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 62, 98, 98,
98, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 98, 98,
98, 96, 98, 98, 98, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 98, 98, 98, 98, 98, 98, 26, 27, 28, 29, 30, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98
}

Definition at line 3648 of file xmlParser.cpp.

Referenced by XMLParserBase64Tool::decodeSize().

◆ base64EncodeTable

XMLCSTR base64EncodeTable
Initial value:
=
_CXML("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")
#define _CXML(c)
Definition: xmlParser.h:224

Definition at line 3642 of file xmlParser.cpp.

Referenced by XMLParserBase64Tool::encode().

◆ base64Fillchar

const char base64Fillchar
static
Initial value:
=
_CXML('=')
#define _CXML(c)
Definition: xmlParser.h:224

Definition at line 3638 of file xmlParser.cpp.

Referenced by XMLParserBase64Tool::decodeSize(), and XMLParserBase64Tool::encode().

◆ characterEncoding

◆ dropWhiteSpace

char dropWhiteSpace = 1
static

◆ guessWideCharChars

char guessWideCharChars = 1
static

◆ removeCommentsInMiddleOfText

char removeCommentsInMiddleOfText = 1
static

◆ XML_ByteTable

const char* XML_ByteTable
static
Initial value:
=
(const char*)XML_utf8ByteTable
static const char XML_utf8ByteTable[256]
Definition: xmlParser.cpp:604

Definition at line 756 of file xmlParser.cpp.

Referenced by fromXMLString(), getNextChar(), ToXMLStringTool::lengthXMLString(), XMLNode::parseClearTag(), XMLNode::setGlobalOptions(), and ToXMLStringTool::toXMLUnSafe().

◆ XML_gb2312ByteTable

const char XML_gb2312ByteTable[256]
static

Definition at line 686 of file xmlParser.cpp.

Referenced by XMLNode::setGlobalOptions().

◆ XML_gbk_big5_ByteTable

const char XML_gbk_big5_ByteTable[256]
static

Definition at line 721 of file xmlParser.cpp.

Referenced by XMLNode::setGlobalOptions().

◆ XML_legacyByteTable

const char XML_legacyByteTable[256]
static
Initial value:
= {
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}

Definition at line 639 of file xmlParser.cpp.

Referenced by XMLNode::setGlobalOptions().

◆ XML_sjisByteTable

const char XML_sjisByteTable[256]
static

Definition at line 651 of file xmlParser.cpp.

Referenced by XMLNode::setGlobalOptions().

◆ XML_utf8ByteTable

const char XML_utf8ByteTable[256]
static

Definition at line 604 of file xmlParser.cpp.

Referenced by XMLNode::guessCharEncoding(), and XMLNode::setGlobalOptions().

◆ XMLClearTags

ALLXMLClearTag XMLClearTags[]
static
Initial value:
= {
{_CXML("<![CDATA["), 9, _CXML("]]>")},
{_CXML("<!DOCTYPE"), 9, _CXML(">")},
{_CXML("<!--"), 4, _CXML("-->")},
{_CXML("<PRE>"), 5, _CXML("</PRE>")},
{nullptr, 0, nullptr}}
#define _CXML(c)
Definition: xmlParser.h:224

Definition at line 49 of file xmlParser.cpp.

Referenced by XMLNode::addClear_priv(), GetNextToken(), XMLNode::maybeAddTxT(), and XMLNode::parseClearTag().

◆ XMLEntities

XMLCharacterEntity XMLEntities[]
static
Initial value:
= {
{_CXML("&amp;"), 5, _CXML('&')}, {_CXML("&lt;"), 4, _CXML('<')},
{_CXML("&gt;"), 4, _CXML('>')}, {_CXML("&quot;"), 6, _CXML('\"')},
{_CXML("&apos;"), 6, _CXML('\'')}, {nullptr, 0, '\0'}}
#define _CXML(c)
Definition: xmlParser.h:224

Definition at line 69 of file xmlParser.cpp.

Referenced by fromXMLString(), ToXMLStringTool::lengthXMLString(), and ToXMLStringTool::toXMLUnSafe().




Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019