HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_JSONWriter Class Referenceabstract

Class which writes ASCII or binary JSON streams. More...

#include <UT_JSONWriter.h>

Classes

class  TiledStream
 
class  TiledStreamBuf
 

Public Member Functions

 UT_JSONWriter (const UT_Options *options=0)
 
virtual ~UT_JSONWriter ()
 
 UT_JSONWriter (const UT_JSONWriter &)=delete
 
UT_JSONWriteroperator= (const UT_JSONWriter &)=delete
 
void setOptions (const UT_Options &options)
 
void getOptions (UT_Options &options) const
 
void setPrecision (int precision)
 Direct access to options. More...
 
int getPrecision () const
 
void setIndentStep (int indentstep)
 
int getIndentStep () const
 
void setUseTokens (bool usetokens)
 
bool getUseTokens () const
 
void setTextWidth (int width)
 
int getTextWidth () const
 
void setComments (bool comment)
 
bool getComments () const
 
void setPrettyPrint (bool prettyprint)
 
bool getPrettyPrint () const
 
void setPrettyCompact (bool compact)
 
bool getPrettyCompact () const
 
bool setBinary (bool bin)
 
bool getBinary () const
 Return whether writing binary or ASCII JSON. More...
 
int64 getNumBytesWritten () const
 Get the number of bytes written to output so far. More...
 
void startNewFile ()
 Start a new embedded file. More...
 
void endNewFile ()
 End a started embedded file. More...
 
