Main MRPT website > C++ reference for MRPT 1.9.9
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
XMLParserBase64Tool Struct Reference

Detailed Description

Helper class to include binary data inside XML strings using "Base64 encoding".

The "XMLParserBase64Tool" class allows you to include any binary data (images, sounds,...) into an XML document using "Base64 encoding". This class is completely separated from the rest of the xmlParser library and can be removed without any problem. To include some binary data into an XML file, you must convert the binary data into standard text (using "encode"). To retrieve the original binary data from the b64-encoded text included inside the XML file, use "decode". Alternatively, these functions can also be used to "encrypt/decrypt" some critical data contained inside the XML (it's not a strong encryption at all, but sometimes it can be useful).

Definition at line 1057 of file xmlParser.h.

#include <xmlparser/xmlParser.h>

Public Member Functions

 XMLParserBase64Tool ()
 
 ~XMLParserBase64Tool ()
 
void freeBuffer ()
 Call this function when you have finished using. More...
 
XMLSTR encode (unsigned char *inByteBuf, unsigned int inByteLen, char formatted=0)
 length of the base64 string that encodes a data buffer of size inBufLen bytes. More...
 
unsigned char * decode (XMLCSTR inString, int *outByteLen=nullptr, XMLError *xe=nullptr)
 The "decode" function returns a pointer to a buffer containing the binary data decoded from "inString" The output buffer will be free'd when the XMLParserBase64Tool object is deleted. More...
 

Static Public Member Functions

static int encodeLength (int inBufLen, char formatted=0)
 this object to release memory used by the internal buffer. More...
 
static unsigned int decodeSize (XMLCSTR inString, XMLError *xe=nullptr)
 containing the base64 string containing the binary data encoded from "inByteBuf" More...
 
static unsigned char decode (XMLCSTR inString, unsigned char *outByteBuf, int inMaxByteOutBuflen, XMLError *xe=nullptr)
 containing the binary data decoded from "inString" More...
 

Private Member Functions

void alloc (int newsize)
 

Private Attributes

voidbuf
 
int buflen
 

Constructor & Destructor Documentation

◆ XMLParserBase64Tool()

XMLParserBase64Tool::XMLParserBase64Tool ( )
inline

Definition at line 1060 of file xmlParser.h.

◆ ~XMLParserBase64Tool()

XMLParserBase64Tool::~XMLParserBase64Tool ( )

Definition at line 3666 of file xmlParser.cpp.

References freeBuffer().

Member Function Documentation

◆ alloc()

void XMLParserBase64Tool::alloc ( int  newsize)
private

Definition at line 3867 of file xmlParser.cpp.

References buf, and buflen.

Referenced by decode(), and encode().

◆ decode() [1/2]

unsigned char * XMLParserBase64Tool::decode ( XMLCSTR  inString,
int *  outByteLen = nullptr,
XMLError xe = nullptr 
)

The "decode" function returns a pointer to a buffer containing the binary data decoded from "inString" The output buffer will be free'd when the XMLParserBase64Tool object is deleted.

All output buffer are sharing the same memory space.

Parameters
inStringIf "instring" is malformed, nullptr will be returned returns a pointer to an internal buffer

Definition at line 3882 of file xmlParser.cpp.

References alloc(), buf, decodeSize(), and eXMLErrorNone.

◆ decode() [2/2]

unsigned char XMLParserBase64Tool::decode ( XMLCSTR  inString,
unsigned char *  outByteBuf,
int  inMaxByteOutBuflen,
XMLError xe = nullptr 
)
static

containing the binary data decoded from "inString"

decodes data from "inString" to "outByteBuf". You need to provide the size (in byte) of "outByteBuf" in "inMaxByteOutBuflen". If "outByteBuf" is not large enough or if data is malformed, then "FALSE" will be returned; otherwise "TRUE". deprecated.

Definition at line 3764 of file xmlParser.cpp.

References BASE64DECODE_READ_NEXT_CHAR, buf, eXMLErrorBase64DecodeBufferTooSmall, eXMLErrorBase64DecodeTruncatedData, and eXMLErrorNone.

◆ decodeSize()

unsigned int XMLParserBase64Tool::decodeSize ( XMLCSTR  inString,
XMLError xe = nullptr 
)
static

containing the base64 string containing the binary data encoded from "inByteBuf"

returns the number of bytes which will be decoded from "inString".

Definition at line 3728 of file xmlParser.cpp.

References base64DecodeTable, base64Fillchar, eXMLErrorBase64DataSizeIsNotMultipleOf4, eXMLErrorBase64DecodeIllegalCharacter, and eXMLErrorNone.

Referenced by decode().

◆ encode()

XMLSTR XMLParserBase64Tool::encode ( unsigned char *  inByteBuf,
unsigned int  inByteLen,
char  formatted = 0 
)

length of the base64 string that encodes a data buffer of size inBufLen bytes.

The "base64Encode" function returns a string containing the base64 encoding of "inByteLen" bytes from "inByteBuf". If "formatted" parameter is true, then there will be a carriage-return every 72 chars. The string will be free'd when the XMLParserBase64Tool object is deleted. All returned strings are sharing the same memory space. returns a pointer to an internal buffer

Definition at line 3681 of file xmlParser.cpp.

References _CXML, alloc(), base64EncodeTable, base64Fillchar, buf, encodeLength(), XMLCHAR, and XMLSTR.

◆ encodeLength()

int XMLParserBase64Tool::encodeLength ( int  inBufLen,
char  formatted = 0 
)
static

this object to release memory used by the internal buffer.

Parameters
formattedIf "formatted"=true, some space will be reserved for a carriage-return every 72 chars. return the

Definition at line 3674 of file xmlParser.cpp.

Referenced by encode().

◆ freeBuffer()

void XMLParserBase64Tool::freeBuffer ( )

Call this function when you have finished using.

Definition at line 3667 of file xmlParser.cpp.

References buf, and buflen.

Referenced by ~XMLParserBase64Tool().

Member Data Documentation

◆ buf

void* XMLParserBase64Tool::buf
private

Definition at line 1118 of file xmlParser.h.

Referenced by alloc(), decode(), encode(), and freeBuffer().

◆ buflen

int XMLParserBase64Tool::buflen
private

Definition at line 1119 of file xmlParser.h.

Referenced by alloc(), and freeBuffer().




Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST