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 
19 class PDG_AttributeQuery;
20 class PDG_AttributeMap;
22 
23 class UT_JSONValue;
24 class UT_JSONWriter;
25 class UT_WorkBuffer;
26 
27 /**
28  * Dictionary attribute type
29  */
31  PDG_AttributeType::eDictArray,
32  UT_OptionsHolder,
33  UT_Array<UT_OptionsHolder>>
34 {
35 public:
36  using Base = PDG_AttributeArray<
40  using Base::Base;
41  using Base::values;
42  using Base::appendValue;
43  using Base::setValue;
44 
45 public:
46  ~PDG_AttributeDictionary() override;
47 
48  /// Returns the total memory usage of all data on this attribute
49  int64 getMemoryUsage(bool inclusive) const override;
50 
51  /// Constructs a new dictionary attribute that copies the data from this
52  /// attribute
53  PDG_AttributeData* clone() const override;
54 
55 
56  /// Writes the dictionary data to the json writer
57  bool saveData(UT_JSONWriter& writer) const override;
58 
59  /// Writes the dictionary data to the json writer
60  void saveData(
61  const UT_StringHolder& key,
62  UT_OptionsHolder& dict) const override;
63 
64  /// Reads the dictionary data from the json value
65  bool loadData(const UT_JSONValue& value) override;
66 
67  /// Reads the dictionary data from the dict
68  bool loadData(
69  const UT_StringHolder& key,
70  const UT_OptionsHolder& dict) override;
71 
72 
73  /// Writes a string representation of the dictionaries to the buffer
74  bool desc(
76  bool pretty_print=false) const;
77  bool desc(
79  bool pretty_print=false) const;
80 
81  /// Writes a string representation of the dictionary at the specified
82  /// index to the buffer
83  bool desc(
85  int component,
86  bool pretty_print=false) const;
87  bool desc(
89  int component,
90  bool pretty_print=false) const;
91 
92  /// Sets values from an array of python dictionary representations
93  void setValue(const UT_StringArray& reprs);
94 
95  /// Sets a value from a python dictionary string representation
96  void setValue(
97  const UT_StringHolder& repr,
98  int component);
99 
100  /// Merges the dictionary into a dictionary in this attribute at the
101  /// specified index
102  void mergeValue(
103  const UT_OptionsHolder& options,
104  int component);
105 
106  /// Removes any dictionary entries at the specified index that match
107  /// the attribute pattern
108  void removeKeys(
110  int component);
111 
112  /// Imports the specified attributes as key/value pairs in the dictionary.
113  void importAttributes(
115  const PDG_AttributeMap& attributes,
116  int component,
117  PDG_AttributeOverwrite overwrite);
118 
119  /// Imports the specified dictionary attribute key/value pairs into
120  /// this dictionary.
121  void mergeAttributes(
123  const PDG_AttributeMap& attributes,
124  int component);
125 
126  /// Queries a floating point value from the dictionary, using the
127  /// specified query string and index
129  fpreal& result,
130  const PDG_AttributeQuery& query,
131  int component) const;
133  fpreal& result,
134  const UT_StringHolder& str,
135  int component) const;
136 
137  /// Queries a string value from the dictionary, using the
138  /// specified query string and index
141  const PDG_AttributeQuery& query,
142  int component) const;
145  const UT_StringHolder& str,
146  int component) const;
147 
148 private:
149  const UT_OptionEntry* queryInternal(
150  const PDG_AttributeQuery& query) const;
151 };
152 
153 #endif
GLenum query
Definition: glad.h:2772
#define PDG_API
Definition: PDG_API.h:23
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.