Formatter which outputs the LLSD as a binary notation format. More...
#include <llsdserialize.h>
Public Member Functions | |
virtual S32 | format (const LLSD &data, std::ostream &ostr, U32 options=LLSDFormatter::OPTIONS_NONE) const |
Call this method to format an LLSD to a stream. | |
LLSDBinaryFormatter () | |
Constructor. | |
Protected Member Functions | |
void | formatString (const std::string &string, std::ostream &ostr) const |
Helper method to serialize strings. | |
virtual | ~LLSDBinaryFormatter () |
Destructor. |
Formatter which outputs the LLSD as a binary notation format.
The binary format is a compact and efficient representation of structured data useful for when transmitting over a small data pipe or when transmission frequency is very high.
The normal boolalpha and real format commands are ignored.
All integers are transmitted in network byte order. The format is:
Undefined: '!'
Boolean: character '1' for true character '0' for false
Integer: 'i' + 4 bytes network byte order
Real: 'r' + 8 bytes IEEE double
UUID: 'u' + 16 byte unsigned integer
String: 's' + 4 byte integer size + string
Date: 'd' + 8 byte IEEE double for seconds since epoch
URI: 'l' + 4 byte integer size + string uri
Binary: 'b' + 4 byte integer size + binary data
Array: '[' + 4 byte integer size + all values + ']'
Map: '{' + 4 byte integer size every(key + value) + '}'
map keys are serialized as 'k' + 4 byte integer size + string
LLSDBinaryFormatter::LLSDBinaryFormatter | ( | ) |
Constructor.
S32 LLSDBinaryFormatter::format | ( | const LLSD & | data, | |
std::ostream & | ostr, | |||
U32 | options = LLSDFormatter::OPTIONS_NONE | |||
) | const [virtual] |
Call this method to format an LLSD to a stream.
data | The data to write. | |
ostr | The destination stream for the data. |
Implements LLSDFormatter.
void LLSDBinaryFormatter::formatString | ( | const std::string & | string, | |
std::ostream & | ostr | |||
) | const [protected] |
Helper method to serialize strings.
This method serializes a network byte order size and the raw string contents.
string | The string to write. | |
ostr | The destination stream for the data. |