HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_IOJSON.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: GA_IOJSON.h ( GA Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GA_IOJSON__
12 #define __GA_IOJSON__
13 
14 #include "GA_API.h"
15 #include "GA_IO.h"
16 
17 #include <SYS/SYS_Types.h>
18 
19 #include <iosfwd>
20 
21 
22 class GA_Detail;
23 class GA_LoadMap;
24 class GA_SaveMap;
25 class GA_Stat;
26 
27 class UT_IStream;
28 class UT_JSONParser;
29 class UT_JSONWriter;
30 class UT_Options;
31 class UT_StringArray;
32 class GA_LoadOptions;
33 class GA_SaveOptions;
34 
35 
36 /// @brief JSON I/O of geometry objects
37 class GA_API GA_IOJSON : public GA_IO
38 {
39 public:
40  GA_IOJSON();
41  ~GA_IOJSON() override;
42 
43  /// @{
44  /// Methods required to implement GA_IO interface
45  const char *getToken() const override;
46  const char *getLabel() const override;
47  bool checkFilename(const char *filename,
48  const GA_SaveOptions *opts) const override;
49  bool checkFilename(const char *filename,
50  const GA_LoadOptions *opts) const override;
51  bool checkByteMagic(uint8 first_byte,
52  const GA_LoadOptions *opts) const override;
53  bool statStream(UT_IStream &is,
54  GA_Stat &stat, uint stat_level) const override;
55  bool readStream(GA_Detail &g,
56  UT_IStream &is,
57  const GA_LoadOptions *opts,
58  UT_StringArray *errors) const override;
59  bool writeFile(const GA_Detail &g,
60  const char *filename,
61  const GA_SaveOptions *opts,
62  UT_StringArray *errors) const override;
63  bool writeStream(const GA_Detail &g,
64  std::ostream &os,
65  bool binary,
66  const GA_SaveOptions *opts,
67  UT_StringArray *errors) const override;
68  /// @}
69 
70  /// Stat geometry from a JSON stream
71  bool statJSON(UT_JSONParser &p,
72  GA_Stat &stat,
73  uint level) const;
74 
75  /// Read geometry from a JSON stream
76  bool readJSON(GA_Detail &g,
77  UT_JSONParser &p,
78  const GA_LoadOptions *options) const;
79  /// Write geometry to a JSON stream
80  bool writeJSON(const GA_Detail &g,
82  const GA_SaveOptions *options) const;
83 
84  /// Check whether filename uses BLOSC compression
85  static bool isScExtension(const char *filename);
86  /// Check whether filename uses GZIP compression
87  static bool isGzExtension(const char *filename);
88 
89 protected:
90  /// @{
91  /// Configuration from GA_IO
92  bool readCheckStdin() const override { return true; }
93  bool readCheckCompressed() const override { return true; }
94  bool writeCheckStdout() const override { return true; }
95  /// @}
96 
97 
98  /// When the JSON loader hits a token it doesn't understand, it will call
99  /// this method. This allows sub-classes to load extra fields.
100  virtual bool jsonLoadExtra(GA_Detail &gdp,
101  UT_JSONParser &p,
102  const char *token,
103  const GA_LoadMap &loadmap) const;
104 
105  /// The jsonSaveExtra method is called during writing. This allows
106  /// sub-classes to save additional information into the JSON stream.
107  virtual bool jsonSaveExtra(const GA_Detail &gdp,
108  UT_JSONWriter &w,
109  const GA_SaveMap &savemap) const;
110 
111  /// When the JSON loader finishes, it will call this method. This allows
112  /// sub-classes to perform any post-load processing.
113  virtual bool finishLoad(GA_Detail &gdp,
114  const GA_LoadMap &) const;
115 };
116 
117 #endif
GT_API const UT_StringHolder filename
Used to pass options and map offset values during saving.
Definition: GA_SaveMap.h:48
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
GLboolean GLboolean g
Definition: glcorearb.h:1222
GLint level
Definition: glcorearb.h:108
virtual bool writeStream(const GA_Detail &g, std::ostream &os, bool binary, const GA_SaveOptions *opts, UT_StringArray *errors) const =0
Write geometry to an output stream.
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:87
#define GA_API
Definition: GA_API.h:14
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
unsigned char uint8
Definition: SYS_Types.h:36
bool readCheckCompressed() const override
Definition: GA_IOJSON.h:93
bool writeCheckStdout() const override
Definition: GA_IOJSON.h:94
Options during loading.
Definition: GA_LoadMap.h:42
JSON I/O of geometry objects.
Definition: GA_IOJSON.h:37
SYS_FORCE_INLINE UT_StringHolder getToken(Add enum_value)
Definition: SOP_Add.proto.h:35
virtual bool writeFile(const GA_Detail &g, const char *filename, const GA_SaveOptions *opts, UT_StringArray *errors) const
virtual bool readStream(GA_Detail &g, UT_IStream &is, const GA_LoadOptions *opts, UT_StringArray *errors) const =0
Load geometry from an input stream.
A map of string to various well defined value types.
Definition: UT_Options.h:84
Class to return information about a GA_Detail.
Definition: GA_Stat.h:50
Container class for all geometry.
Definition: GA_Detail.h:96
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
Class to specify options for loading geometry.
unsigned int uint
Definition: SYS_Types.h:45
bool readCheckStdin() const override
Definition: GA_IOJSON.h:92