HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 <iosfwd>
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  bool jsonRealPreserveType(fpreal16 value);
118  /// Write a 32 bit real
119  bool jsonReal(fpreal32 value);
120  bool jsonRealPreserveType(fpreal32 value);
121  /// Write a 64 bit real
122  bool jsonReal(fpreal64 value);
123  bool jsonRealPreserveType(fpreal64 value);
124  /// Write a quoted string.
125  /// @warning Please use jsonKey() to write key strings.
126  /// @note Use jsonStringToken() to take advantage of token compression
127  /// (this can be turned off with the @c usetokens option in the
128  /// constructor).
129  /// @see UT_JID
130  bool jsonString(const char *value, int64 length=0);
131 
132  /// For binary streams, common strings can be output more efficiently using
133  /// the token interface. Token strings will appear as strings in ASCII
134  /// streams.
135  bool jsonStringToken(const UT_StringRef &value);
136  bool jsonStringToken(const char *value, int64 length)
137  {
139  if (length <= 0)
140  result.reference(value);
141  else
142  result.fastReferenceWithStrlen(value, length);
143  return jsonStringToken(result);
144  }
145 
146  /// @{
147  /// Write a standard JSON value to the stream. Overloaded method to allow
148  /// convenient use in templated code.
149  bool jsonValue(bool value) { return jsonBool(value); }
150  bool jsonValue(int8 value) { return jsonInt((int32)value); }
151  bool jsonValue(int16 value) { return jsonInt((int32)value); }
152  bool jsonValue(int32 value) { return jsonInt(value); }
153  bool jsonValue(int64 value) { return jsonInt(value); }
154  bool jsonValue(fpreal16 value) { return jsonReal(value); }
155  bool jsonValue(fpreal32 value) { return jsonReal(value); }
156  bool jsonValue(fpreal64 value) { return jsonReal(value); }
157  bool jsonValue(const char *v) { return jsonStringToken(v); }
158  bool jsonValue(const UT_String &v)
159  { return jsonStringToken(v.c_str(), v.length()); }
160  bool jsonValue(const std::string &v)
161  { return jsonStringToken(v.c_str(), v.length()); }
162  bool jsonValue(const UT_StringRef &v) { return jsonStringToken(v); }
163  bool jsonValue(const UT_Int16Array &v)
164  { return jsonUniformArray(v); }
165  bool jsonValue(const UT_Int32Array &v)
166  { return jsonUniformArray(v); }
167  bool jsonValue(const UT_Int64Array &v)
168  { return jsonUniformArray(v); }
170  { return jsonUniformArray(v); }
172  { return jsonUniformArray(v); }
174  { return jsonStringTokenArray(v); }
175  bool jsonValue(const UT_JSONValue &v);
176  /// @}
177 
178  /// Begin a map/object dictionary
179  bool jsonBeginMap();
180  /// Write a quoted key for the object
181  /// @note Use jsonKeyToken() to take advantage of token compression
182  /// (this can be turned off with the @c usetokens option in the
183  /// constructor).
184  /// @see UT_JID
185  bool jsonKey(const char *value, int64 length=0);
186  /// For binary streams, common key strings can be output more efficiently
187  /// using the token interface. Token key strings will appear as strings in
188  /// ASCII streams.
189  bool jsonKeyToken(const UT_StringRef &value);
190  bool jsonKeyToken(const char *value, int64 length)
191  {
193  if (length <= 0)
194  result.reference(value);
195  else
196  result.fastReferenceWithStrlen(value, length);
197  return jsonKeyToken(result);
198  }
199 
200  /// @{
201  /// Convenience method to write the key/value pair to a map
202  template <typename T> SYS_FORCE_INLINE bool
203  jsonKeyValue(const UT_StringRef &key, const T &value)
204  {
205  bool ok = jsonKeyToken(key);
206  return ok && jsonValue(value);
207  }
208 
209  template <typename T> SYS_FORCE_INLINE bool
210  jsonKeyTokenValue(const UT_StringRef &key, const T &value)
211  {
212  bool ok = jsonKeyToken(key);
213  return ok && jsonValue(value);
214  }
215  /// @}
216 
217  /// End the object
218  bool jsonEndMap();
219 
220  /// Begin a generic array object
221  bool jsonBeginArray();
222  /// End a generic array object
223  /// By default, a new line will be output for pretty printing. The newline
224  /// can give a hint to omit the new line before the end of the array
225  /// marker.
226  bool jsonEndArray(bool newline=true);
227 
228  /// When writing binary JSON files, uniform arrays can be encoded without
229  /// repetition of the type information which results in a more compressed
230  /// data format.
231  ///
232  /// @c beingUniformArray() starts a uniform array.
233  /// The @c id should be one of:
234  /// - UT_JID_BOOL
235  /// - UT_JID_INT8
236  /// - UT_JID_INT16
237  /// - UT_JID_INT32
238  /// - UT_JID_INT64
239  /// - UT_JID_UINT8
240  /// - UT_JID_UINT16
241  /// - UT_JID_REAL16
242  /// - UT_JID_REAL32
243  /// - UT_JID_REAL64
244  /// - UT_JID_STRING
245  bool beginUniformArray(int64 length, UT_JID id);
246  /// Write a bool value to a uniform array. The bool values are packed into
247  /// a bit array (where each 32-bit word stores 32 bits).
248  bool uniformWrite(bool value);
249  /// Write an 8 bit integer value to the uniform array
250  bool uniformWrite(int8 value);
251  /// Write an 16 bit integer value to the uniform array
252  bool uniformWrite(int16 value);
253  /// Write an 32 bit integer value to the uniform array
254  bool uniformWrite(int32 value);
255  /// Write an 64 bit integer value to the uniform array
256  bool uniformWrite(int64 value);
257  /// Write an 16 bit float/real value to the uniform array
258  bool uniformWrite(fpreal16 value);
259  /// Write an 32 bit float/real value to the uniform array
260  bool uniformWrite(fpreal32 value);
261  /// Write an 64 bit float/real value to the uniform array
262  bool uniformWrite(fpreal64 value);
263  /// Write an 8 bit unsigned integer value to the uniform array
264  bool uniformWrite(uint8 value);
265  /// Write an 16 bit unsigned integer value to the uniform array
266  bool uniformWrite(uint16 value);
267  /// Write a string to the uniform array
268  bool uniformWrite(const char *value, int64 length=0);
269  /// Write a block of 8 bit integer values to the uniform array
270  bool uniformBlockWrite(const int8 *value, int64 count);
271  /// Write a block of 16 bit integer values to the uniform array
272  bool uniformBlockWrite(const int16 *value, int64 count);
273  /// Write a block of 32 bit integer values to the uniform array
274  bool uniformBlockWrite(const int32 *value, int64 count);
275  /// Write a block of 64 bit integer values to the uniform array
276  bool uniformBlockWrite(const int64 *value, int64 count);
277  /// Write a block of 16 bit float/real values to the uniform array
278  bool uniformBlockWrite(const fpreal16 *value, int64 count);
279  /// Write a block of 32 bit float/real values to the uniform array
280  bool uniformBlockWrite(const fpreal32 *value, int64 count);
281  /// Write a block of 64 bit float/real values to the uniform array
282  bool uniformBlockWrite(const fpreal64 *value, int64 count);
283  /// Write a block of 8 bit unsigned integer values to the uniform array
284  bool uniformBlockWrite(const uint8 *value, int64 count);
285  /// Write a block of 16 bit unsigned integer values to the uniform array
286  bool uniformBlockWrite(const uint16 *value, int64 count);
287  /// End the uniform array.
288  /// @param nwritten @n
289  /// If provided, the number of items written is returned.
290  /// @note The JSONWriter class will automatically clamp or fill the uniform
291  /// array with 0, but nwritten will return the actual number of calls to
292  /// uniformWrite().
293  bool endUniformArray(int64 *nwritten=0);
294 
295  /// Internally called to write raw data to output.
296  virtual bool writeData(const void *data, int64 bytes);
297 
298  /// Returns the JID that matches the given type.
299  static UT_JID jidFromValue(const bool *) { return UT_JID_BOOL; }
300  static UT_JID jidFromValue(const int8 *) { return UT_JID_INT8; }
301  static UT_JID jidFromValue(const int16 *) { return UT_JID_INT16; }
302  static UT_JID jidFromValue(const int32 *) { return UT_JID_INT32; }
303  static UT_JID jidFromValue(const int64 *) { return UT_JID_INT64; }
304  static UT_JID jidFromValue(const fpreal16 *) { return UT_JID_REAL16; }
305  static UT_JID jidFromValue(const fpreal32 *) { return UT_JID_REAL32; }
306  static UT_JID jidFromValue(const fpreal64 *) { return UT_JID_REAL64; }
307  static UT_JID jidFromValue(const uint8 *) { return UT_JID_UINT8; }
308  static UT_JID jidFromValue(const uint16 *) { return UT_JID_UINT16; }
309 
310  /// Efficent method of writing a uniform array of int8 values
311  bool jsonUniformArray(int64 length, const int8 *value);
312  /// Efficent method of writing a uniform array of int16 values
313  bool jsonUniformArray(int64 length, const int16 *value);
314  /// Efficent method of writing a uniform array of int32 values
315  bool jsonUniformArray(int64 length, const int32 *value);
316  /// Efficent method of writing a uniform array of int64 values
317  bool jsonUniformArray(int64 length, const int64 *value);
318  /// Efficent method of writing a uniform array of fpreal16 values
319  bool jsonUniformArray(int64 length, const fpreal16 *value);
320  /// Efficent method of writing a uniform array of fpreal32 values
321  bool jsonUniformArray(int64 length, const fpreal32 *value);
322  /// Efficent method of writing a uniform array of fpreal64 values
323  bool jsonUniformArray(int64 length, const fpreal64 *value);
324 
325  /// Efficent method of writing a uniform array of uint8 values
326  bool jsonUniformArray(int64 length, const uint8 *value);
327  /// Efficent method of writing a uniform array of uint16 values
328  bool jsonUniformArray(int64 length, const uint16 *value);
329 
330  /// Efficient method of writing a uniform array of bool values
331  bool jsonUniformArray(int64 length, const UT_BitArray &value,
332  bool verbose_ascii = false);
333 
334  /// @{
335  /// Convenience method for saving common array types
337  { return jsonUniformArray(a.size(), a.data()); }
339  { return jsonUniformArray(a.size(), a.data()); }
341  { return jsonUniformArray(a.size(), a.data()); }
343  { return jsonUniformArray(a.size(), a.data()); }
345  { return jsonUniformArray(a.size(), a.data()); }
346  /// @}
347 
348  /// Convenience method to save an array of strings
349  bool jsonStringArray(const UT_StringArray &a);
350  /// Convenience method to save an array of strings (as tokens)
351  bool jsonStringTokenArray(const UT_StringArray &a);
352 
353  /// A TiledStream allows you to write a blob of binary data to a JSON
354  /// stream in an efficient manner. The data is buffered into uniform
355  /// arrays which are output into a standard JSON array. The resulting data
356  /// looks something like: @code
357  /// [ {options} tile1-data tile2-data ]
358  /// @endcode
359  /// The tile-data is written as JSON string objects. You can read these
360  /// yourself, or use the TiledStream in UT_JSONParser.
361  ///
362  /// You should never write to the JSONWriter while the TiledStream is open.
363  ///
364  /// An example of using this might be something like: @code
365  /// bool storeStream(UT_IStream &is)
366  /// {
367  /// UT_JSONWriter::TiledStream os(writer);
368  /// char buffer[128];
369  /// int nread;
370  /// while ((nread = is.bread(buffer, 128)) > 0)
371  /// if (!os.write(buffer, nread)) return false;
372  /// return true;
373  /// }
374  /// @endcode
375  class UT_API TiledStreamBuf : public std::streambuf
376  {
377  public:
379  virtual ~TiledStreamBuf();
380 
381  protected:
382  // write one character
383  virtual int_type overflow(int_type c);
384 
385  // write multiple characters
386  virtual std::streamsize xsputn (const char* s, std::streamsize num);
387 
388  private:
389  bool write(const void *data, exint bytes);
390  void close();
391 
392  bool writeTile(const char *data, exint bytes);
393  bool flush();
394  UT_JSONWriter &myWriter;
395  char *myBuffer;
396  exint myLength;
397  };
398 
399  class UT_API TiledStream : public std::ostream
400  {
401  public:
403  virtual ~TiledStream();
404 
405  private:
406  TiledStreamBuf myBuf;
407  };
408 
409 protected:
410  /// The sub-class must implement this method to write data
411  virtual bool subclassWriteData(const void* data, int64 bytes) = 0;
412 
413 protected:
414  /// Get the nesting level (i.e. how deeply nested in maps/arrays)
415  int getNesting() const { return myStack.entries(); }
416 private:
417  int precision16() const { return (myPrecision+1)/2; }
418  int precision32() const { return myPrecision; }
419  int precision64() const { return myPrecision*2; }
420  /// @private: ASCII indent
421  bool indent();
422  /// @private: ASCII prefix
423  bool prefix();
424  /// @private: Convenience method to write a UT_JID
425  bool writeId(UT_JID id);
426  /// @private: Convenience method to write an encoded length @see UT_JID
427  bool writeLength(int64 length);
428  /// @private: Write a token string
429  bool writeTokenString(const UT_StringRef &str);
430  /// @private: Write a string of data (not quoted)
431  bool writeString(const char *str, int64 bytes=0);
432  /// @private: Write a quoted string
433  bool quotedString(const char *str, int64 bytes=0);
434  /// @private: Write an ASCII "bool" value
435  bool writeAB(bool i);
436  /// @private: Write an ASCII "integer" value
437  bool writeAI(int64 i);
438  /// @private: Write an ASCII "float" value
439  bool writeAF(fpreal64 i, int precision);
440  /// @private: Write an ASCII "float" value and ensure it has a decimal point
441  bool writeAFPreserveType(fpreal64, int precision);
442  /// @private: Start an array (possibly uniform encoding)
443  bool startArray(UT_JID id, UT_JID type=UT_JID_NULL);
444  /// @private: Finish array
445  bool finishArray(UT_JID id, bool newline=true);
446  /// @private: Flush bits for a uniform array of bools
447  bool flushBits();
448  /// @private: Push nesting of map/array
449  void pushState(UT_JID id);
450  /// @private: Pop state
451  void popState(UT_JID id);
452  /// @private: Set the prefix for ASCII encoding
453  void setPrefix();
454  /// @private: Build indent string
455  void bumpIndent(int dir);
456  /// @private: New line & indent
457  bool newLine(bool force=false);
458 
459  /// Method to detail with long lines in ASCII files
460  bool countAndWrite(const void *data, int64 bytes);
461 
462  template <typename T> bool
463  uniformArrayI(UT_JID id, int64 length, const T *data);
464  template <typename T> bool
465  uniformArrayF(UT_JID id, int64 length, const T *data);
466  template <typename T> bool
467  uniformBlockWriteImplI(const T *data, int64 count);
468  template <typename T> bool
469  uniformBlockWriteImplF(const T *data, int64 count, int prec);
470 
471  enum
472  {
473  PREFIX_FIRST, // First element (no prefix)
474  PREFIX_ARRAY, // Use array prefix
475  PREFIX_MAP, // Use object prefix
476  };
477 
478  UT_IntArray myStack;
479  UT_WorkBuffer myIndentString;
480  UT_StringMap<int64> myTokens;
481  UT_Int64Array myTokenCountStack;
482  char *myASeparator; // Array separator string
483  char *myKSeparator; // Keyword separator string
484  int64 myCurrentFilePosition;
485  int64 myUWriteSize; // Uniform write size
486  int64 myUWriteCount; // Uniform entities written
487  int64 myTokenCount;
488  UT_JID myUniform; // Type of data for fixed array
489  uint32 myBitValue; // For packing bit arrays
490  int myBitCount;
491  int myPrefix;
492  int myPrecision; // ASCII float precision
493  int myIndent; // ASCII indent level
494  int myIndentStep; // ASCII indent step
495  int myTextWidth; // ASCII max line length
496  int myLineLength; // ASCII line length
497  bool myBinary; // ASCII or binary
498  bool myTokenStrings; // Use token strings
499  bool myComments; // Emit comments
500  bool myPrettyPrint; // Pretty print
501  bool myNewLine; // For line wrapping
502  bool myJoinNext;
503 };
504 
505 /// Convenience class to allocate a writer which is automatically deleted
506 /// For example: @code
507 /// bool save(UT_JSONWriter &w) { ... } // Method to save to standard writer
508 ///
509 /// bool save(UT_WorkBuffer &buffer) // Save to a UT_WorkBuffer
510 /// {
511 /// UT_AutoJSONWriter w(buffer);
512 /// return save(w);
513 /// }
514 /// bool save(UT_JSONValue &value) // Save to a UT_JSONValue
515 /// {
516 /// UT_AutoJSONWriter w(value);
517 /// return save(w);
518 /// }
519 /// @endcode
521 {
522 public:
523  /// Write directly to the UT_WorkBuffer
525  : myWriter(UT_JSONWriter::allocWriter(b))
526  {
527  }
528  /// Write to the given ostream (binary and optionally gzipped)
529  UT_AutoJSONWriter(std::ostream &os,
530  bool binary,
531  UT_CompressionType compressionType = UT_COMPRESSION_TYPE_NONE )
532  : myWriter(UT_JSONWriter::allocWriter(os, binary, compressionType))
533  {
534  }
535  /// Write to the given filename (binary and optionally gzipped)
536  UT_AutoJSONWriter(const char *filename,
537  bool binary,
539  : myWriter(UT_JSONWriter::allocWriter(filename, binary, compressionType))
540  {
541  }
542  /// Write directly to the UT_JSONValue
544  : myWriter(UT_JSONWriter::allocWriter(value))
545  {
546  }
548  {
549  delete myWriter;
550  }
551 
552  /// @{
553  /// Access to the writer
554  UT_JSONWriter &writer() const { return *myWriter; }
555  UT_JSONWriter &operator*() const { return *myWriter; }
556  UT_JSONWriter *operator->() const { return myWriter; }
557  /// @}
558 
559  /// Allow implicit casting between an auto-writer and the underlying writer
560  operator UT_JSONWriter &() { return *myWriter; }
561 
562  /// Close the stream (causing all data to be flushed)
563  void close()
564  {
565  delete myWriter;
566  myWriter = NULL;
567  }
568 private:
569  UT_JSONWriter *myWriter;
570 };
571 
572 #endif
GLdouble s
Definition: glew.h:1390
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.
GT_API const UT_StringHolder filename
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:390
bool jsonValue(int32 value)
unsigned length(void) const
Return length of string.
Definition: UT_String.h:539
0x23 and 0x24 are reserved for future use (32/64 bit unsigned)
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:9477
The following byte represents an unsigned 8 bit integer.
#define UT_API
Definition: UT_API.h:13
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
const GLdouble * v
Definition: glew.h:1391
bool jsonValue(fpreal16 value)
UT_JSONWriter & writer() const
bool jsonValue(const UT_String &v)
bool jsonUniformArray(const UT_Int32Array &a)
exint size() const
Definition: UT_Array.h:451
const char * c_str() const
Definition: UT_String.h:502
bool jsonValue(const char *v)
signed char int8
Definition: SYS_Types.h:35
The following 8 bytes represent an 64 bit real (float)
The following 8 bytes represent an 64 bit integer.
bool jsonValue(const UT_Fpreal32Array &v)
bool jsonValue(const UT_StringRef &v)
long long int64
Definition: SYS_Types.h:111
The following 2 bytes represent an 16 bit integer.
static UT_JID jidFromValue(const fpreal64 *)
SYS_FORCE_INLINE bool jsonKeyTokenValue(const UT_StringRef &key, const T &value)
void writeString(std::ostream &os, const Name &name)
Definition: Name.h:58
int64 exint
Definition: SYS_Types.h:120
GLuint buffer
Definition: glew.h:1680
UT_AutoJSONWriter(UT_JSONValue &value)
Write directly to the UT_JSONValue.
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
const GLuint GLenum const void * binary
Definition: glew.h:3502
static UT_JID jidFromValue(const fpreal16 *)
double fpreal64
Definition: SYS_Types.h:196
#define SYS_PRINTF_CHECK_ATTRIBUTE(string_index, first_to_check)
Definition: SYS_Types.h:432
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1890
bool jsonValue(int16 value)
const GLfloat * c
Definition: glew.h:16296
GLuint GLsizei GLsizei * length
Definition: glew.h:1825
int int32
Definition: SYS_Types.h:39
The following 4 bytes represent an 32 bit integer.
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
void fastReferenceWithStrlen(const char *src, exint length)
bool jsonUniformArray(const UT_Int16Array &a)
bool jsonValue(const UT_Int16Array &v)
bool jsonUniformArray(const UT_Int64Array &a)
GLdouble GLdouble GLdouble b
Definition: glew.h:9122
GLsizei const GLchar *const * string
Definition: glew.h:1844
unsigned short uint16
Definition: SYS_Types.h:38
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 *)
bool jsonValue(const std::string &v)
GLuint num
Definition: glew.h:2690
unsigned char uint8
Definition: SYS_Types.h:36
UT_CompressionType
T * data()
Definition: UT_Array.h:625
virtual void close()
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: glew.h:1254
SYS_FORCE_INLINE bool jsonKeyValue(const UT_StringRef &key, const T &value)
GLuint GLuint GLsizei count
Definition: glew.h:1253
static UT_JID jidFromValue(const uint8 *)
bool jsonValue(int8 value)
bool jsonValue(const UT_Int32Array &v)
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:76
UT_JSONWriter * operator->() const
void reference(const char *src)
bool jsonValue(int64 value)
GLuint64EXT * result
Definition: glew.h:14007
int getNesting() const
Get the nesting level (i.e. how deeply nested in maps/arrays)
static UT_JID jidFromValue(const int32 *)
bool jsonUniformArray(const UT_Fpreal64Array &a)
#define const
Definition: zconf.h:214
bool jsonValue(const UT_Fpreal64Array &v)
short int16
Definition: SYS_Types.h:37
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 *)
GLenum GLint GLint * precision
Definition: glew.h:3500
GLsizei const GLfloat * value
Definition: glew.h:1849
float fpreal32
Definition: SYS_Types.h:195
bool jsonValue(const UT_StringArray &v)
unsigned int uint32
Definition: SYS_Types.h:40
bool jsonValue(const UT_Int64Array &v)