HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDG_AttributeDictionary.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  * COMMENTS:
7  */
8 
9 #ifndef __PDG_ATTRIBUTE_DICT_H__
10 #define __PDG_ATTRIBUTE_DICT_H__
11 
12 #include "PDG_API.h"
13 
14 #include "PDG_AttributeArray.h"
15 
16 #include <UT/UT_Options.h>
17 #include <UT/UT_StringArray.h>
18 #include <UT/UT_WorkBuffer.h>
19 
20 class PDG_AttributeQuery;
21 class PDG_AttributeMap;
23 
24 class UT_JSONValue;
25 class UT_JSONWriter;
26 class UT_WorkBuffer;
27 
28 /**
29  * Dictionary attribute type
30  */
32  PDG_AttributeType::eDictArray,
33  UT_OptionsHolder,
34  UT_Array<UT_OptionsHolder>>
35 {
36 public:
37  using Base = PDG_AttributeArray<
41  using Base::Base;
42  using Base::values;
43  using Base::appendValue;
44  using Base::setValue;
45 
46 public:
47  ~PDG_AttributeDictionary() override;
48 
49  /// Returns the total memory usage of all data on this attribute
50  int64 getMemoryUsage(bool inclusive) const override;
51 
52  /// Constructs a new dictionary attribute that copies the data from this
53  /// attribute
54  PDG_AttributeData* clone() const override;
55 
56 
57  /// Writes the dictionary data to the json writer
58  bool saveData(UT_JSONWriter& writer) const override;
59 
60  /// Writes the dictionary data to the json writer
61  void saveData(
62  const UT_StringHolder& key,
63  UT_OptionsHolder& dict) const override;
64 
65  /// Reads the dictionary data from the json value
66  bool loadData(const UT_JSONValue& value) override;
67 
68  /// Reads the dictionary data from the dict
69  bool loadData(
70  const UT_StringHolder& key,
71  const UT_OptionsHolder& dict) override;
72 
73 
74  /// Writes a string representation of the dictionaries to the buffer
75  bool desc(
77  bool pretty_print=false) const;
78  bool desc(
80  bool pretty_print=false) const;
81 
82  /// Writes a string representation of the dictionary at the specified
83  /// index to the buffer
84  bool desc(
86  int component,
87  bool pretty_print=false) const;
88  bool desc(
90  int component,
91  bool pretty_print=false) const;
92 
93  /// Sets values from an array of python dictionary representations
94  void setValue(const UT_StringArray& reprs);
95 
96  /// Sets a value from a python dictionary string representation
97  void setValue(
98  const UT_StringHolder& repr,
99  int component);
100 
101  /// Merges the dictionary into a dictionary in this attribute at the
102  /// specified index
103  void mergeValue(
104  const UT_OptionsHolder& options,
105  int component);
106 
107  /// Removes any dictionary entries at the specified index that match
108  /// the attribute pattern
109  void removeKeys(
111  int component);
112 
113  /// Imports the specified attributes as key/value pairs in the dictionary.
114  void importAttributes(
116  const PDG_AttributeMap& attributes,
117  int component,
118  PDG_AttributeOverwrite overwrite);
119 
120  /// Imports the specified dictionary attribute key/value pairs into
121  /// this dictionary.
122  void mergeAttributes(
124  const PDG_AttributeMap& attributes,
125  int component);
126 
127  /// Queries a floating point value from the dictionary, using the
128  /// specified query string and index
130  fpreal& result,
131  const PDG_AttributeQuery& query,
132  exint& query_index,
133  int component) const;
135  fpreal& result,
136  const UT_StringHolder& str,
137  int component) const;
138 
139  /// Queries a string value from the dictionary, using the
140  /// specified query string and index
143  const PDG_AttributeQuery& query,
144  exint& query_index,
145  int component) const;
148  const UT_StringHolder& str,
149  int component) const;
150 
151 private:
152  const UT_OptionEntry* queryInternal(
153  const PDG_AttributeQuery& query,
154  exint& query_index) const;
155 };
156 
157 #endif
GLenum query
Definition: glad.h:2772
#define PDG_API
Definition: PDG_API.h:23
int64 exint
Definition: SYS_Types.h:125
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
**But if you need a result
Definition: thread.h:613
__hostdev__ void setValue(uint32_t offset, bool v)
Definition: NanoVDB.h:5750
PDG_AttributeOverwrite
virtual bool loadData(const UT_JSONValue &)=0
Loads data from a JSON value.
void setValue(const ArrayType &data)
PDG_AttributeCast
Enumeration of attribute cast results.
virtual bool saveData(UT_JSONWriter &) const =0
Serializes the data to a JSON writer.
long long int64
Definition: SYS_Types.h:116
GLushort pattern
Definition: glad.h:2583
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
virtual int64 getMemoryUsage(bool inclusive) const =0
Returns the memory usage of the attribute and its data.
fpreal64 fpreal
Definition: SYS_Types.h:277
Class to store JSON objects as C++ objects.
Definition: UT_JSONValue.h:99
Definition: core.h:1131
virtual PDG_AttributeData * clone() const =0
Deep copies this attribute.
An array of UT_OptionsHolder values.