XBinder XML Runtime  XBinder Version 3.0.x
Public Member Functions | Protected Member Functions | List of all members
OSXMLEncodeBuffer Class Reference

The OSXMLEncodeBuffer class is derived from the OSXMLEncodeBase class. More...

#include <OSXMLEncodeBuffer.h>

Inheritance diagram for OSXMLEncodeBuffer:
OSXMLEncodeBase OSXMLMessageBuffer

Public Member Functions

EXTXMLMETHOD OSXMLEncodeBuffer ()
 Default constructor.
 
EXTXMLMETHOD OSXMLEncodeBuffer (OSOCTET *pMsgBuf, size_t msgBufLen)
 This constructor allows a static message buffer to be specified to receive the encoded message. More...
 
int addXMLHeader (const OSUTF8CHAR *version=OSUTF8("1.0"), const OSUTF8CHAR *encoding=OSUTF8(OSXMLHDRUTF8), OSBOOL newLine=TRUE)
 This method adds XML header text to the output buffer with the given version number and encoding attributes. More...
 
EXTXMLMETHOD int addXMLText (const OSUTF8CHAR *text)
 This method adds encoded XML text to the encode buffer. More...
 
virtual size_t getMsgLen ()
 This method returns the length of a previously encoded XML message. More...
 
virtual EXTXMLMETHOD int init ()
 This method reinitializes the encode buffer to allow a new message to be encoded. More...
 
virtual OSBOOL isA (Type bufferType)
 This is a virtual method that must be overridden by derived classes to allow identification of the class. More...
 
void nullTerminate ()
 This method adds a null-terminator character ('\0') at the current buffer position.
 
