OSJSONEncodeStream Class Reference
The OSJSONEncodeStream class is derived from the OSJSONMessageBuffer base class. More...
#include <OSJSONEncodeStream.h>
Public Member Functions | |
EXTJSONMETHOD | OSJSONEncodeStream (OSRTOutputStream &outputStream) |
This version of the OSJSONEncodeStream constructor takes a reference to the OSOutputStream object. | |
OSJSONEncodeStream (OSRTOutputStream *pOutputStream, OSBOOL ownStream=TRUE) | |
This version of the OSJSONEncodeStream constructor takes a pointer to the OSRTOutputStream object. | |
EXTJSONMETHOD 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. | |
EXTJSONMETHOD int | encodeText (const OSUTF8CHAR *value) |
This method encodes JSON textual content. | |
virtual EXTJSONMETHOD 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. | |
Protected Attributes | |
OSRTOutputStream * | mpStream |
A pointer to an OSRTOutputStream object. | |
OSBOOL | mbOwnStream |
TRUE if the OSJSONEncodeStream 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 OSJSONEncodeStream class is derived from the OSJSONMessageBuffer base class.
It contains variables and methods specific to streaming encoding JSON messages. It is used to manage the stream into which a message is to be encoded.
Definition at line 40 of file OSJSONEncodeStream.h.
Constructor & Destructor Documentation
EXTJSONMETHOD OSJSONEncodeStream::OSJSONEncodeStream | ( | OSRTOutputStream & | outputStream | ) |
This version of the OSJSONEncodeStream constructor takes a reference to the OSOutputStream object.
The stream is assumed to have been previously initialized.
- Parameters:
-
outputStream reference to the OSOutputStream object
OSJSONEncodeStream::OSJSONEncodeStream | ( | OSRTOutputStream * | pOutputStream, | |
OSBOOL | ownStream = TRUE | |||
) |
This version of the OSJSONEncodeStream 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
EXTJSONMETHOD int OSJSONEncodeStream::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.
EXTJSONMETHOD int OSJSONEncodeStream::encodeText | ( | const OSUTF8CHAR * | value | ) |
This method encodes JSON textual content.
JSON metadata characters are escaped. The input value is specified in UTF-8 character format.
- Parameters:
-
value UTF-8 string value to be encoded.
- Returns:
- Completion status of operation:
- 0 = success,
- negative return value is error.
virtual const OSOCTET* OSJSONEncodeStream::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 135 of file OSJSONEncodeStream.h.
OSRTOutputStream* OSJSONEncodeStream::getStream | ( | ) | const [inline] |
This method returns the output stream associated with the object.
- Returns:
- A pointer to the output stream.
Definition at line 142 of file OSJSONEncodeStream.h.
virtual EXTJSONMETHOD int OSJSONEncodeStream::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 OSJSONEncodeStream::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, JSONEncode, and JSONDecode.
- Returns:
- Boolean result of the match operation. True if the
bufferType
argument isJSONEncode
. argument.
Definition at line 124 of file OSJSONEncodeStream.h.
Member Data Documentation
OSBOOL OSJSONEncodeStream::mbOwnStream [protected] |
TRUE if the OSJSONEncodeStream object will close and free the stream in the destructor.
Definition at line 47 of file OSJSONEncodeStream.h.
OSCTXT* OSJSONEncodeStream::mpCtxt [protected] |
Internal pointer to the context structure associated with the stream for making C function calls.
Definition at line 51 of file OSJSONEncodeStream.h.
OSRTOutputStream* OSJSONEncodeStream::mpStream [protected] |
A pointer to an OSRTOutputStream object.
Definition at line 43 of file OSJSONEncodeStream.h.
The documentation for this class was generated from the following file: