#include <UT_JSONWriter.h>
Public Member Functions | |
| UT_JSONWriter (const UT_Options *options=0) | |
| virtual | ~UT_JSONWriter () |
| void | setOptions (const UT_Options &options) |
| void | getOptions (UT_Options &options) const |
| bool | setBinary (bool bin) |
| virtual bool | enableGZip () |
| bool | getBinary () const |
| Return whether writing binary or ASCII JSON. | |
| bool | jsonComment (const char *format,...) |
| bool | jsonNull () |
| Write a null to the stream. | |
| bool | jsonBool (bool value) |
| Write true/false. | |
| bool | jsonInt (int32 value) |
| Write an integer value. | |
| bool | jsonInt (int64 value) |
| Write a 64 bit integer value. | |
| bool | jsonReal (fpreal16 value) |
| Write a 16 bit real. | |
| bool | jsonReal (fpreal32 value) |
| Write a 32 bit real. | |
| bool | jsonReal (fpreal64 value) |
| Write a 64 bit real. | |
| bool | jsonString (const char *value, int64 length=0) |
| bool | jsonStringToken (const char *value, int64 length=0) |
| bool | jsonValue (bool value) |
| bool | jsonValue (int8 value) |
| bool | jsonValue (int16 value) |
| bool | jsonValue (int32 value) |
| bool | jsonValue (int64 value) |
| bool | jsonValue (fpreal16 value) |
| bool | jsonValue (fpreal32 value) |
| bool | jsonValue (fpreal64 value) |
| bool | jsonBeginMap () |
| Begin a map/object dictionary. | |
| bool | jsonKey (const char *value, int64 length=0) |
| bool | jsonKeyToken (const char *value, int64 length=0) |
| bool | jsonEndMap () |
| End the object. | |
| bool | jsonBeginArray () |
| Begin a generic array object. | |
| bool | jsonEndArray (bool newline=true) |
| bool | beginUniformArray (int64 length, UT_JID id) |
| bool | uniformWrite (bool value) |
| bool | uniformWrite (int8 value) |
| Write an 8 bit integer value to the uniform array. | |
| bool | uniformWrite (int16 value) |
| Write an 16 bit integer value to the uniform array. | |
| bool | uniformWrite (int32 value) |
| Write an 32 bit integer value to the uniform array. | |
| bool | uniformWrite (int64 value) |
| Write an 64 bit integer value to the uniform array. | |
| bool | uniformWrite (fpreal16 value) |
| Write an 16 bit float/real value to the uniform array. | |
| bool | uniformWrite (fpreal32 value) |
| Write an 32 bit float/real value to the uniform array. | |
| bool | uniformWrite (fpreal64 value) |
| Write an 64 bit float/real value to the uniform array. | |
| bool | uniformWrite (uint8 value) |
| Write an 8 bit unsigned integer value to the uniform array. | |
| bool | uniformWrite (uint16 value) |
| Write an 16 bit unsigned integer value to the uniform array. | |
| bool | uniformWrite (const char *value, int64 length=0) |
| Write a string to the uniform array. | |
| bool | endUniformArray (int64 *nwritten=0) |
| bool | jsonUniformArray (int64 length, const int8 *value) |
| Efficent method of writing a uniform array of int8 values. | |
| bool | jsonUniformArray (int64 length, const int16 *value) |
| Efficent method of writing a uniform array of int16 values. | |
| bool | jsonUniformArray (int64 length, const int32 *value) |
| Efficent method of writing a uniform array of int32 values. | |
| bool | jsonUniformArray (int64 length, const int64 *value) |
| Efficent method of writing a uniform array of int64 values. | |
| bool | jsonUniformArray (int64 length, const fpreal16 *value) |
| Efficent method of writing a uniform array of fpreal16 values. | |
| bool | jsonUniformArray (int64 length, const fpreal32 *value) |
| Efficent method of writing a uniform array of fpreal32 values. | |
| bool | jsonUniformArray (int64 length, const fpreal64 *value) |
| Efficent method of writing a uniform array of fpreal64 values. | |
| bool | jsonUniformArray (int64 length, const uint8 *value) |
| Efficent method of writing a uniform array of uint8 values. | |
| bool | jsonUniformArray (int64 length, const uint16 *value) |
| Efficent method of writing a uniform array of uint16 values. | |
Static Public Member Functions | |
| static UT_JSONWriter * | allocWriter (UT_WorkBuffer &buffer) |
| static UT_JSONWriter * | allocWriter (ostream &os, bool binary, bool gzip=false) |
| static UT_JSONWriter * | allocWriter (const char *filename, bool binary, bool gzip=false) |
Protected Member Functions | |
| virtual bool | writeData (const void *data, int64 bytes)=0 |
| The sub-class must implement this method to write data. | |
| int | getNesting () const |
| Get the nesting level (i.e. how deeply nested in maps/arrays). | |
The JSON format (http://www.json.org) is a generic way to store data. Houdini extends JSON to a byte-stream binary encoding (see UT_JID for details). The UT_JSONWriter class is used to write JSON (binary or ASCII) to a stream.
Definition at line 35 of file UT_JSONWriter.h.
| UT_JSONWriter::UT_JSONWriter | ( | const UT_Options * | options = 0 |
) |
| virtual UT_JSONWriter::~UT_JSONWriter | ( | ) | [virtual] |
| static UT_JSONWriter* UT_JSONWriter::allocWriter | ( | const char * | filename, | |
| bool | binary, | |||
| bool | gzip = false | |||
| ) | [static] |
Allocate a JSON Writer which writes to a named file. Please delete when finished with the writer.
| static UT_JSONWriter* UT_JSONWriter::allocWriter | ( | ostream & | os, | |
| bool | binary, | |||
| bool | gzip = false | |||
| ) | [static] |
Allocate a JSON Writer which writes to an output stream. Please delete when finished with the writer.
| static UT_JSONWriter* UT_JSONWriter::allocWriter | ( | UT_WorkBuffer & | buffer | ) | [static] |
Allocate a JSON Writer which will fill a UT_WorkBuffer. Please delete when finished with the writer.
When writing binary JSON files, uniform arrays can be encoded without repetition of the type information which results in a more compressed data format.
beingUniformArray() starts a uniform array. The id should be one of:
| virtual bool UT_JSONWriter::enableGZip | ( | ) | [virtual] |
Turn on gzip compression (if possible). This must be called before setBinary().
| bool UT_JSONWriter::endUniformArray | ( | int64 * | nwritten = 0 |
) |
End the uniform array.
| nwritten | If provided, the number of items written is returned. |
| bool UT_JSONWriter::getBinary | ( | ) | const [inline] |
| int UT_JSONWriter::getNesting | ( | ) | const [inline, protected] |
Get the nesting level (i.e. how deeply nested in maps/arrays).
Definition at line 226 of file UT_JSONWriter.h.
| void UT_JSONWriter::getOptions | ( | UT_Options & | options | ) | const |
Get the current options. This will set the token/values in the UT_Options based on options from setOptions()
| bool UT_JSONWriter::jsonBeginArray | ( | ) |
Begin a generic array object.
| bool UT_JSONWriter::jsonBeginMap | ( | ) |
Begin a map/object dictionary.
| bool UT_JSONWriter::jsonBool | ( | bool | value | ) |
Write true/false.
| bool UT_JSONWriter::jsonComment | ( | const char * | format, | |
| ... | ||||
| ) |
Output a comment in the JSON stream. Not all JSON parsers (actually very few) support comments. The json:comments must be enabled for this statement to have any effect.
| bool UT_JSONWriter::jsonEndArray | ( | bool | newline = true |
) |
End a generic array object By default, a new line will be output for pretty printing. The newline can give a hint to omit the new line before the end of the array marker.
| bool UT_JSONWriter::jsonEndMap | ( | ) |
End the object.
| bool UT_JSONWriter::jsonInt | ( | int64 | value | ) |
Write a 64 bit integer value.
| bool UT_JSONWriter::jsonInt | ( | int32 | value | ) |
Write an integer value.
| bool UT_JSONWriter::jsonKey | ( | const char * | value, | |
| int64 | length = 0 | |||
| ) |
Write a quoted key for the object
usetokens option in the constructor). | bool UT_JSONWriter::jsonKeyToken | ( | const char * | value, | |
| int64 | length = 0 | |||
| ) |
For binary streams, common key strings can be output more efficiently using the token interface. Token key strings will appear as strings in ASCII streams.
| bool UT_JSONWriter::jsonNull | ( | ) |
Write a null to the stream.
| bool UT_JSONWriter::jsonReal | ( | fpreal64 | value | ) |
Write a 64 bit real.
| bool UT_JSONWriter::jsonReal | ( | fpreal32 | value | ) |
Write a 32 bit real.
| bool UT_JSONWriter::jsonReal | ( | fpreal16 | value | ) |
Write a 16 bit real.
| bool UT_JSONWriter::jsonString | ( | const char * | value, | |
| int64 | length = 0 | |||
| ) |
Write a quoted string.
usetokens option in the constructor). | bool UT_JSONWriter::jsonStringToken | ( | const char * | value, | |
| int64 | length = 0 | |||
| ) |
For binary streams, common strings can be output more efficiently using the token interface. Token strings will appear as strings in ASCII streams.
Efficent method of writing a uniform array of uint16 values.
Efficent method of writing a uniform array of uint8 values.
Efficent method of writing a uniform array of fpreal64 values.
Efficent method of writing a uniform array of fpreal32 values.
Efficent method of writing a uniform array of fpreal16 values.
Efficent method of writing a uniform array of int64 values.
Efficent method of writing a uniform array of int32 values.
Efficent method of writing a uniform array of int16 values.
Efficent method of writing a uniform array of int8 values.
| bool UT_JSONWriter::jsonValue | ( | fpreal64 | value | ) | [inline] |
Definition at line 126 of file UT_JSONWriter.h.
| bool UT_JSONWriter::jsonValue | ( | fpreal32 | value | ) | [inline] |
Definition at line 125 of file UT_JSONWriter.h.
| bool UT_JSONWriter::jsonValue | ( | fpreal16 | value | ) | [inline] |
Definition at line 124 of file UT_JSONWriter.h.
| bool UT_JSONWriter::jsonValue | ( | int64 | value | ) | [inline] |
Definition at line 123 of file UT_JSONWriter.h.
| bool UT_JSONWriter::jsonValue | ( | int32 | value | ) | [inline] |
Definition at line 122 of file UT_JSONWriter.h.
| bool UT_JSONWriter::jsonValue | ( | int16 | value | ) | [inline] |
Definition at line 121 of file UT_JSONWriter.h.
| bool UT_JSONWriter::jsonValue | ( | int8 | value | ) | [inline] |
Definition at line 120 of file UT_JSONWriter.h.
| bool UT_JSONWriter::jsonValue | ( | bool | value | ) | [inline] |
Write a standard JSON value to the stream. Overloaded method to allow convenient use in templated code.
Definition at line 119 of file UT_JSONWriter.h.
| bool UT_JSONWriter::setBinary | ( | bool | bin | ) |
Turn the JSON writer into a binary JSON (bJSON) writer.
| void UT_JSONWriter::setOptions | ( | const UT_Options & | options | ) |
Set formatting/control options base on the UT_Options. The following options are scanned:
| bool UT_JSONWriter::uniformWrite | ( | const char * | value, | |
| int64 | length = 0 | |||
| ) |
Write a string to the uniform array.
| bool UT_JSONWriter::uniformWrite | ( | uint16 | value | ) |
Write an 16 bit unsigned integer value to the uniform array.
| bool UT_JSONWriter::uniformWrite | ( | uint8 | value | ) |
Write an 8 bit unsigned integer value to the uniform array.
| bool UT_JSONWriter::uniformWrite | ( | fpreal64 | value | ) |
Write an 64 bit float/real value to the uniform array.
| bool UT_JSONWriter::uniformWrite | ( | fpreal32 | value | ) |
Write an 32 bit float/real value to the uniform array.
| bool UT_JSONWriter::uniformWrite | ( | fpreal16 | value | ) |
Write an 16 bit float/real value to the uniform array.
| bool UT_JSONWriter::uniformWrite | ( | int64 | value | ) |
Write an 64 bit integer value to the uniform array.
| bool UT_JSONWriter::uniformWrite | ( | int32 | value | ) |
Write an 32 bit integer value to the uniform array.
| bool UT_JSONWriter::uniformWrite | ( | int16 | value | ) |
Write an 16 bit integer value to the uniform array.
| bool UT_JSONWriter::uniformWrite | ( | int8 | value | ) |
Write an 8 bit integer value to the uniform array.
| bool UT_JSONWriter::uniformWrite | ( | bool | value | ) |
Write a bool value to a uniform array. The bool values are packed into a bit array (where each 32-bit word stores 32 bits).
| virtual bool UT_JSONWriter::writeData | ( | const void * | data, | |
| int64 | bytes | |||
| ) | [protected, pure virtual] |
The sub-class must implement this method to write data.
1.5.9