EXTXMLMETHOD void setFragment (OSBOOL value=TRUE)
 This method sets a flag indicating that the data is to be encoded as ax XML fragment instead of as a complete XML document (i.e. More...
 
virtual EXTXMLMETHOD long write (const char *filename)
 This method writes the encoded message to the given file. More...
 
virtual EXTXMLMETHOD long write (FILE *fp)
 This version of the write method writes to a file that is specified by a FILE pointer. More...
 
- Public Member Functions inherited from OSXMLEncodeBase
EXTXMLMETHOD int encodeAttr (const OSUTF8CHAR *name, const OSUTF8CHAR *value)
 This function encodes an attribute in which the name and value are given as null-terminated UTF-8 strings. More...
 
EXTXMLMETHOD int encodeText (const OSUTF8CHAR *value)
 This method encodes XML textual content. More...
 
EXTXMLMETHOD int endDocument ()
 This method ends an XML document by flushing any remaining data to the stream.
 
EXTXMLMETHOD int endElement (const OSUTF8CHAR *elemName, OSXMLNamespace *pNS=0)
 This method encodes an end element tag value (</elemName>). More...
 
EXTXMLMETHOD int startDocument ()
 This method writes information to start an XML document to the encode stream. More...
 
EXTXMLMETHOD int startElement (const OSUTF8CHAR *elemName, OSXMLNamespace *pNS=0, OSRTDList *pNSAttrs=0, OSBOOL terminate=FALSE)
 This method writes information to start an XML element to the encode stream. More...
 
EXTXMLMETHOD int termStartElement ()
 This metod terminates a currently open XML start element by adding either a '>' or '/>' (if empty) terminator. More...
 
- Public Member Functions inherited from OSXMLMessageBuffer
virtual EXTXMLMETHOD void * getAppInfo ()
 The getAppInfo method returns the pointer to application context information.
 
EXTXMLMETHOD int getIndent ()
 This method returns current XML output indent value. More...
 
EXTXMLMETHOD int getIndentChar ()
 This method returns current XML output indent character value (default is space). More...
 
EXTXMLMETHOD OSBOOL getWriteBOM ()
 This function returns whether writing the Unicode BOM is currently enabled or disabled. More...
 
virtual EXTXMLMETHOD void setNamespace (const OSUTF8CHAR *prefix, const OSUTF8CHAR *uri, OSRTDList *pNSAttrs=0)
 This method sets a namespace in the context namespace list. More...
 
virtual EXTXMLMETHOD void setAppInfo (void *pXMLInfo)
 This method sets application specific context information within the common context structure. More...
 
EXTXMLMETHOD void setFormatting (OSBOOL doFormatting)
 This method sets XML output formatting to the given value. More...
 
EXTXMLMETHOD void setIndent (OSUINT8 indent)
 This method sets XML output indent to the given value. More...
 
EXTXMLMETHOD void setIndentChar (char indentChar)
 This method sets XML output indent character to the given value. More...
 
EXTXMLMETHOD void setWriteBOM (OSBOOL write)
 This method sets whether to write the Unicode byte order mark before the XML header. More...
 

Protected Member Functions

 OSXMLEncodeBuffer (OSRTContext *pContext)
 
- Protected Member Functions inherited from OSXMLEncodeBase
EXTXMLMETHOD OSXMLEncodeBase (OSRTContext *pContext=0)
 The protected constructor creates a new context and sets the buffer class type. More...
 
- Protected Member Functions inherited from OSXMLMessageBuffer
EXTXMLMETHOD OSXMLMessageBuffer (Type bufferType, OSRTContext *pContext=0)
 The protected constructor creates a new context and sets the buffer class type. More...
 

Detailed Description

The OSXMLEncodeBuffer class is derived from the OSXMLEncodeBase class.

It contains variables and methods specific to encoding XML messages. It is used to manage the buffer into which a message is to be encoded.

Definition at line 38 of file OSXMLEncodeBuffer.h.

Constructor & Destructor Documentation

◆ OSXMLEncodeBuffer()

EXTXMLMETHOD OSXMLEncodeBuffer::OSXMLEncodeBuffer ( OSOCTET *  pMsgBuf,
size_t  msgBufLen 
)

This constructor allows a static message buffer to be specified to receive the encoded message.

Parameters
pMsgBufA pointer to a fixed size message buffer to receive the encoded message.
msgBufLenSize of the fixed-size message buffer.

Member Function Documentation

◆ addXMLHeader()

int OSXMLEncodeBuffer::addXMLHeader ( const OSUTF8CHAR *  version = OSUTF8("1.0"),
const OSUTF8CHAR *  encoding = OSUTF8(OSXMLHDRUTF8),
OSBOOL  newLine = TRUE 
)

This method adds XML header text to the output buffer with the given version number and encoding attributes.

Parameters
versionXML version (default is 1.0)
encodingCharacter encoding (default is UTF-8)
newLineAdd newline char at end of header
Returns
Zero if success or negative error code.

◆ addXMLText()

EXTXMLMETHOD int OSXMLEncodeBuffer::addXMLText ( const OSUTF8CHAR *  text)

This method adds encoded XML text to the encode buffer.

It is assumed that the user has already processed the text to do character escaping, etc.. The text is copied directly to the buffer as-is.

Parameters
textEncoded XML text to be added to the buffer.
Returns
Zero if success or negative error code.

◆ getMsgLen()

virtual size_t OSXMLEncodeBuffer::getMsgLen ( )
inlinevirtual

This method returns the length of a previously encoded XML message.

Returns
Length of the XML message encapsulated within this buffer object.

Definition at line 90 of file OSXMLEncodeBuffer.h.

◆ init()

virtual EXTXMLMETHOD int OSXMLEncodeBuffer::init ( )
virtual

This method reinitializes the encode buffer to allow a new message to be encoded.

This makes it possible to reuse one message buffer object in a loop to encode multiple messages. After this method is called, any previously encoded message in the buffer will be overwritten on the next encode call.

◆ isA()

virtual OSBOOL OSXMLEncodeBuffer::isA ( Type  bufferType)
inlinevirtual

This is a virtual method that must be overridden by derived classes to allow identification of the class.

The base class variant is abstract. This method matches an enumerated identifier defined in the base class. One identifier is declared for each of the derived classes.

Parameters
bufferTypeEnumerated identifier specifying a derived class. This type is defined as a public access type in the OSRTMessageBufferIF base interface. Possible values include BEREncode, BERDecode, PEREncode, PERDecode, XMLEncode, and XMLDecode.
Returns
Boolean result of the match operation. True if the bufferType argument is XMLEncode. argument.

Definition at line 118 of file OSXMLEncodeBuffer.h.

◆ setFragment()

EXTXMLMETHOD void OSXMLEncodeBuffer::setFragment ( OSBOOL  value = TRUE)

This method sets a flag indicating that the data is to be encoded as ax XML fragment instead of as a complete XML document (i.e.

an XML header will not be added).

◆ write() [1/2]

virtual EXTXMLMETHOD long OSXMLEncodeBuffer::write ( const char *  filename)
virtual

This method writes the encoded message to the given file.

Parameters
filenameThe name of file to which the encoded message will be written.
Returns
Number of octets actually written. This value may be less than the actual message length if an error occurs.

◆ write() [2/2]

virtual EXTXMLMETHOD long OSXMLEncodeBuffer::write ( FILE *  fp)
virtual

This version of the write method writes to a file that is specified by a FILE pointer.

Parameters
fpPointer to FILE structure to which the encoded message will be written.
Returns
Number of octets actually written. This value may be less than the actual message length if an error occurs.

The documentation for this class was generated from the following file: