HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_PrimitiveJSONExtend.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_PrimitiveJSONExtend.h ( GA Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GA_PrimitiveJSONExtend__
12 #define __GA_PrimitiveJSONExtend__
13 
14 #include "GA_API.h"
15 #include "GA_PrimitiveJSON.h"
16 
17 
18 class GA_LoadMap;
19 class GA_Primitive;
20 class GA_SaveMap;
21 
22 class UT_JSONParser;
23 class UT_JSONValue;
24 class UT_JSONWriter;
25 
26 
27 /// Class which extends an existing JSON schema
29 {
30 public:
32  ~GA_PrimitiveJSONExtend() override;
33 
34  /// @{
35  /// Methods implemented from base GA_PrimitiveJSON. These methods are all
36  /// implemented as: @code
37  /// if (isBase(i))
38  /// myBase->method(i, ...);
39  /// else
40  /// localMethod(getLocal(i), ...);
41  /// @endcode
42  /// Return the number of data fields in the primitive private schema
43  int getEntries() const override;
44  const UT_StringHolder &getKeyword(int i) const override;
45  bool saveField(const GA_Primitive *prim, int i,
47  const GA_SaveMap &map) const override;
48  bool saveField(const GA_Primitive *prim, int i,
50  const GA_SaveMap &map) const override;
51  bool loadField(GA_Primitive *prim, int i,
52  UT_JSONParser &p,
53  const GA_LoadMap &map) const override;
54  bool loadField(GA_Primitive *prim, int i,
55  UT_JSONParser &p, const UT_JSONValue &value,
56  const GA_LoadMap &map) const override;
57  bool isEqual(int i,
58  const GA_Primitive *prim1,
59  const GA_Primitive *prim2) const override;
60  /// @}
61 
62  /// @{
63  /// The local methods return information about the local schema (i.e. the
64  /// extending schema. All indices (@c i) are 0 based.
65  virtual int localEntries() const = 0;
66  virtual const UT_StringHolder &localKeyword(int i) const = 0;
67  virtual bool localSave(const GA_Primitive *prim, int i,
68  UT_JSONWriter &w,
69  const GA_SaveMap &map) const = 0;
70  virtual bool localSave(const GA_Primitive *prim, int i,
71  UT_JSONValue &value,
72  const GA_SaveMap &map) const = 0;
73  virtual bool localLoad(GA_Primitive *prim, int i,
74  UT_JSONParser &p,
75  const GA_LoadMap &map) const = 0;
76  virtual bool localLoad(GA_Primitive *prim, int i,
77  UT_JSONParser &p, const UT_JSONValue &value,
78  const GA_LoadMap &map) const = 0;
79  virtual bool localIsEqual(int i,
80  const GA_Primitive *prim1,
81  const GA_Primitive *prim2) const = 0;
82  /// @}
83 
84 protected:
85  bool isBase(int i) const { return i < myBaseEntries; }
86  int getLocal(int i) const { return i - myBaseEntries; }
87 
90 };
91 
92 #endif
const GA_PrimitiveJSON * myBase
Used to pass options and map offset values during saving.
Definition: GA_SaveMap.h:48
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
virtual bool isEqual(int i, const GA_Primitive *prim1, const GA_Primitive *prim2) const =0
virtual bool loadField(GA_Primitive *prim, int i, UT_JSONParser &p, const GA_LoadMap &load) const =0
Provide a JSON interface to a primitive.
Options during loading.
Definition: GA_LoadMap.h:42
Class which extends an existing JSON schema.
virtual bool saveField(const GA_Primitive *prim, int i, UT_JSONWriter &w, const GA_SaveMap &save) const =0
Class to store JSON objects as C++ objects.
Definition: UT_JSONValue.h:99
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
Definition: core.h:1131
virtual int getEntries() const =0
Return the number of data fields in the primitive private schema.
virtual const UT_StringHolder & getKeyword(int i) const =0