OSXMLEncodeStream Class Reference

The OSXMLEncodeStream class is derived from the OSXMLMessageBuffer base class. More...

#include <OSXMLEncodeStream.h>

Inheritance diagram for OSXMLEncodeStream:
OSXMLMessageBuffer

List of all members.

Public Member Functions

EXTXMLMETHOD OSXMLEncodeStream (OSRTOutputStream &outputStream)
 This version of the OSXMLEncodeStream constructor takes a reference to the OSOutputStream object.
 OSXMLEncodeStream (OSRTOutputStream *pOutputStream, OSBOOL ownStream=TRUE)
 This version of the OSXMLEncodeStream constructor takes a pointer to the OSRTOutputStream object.
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.
EXTXMLMETHOD int encodeText (const OSUTF8CHAR *value)
 This method encodes XML textual content.
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>).
virtual EXTXMLMETHOD int init ()
 This method reinitializes the encode stream to allow a new message to be encoded.
virtual OSBOOL isA (int bufferType)
 This is a virtual method that must be overridden by derived classes to allow identification of the class.
virtual const OSOCTET * getMsgPtr ()
 This is a virtual method that must be overridden by derived classes to allow access to the stored message.
OSRTOutputStream * getStream () const
 This method returns the output stream associated with the object.
EXTXMLMETHOD int startDocument ()
 This method writes information to start an XML document to the encode stream.
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.
EXTXMLMETHOD int termStartElement ()
 This metod terminates a currently open XML start element by adding either a '>' or '/>' (if empty) terminator.

Protected Attributes

OSRTOutputStream * mpStream
 A pointer to an OSRTOutputStream object.
OSBOOL mbOwnStream
 TRUE if the OSXMLEncodeStream object will close and free the stream in the destructor.
OSCTXT * mpCtxt
 Internal pointer to the context structure associated with the stream for making C function calls.

Detailed Description

The OSXMLEncodeStream class is derived from the OSXMLMessageBuffer base class.

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

Definition at line 40 of file OSXMLEncodeStream.h.


Constructor & Destructor Documentation

EXTXMLMETHOD OSXMLEncodeStream::OSXMLEncodeStream ( OSRTOutputStream &  outputStream  ) 

This version of the OSXMLEncodeStream constructor takes a reference to the OSOutputStream object.

The stream is assumed to have been previously initialized.

Parameters:
outputStream reference to the OSOutputStream object
OSXMLEncodeStream::OSXMLEncodeStream ( OSRTOutputStream *  pOutputStream,
OSBOOL  ownStream = TRUE 
)

This version of the OSXMLEncodeStream constructor takes a pointer to the OSRTOutputStream object.

The stream is assumed to have been previously initialized. If ownStream is set to TRUE, then stream will be closed and freed in the destructor.

Parameters:
pOutputStream reference to the OSOutputStream object
ownStream set ownership for the passed stream object.

Member Function Documentation

EXTXMLMETHOD int OSXMLEncodeStream::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.

Parameters:
name Attribute name.
value UTF-8 string value to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTXMLMETHOD int OSXMLEncodeStream::encodeText ( const OSUTF8CHAR *  value  ) 

This method encodes XML textual content.

XML metadata characters such as '<' are escaped. The input value is specified in UTF-8 character format but may be transformed if a different character encoding is enabled.

Parameters:
value UTF-8 string value to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTXMLMETHOD int OSXMLEncodeStream::endElement ( const OSUTF8CHAR *  elemName,
OSXMLNamespace *  pNS = 0 
)

This method encodes an end element tag value (</elemName>).

Parameters:
elemName XML element name.
pNS XML namespace information (prefix and URI).
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
virtual const OSOCTET* OSXMLEncodeStream::getMsgPtr (  )  [inline, virtual]

This is a virtual method that must be overridden by derived classes to allow access to the stored message.

The base class implementation returns a null value.

Returns:
A pointer to the stored message.

Definition at line 154 of file OSXMLEncodeStream.h.

OSRTOutputStream* OSXMLEncodeStream::getStream (  )  const [inline]

This method returns the output stream associated with the object.

Returns:
A pointer to the output stream.

Definition at line 161 of file OSXMLEncodeStream.h.

virtual EXTXMLMETHOD int OSXMLEncodeStream::init (  )  [virtual]

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

This makes it possible to reuse one stream object in a loop to encode multiple messages.

virtual OSBOOL OSXMLEncodeStream::isA ( int  bufferType  )  [inline, virtual]

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:
bufferType Enumerated 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 143 of file OSXMLEncodeStream.h.

EXTXMLMETHOD int OSXMLEncodeStream::startDocument (  ) 

This method writes information to start an XML document to the encode stream.

This includes the XML header declaration.

EXTXMLMETHOD int OSXMLEncodeStream::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.

It can leave the element open so that attributes can be added.

Parameters:
elemName XML element name.
pNS XML namespace information (prefix and URI). If the prefix is NULL, this method will search the context's namespace stack for a prefix to use.
pNSAttrs List of namespace attributes to be added to element.
terminate Add closing '>' character.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTXMLMETHOD int OSXMLEncodeStream::termStartElement (  ) 

This metod terminates a currently open XML start element by adding either a '>' or '/>' (if empty) terminator.

It will also add XSI attributes to the element. Note that is important to use this method to terminate the element rather than writng a closing angle bracket text to the stream directly due to the way state is maintained in the context.

Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.

Member Data Documentation

OSBOOL OSXMLEncodeStream::mbOwnStream [protected]

TRUE if the OSXMLEncodeStream object will close and free the stream in the destructor.

Definition at line 47 of file OSXMLEncodeStream.h.

OSCTXT* OSXMLEncodeStream::mpCtxt [protected]

Internal pointer to the context structure associated with the stream for making C function calls.

Definition at line 51 of file OSXMLEncodeStream.h.

OSRTOutputStream* OSXMLEncodeStream::mpStream [protected]

A pointer to an OSRTOutputStream object.

Definition at line 43 of file OSXMLEncodeStream.h.


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