bool jsonComment (const char *format,...) SYS_PRINTF_CHECK_ATTRIBUTE(2
 
bool bool jsonNull ()
 Write a null to the stream. More...
 
bool jsonBool (bool value)
 Write true/false. More...
 
bool jsonInt (int32 value)
 Write an integer value. More...
 
bool jsonInt (int64 value)
 Write a 64 bit integer value. More...
 
bool jsonInt64 (int64 value)
 Write a 64 bit integer as a 64 bit integer. More...
 
bool jsonReal (fpreal16 value)
 Write a 16 bit real. More...
 
bool jsonRealPreserveType (fpreal16 value)
 
bool jsonReal (fpreal32 value)
 Write a 32 bit real. More...
 
bool jsonRealPreserveType (fpreal32 value)
 
bool jsonReal (fpreal64 value)
 Write a 64 bit real. More...
 
bool jsonRealPreserveType (fpreal64 value)
 
bool jsonString (const char *value, int64 length=0)
 
bool jsonStringToken (const UT_StringRef &value)
 
bool jsonStringToken (const char *value, int64 length)
 
bool jsonBeginMap ()
 Begin a map/object dictionary. More...
 
bool jsonKey (const char *value, int64 length=0)
 
bool jsonKeyToken (const UT_StringRef &value)
 
bool jsonKeyToken (const char *value, int64 length)
 
bool jsonEndMap ()
 End the object. More...
 
bool jsonBeginArray ()
 Begin a generic array object. More...
 
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. More...
 
bool uniformWrite (int16 value)
 Write an 16 bit integer value to the uniform array. More...
 
bool uniformWrite (int32 value)
 Write an 32 bit integer value to the uniform array. More...
 
bool uniformWrite (int64 value)
 Write an 64 bit integer value to the uniform array. More...
 
bool uniformWrite (fpreal16 value)
 Write an 16 bit float/real value to the uniform array. More...
 
bool uniformWrite (fpreal32 value)
 Write an 32 bit float/real value to the uniform array. More...
 
bool uniformWrite (fpreal64 value)
 Write an 64 bit float/real value to the uniform array. More...
 
bool uniformWrite (uint8 value)
 Write an 8 bit unsigned integer value to the uniform array. More...
 
bool uniformWrite (uint16 value)
 Write an 16 bit unsigned integer value to the uniform array. More...
 
bool uniformWrite (const char *value, int64 length=0)
 Write a string to the uniform array. More...
 
bool uniformBlockWrite (const int8 *value, int64 count)
 Write a block of 8 bit integer values to the uniform array. More...
 
bool uniformBlockWrite (const int16 *value, int64 count)
 Write a block of 16 bit integer values to the uniform array. More...
 
bool uniformBlockWrite (const int32 *value, int64 count)
 Write a block of 32 bit integer values to the uniform array. More...
 
bool uniformBlockWrite (const int64 *value, int64 count)
 Write a block of 64 bit integer values to the uniform array. More...
 
bool uniformBlockWrite (const fpreal16 *value, int64 count)
 Write a block of 16 bit float/real values to the uniform array. More...
 
bool uniformBlockWrite (const fpreal32 *value, int64 count)
 Write a block of 32 bit float/real values to the uniform array. More...
 
bool uniformBlockWrite (const fpreal64 *value, int64 count)
 Write a block of 64 bit float/real values to the uniform array. More...
 
bool uniformBlockWrite (const uint8 *value, int64 count)
 Write a block of 8 bit unsigned integer values to the uniform array. More...
 
bool uniformBlockWrite (const uint16 *value, int64 count)
 Write a block of 16 bit unsigned integer values to the uniform array. More...
 
bool endUniformArray (int64 *nwritten=0)
 
virtual bool writeData (const void *data, int64 bytes)
 Internally called to write raw data to output. More...
 
bool jsonUniformArray (int64 length, const int8 *value)
 Efficent method of writing a uniform array of int8 values. More...
 
bool jsonUniformArray (int64 length, const int16 *value)
 Efficent method of writing a uniform array of int16 values. More...
 
bool jsonUniformArray (int64 length, const int32 *value)
 Efficent method of writing a uniform array of int32 values. More...
 
bool jsonUniformArray (int64 length, const int64 *value)
 Efficent method of writing a uniform array of int64 values. More...
 
bool jsonUniformArray (int64 length, const fpreal16 *value)
 Efficent method of writing a uniform array of fpreal16 values. More...
 
bool jsonUniformArray (int64 length, const fpreal32 *value)
 Efficent method of writing a uniform array of fpreal32 values. More...
 
bool jsonUniformArray (int64 length, const fpreal64 *value)
 Efficent method of writing a uniform array of fpreal64 values. More...
 
bool jsonUniformArray (int64 length, const uint8 *value)
 Efficent method of writing a uniform array of uint8 values. More...
 
bool jsonUniformArray (int64 length, const uint16 *value)
 Efficent method of writing a uniform array of uint16 values. More...
 
bool jsonUniformArray (int64 length, const UT_BitArray &value, bool verbose_ascii=false)
 Efficient method of writing a uniform array of bool values. More...
 
template<typename T >
bool jsonSetAsArray (const UT_Set< T > &a)
 Convenience method to save a set as an array of strings. More...
 
bool jsonStringArray (const UT_StringArray &a)
 Convenience method to save an array of strings. More...
 
bool jsonStringTokenArray (const UT_StringArray &a)
 Convenience method to save an array of strings (as tokens) More...
 
bool jsonValue (bool value)
 
bool jsonValue (int8 value)
 
bool jsonValue (int16 value)
 
bool jsonValue (int32 value)
 
bool jsonValue (unsigned value)
 
bool jsonValue (int64 value)
 
bool jsonValue (fpreal16 value)
 
bool jsonValue (fpreal32 value)
 
bool jsonValue (fpreal64 value)
 
bool jsonValue (const char *v)
 
bool jsonValue (const UT_String &v)
 
bool jsonValue (const std::string &v)
 
bool jsonValue (const UT_StringRef &v)
 
bool jsonValue (const UT_Int16Array &v)
 
bool jsonValue (const UT_Int32Array &v)
 
bool jsonValue (const UT_Int64Array &v)
 
bool jsonValue (const UT_Fpreal32Array &v)
 
bool jsonValue (const UT_Fpreal64Array &v)
 
bool jsonValue (const UT_StringArray &v)
 
bool jsonValue (const UT_JSONValue &v)
 
template<typename T >
bool jsonValue (const UT_Set< T > &v)
 
template<typename T >
SYS_FORCE_INLINE bool jsonKeyValue (const UT_StringRef &key, const T &value)
 
template<typename T >
SYS_FORCE_INLINE bool jsonKeyTokenValue (const UT_StringRef &key, const T &value)
 
bool jsonUniformArray (const UT_Int16Array &a)
 
bool jsonUniformArray (const UT_Int32Array &a)
 
bool jsonUniformArray (const UT_Int64Array &a)
 
bool jsonUniformArray (const UT_Fpreal32Array &a)
 
bool jsonUniformArray (const UT_Fpreal64Array &a)
 

Static Public Member Functions

static UT_JSONWriterallocWriter (UT_WorkBuffer &buffer)
 
static UT_JSONWriterallocWriter (std::ostream &os, bool binary, UT_CompressionType compressionType=UT_COMPRESSION_TYPE_NONE)
 
static UT_JSONWriterallocWriter (const char *filename, bool binary, UT_CompressionType compressionType=UT_COMPRESSION_TYPE_NONE)
 
static UT_JSONWriterallocWriter (UT_JSONValue &value)
 
static UT_JID jidFromValue (const bool *)
 Returns the JID that matches the given type. More...
 
static UT_JID jidFromValue (const int8 *)
 
static UT_JID jidFromValue (const int16 *)
 
static UT_JID jidFromValue (const int32 *)
 
static UT_JID jidFromValue (const int64 *)
 
static UT_JID jidFromValue (const fpreal16 *)
 
static UT_JID jidFromValue (const fpreal32 *)
 
static UT_JID jidFromValue (const fpreal64 *)
 
static UT_JID jidFromValue (const uint8 *)
 
static UT_JID jidFromValue (const uint16 *)
 

Protected Member Functions

virtual bool subclassWriteData (const void *data, int64 bytes)=0
 The sub-class must implement this method to write data. More...
 
int getNesting () const
 Get the nesting level (i.e. how deeply nested in maps/arrays) More...
 

Detailed Description

Class which writes ASCII or binary JSON streams.

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.

See Also
UT_JID, UT_JSONValue, UT_AutoJSONWriter
Examples:
karma_procedurals/BRAY_HdSphere.C, packedshareddata/GU_PackedSharedData.C, packedshareddata/GU_PackedSharedData.h, SOP/SOP_BouncyAgent.C, tetprim/GEO_PrimTetra.C, and tetprim/GEO_PrimTetra.h.

Definition at line 37 of file UT_JSONWriter.h.

Constructor & Destructor Documentation

UT_JSONWriter::UT_JSONWriter ( const UT_Options options = 0)
Parameters
options
A UT_Options class which sets specific format options.
See Also
setOptions()
virtual UT_JSONWriter::~UT_JSONWriter ( )
virtual
UT_JSONWriter::UT_JSONWriter ( const UT_JSONWriter )
delete

Member Function Documentation

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.

static UT_JSONWriter* UT_JSONWriter::allocWriter ( std::ostream &  os,
bool  binary,
UT_CompressionType  compressionType = UT_COMPRESSION_TYPE_NONE 
)
static

Allocate a JSON Writer which writes to an output stream. Please delete when finished with the writer.

static UT_JSONWriter* UT_JSONWriter::allocWriter ( const char *  filename,
bool  binary,
UT_CompressionType  compressionType = UT_COMPRESSION_TYPE_NONE 
)
static

Allocate a JSON Writer which writes to a named file. Please delete when finished with the writer.

static UT_JSONWriter* UT_JSONWriter::allocWriter ( UT_JSONValue value)
static

Allocate a JSON Writer which writes into a given UT_JSONValue. The value will only be set properly at the conclusion of writing. Please delete when finished with the writer.

bool UT_JSONWriter::beginUniformArray ( int64  length,
UT_JID  id 
)

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:

  • UT_JID_BOOL
  • UT_JID_INT8
  • UT_JID_INT16
  • UT_JID_INT32
  • UT_JID_INT64
  • UT_JID_UINT8
  • UT_JID_UINT16
  • UT_JID_REAL16
  • UT_JID_REAL32
  • UT_JID_REAL64
  • UT_JID_STRING
void UT_JSONWriter::endNewFile ( )

End a started embedded file.

bool UT_JSONWriter::endUniformArray ( int64 nwritten = 0)

End the uniform array.

Parameters
nwritten
If provided, the number of items written is returned.
Note
The JSONWriter class will automatically clamp or fill the uniform array with 0, but nwritten will return the actual number of calls to uniformWrite().
bool UT_JSONWriter::getBinary ( ) const
inline

Return whether writing binary or ASCII JSON.

Definition at line 113 of file UT_JSONWriter.h.

bool UT_JSONWriter::getComments ( ) const
inline

Definition at line 100 of file UT_JSONWriter.h.

int UT_JSONWriter::getIndentStep ( ) const
inline

Definition at line 94 of file UT_JSONWriter.h.

int UT_JSONWriter::getNesting ( ) const
inlineprotected

Get the nesting level (i.e. how deeply nested in maps/arrays)

Definition at line 465 of file UT_JSONWriter.h.

int64 UT_JSONWriter::getNumBytesWritten ( ) const
inline

Get the number of bytes written to output so far.

Examples:
packedshareddata/GU_PackedSharedData.C.

Definition at line 116 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()

int UT_JSONWriter::getPrecision ( ) const
inline

Definition at line 92 of file UT_JSONWriter.h.

bool UT_JSONWriter::getPrettyCompact ( ) const
inline

Definition at line 104 of file UT_JSONWriter.h.

bool UT_JSONWriter::getPrettyPrint ( ) const
inline

Definition at line 102 of file UT_JSONWriter.h.

int UT_JSONWriter::getTextWidth ( ) const
inline

Definition at line 98 of file UT_JSONWriter.h.

bool UT_JSONWriter::getUseTokens ( ) const
inline

Definition at line 96 of file UT_JSONWriter.h.

static UT_JID UT_JSONWriter::jidFromValue ( const bool *  )
inlinestatic

Returns the JID that matches the given type.

Definition at line 331 of file UT_JSONWriter.h.

static UT_JID UT_JSONWriter::jidFromValue ( const int8 )
inlinestatic

Definition at line 332 of file UT_JSONWriter.h.

static UT_JID UT_JSONWriter::jidFromValue ( const int16 )
inlinestatic

Definition at line 333 of file UT_JSONWriter.h.

static UT_JID UT_JSONWriter::jidFromValue ( const int32 )
inlinestatic

Definition at line 334 of file UT_JSONWriter.h.

static UT_JID UT_JSONWriter::jidFromValue ( const int64 )
inlinestatic

Definition at line 335 of file UT_JSONWriter.h.

static UT_JID UT_JSONWriter::jidFromValue ( const fpreal16 )
inlinestatic

Definition at line 336 of file UT_JSONWriter.h.

static UT_JID UT_JSONWriter::jidFromValue ( const fpreal32 )
inlinestatic

Definition at line 337 of file UT_JSONWriter.h.

static UT_JID UT_JSONWriter::jidFromValue ( const fpreal64 )
inlinestatic

Definition at line 338 of file UT_JSONWriter.h.

static UT_JID UT_JSONWriter::jidFromValue ( const uint8 )
inlinestatic

Definition at line 339 of file UT_JSONWriter.h.

static UT_JID UT_JSONWriter::jidFromValue ( const uint16 )
inlinestatic

Definition at line 340 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonBeginArray ( )

Begin a generic array object.

Examples:
packedshareddata/GU_PackedSharedData.C.
bool UT_JSONWriter::jsonBeginMap ( )
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.

Examples:
packedshareddata/GU_PackedSharedData.C.
bool UT_JSONWriter::jsonEndMap ( )
bool UT_JSONWriter::jsonInt ( int32  value)

Write an integer value.

bool UT_JSONWriter::jsonInt ( int64  value)

Write a 64 bit integer value.

bool UT_JSONWriter::jsonInt64 ( int64  value)

Write a 64 bit integer as a 64 bit integer.

bool UT_JSONWriter::jsonKey ( const char *  value,
int64  length = 0 
)

Write a quoted key for the object

Note
Use jsonKeyToken() to take advantage of token compression (this can be turned off with the usetokens option in the constructor).
See Also
UT_JID
Examples:
SOP/SOP_BouncyAgent.C.
bool UT_JSONWriter::jsonKeyToken ( const UT_StringRef value)

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.

Examples:
packedshareddata/GU_PackedSharedData.C.
bool UT_JSONWriter::jsonKeyToken ( const char *  value,
int64  length 
)
inline

Definition at line 222 of file UT_JSONWriter.h.

template<typename T >
SYS_FORCE_INLINE bool UT_JSONWriter::jsonKeyTokenValue ( const UT_StringRef key,
const T value 
)
inline

Convenience method to write the key/value pair to a map

Definition at line 242 of file UT_JSONWriter.h.

template<typename T >
SYS_FORCE_INLINE bool UT_JSONWriter::jsonKeyValue ( const UT_StringRef key,
const T value 
)
inline

Convenience method to write the key/value pair to a map

Examples:
karma_procedurals/BRAY_HdSphere.C.

Definition at line 235 of file UT_JSONWriter.h.

bool bool UT_JSONWriter::jsonNull ( )

Write a null to the stream.

bool UT_JSONWriter::jsonReal ( fpreal16  value)

Write a 16 bit real.

bool UT_JSONWriter::jsonReal ( fpreal32  value)

Write a 32 bit real.

bool UT_JSONWriter::jsonReal ( fpreal64  value)

Write a 64 bit real.

bool UT_JSONWriter::jsonRealPreserveType ( fpreal16  value)
bool UT_JSONWriter::jsonRealPreserveType ( fpreal32  value)
bool UT_JSONWriter::jsonRealPreserveType ( fpreal64  value)
template<typename T >
bool UT_JSONWriter::jsonSetAsArray ( const UT_Set< T > &  a)
inline

Convenience method to save a set as an array of strings.

Definition at line 382 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonString ( const char *  value,
int64  length = 0 
)

Write a quoted string.

Warning
Please use jsonKey() to write key strings.
Note
Use jsonStringToken() to take advantage of token compression (this can be turned off with the usetokens option in the constructor).
See Also
UT_JID
Examples:
packedshareddata/GU_PackedSharedData.C.
bool UT_JSONWriter::jsonStringArray ( const UT_StringArray a)

Convenience method to save an array of strings.

bool UT_JSONWriter::jsonStringToken ( const UT_StringRef value)

For binary streams, common strings can be output more efficiently using the token interface. Token strings will appear as strings in ASCII streams.

Examples:
packedshareddata/GU_PackedSharedData.C.
bool UT_JSONWriter::jsonStringToken ( const char *  value,
int64  length 
)
inline

Definition at line 162 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonStringTokenArray ( const UT_StringArray a)

Convenience method to save an array of strings (as tokens)

bool UT_JSONWriter::jsonUniformArray ( int64  length,
const int8 value 
)

Efficent method of writing a uniform array of int8 values.

bool UT_JSONWriter::jsonUniformArray ( int64  length,
const int16 value 
)

Efficent method of writing a uniform array of int16 values.

bool UT_JSONWriter::jsonUniformArray ( int64  length,
const int32 value 
)

Efficent method of writing a uniform array of int32 values.

bool UT_JSONWriter::jsonUniformArray ( int64  length,
const int64 value 
)

Efficent method of writing a uniform array of int64 values.

bool UT_JSONWriter::jsonUniformArray ( int64  length,
const fpreal16 value 
)

Efficent method of writing a uniform array of fpreal16 values.

bool UT_JSONWriter::jsonUniformArray ( int64  length,
const fpreal32 value 
)

Efficent method of writing a uniform array of fpreal32 values.

bool UT_JSONWriter::jsonUniformArray ( int64  length,
const fpreal64 value 
)

Efficent method of writing a uniform array of fpreal64 values.

bool UT_JSONWriter::jsonUniformArray ( int64  length,
const uint8 value 
)

Efficent method of writing a uniform array of uint8 values.

bool UT_JSONWriter::jsonUniformArray ( int64  length,
const uint16 value 
)

Efficent method of writing a uniform array of uint16 values.

bool UT_JSONWriter::jsonUniformArray ( int64  length,
const UT_BitArray value,
bool  verbose_ascii = false 
)

Efficient method of writing a uniform array of bool values.

bool UT_JSONWriter::jsonUniformArray ( const UT_Int16Array a)
inline

Convenience method for saving common array types

Definition at line 368 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonUniformArray ( const UT_Int32Array a)
inline

Convenience method for saving common array types

Definition at line 370 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonUniformArray ( const UT_Int64Array a)
inline

Convenience method for saving common array types

Definition at line 372 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonUniformArray ( const UT_Fpreal32Array a)
inline

Convenience method for saving common array types

Definition at line 374 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonUniformArray ( const UT_Fpreal64Array a)
inline

Convenience method for saving common array types

Definition at line 376 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.

Examples:
SOP/SOP_BouncyAgent.C.

Definition at line 175 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonValue ( int8  value)
inline

Write a standard JSON value to the stream. Overloaded method to allow convenient use in templated code.

Definition at line 176 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonValue ( int16  value)
inline

Write a standard JSON value to the stream. Overloaded method to allow convenient use in templated code.

Definition at line 177 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonValue ( int32  value)
inline

Write a standard JSON value to the stream. Overloaded method to allow convenient use in templated code.

Definition at line 178 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonValue ( unsigned  value)
inline

Write a standard JSON value to the stream. Overloaded method to allow convenient use in templated code.

Definition at line 179 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonValue ( int64  value)
inline

Write a standard JSON value to the stream. Overloaded method to allow convenient use in templated code.

Definition at line 180 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonValue ( fpreal16  value)
inline

Write a standard JSON value to the stream. Overloaded method to allow convenient use in templated code.

Definition at line 181 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonValue ( fpreal32  value)
inline

Write a standard JSON value to the stream. Overloaded method to allow convenient use in templated code.

Definition at line 182 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonValue ( fpreal64  value)
inline

Write a standard JSON value to the stream. Overloaded method to allow convenient use in templated code.

Definition at line 183 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonValue ( const char *  v)
inline

Write a standard JSON value to the stream. Overloaded method to allow convenient use in templated code.

Definition at line 184 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonValue ( const UT_String v)
inline

Write a standard JSON value to the stream. Overloaded method to allow convenient use in templated code.

Definition at line 185 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonValue ( const std::string v)
inline

Write a standard JSON value to the stream. Overloaded method to allow convenient use in templated code.

Definition at line 187 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonValue ( const UT_StringRef v)
inline

Write a standard JSON value to the stream. Overloaded method to allow convenient use in templated code.

Definition at line 189 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonValue ( const UT_Int16Array v)
inline

Write a standard JSON value to the stream. Overloaded method to allow convenient use in templated code.

Definition at line 190 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonValue ( const UT_Int32Array v)
inline

Write a standard JSON value to the stream. Overloaded method to allow convenient use in templated code.

Definition at line 192 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonValue ( const UT_Int64Array v)
inline

Write a standard JSON value to the stream. Overloaded method to allow convenient use in templated code.

Definition at line 194 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonValue ( const UT_Fpreal32Array v)
inline

Write a standard JSON value to the stream. Overloaded method to allow convenient use in templated code.

Definition at line 196 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonValue ( const UT_Fpreal64Array v)
inline

Write a standard JSON value to the stream. Overloaded method to allow convenient use in templated code.

Definition at line 198 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonValue ( const UT_StringArray v)
inline

Write a standard JSON value to the stream. Overloaded method to allow convenient use in templated code.

Definition at line 200 of file UT_JSONWriter.h.

bool UT_JSONWriter::jsonValue ( const UT_JSONValue v)

Write a standard JSON value to the stream. Overloaded method to allow convenient use in templated code.

template<typename T >
bool UT_JSONWriter::jsonValue ( const UT_Set< T > &  v)
inline

Write a standard JSON value to the stream. Overloaded method to allow convenient use in templated code.

Definition at line 204 of file UT_JSONWriter.h.

UT_JSONWriter& UT_JSONWriter::operator= ( const UT_JSONWriter )
delete
bool UT_JSONWriter::setBinary ( bool  bin)

Turn the JSON writer into a binary JSON (bJSON) writer.

Warning
This method must be called before any other data is written to the JSON file. It's a good idea to call in the sub-class constructor.
void UT_JSONWriter::setComments ( bool  comment)
inline

Definition at line 99 of file UT_JSONWriter.h.

void UT_JSONWriter::setIndentStep ( int  indentstep)
inline

Definition at line 93 of file UT_JSONWriter.h.

void UT_JSONWriter::setOptions ( const UT_Options options)

Set formatting/control options base on the UT_Options. The following options are scanned:

  • int "json:precision" – ASCII float precision [9]. Note half-precision floats will use half this precision, while double precision will use twice the digits.
  • int "json:indentstep" – ASCII indent step for maps/arrays [8]
  • int "json:textwidth" – ASCII wrap lines after byte count [256]
  • bool "json:comments" – Allow comments in ASCII stream [false]
  • bool "json:prettyprint" – Pretty print ASCII stream [true]
  • bool "json:usetokens" – Binary string token compression [true]
  • bool "json:prettycompact" – Add a space after separators, a more compact pretty print matching Python [false]
void UT_JSONWriter::setPrecision ( int  precision)
inline

Direct access to options.

Definition at line 91 of file UT_JSONWriter.h.

void UT_JSONWriter::setPrettyCompact ( bool  compact)
inline

Definition at line 103 of file UT_JSONWriter.h.

void UT_JSONWriter::setPrettyPrint ( bool  prettyprint)
inline

Definition at line 101 of file UT_JSONWriter.h.

void UT_JSONWriter::setTextWidth ( int  width)
inline

Definition at line 97 of file UT_JSONWriter.h.

void UT_JSONWriter::setUseTokens ( bool  usetokens)
inline

Definition at line 95 of file UT_JSONWriter.h.

void UT_JSONWriter::startNewFile ( )

Start a new embedded file.

virtual bool UT_JSONWriter::subclassWriteData ( const void data,
int64  bytes 
)
protectedpure virtual

The sub-class must implement this method to write data.

bool UT_JSONWriter::uniformBlockWrite ( const int8 value,
int64  count 
)

Write a block of 8 bit integer values to the uniform array.

bool UT_JSONWriter::uniformBlockWrite ( const int16 value,
int64  count 
)

Write a block of 16 bit integer values to the uniform array.

bool UT_JSONWriter::uniformBlockWrite ( const int32 value,
int64  count 
)

Write a block of 32 bit integer values to the uniform array.

bool UT_JSONWriter::uniformBlockWrite ( const int64 value,
int64  count 
)

Write a block of 64 bit integer values to the uniform array.

bool UT_JSONWriter::uniformBlockWrite ( const fpreal16 value,
int64  count 
)

Write a block of 16 bit float/real values to the uniform array.

bool UT_JSONWriter::uniformBlockWrite ( const fpreal32 value,
int64  count 
)

Write a block of 32 bit float/real values to the uniform array.

bool UT_JSONWriter::uniformBlockWrite ( const fpreal64 value,
int64  count 
)

Write a block of 64 bit float/real values to the uniform array.

bool UT_JSONWriter::uniformBlockWrite ( const uint8 value,
int64  count 
)

Write a block of 8 bit unsigned integer values to the uniform array.

bool UT_JSONWriter::uniformBlockWrite ( const uint16 value,
int64  count 
)

Write a block of 16 bit unsigned integer values 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).

bool UT_JSONWriter::uniformWrite ( int8  value)

Write an 8 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 ( int32  value)

Write an 32 bit integer 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 ( fpreal16  value)

Write an 16 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 ( fpreal64  value)

Write an 64 bit float/real 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 ( uint16  value)

Write an 16 bit unsigned integer value to the uniform array.

bool UT_JSONWriter::uniformWrite ( const char *  value,
int64  length = 0 
)

Write a string to the uniform array.

virtual bool UT_JSONWriter::writeData ( const void data,
int64  bytes 
)
virtual

Internally called to write raw data to output.


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