Pooka SDK API Reference
SGMLUtil Class Reference

#include <SGMLUtil.h>

Detailed Description

A utility class provides some functions for SGML (Standard Generalized Markup Language)

In the current version of SGMLUtil, only few basic functions are provided to do SGML entity conversion.

Remarks
Refer https://en.wikipedia.org/wiki/Standard_Generalized_Markup_Language for more details about SGML.
Refer https://en.wikipedia.org/wiki/SGML_entity for more details about SGML entity.
Refer https://en.wikipedia.org/wiki/Numeric_character_reference for more details about SGML NCR.

Static Public Member Functions

static wchar_t decodeSGMLEntity (wchar_t *sgmlEntity, int length=-1)
 
static wchar_t * decodeString (wchar_t *srcBuffer, int length=-1, bool withTolerance=false)
 
static int getEncodedStringLength (const wchar_t *srcBuffer)
 
static wchar_t * encodeString (wchar_t *destBuffer, const wchar_t *srcBuffer)
 

Static Public Attributes

static const int MIN_ENTITY_LENGTH = 2
 
static const int MAX_ENTITY_LENGTH = 31
 

Member Function Documentation

§ decodeSGMLEntity()

static wchar_t decodeSGMLEntity ( wchar_t *  sgmlEntity,
int  length = -1 
)
static

Decode a SGL entity and return the decoded character.

Note if the given string does not contain SGML entity, the original string will be returned; if the given string contains a SGML entity in invalid format, '\x0' (ASCII code 0) will be returned.

Parameters
sgmlEntityA wide-char C string contains a SGML entity
lengthThe length that marks the portion of the give C string to be decoded. The default value means decoding will be performed for the whole C string.
Returns
The character decoded from SGML entity.

§ decodeString()

static wchar_t* decodeString ( wchar_t *  srcBuffer,
int  length = -1,
bool  withTolerance = false 
)
static

Decode SGML entities in a given C string, generate a new C string and return it by pointer.

Caution Caller needs to destroy the returned C string.

Parameters
srcBufferA wide-char C string may contains characters need to be encoded in SGML entity
lengthThe length that marks the portion of the give C string need to be decoded. The default value means decoding will be performed for the whole C string.
withToleranceTrue means to do the decoding with a bit tolerance on the entity syntax. For example, the ending token ';' at the end of entity can be missing for NCR (Numeric character reference) entities.
False means the entity syntax must be completely correct.
Returns
A newly generated wide-char C string contains the decoded string, caller needs to destroy the returned C string.

§ getEncodedStringLength()

static int getEncodedStringLength ( const wchar_t *  srcBuffer)
static

Gets the length of a given C string after certain characters it contains have been encoded into SGML entities .

Parameters
srcBufferA wide-char C string may contains characters need to be encoded in SGML entity.
Returns
The encoded string length.

§ encodeString()

static wchar_t* encodeString ( wchar_t *  destBuffer,
const wchar_t *  srcBuffer 
)
static

Encode a C string so that certain characters it contains are encoded into SGML entities .

Parameters
destBufferA wide-char C string used to receive the encoded string.
This C string must have enough capacity to receive the encoded string. To get the encoded string length, use function getEncodedStringLength().
srcBufferA wide-char C string may contains characters need to be encoded in SGML entity.
Returns
The encoded C string, a pointer to the passed-in argument destBuffer.

Member Data Documentation

§ MIN_ENTITY_LENGTH

const int MIN_ENTITY_LENGTH = 2
static

The minimum length of SGML entity, measured by characters.

§ MAX_ENTITY_LENGTH

const int MAX_ENTITY_LENGTH = 31
static

The maximum length of SGML entity, measured by characters.