LLC2_API
Public Member Functions | Static Public Member Functions

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

#include <xmlParser.h>

List of all members.

Public Member Functions

 XMLParserBase64Tool ()
 ~XMLParserBase64Tool ()
void freeBuffer ()
 Call this function when you have finished using this object to release memory used by the internal buffer.
XMLSTR encode (unsigned char *inByteBuf, unsigned int inByteLen, char formatted=0)
 The "base64Encode" function returns a string containing the base64 encoding of "inByteLen" bytes from "inByteBuf".
unsigned char * decode (XMLCSTR inString, int *outByteLen=NULL, XMLError *xe=NULL)
 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.

Static Public Member Functions

static int encodeLength (int inBufLen, char formatted=0)
static unsigned int decodeSize (XMLCSTR inString, XMLError *xe=NULL)
 returns the number of bytes which will be decoded from "inString".
static unsigned char decode (XMLCSTR inString, unsigned char *outByteBuf, int inMaxByteOutBuflen, XMLError *xe=NULL)
 decodes data from "inString" to "outByteBuf".

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 690 of file xmlParser.h.


Constructor & Destructor Documentation

XMLParserBase64Tool::XMLParserBase64Tool ( ) [inline]

Definition at line 693 of file xmlParser.h.

XMLParserBase64Tool::~XMLParserBase64Tool ( )

Definition at line 2793 of file xmlParser.cpp.

References freeBuffer().


Member Function Documentation

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

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, NULL will be returned returns a pointer to an internal buffer containing the binary data decoded from "inString"

Definition at line 2929 of file xmlParser.cpp.

References decodeSize(), and eXMLErrorNone.

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

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 2862 of file xmlParser.cpp.

References BASE64DECODE_READ_NEXT_CHAR, eXMLErrorBase64DecodeBufferTooSmall, eXMLErrorBase64DecodeTruncatedData, and eXMLErrorNone.

unsigned int XMLParserBase64Tool::decodeSize ( XMLCSTR  inString,
XMLError xe = NULL 
) [static]

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

Definition at line 2839 of file xmlParser.cpp.

References eXMLErrorBase64DataSizeIsNotMultipleOf4, eXMLErrorBase64DecodeIllegalCharacter, and eXMLErrorNone.

Referenced by decode().

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

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 containing the base64 string containing the binary data encoded from "inByteBuf"

Definition at line 2804 of file xmlParser.cpp.

References _CXML, encodeLength(), XMLCHAR, and XMLSTR.

int XMLParserBase64Tool::encodeLength ( int  inBufLen,
char  formatted = 0 
) [static]
Parameters:
formattedIf "formatted"=true, some space will be reserved for a carriage-return every 72 chars. return the length of the base64 string that encodes a data buffer of size inBufLen bytes.

Definition at line 2797 of file xmlParser.cpp.

Referenced by encode().

void XMLParserBase64Tool::freeBuffer ( )

Call this function when you have finished using this object to release memory used by the internal buffer.

Definition at line 2795 of file xmlParser.cpp.

Referenced by ~XMLParserBase64Tool().


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