HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_JSONWriter.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_JSONWriter.h ( UT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __UT_JSONWriter__
12 #define __UT_JSONWriter__
13 
14 #include "UT_Compression.h"
15 #include "UT_IntArray.h"
16 #include "UT_JSONDefines.h"
17 #include "UT_StringMap.h"
18 #include "UT_WorkBuffer.h"
19 #include <iostream>
20 
21 class UT_Options;
22 class UT_BitArray;
23 class UT_JSONValue;
24 
25 /// @brief Class which writes ASCII or binary JSON streams
26 ///
27 /// The JSON format (http://www.json.org) is a generic way to store data.
28 /// Houdini extends JSON to a byte-stream binary encoding (see UT_JID for
29 /// details). The UT_JSONWriter class is used to write JSON (binary or
30 /// ASCII) to a stream.
31 /// @see UT_JID
33 {
34 public:
35  /// @param options @n
36  /// A UT_Options class which sets specific format options.
37  /// @see setOptions()
38  UT_JSONWriter(const UT_Options *options=0);
39  virtual ~UT_JSONWriter();
40 
41  /// Allocate a JSON Writer which will fill a UT_WorkBuffer.
42  /// Please delete when finished with the writer.
43  static UT_JSONWriter *allocWriter(UT_WorkBuffer &buffer);
44 
45  /// Allocate a JSON Writer which writes to an output stream.
46  /// Please delete when finished with the writer.
47  static UT_JSONWriter *allocWriter(
48  std::ostream &os,
49  bool binary,
51 
52  /// Allocate a JSON Writer which writes to a named file.
53  /// Please delete when finished with the writer.
54  static UT_JSONWriter *allocWriter(
55  const char *filename,
56  bool binary,
58 
59  /// Allocate a JSON Writer which writes into a given UT_JSONValue. The
60  /// value will only be set properly at the conclusion of writing.
61  /// Please delete when finished with the writer.
62  static UT_JSONWriter *allocWriter(UT_JSONValue &value);
63 
64  /// Set formatting/control options base on the UT_Options. The following
65  /// options are scanned:
66  /// - @b int @b "json:precision" -- ASCII float precision [9].
67  /// Note half-precision floats will use half this precision, while double
68  /// precision will use twice the digits.
69  /// - @b int @b "json:indentstep" -- ASCII indent step for maps/arrays [8]
70  /// - @b int @b "json:textwidth" -- ASCII wrap lines after byte count [256]
71  /// - @b bool @b "json:comments" -- Allow comments in ASCII stream [false]
72  /// - @b bool @b "json:prettyprint" -- Pretty print ASCII stream [true]
73  /// - @b bool @b "json:usetokens" -- Binary string token compression [true]
74  void setOptions(const UT_Options &options);
75 
76  /// Get the current options. This will set the token/values in
77  /// the UT_Options based on options from setOptions()
78  void getOptions(UT_Options &options) const;
79 
80  /// Turn the JSON writer into a binary JSON (bJSON) writer.
81  /// @warning This method must be called before any other data is written to
82  /// the JSON file. It's a @b good idea to call in the sub-class
83  /// constructor.
84  bool setBinary(bool bin);
85 
86  /// Return whether writing binary or ASCII JSON
87  bool getBinary() const { return myBinary; }
88 
89  /// Get the number of bytes written to output so far.
90  int64 getNumBytesWritten() const { return myCurrentFilePosition; }
91 
92  /// Start a new embedded file
93  void startNewFile();
94 
95  /// End a started embedded file
96  void endNewFile();
97 
98  /// Output a comment in the JSON stream. Not all JSON parsers (actually
99  /// very few) support comments. The json:comments must be enabled for this
100  /// statement to have any effect.
101  bool jsonComment(const char *format, ...)
103 
104  // Standard JSON types
105  /// Write a @b null to the stream
106  bool jsonNull();
107  /// Write true/false
108  bool jsonBool(bool value);
109  /// Write an integer value
110  bool jsonInt(int32 value);
111  /// Write a 64 bit integer value
112  bool jsonInt(int64 value);
113  /// Write a 64 bit integer as a 64 bit integer
114  bool jsonInt64(int64 value);
115  /// Write a 16 bit real
116  bool jsonReal(fpreal16 value);
117  /// Write a 32 bit real
118  bool jsonReal(fpreal32 value);
119  /// Write a 64 bit real
120  bool jsonReal(fpreal64 value);
121  /// Write a quoted string.
122  /// @warning Please use jsonKey() to write key strings.
123  /// @note Use jsonStringToken() to take advantage of token compression
124  /// (this can be turned off with the @c usetokens option in the
125  /// constructor).
126  /// @see UT_JID
127  bool jsonString(const char *value, int64 length=0);
128 
129  /// For binary streams, common strings can be output more efficiently using
130  /// the token interface. Token strings will appear as strings in ASCII
131  /// streams.
132  bool jsonStringToken(const UT_StringRef &value);
133  bool jsonStringToken(const char *value, int64 length)
134  {
135  UT_StringRef result;
136  if (length <= 0)
137  result.reference(value);
138  else
139  result.fastReferenceWithStrlen(value, length);
140  return jsonStringToken(result);
141  }
142 
143  /// Write a standard JSON value to the stream. Overloaded method to allow
144  /// convenient use in templated code.
145  bool jsonValue(bool value) { return jsonBool(value); }
146  bool jsonValue(int8 value) { return jsonInt((int32)value); }
147  bool jsonValue(int16 value) { return jsonInt((int32)value); }
148  bool jsonValue(int32 value) { return jsonInt(value); }
149  bool jsonValue(int64 value) { return jsonInt(value); }
150  bool jsonValue(fpreal16 value) { return jsonReal(value); }
151  bool jsonValue(fpreal32 value) { return jsonReal(value); }
152  bool jsonValue(fpreal64 value) { return jsonReal(value); }
153 
154  /// Begin a map/object dictionary
155  bool jsonBeginMap();
156  /// Write a quoted key for the object
157  /// @note Use jsonKeyToken() to take advantage of token compression
158  /// (this can be turned off with the @c usetokens option in the
159  /// constructor).
160  /// @see UT_JID
161  bool jsonKey(const char *value, int64 length=0);
162  /// For binary streams, common key strings can be output more efficiently
163  /// using the token interface. Token key strings will appear as strings in
164  /// ASCII streams.
165  bool jsonKeyToken(const UT_StringRef &value);
166  bool jsonKeyToken(const char *value, int64 length)
167  {
168  UT_StringRef result;
169  if (length <= 0)
170  result.reference(value);
171  else
172  result.fastReferenceWithStrlen(value, length);
173  return jsonKeyToken(result);
174  }
175  /// End the object
176  bool jsonEndMap();
177 
178  /// Begin a generic array object
179  bool jsonBeginArray();
180  /// End a generic array object
181  /// By default, a new line will be output for pretty printing. The newline
182  /// can give a hint to omit the new line before the end of the array
183  /// marker.
184  bool jsonEndArray(bool newline=true);
185 
186  /// When writing binary JSON files, uniform arrays can be encoded without
187  /// repetition of the type information which results in a more compressed
188  /// data format.
189  ///
190  /// @c beingUniformArray() starts a uniform array.
191  /// The @c id should be one of:
192  /// - UT_JID_BOOL
193  /// - UT_JID_INT8
194  /// - UT_JID_INT16
195  /// - UT_JID_INT32
196  /// - UT_JID_INT64
197  /// - UT_JID_UINT8
198  /// - UT_JID_UINT16
199  /// - UT_JID_REAL16
200  /// - UT_JID_REAL32
201  /// - UT_JID_REAL64
202  /// - UT_JID_STRING
203  bool beginUniformArray(int64 length, UT_JID id);
204  /// Write a bool value to a uniform array. The bool values are packed into
205  /// a bit array (where each 32-bit word stores 32 bits).
206  bool uniformWrite(bool value);
207  /// Write an 8 bit integer value to the uniform array
208  bool uniformWrite(int8 value);
209  /// Write an 16 bit integer value to the uniform array
210  bool uniformWrite(int16 value);
211  /// Write an 32 bit integer value to the uniform array
212  bool uniformWrite(int32 value);
213  /// Write an 64 bit integer value to the uniform array
214  bool uniformWrite(int64 value);
215  /// Write an 16 bit float/real value to the uniform array
216  bool uniformWrite(fpreal16 value);
217  /// Write an 32 bit float/real value to the uniform array
218  bool uniformWrite(fpreal32 value);
219  /// Write an 64 bit float/real value to the uniform array
220  bool uniformWrite(fpreal64 value);
221  /// Write an 8 bit unsigned integer value to the uniform array
222  bool uniformWrite(uint8 value);
223  /// Write an 16 bit unsigned integer value to the uniform array
224  bool uniformWrite(uint16 value);
225  /// Write a string to the uniform array
226  bool uniformWrite(const char *value, int64 length=0);
227  /// Write a block of 8 bit integer values to the uniform array
228  bool uniformBlockWrite(const int8 *value, int64 count);
229  /// Write a block of 16 bit integer values to the uniform array
230  bool uniformBlockWrite(const int16 *value, int64 count);
231  /// Write a block of 32 bit integer values to the uniform array
232  bool uniformBlockWrite(const int32 *value, int64 count);
233  /// Write a block of 64 bit integer values to the uniform array
234  bool uniformBlockWrite(const int64 *value, int64 count);
235  /// Write a block of 16 bit float/real values to the uniform array
236  bool uniformBlockWrite(const fpreal16 *value, int64 count);
237  /// Write a block of 32 bit float/real values to the uniform array
238  bool uniformBlockWrite(const fpreal32 *value, int64 count);
239  /// Write a block of 64 bit float/real values to the uniform array
240  bool uniformBlockWrite(const fpreal64 *value, int64 count);
241  /// Write a block of 8 bit unsigned integer values to the uniform array
242  bool uniformBlockWrite(const uint8 *value, int64 count);
243  /// Write a block of 16 bit unsigned integer values to the uniform array
244  bool uniformBlockWrite(const uint16 *value, int64 count);
245  /// End the uniform array.
246  /// @param nwritten @n
247  /// If provided, the number of items written is returned.
248  /// @note The JSONWriter class will automatically clamp or fill the uniform
249  /// array with 0, but nwritten will return the actual number of calls to
250  /// uniformWrite().
251  bool endUniformArray(int64 *nwritten=0);
252 
253  /// Internally called to write raw data to output.
254  virtual bool writeData(const void *data, int64 bytes);
255 
256  /// Returns the JID that matches the given type.
257  static UT_JID jidFromValue(const bool *) { return UT_JID_BOOL; }
258  static UT_JID jidFromValue(const int8 *) { return UT_JID_INT8; }
259  static UT_JID jidFromValue(const int16 *) { return UT_JID_INT16; }
260  static UT_JID jidFromValue(const int32 *) { return UT_JID_INT32; }
261  static UT_JID jidFromValue(const int64 *) { return UT_JID_INT64; }
262  static UT_JID jidFromValue(const fpreal16 *) { return UT_JID_REAL16; }
263  static UT_JID jidFromValue(const fpreal32 *) { return UT_JID_REAL32; }
264  static UT_JID jidFromValue(const fpreal64 *) { return UT_JID_REAL64; }
265  static UT_JID jidFromValue(const uint8 *) { return UT_JID_UINT8; }
266  static UT_JID jidFromValue(const uint16 *) { return UT_JID_UINT16; }
267 
268  /// Efficent method of writing a uniform array of int8 values
269  bool jsonUniformArray(int64 length, const int8 *value);
270  /// Efficent method of writing a uniform array of int16 values
271  bool jsonUniformArray(int64 length, const int16 *value);
272  /// Efficent method of writing a uniform array of int32 values
273  bool jsonUniformArray(int64 length, const int32 *value);
274  /// Efficent method of writing a uniform array of int64 values
275  bool jsonUniformArray(int64 length, const int64 *value);
276  /// Efficent method of writing a uniform array of fpreal16 values
277  bool jsonUniformArray(int64 length, const fpreal16 *value);
278  /// Efficent method of writing a uniform array of fpreal32 values
279  bool jsonUniformArray(int64 length, const fpreal32 *value);
280  /// Efficent method of writing a uniform array of fpreal64 values
281  bool jsonUniformArray(int64 length, const fpreal64 *value);
282 
283  /// Efficent method of writing a uniform array of uint8 values
284  bool jsonUniformArray(int64 length, const uint8 *value);
285  /// Efficent method of writing a uniform array of uint16 values
286  bool jsonUniformArray(int64 length, const uint16 *value);
287 
288  /// Efficient method of writing a uniform array of bool values
289  bool jsonUniformArray(int64 length, const UT_BitArray &value,
290  bool verbose_ascii = false);
291 
292  /// @{
293  /// Convenience method for saving common array types
295  { return jsonUniformArray(a.size(), a.data()); }
297  { return jsonUniformArray(a.size(), a.data()); }
299  { return jsonUniformArray(a.size(), a.data()); }
301  { return jsonUniformArray(a.size(), a.data()); }
303  { return jsonUniformArray(a.size(), a.data()); }
304  /// @}
305 
306  /// Convenience method to save an array of strings
307  bool jsonStringArray(const UT_StringArray &a);
308  /// Convenience method to save an array of strings (as tokens)
309  bool jsonStringTokenArray(const UT_StringArray &a);
310 
311  /// A TiledStream allows you to write a blob of binary data to a JSON
312  /// stream in an efficient manner. The data is buffered into uniform
313  /// arrays which are output into a standard JSON array. The resulting data
314  /// looks something like: @code
315  /// [ {options} tile1-data tile2-data ]
316  /// @endcode
317  /// The tile-data is written as JSON string objects. You can read these
318  /// yourself, or use the TiledStream in UT_JSONParser.
319  ///
320  /// You should never write to the JSONWriter while the TiledStream is open.
321  ///
322  /// An example of using this might be something like: @code
323  /// bool storeStream(UT_IStream &is)
324  /// {
325  /// UT_JSONWriter::TiledStream os(writer);
326  /// char buffer[128];
327  /// int nread;
328  /// while ((nread = is.bread(buffer, 128)) > 0)
329  /// if (!os.write(buffer, nread)) return false;
330  /// return true;
331  /// }
332  /// @endcode
333  class UT_API TiledStreamBuf : public std::streambuf
334  {
335  public:
337  virtual ~TiledStreamBuf();
338 
339  protected:
340  // write one character
341  virtual int_type overflow(int_type c);
342 
343  // write multiple characters
344  virtual std::streamsize xsputn (const char* s, std::streamsize num);
345 
346  private:
347  bool write(const void *data, exint bytes);
348  void close();
349 
350  bool writeTile(const char *data, exint bytes);
351  bool flush();
352  UT_JSONWriter &myWriter;
353  char *myBuffer;
354  exint myLength;
355  };
356 
357  class UT_API TiledStream : public std::ostream
358  {
359  public:
361  virtual ~TiledStream();
362 
363  private:
364  TiledStreamBuf myBuf;
365  };
366 
367 protected:
368  /// The sub-class must implement this method to write data
369  virtual bool subclassWriteData(const void* data, int64 bytes) = 0;
370 
371 protected:
372  /// Get the nesting level (i.e. how deeply nested in maps/arrays)
373  int getNesting() const { return myStack.entries(); }
374 private:
375  int precision16() const { return (myPrecision+1)/2; }
376  int precision32() const { return myPrecision; }
377  int precision64() const { return myPrecision*2; }
378  /// @private: ASCII indent
379  bool indent();
380  /// @private: ASCII prefix
381  bool prefix();
382  /// @private: Convenience method to write a UT_JID
383  bool writeId(UT_JID id);
384  /// @private: Convenience method to write an encoded length @see UT_JID
385  bool writeLength(int64 length);
386  /// @private: Write a token string
387  bool writeTokenString(const UT_StringRef &str);
388  /// @private: Write a string of data (not quoted)
389  bool writeString(const char *str, int64 bytes=0);
390  /// @private: Write a quoted string
391  bool quotedString(const char *str, int64 bytes=0);
392  /// @private: Write an ASCII "bool" value
393  bool writeAB(bool i);
394  /// @private: Write an ASCII "integer" value
395  bool writeAI(int64 i);
396  /// @private: Write an ASCII "float" value
397  bool writeAF(fpreal64 i, int precision);
398  /// @private: Start an array (possibly uniform encoding)
399  bool startArray(UT_JID id, UT_JID type=UT_JID_NULL);
400  /// @private: Finish array
401  bool finishArray(UT_JID id, bool newline=true);
402  /// @private: Flush bits for a uniform array of bools
403  bool flushBits();
404  /// @private: Push nesting of map/array
405  void pushState(UT_JID id);
406  /// @private: Pop state
407  void popState(UT_JID id);
408  /// @private: Set the prefix for ASCII encoding
409  void setPrefix();
410  /// @private: Build indent string
411  void bumpIndent(int dir);
412  /// @private: New line & indent
413  bool newLine(bool force=false);
414 
415  /// Method to detail with long lines in ASCII files
416  bool countAndWrite(const void *data, int64 bytes);
417 
418  template <typename T> bool
419  uniformArrayI(UT_JID id, int64 length, const T *data);
420  template <typename T> bool
421  uniformArrayF(UT_JID id, int64 length, const T *data);
422  template <typename T> bool
423  uniformBlockWriteImplI(const T *data, int64 count);
424  template <typename T> bool
425  uniformBlockWriteImplF(const T *data, int64 count, int prec);
426 
427  enum
428  {
429  PREFIX_FIRST, // First element (no prefix)
430  PREFIX_ARRAY, // Use array prefix
431  PREFIX_MAP, // Use object prefix
432  };
433 
434  UT_IntArray myStack;
435  UT_WorkBuffer myIndentString;
436  UT_StringMap<int64> myTokens;
437  UT_Int64Array myTokenCountStack;
438  char *myASeparator; // Array separator string
439  char *myKSeparator; // Keyword separator string
440  int64 myCurrentFilePosition;
441  int64 myUWriteSize; // Uniform write size
442  int64 myUWriteCount; // Uniform entities written
443  int64 myTokenCount;
444  UT_JID myUniform; // Type of data for fixed array
445  uint32 myBitValue; // For packing bit arrays
446  int myBitCount;
447  int myPrefix;
448  int myPrecision; // ASCII float precision
449  int myIndent; // ASCII indent level
450  int myIndentStep; // ASCII indent step
451  int myTextWidth; // ASCII max line length
452  int myLineLength; // ASCII line length
453  bool myBinary; // ASCII or binary
454  bool myTokenStrings; // Use token strings
455  bool myComments; // Emit comments
456  bool myPrettyPrint; // Pretty print
457  bool myNewLine; // For line wrapping
458  bool myJoinNext;
459 };
460 
461 /// Convenience class to allocate a writer which is automatically deleted
462 /// For example: @code
463 /// bool save(UT_JSONWriter &w) { ... } // Method to save to standard writer
464 ///
465 /// bool save(UT_WorkBuffer &buffer) // Save to a UT_WorkBuffer
466 /// {
467 /// UT_AutoJSONWriter w(buffer);
468 /// return save(w);
469 /// }
470 /// bool save(UT_JSONValue &value) // Save to a UT_JSONValue
471 /// {
472 /// UT_AutoJSONWriter w(value);
473 /// return save(w);
474 /// }
475 /// @endcode
477 {
478 public:
479  /// Write directly to the UT_WorkBuffer
481  : myWriter(UT_JSONWriter::allocWriter(b))
482  {
483  }
484  /// Write to the given ostream (binary and optionally gzipped)
485  UT_AutoJSONWriter(std::ostream &os,
486  bool binary,
487  UT_CompressionType compressionType = UT_COMPRESSION_TYPE_NONE )
488  : myWriter(UT_JSONWriter::allocWriter(os, binary, compressionType))
489  {
490  }
491  /// Write to the given filename (binary and optionally gzipped)
492  UT_AutoJSONWriter(const char *filename,
493  bool binary,
495  : myWriter(UT_JSONWriter::allocWriter(filename, binary, compressionType))
496  {
497  }
498  /// Write directly to the UT_JSONValue
500  : myWriter(UT_JSONWriter::allocWriter(value))
501  {
502  }
504  {
505  delete myWriter;
506  }
507 
508  /// @{
509  /// Access to the writer
510  UT_JSONWriter &writer() const { return *myWriter; }
511  UT_JSONWriter &operator*() const { return *myWriter; }
512  UT_JSONWriter *operator->() const { return myWriter; }
513  /// @}
514 
515  /// Allow implicit casting between an auto-writer and the underlying writer
516  operator UT_JSONWriter &() { return *myWriter; }
517 
518  /// Close the stream (causing all data to be flushed)
519  void close()
520  {
521  delete myWriter;
522  myWriter = NULL;
523  }
524 private:
525  UT_JSONWriter *myWriter;
526 };
527 
528 #endif
UT_JSONWriter & operator*() const
The following byte represents an 8 bit integer.
bool jsonValue(bool value)
UT_AutoJSONWriter(const char *filename, bool binary, UT_CompressionType compressionType=UT_COMPRESSION_TYPE_NONE)
Write to the given filename (binary and optionally gzipped)
static UT_JID jidFromValue(const fpreal32 *)
static UT_JID jidFromValue(const int64 *)
No data follows the NULL token.
int64 getNumBytesWritten() const
Get the number of bytes written to output so far.
Definition: UT_JSONWriter.h:90
UT_AutoJSONWriter(UT_WorkBuffer &b)
Write directly to the UT_WorkBuffer.
The following 4 bytes represent an 32 bit real (float)
bool jsonKeyToken(const char *value, int64 length)
UT_JID
The UT_JID enums are used in byte-stream encoding of binary JSON.
static UT_JID jidFromValue(const bool *)
Returns the JID that matches the given type.
bool getBinary() const
Return whether writing binary or ASCII JSON.
Definition: UT_JSONWriter.h:87
void writeData(std::ostream &os, const T *data, Index count, uint32_t compression)
Definition: Compression.h:255
bool jsonValue(int32 value)
0x23 and 0x24 are reserved for future use (32/64 bit unsigned)
const GLuint GLenum const void * binary
Definition: glcorearb.h:1923
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1221
The following byte represents an unsigned 8 bit integer.
#define UT_API
Definition: UT_API.h:12
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
bool jsonValue(fpreal16 value)
UT_JSONWriter & writer() const
bool jsonUniformArray(const UT_Int32Array &a)
GLuint buffer
Definition: glcorearb.h:659
png_uint_32 i
Definition: png.h:2877
exint size() const
Definition: UT_Array.h:444
signed char int8
Definition: SYS_Types.h:30
The following 8 bytes represent an 64 bit real (float)
The following 8 bytes represent an 64 bit integer.
long long int64
Definition: SYS_Types.h:106
The following 2 bytes represent an 16 bit integer.
static UT_JID jidFromValue(const fpreal64 *)
void writeString(std::ostream &os, const Name &name)
Definition: Name.h:58
int64 exint
Definition: SYS_Types.h:115
UT_AutoJSONWriter(UT_JSONValue &value)
Write directly to the UT_JSONValue.
static UT_JID jidFromValue(const fpreal16 *)
double fpreal64
Definition: SYS_Types.h:191
#define SYS_PRINTF_CHECK_ATTRIBUTE(string_index, first_to_check)
Definition: SYS_Types.h:425
bool jsonValue(int16 value)
GLboolean * data
Definition: glcorearb.h:130
int int32
Definition: SYS_Types.h:34
The following 4 bytes represent an 32 bit integer.
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
void fastReferenceWithStrlen(const char *src, exint length)
GLint GLsizei count
Definition: glcorearb.h:404
bool jsonUniformArray(const UT_Int16Array &a)
bool jsonUniformArray(const UT_Int64Array &a)
GLenum GLint GLint * precision
Definition: glcorearb.h:1924
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:107
unsigned short uint16
Definition: SYS_Types.h:33
GLsizei const GLfloat * value
Definition: glcorearb.h:823
bool jsonUniformArray(const UT_Fpreal32Array &a)
A map of string to various well defined value types.
Definition: UT_Options.h:42
static UT_JID jidFromValue(const int8 *)
static UT_JID jidFromValue(const uint16 *)
unsigned char uint8
Definition: SYS_Types.h:31
UT_CompressionType
T * data()
Definition: UT_Array.h:610
virtual void close()
static UT_JID jidFromValue(const uint8 *)
bool jsonValue(int8 value)
UT_AutoJSONWriter(std::ostream &os, bool binary, UT_CompressionType compressionType=UT_COMPRESSION_TYPE_NONE)
Write to the given ostream (binary and optionally gzipped)
Class to store JSON objects as C++ objects.
Definition: UT_JSONValue.h:75
UT_JSONWriter * operator->() const
void reference(const char *src)
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
bool jsonValue(int64 value)
int getNesting() const
Get the nesting level (i.e. how deeply nested in maps/arrays)
png_infop png_uint_32 int num
Definition: png.h:2158
static UT_JID jidFromValue(const int32 *)
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
bool jsonUniformArray(const UT_Fpreal64Array &a)
#define const
Definition: zconf.h:214
short int16
Definition: SYS_Types.h:32
bool jsonValue(fpreal64 value)
void write(T &out, bool v)
Definition: ImfXdr.h:332
The following 2 bytes represents an unsigned 16 bit integer.
void close()
Close the stream (causing all data to be flushed)
bool jsonValue(fpreal32 value)
static UT_JID jidFromValue(const int16 *)
float fpreal32
Definition: SYS_Types.h:190
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:794
unsigned int uint32
Definition: SYS_Types.h:35