HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_Options.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_Options.h (C++, Utility Library)
7  *
8  * COMMENTS: This is a smaller, faster, more type-safe version of
9  * UT_OptionFile. The reason UT_OptionFile was not simply
10  * re-implemented is that when saving and loading UT_OptionFiles,
11  * no information about the type of each option is saved. This
12  * implementation writes out the type of each data item.
13  *
14  */
15 
16 #ifndef _UT_OPTIONS_H_
17 #define _UT_OPTIONS_H_
18 
19 #include "UT_API.h"
20 #include "UT_SmallObject.h"
21 #include "UT_StringArray.h"
22 #include "UT_StringHolder.h"
23 #include "UT_ArrayStringMap.h"
24 #include "UT_UniquePtr.h"
25 #include "UT_SharedPtr.h"
26 #include "UT_VectorTypes.h"
27 #include "UT_ValArray.h"
28 #include <SYS/SYS_TypeTraits.h>
29 #include <iosfwd>
30 #include <string>
31 #include <memory>
32 
33 
34 class UT_IStream;
35 class UT_JSONValue;
36 class UT_JSONValueMap;
37 class UT_JSONParser;
38 class UT_JSONWriter;
39 class UT_WorkBuffer;
40 
41 // NOTE: The values of UT_OptionType are saved to disk, thus we should NOT
42 // reorder these options if we want to maintain compatibility with older
43 // saved options.
45 {
59  UT_OPTION_STRINGRAW = 12, // used by getPyOptionString
60  UT_OPTION_INTARRAY = 13, // Array of integers
61  UT_OPTION_FPREALARRAY = 14, // Array of float/double
64  UT_OPTION_DICT = 17, // Option of option
66 
67  UT_OPTION_NUM_TYPES // Sentinal
68 };
69 
70 /// String formatting options for getOptionString
72 {
73  UT_OPTFMT_DISPLAY, // Format for display
74  UT_OPTFMT_PYTHON, // Format for python
75  UT_OPTFMT_VEX, // Format for VEX arguments
77 };
78 
79 class UT_OptionsHolder;
80 class UT_OptionEntry;
82 
83 /// A map of string to various well defined value types
85 {
86 private:
87  /// Storage type for the option map
89 
90 public:
91  // Default constructor (empty options)
92  UT_Options();
93  // Copy c-tor
94  UT_Options(const UT_Options &src);
95  virtual ~UT_Options();
96 
97  /// Variadic constructor that allows addition of options during
98  /// construction. Using this option requires very careful coding (as does
99  /// all variadic coding). For example, there is no type checking of
100  /// variadic arguments. If there are floating point arguments, they @b
101  /// must be specified as double (i.e. Not "0", but rather "0.0").
102  /// Type tokens expected are:
103  /// - "int" @n A single @b int value follows
104  /// - "int64" @n A single @b int64 value follows
105  /// - "bool" @n A single @b int follows
106  /// - "float" @n A single @b double follows
107  /// - "string" @n A single string value follows
108  /// - "vector2" @n Two (2) double arguments follow
109  /// - "vector3" @n Three (3) double arguments follow
110  /// - "vector4" @n Four (4) double arguments follow
111  /// - "quaternion" @n Four (4) double arguments follow
112  /// - "matrix2" @n Four (4) double arguments follow
113  /// - "matrix3" @n Nine (9) double arguments follow
114  /// - "matrix4" @n Sixteen (16) double arguments follow
115  /// - "uv" @n Two (2) double arguments follow
116  /// - "uvw" @n Three (3) double arguments follow
117  /// - "stringraw" @n A single string value follows
118  /// - "int[N]" @n
119  /// @c N @b int values follow (creating an integer array).
120  /// Replace @c N with the actual value (of course).
121  /// No spaces may occur in the type name.
122  /// - "int64[N]" @n
123  /// @c N @b int64 values follow (creating an integer array).
124  /// Replace @c N with the actual value (of course).
125  /// No spaces may occur in the type name.
126  /// - "float[N]" @n
127  /// @c N @b double values follow (creating a float array).
128  /// Replace @c N with the actual value (of course).
129  /// No spaces may occur in the type name.
130  /// - "string[N]" @n
131  /// @c N @b string values follow (creating a string array).
132  /// Replace @c N with the actual value (of course).
133  /// No spaces may occur in the type name.
134  ///
135  /// Special type tokens
136  /// - "i_vector2", "i_vector3", "i_vector4", @n
137  /// A single @b double is used to set all components of the vector
138  /// - "i_quaternion" @n
139  /// A single @b double is used to set all components of the vector
140  /// - "i_uv", "i_uvw" @n
141  /// A single @b double is used to set all components of the vector
142  /// - "i_matrix3", "i_matrix4" @n
143  /// A single @b double is used to set the diagonal of the matrix3.
144  /// - "i_int[N]" @n
145  /// A single @b int64 is used to set all components of the array
146  /// - "i_float[N]" @n
147  /// A single @b double is used to set all components of the array
148  ///
149  /// The option name should follow the type specifier (separated by a single
150  /// space).
151  ///
152  /// A nullptr keyword determines the end of the options.
153  ///
154  /// Examples: @code
155  /// UT_Options options("int ival", 0,
156  /// "int64 i64val", (int64)5,
157  /// "bool toggle", (int)1,
158  /// "float fval", (fpreal64)0,
159  /// "vector3 P", 0.0, 1.0, 2.0,
160  /// "string map", "texture.pic",
161  /// "int[2] iarray", int64(0), int64(1),
162  /// nullptr); <======= MUST TERMINATE =======
163  /// @code
164  /// Common errors include: @code
165  /// UT_Options options(
166  /// "int ival", (int64)0, // Error, must be int
167  /// "int64 ival", (int)0, // Error, must be int64
168  /// "vector3 fval", 0, 1.0, 2.0, // First entry is an int!
169  /// "float[3] farray", 0.0, 1.0, // Missing 3rd value
170  /// /* MISSING nullptr TERMINATOR */);
171  /// @endcode
172  ///
173  /// This function effectively does not call optionChanged.
174  UT_Options(const char *type_and_name, ...);
175 
176  /// Lookup an option type based on a keyword
177  static UT_OptionType optionType(const UT_StringRef &kwd);
178 
179  // This function does not call optionChanged.
180  void clear();
181 
182  // Returns true on success or if the file didn't exist;
183  // returns false only if the file encounters an error.
184  // The load methods can handle files saved either with this save
185  // or with saveAsJSON. saveAsJSON is preferable as it handles 64bit
186  // floats and ints, but can't be read before H10.5
187  // When 'compact' parameter is true, the info is not explicitly saved.
188  bool load(const char *filename);
189  bool save(const char *filename) const;
190  bool saveOrdered(const char *filename) const;
191  bool load(const char *filename, UT_IStream &is);
192  bool save(const char *filename, std::ostream &os) const;
193  bool saveOrdered(const char *filename, std::ostream &os) const;
194 
195  bool saveAsJSON(const char *filename,
196  bool binary = true,
197  bool compact = false) const;
198  bool saveAsJSON(const char *filename, std::ostream &os,
199  bool binary = true,
200  bool compact = false) const;
201 
202  // Remove an option.
203  void removeOption(const UT_StringHolder &name);
204 
205  // Get the string representation of any of our options. Note that, if
206  // the value contains binary data with null characters, you can't determine
207  // the length of the data with UT_String version of these methods.
208  bool getOptionString(const UT_StringHolder &name,
210  UT_WorkBuffer &result) const;
211  bool getOptionString(const UT_StringHolder &name,
212  UT_OptionFormat format,
213  UT_String &result) const;
214 
215  // Append the python dictionary representation of ALL our options to the
216  // buffer
217  bool appendPyDictionary(UT_WorkBuffer &result,
218  bool sorted=false) const;
219 
220  // Parse a python dictionary string and merge the results into our
221  // options.
222  bool setFromPyDictionary(const char *dict);
223 
224  // Parse a python formatted value and set it as the named option.
225  bool setPyOptionString(const UT_StringHolder &name,
226  const char *value);
227 
228  /// Save a UT_Options to JSON format using UT_JSONWriter
229  /// @param compact If true, the type info is not explicitly saved.
230  bool save(UT_JSONWriter &w, bool compact = false) const;
231 
232  /// Save a UT_Options to a UT_JSONValue
233  /// @param compact If true, the type info is not explicitly saved.
234  void save(UT_JSONValueMap &map, bool compact = false) const;
235 
236  /// Load a UT_Options from a JSON parser.
237  /// @param parser Parser
238  /// @param do_clear Clear existing map before loading
239  /// If true and the first object in the JSON stream is not a map object,
240  /// then the parser will fail (with an error). Otherwise a warning will
241  /// be added and the object will be skipped.
242  /// @param is If this is specified, then data will be read from that
243  /// stream rather than the stream associated with the parser.
244  /// @param require_type If true, the JSON input must contain option entries
245  /// in a format that explicitly specifies both the 'type' and the 'value'.
246  /// Otherwise, JSON may specify value directly, and the type will be
247  /// deduced implicitly from the value.
248  bool load(UT_JSONParser &parser,
249  bool do_clear,
250  UT_IStream *is = 0,
251  bool require_type = true);
252 
253  /// Loads a UT_Options from a JSONValue map.
254  /// @param allow_type Controls if a map with "type" and "value" entries
255  /// will be interpreted as an explicit type request.
256  /// @param allow_dict Controls if a map will be turned into a nested
257  /// dictionary.
258  /// Note: if both 'allow_type' and 'allow_dict' are true , things that
259  /// look like types will be treated as such; the rest as dictionaries.
260  bool load(UT_JSONValueMap &map,
261  bool do_clear,
262  bool allow_type = true,
263  bool allow_dict = false);
264 
265  /// Writes a JSON dump to ostream of the current options.
266  void dump(std::ostream &os) const;
267  /// Dump to stdout/cout
268  void dump() const;
269 
270  // Functions for accessing the options by name.
271  bool hasOption(const UT_StringRef &name) const;
272  UT_OptionType getOptionType(const UT_StringRef &name) const;
273  const UT_OptionEntry*getOptionEntry(const UT_StringRef &name) const;
274 
275  exint getNumOptions() const { return myMap.size(); }
276  exint size() const { return getNumOptions(); }
277  exint entries() const { return getNumOptions(); }
278 
279  // Functions for accessing all options sequentially.
281  {
282  public:
284  : myOptions(nullptr)
285  {}
286  iterator(const iterator &i)
287  : myOptions(i.myOptions)
288  , myIterator(i.myIterator)
289  , myEnd(i.myEnd)
290  {}
291  const UT_StringHolder &name() const
292  { return myIterator->first; }
293  const UT_OptionEntry *entry() const
294  { return myIterator->second.get(); }
295  UT_OptionType type() const;
296  const UT_OptionEntry *operator*() const { return entry(); }
297 
299  {
300  myOptions = i.myOptions;
301  myIterator = i.myIterator;
302  myEnd = i.myEnd;
303  return *this;
304  }
305  bool operator==(const iterator &i) const
306  {
307  return myIterator == i.myIterator;
308  }
309  bool operator!=(const iterator &i) const
310  { return !(*this == i); }
311  iterator &operator++() { advance(); return *this; }
312  bool atEnd() const { return myIterator == myEnd; }
313  void advance() { ++myIterator; }
314  private:
315  iterator(const UT_Options &opts, const MapType::const_iterator &it,
317  : myOptions(&opts)
318  , myIterator(it)
319  , myEnd(end)
320  {
321  }
322  const UT_Options *myOptions;
323  MapType::const_iterator myIterator;
324  MapType::const_iterator myEnd;
325  friend class UT_Options;
326  };
328  {
329  public:
331  : myKeys()
332  , myValues()
333  , myOrder()
334  , myPos(0)
335  , myCurr(0)
336  {
337  }
339  : myKeys(src.myKeys)
340  , myValues(src.myValues)
341  , myOrder(src.myOrder)
342  , myPos(src.myPos)
343  , myCurr(src.myCurr)
344  {
345  }
346  const UT_StringHolder &name() const
347  { return myKeys(myCurr); }
348  const UT_OptionEntry *entry() const
349  { return myValues(myCurr); }
350  UT_OptionType type() const;
351  const UT_OptionEntry *operator*() const { return entry(); }
352 
354  {
355  myKeys = i.myKeys;
356  myValues = i.myValues;
357  myOrder = i.myOrder;
358  myPos = i.myPos;
359  myCurr = i.myCurr;
360  return *this;
361  }
362  bool operator==(const ordered_iterator &i) const
363  {
364  if (i.atEnd() && atEnd())
365  return true;
366  // Iterators are only equal if they are both at
367  // the end.
368  return false;
369  }
370  bool operator!=(const ordered_iterator &i) const
371  { return !(*this == i); }
372  ordered_iterator &operator++() { advance(); return *this; }
373  bool atEnd() const { return myPos >= myOrder.entries(); }
374  void advance()
375  {
376  myPos++;
377  if (myPos < myOrder.entries())
378  myCurr = myOrder(myPos);
379  }
380  private:
381  class comparator
382  {
383  public:
384  comparator(const UT_ValArray<UT_StringHolder> &keys)
385  : myKeys(keys)
386  {
387  }
388  bool operator()(int a, int b) const
389  {
390  UT_ASSERT(a >= 0 && a < myKeys.entries());
391  UT_ASSERT(b >= 0 && b < myKeys.entries());
392  return myKeys(a) < myKeys(b);
393  }
394  private:
395  const UT_ValArray<UT_StringHolder> &myKeys;
396  };
397  // If you get an error here, maybe you meant to call obegin()?
398  explicit ordered_iterator(iterator it)
399  : myKeys()
400  , myValues()
401  , myOrder()
402  , myPos(0)
403  , myCurr(0)
404  {
405  int index = 0;
406  for (; !it.atEnd(); ++it, ++index)
407  {
408  myKeys.append(it.name());
409  myValues.append(it.entry());
410  myOrder.append(index);
411  }
412  myOrder.sort(comparator(myKeys));
413  if (myOrder.entries())
414  myCurr = myOrder(0);
415  }
416 
420  int myPos;
421  int myCurr;
422  friend class UT_Options;
423  };
424  iterator begin() const
425  { return iterator(*this, myMap.begin(), myMap.end()); }
426  iterator end() const
427  { return iterator(*this, myMap.end(), myMap.end()); }
429  { return ordered_iterator(begin()); }
431  { return ordered_iterator(end()); }
432 
433  // Functions for accessing specific option values.
434  int64 getOptionI(const UT_StringRef &name) const;
435  bool getOptionB(const UT_StringRef &name) const;
436  fpreal64 getOptionF(const UT_StringRef &name) const;
437  const UT_Vector2D &getOptionV2(const UT_StringRef &name) const;
438  const UT_Vector3D &getOptionV3(const UT_StringRef &name) const;
439  const UT_Vector4D &getOptionV4(const UT_StringRef &name) const;
440  const UT_QuaternionD &getOptionQ(const UT_StringRef &name) const;
441  const UT_Matrix2D &getOptionM2(const UT_StringRef &name) const;
442  const UT_Matrix3D &getOptionM3(const UT_StringRef &name) const;
443  const UT_Matrix4D &getOptionM4(const UT_StringRef &name) const;
444  const UT_Vector2D &getOptionUV(const UT_StringRef &name) const;
445  const UT_Vector3D &getOptionUVW(const UT_StringRef &name) const;
446 
447  // Note that, if the string value contains binary data with null
448  // characters, the UT_String version of getOptionS will not be able to
449  // tell you the length of the data, since UT_String doesn't store the
450  // length.
451  const UT_StringHolder &getOptionS(const UT_StringRef &name) const;
452  void getOptionS(const UT_StringRef &name,
453  std::string &value) const;
454  void getOptionS(const UT_StringRef &name,
455  UT_String &value) const;
456  void getOptionS(const UT_StringRef &name,
457  UT_StringHolder &value) const;
458  void getOptionS(const UT_StringRef &,
459  UT_WorkBuffer &value) const;
460  const UT_OptionsHolder &getOptionDict(const UT_StringRef &name) const;
461 
462  const UT_Int64Array &getOptionIArray(const UT_StringRef &) const;
463  const UT_Fpreal64Array &getOptionFArray(const UT_StringRef &) const;
464  const UT_StringArray &getOptionSArray(const UT_StringRef &) const;
466 
467  // Returns a valid number if this option is a float or an int.
468  // In the case of an int, it is converted to a float.
469  fpreal64 getOptionNum(const UT_StringRef &) const;
470 
471  // Functions for accessing option values. These methods will perform some
472  // minimal "casting".
473  // importOption(... bool &value) - Tests integers and string options
474  // importOption(... fpreal &value) - Evaluates integer/bool options
475  // importOption(... UT_Vector2 &) - Evaluates Vector2 or UV
476  // importOption(... UT_Vector3 &) - Evaluates Vector3 or UVW
477  //
478  bool importOption(const UT_StringRef &name, int &value) const;
479  bool importOption(const UT_StringRef &name, int64 &value) const;
480  bool importOption(const UT_StringRef &name, bool &value) const;
481  bool importOption(const UT_StringRef &name,
482  fpreal32 &value) const;
483  bool importOption(const UT_StringRef &name,
484  fpreal64 &value) const;
485  bool importOption(const UT_StringRef &name,
486  std::string &value) const;
487  bool importOption(const UT_StringRef &name,
488  UT_String &value) const;
489  bool importOption(const UT_StringRef &name,
490  UT_StringHolder &value) const;
491  bool importOption(const UT_StringRef &name,
492  UT_OptionsHolder &value) const;
493  bool importOption(const UT_StringRef &name,
494  UT_Vector2F &value) const;
495  bool importOption(const UT_StringRef &name,
496  UT_Vector3F &value) const;
497  bool importOption(const UT_StringRef &name,
498  UT_Vector4F &value) const;
499  bool importOption(const UT_StringRef &name,
500  UT_QuaternionF &value) const;
501  bool importOption(const UT_StringRef &name,
502  UT_Matrix2F &value) const;
503  bool importOption(const UT_StringRef &name,
504  UT_Matrix3F &value) const;
505  bool importOption(const UT_StringRef &name,
506  UT_Matrix4F &value) const;
507  bool importOption(const UT_StringRef &name,
508  UT_Vector2D &value) const;
509  bool importOption(const UT_StringRef &name,
510  UT_Vector3D &value) const;
511  bool importOption(const UT_StringRef &name,
512  UT_Vector4D &value) const;
513  bool importOption(const UT_StringRef &name,
514  UT_QuaternionD &value) const;
515  bool importOption(const UT_StringRef &name,
516  UT_Matrix2D &value) const;
517  bool importOption(const UT_StringRef &name,
518  UT_Matrix3D &value) const;
519  bool importOption(const UT_StringRef &name,
520  UT_Matrix4D &value) const;
521 
522  // Generic import which handles arbitrary length int/float data
523  bool importOption(const UT_StringRef &name,
524  UT_Array<int32> &value) const;
525  bool importOption(const UT_StringRef &name,
526  UT_Array<int64> &value) const;
527  bool importOption(const UT_StringRef &name,
528  UT_Array<fpreal32> &value) const;
529  bool importOption(const UT_StringRef &name,
530  UT_Array<fpreal64> &value) const;
531 
532  // Import a string array
533  bool importOption(const UT_StringRef &name,
534  UT_StringArray &value) const;
535  bool importOption(const UT_StringRef &name,
536  UT_Array<UT_StringHolder> &value) const;
537 
538  // Import a dictionary array.
539  bool importOption(const UT_StringRef &name,
540  UT_Array<UT_OptionsHolder> &value) const;
541 
542  // Import a single element from a scalar, vector, matrix or array
543  bool importElement(const UT_StringRef &name,
544  fpreal &value,
545  exint index = 0) const;
546  bool importElement(const UT_StringRef &name,
547  int64 &value,
548  exint index = 0) const;
549 
550 
551  // All these functions cause optionChanged to be called.
553  int64 value);
555  bool value);
557  fpreal64 value);
558  // Note that you can store binary data (that can contain null characters
559  // or that isn't null-terminated) in a string option by passing in a
560  // UT_WorkBuffer, or std::string.
562  const UT_StringHolder &value);
563  // setOptionSRaw() is the same as setOptionS() instead of it being
564  // additionally tagged as a "raw" string so that getPyOptionString() and
565  // appendPyDictionary() won't add quotes around the value. To retrieve its
566  // value, use getOptionS().
568  const UT_StringHolder &value);
570  const UT_OptionsHolder &value);
572  const UT_Vector2F &value);
574  const UT_Vector2D &value);
576  fpreal64 x, fpreal64 y);
578  const UT_Vector3F &value);
580  const UT_Vector3D &value);
584  const UT_Vector4F &value);
586  const UT_Vector4D &value);
588  fpreal64 x, fpreal64 y,
589  fpreal64 z, fpreal64 w);
591  const UT_QuaternionF &value);
593  const UT_QuaternionD &value);
595  const UT_Matrix2F &value);
597  const UT_Matrix2D &value);
599  const UT_Matrix3F &value);
601  const UT_Matrix3D &value);
603  const UT_Matrix4F &value);
605  const UT_Matrix4D &value);
607  const UT_Vector2F &value);
609  const UT_Vector2D &value);
611  const UT_Vector3F &value);
613  const UT_Vector3D &value);
614  /// @{
615  /// Set integer array options
617  const int32 *values, size_t size);
619  const int64 *values, size_t size);
621  const UT_Array<int64> &value);
622  /// @}
623  /// @{
624  /// Set float/double array options
626  const fpreal32 *values, size_t size);
628  const fpreal64 *values, size_t size);
630  const UT_Array<fpreal64> &value);
631  /// @}
632 
633  /// Set string array options
635  const UT_StringHolder *values,
636  size_t size);
638  const char *const*values,
639  size_t size);
641  const UT_StringArray &value);
642 
643  /// Set dict array options
645  const UT_OptionsHolder *values,
646  size_t size);
648  const UT_Array<UT_OptionsHolder> &value);
649 
650  /// Get a hash code for the options
651  unsigned hash() const;
652 
653  /// Comparison operator
654  bool operator==(const UT_Options &src) const
655  { return isEqual(src, 0.0); }
656  bool operator!=(const UT_Options &src) const
657  { return !(*this == src); }
658 
659  /// Comparison operator with a tolerance for float values.
660  bool isEqual(const UT_Options &src, fpreal64 tol) const;
661 
662  /// Assignment operator
663  const UT_Options &operator=(const UT_Options &src);
664  void merge(const UT_Options &src);
665  void merge(const UT_Options &src,
666  bool (*match)(const UT_StringHolder &name,
667  const UT_OptionEntry *, void *),
668  void *data);
669  virtual int64 getMemoryUsage(bool inclusive) const;
670 
671  // This will steal the option from the unique ptr.
672  void setOption(const UT_StringHolder &name,
673  UT_OptionEntryPtr value);
674 
675 protected:
676  const UT_StringHolder *findOptionS(const UT_StringRef &name) const;
677  void addError(const char *filename, int linecount,
678  const char *error_str) const;
679  bool sendOptionChanges() const
680  { return mySendOptionChanges; }
682  { mySendOptionChanges = f; }
683  virtual void optionChanged(const char *name);
684  UT_OptionEntryPtr parsePyValue(const char *&value,
685  char sep_delim,
686  char close_delim = '\0');
687 
688 private:
689  template <class ITER>
690  bool save(ITER start, const char *filename, std::ostream &os) const;
691 
692  MapType myMap;
693  bool mySendOptionChanges;
694 };
695 
696 /// A holder for a options, which caches the hash value.
697 /// A UT_OptionsRef does not necessarily own the options, and it is therefore
698 /// not safe to e.g. store a UT_OptionsRef in a container or member variable.
699 /// @see UT_OptionsHolder
701 {
702 public:
704 
707  {
708  init();
709  }
710 
711  /// Will make a shallow reference.
714  {
715  init();
716  reference(opt);
717  }
718 
719  /// Shares a reference with the source.
722  {
723  mySoftRef = s.mySoftRef;
724  mySharedRef = s.mySharedRef;
725  myHash = s.myHash;
726  }
727 
728  /// Move constructor. Steals the working data from the original.
731  {
732  mySoftRef = s.mySoftRef;
733  mySharedRef = std::move(s.mySharedRef);
734  myHash = s.myHash;
735  s.init();
736  }
737 
740  {
741  }
742 
743  /// Special sentinel value support
744  /// @{
745  enum UT_OptionsSentinelType { SENTINEL };
746 
747  SYS_FORCE_INLINE explicit
749  : mySoftRef((const UT_Options *)SENTINEL_DATA)
750  , myHash(SENTINEL_HASH)
751  {
752  }
753 
755  bool isSentinel() const
756  {
757  return uintptr_t(mySoftRef) == SENTINEL_DATA && myHash == SENTINEL_HASH;
758  }
759 
762  {
763  init();
764  myHash = SENTINEL_HASH;
765  mySoftRef = (const UT_Options *) SENTINEL_DATA;
766  }
767  /// @}
768 
769  /// Returns true this object is the sole owner of the underlying options
770  bool isUnique() const
771  {
772  // Soft references are not unique. (This includes sentinels)
773  if (mySoftRef)
774  return false;
775  // If the shared ref is null, it isn't unique.
776  if (!mySharedRef.get())
777  return false;
778 
779  return mySharedRef.unique();
780  }
781 
782  /// Returns the shared ptr use count. 0 if not a shared
783  /// pointer. (null or soft ref)
784  int use_count() const
785  {
786  if (mySoftRef)
787  return 0;
788  if (!mySharedRef.get())
789  return 0;
790  return mySharedRef.use_count();
791  }
792 
793  /// Shares a reference with the source.
795  {
796  // Can now blindly copy.
797  mySoftRef = s.mySoftRef;
798  mySharedRef = s.mySharedRef;
799  myHash = s.myHash;
800  return *this;
801  }
802 
803  /// Move the contents of about-to-be-destructed options
804  /// s to this string.
807  {
808  // Can just swap, since s is about to be destructed.
809  swap(s);
810  return *this;
811  }
812 
814  const UT_Options *optionsOrNull() const
815  {
816  if (isSentinel())
817  return nullptr;
818  return rawOptions();
819  }
820 
822  const UT_Options *options() const
823  {
824  const UT_Options *result = optionsOrNull();
825  if (result == nullptr)
826  return &theEmptyOptionsData;
827  return result;
828  }
829 
830  bool operator==(const UT_OptionsRef &s) const
831  {
832  const UT_Options *a = rawOptions();
833  const UT_Options *b = s.rawOptions();
834 
835  if (a == b)
836  return true;
837 
838  // If they are not equal, we have to test null and sentinel.
839  // If either one is null or sentinel, we know they must be
840  // unequal.
841  if (!a || !b || (uintptr_t(a) == SENTINEL_DATA) || (uintptr_t(b) == SENTINEL_DATA))
842  return false;
843 
844  // If we have hashes and they are unequal, we must
845  // be unequal.
846  if (myHash && s.myHash)
847  {
848  if (myHash != s.myHash)
849  return false;
850  }
851 
852  // Now we have de-referenceable options pointers.
853  return (*a == *b);
854  }
855 
856  bool operator==(const UT_Options *b) const
857  {
858  const UT_Options *a = rawOptions();
859 
860  if (a == b)
861  return true;
862 
863  // If they are not equal, we have to test null and sentinel.
864  // If either one is null or sentinel, we know they must be
865  // unequal.
866  if (!a || !b || (uintptr_t(a) == SENTINEL_DATA) || (uintptr_t(b) == SENTINEL_DATA))
867  return false;
868 
869  // Can't test hashes as we don't have it for a raw pointer.
870 
871  // Now we have de-referenceable options pointers.
872  return (*a == *b);
873  }
874 
875  bool operator!=(const UT_OptionsRef &s) const
876  { return !operator==(s); }
877  bool operator!=(const UT_Options *s) const
878  { return !operator==(s); }
879 
880  /// Comparison operator with a tolerance for float values.
881  bool isEqual(const UT_OptionsRef &s, fpreal64 tol) const;
882 
883  SYS_FORCE_INLINE const UT_Options *operator->() const { return options(); }
884  SYS_FORCE_INLINE const UT_Options &operator*() const { return *options(); }
885 
887  void swap( UT_OptionsRef &other )
888  {
889  UTswap(mySoftRef, other.mySoftRef);
890  UTswap(mySharedRef, other.mySharedRef);
891  UTswap(myHash, other.myHash);
892  }
893 
894  /// Friend specialization of std::swap() to use UT_OptionsRef::swap()
895  friend void swap(UT_OptionsRef& a, UT_OptionsRef& b) { a.swap(b); }
896 
898  void clear()
899  {
900  init();
901  }
902 
903  bool isEmpty() const
904  {
905  const UT_Options *opt = optionsOrNull();
906  if (!opt)
907  return true;
908 
909  if (opt->getNumOptions() == 0)
910  return true;
911 
912  return false;
913  }
914 
915  explicit operator bool() const { return !isEmpty(); }
916 
917  unsigned hash() const
918  {
919  if (myHash)
920  return myHash;
921 
922  const UT_Options *opt = optionsOrNull();
923  if (!opt)
924  return 0;
925 
926  unsigned localhash = opt->hash();
927  if (!localhash)
928  localhash++;
929  myHash = localhash;
930  return myHash;
931  }
932 
933  /// Make a light weight reference to the source.
934  /// Caller must make sure src lives for the duration of this object,
935  /// and any objects value copied from this!
936  void reference(const UT_Options *src)
937  {
938  init();
939  mySoftRef = src;
940  }
941 
942  int64 getMemoryUsage(bool inclusive) const
943  {
944  int64 mem = inclusive ? sizeof(*this) : 0;
945 
946  const UT_Options *opt = optionsOrNull();
947  if (opt)
948  mem += opt->getMemoryUsage(true);
949  return mem;
950  }
951 
952  static const UT_Options &emptyOptions() { return theEmptyOptionsData; }
953 
954 private:
955  void init()
956  {
957  mySoftRef = nullptr;
958  mySharedRef.reset();
959  myHash = 0;
960  }
961 
962  void copy(const UT_OptionsRef &s)
963  {
964  mySoftRef = s.mySoftRef;
965  mySharedRef = s.mySharedRef;
966  myHash = s.myHash;
967  }
968 
970  const UT_Options *rawOptions() const
971  {
972  if (mySoftRef)
973  return mySoftRef;
974  return mySharedRef.get();
975  }
976 
977 
978  /// Either softref or shared ref should be set, never both.
979  /// Note that this might be possible to collapse into a single
980  /// shared ptr using the semantic that use_count==0 means soft ref.
981  const UT_Options *mySoftRef;
982  UT_SharedPtr<UT_Options> mySharedRef;
983 
984  /// Optional hash, 0 if not computed yet.
985  mutable int myHash;
986 
987  // UT_OptionsHolder needs to be a friend class so that the
988  // UT_OptionsHolder(const UT_OptionsRef &) constructor can access myHash and
989  // getHolder() for the UT_OptionsRef that is passed in.
990  friend class UT_OptionsHolder;
991 
992  static constexpr uintptr_t SENTINEL_DATA = 1;
993  static constexpr uint32 SENTINEL_HASH = 0xdeadbeef;
994 
995  // Because we want a null options pointer to return an empty options,
996  // we need a canonical empty options to return.
997  static const UT_Options theEmptyOptionsData;
998 
999  template<typename T>
1000  static SYS_FORCE_INLINE bool isSentinelOrNullPtr(const T *p)
1001  {
1002  return uintptr_t(p) <= SENTINEL_DATA;
1003  }
1004 };
1005 
1007 {
1008  return opt.hash();
1009 }
1010 
1011 
1013 {
1014 public:
1015  /// UT_OptionsHolder can be constructed with UT_OptionsHolder::REFERENCE to
1016  /// create a shallow reference to the const char *.
1017  enum UT_OptionsReferenceType { REFERENCE };
1018 
1021  : UT_OptionsRef()
1022  {
1023  }
1024 
1025  /// Will make a copy of the provided options.
1028  {
1029  mySoftRef = nullptr;
1030  if (opt)
1031  mySharedRef = UTmakeShared<UT_Options>(*opt);
1032  else
1033  mySharedRef.reset();
1034  }
1035 
1036  /// Will make a shallow reference.
1039  : UT_OptionsRef(opt)
1040  {
1041  }
1042 
1043  /// Makes a shallow reference to the contents of the UT_OptionsRef.
1046  : UT_OptionsRef(ref)
1047  {
1048  }
1049 
1050  /// Makes a deep copy of the provided UT_OptionsRef.
1051  /// This constructor is not marked explicit since we often want this
1052  /// conversion (e.g. when inserting a UT_OptionsRef into a UT_OptionsMap, as
1053  /// with the const char* constructor).
1055 
1056  /// Construct as a sentinel value
1057  SYS_FORCE_INLINE explicit
1059  : UT_OptionsRef(sentinel)
1060  {
1061  }
1062 
1063  /// Makes a copy of the provided options.
1066  : UT_OptionsRef(str)
1067  {
1068  }
1069 
1070  /// Move constructor. Steals the working data from the original.
1073  : UT_OptionsRef(std::move(a))
1074  {
1075  }
1076 
1077  /// Makes a bit-wise copy of the options and adjust the reference count.
1080  {
1082  return *this;
1083  }
1084 
1085  /// Move the contents of about-to-be-destructed options
1086  /// s to this options.
1089  {
1090  UT_OptionsRef::operator=(std::move(s));
1091  return *this;
1092  }
1093 
1095  void swap(UT_OptionsHolder &other)
1096  {
1097  UT_OptionsRef::swap(other);
1098  }
1099 
1101  void swap(UT_OptionsRef &other)
1102  {
1103  UT_OptionsRef::swap(other);
1104  // harden ourselves like UT_OptionsHolder::operator=(UT_OptionsRef&)
1105  if (isSentinelOrNullPtr(mySoftRef))
1106  return; // already a holder
1107  mySharedRef = UTmakeShared<UT_Options>(*mySoftRef);
1108  mySoftRef = nullptr;
1109  }
1110 
1111  /// Returns a writeable UT_Options which will modify the contents
1112  /// of this options holder. When this is copied or deleted, the
1113  /// returned pointer must not be used any more. (Ideally we could
1114  /// erase ourself and return a UniquePtr for correct life time,
1115  /// but we can't steal from a shared pointer)
1116  ///
1117  /// Use update() whereever possible instead as it is much safer.
1119  {
1120  // Harden if soft.
1121  if (!isUnique())
1122  {
1123  mySharedRef = UTmakeShared<UT_Options>(*options());
1124  mySoftRef = nullptr;
1125  }
1126  UT_ASSERT(isUnique());
1127 
1128  // Since we are going to be edited, we must reset our hash.
1129  myHash = 0;
1130 
1131  return SYSconst_cast(options());
1132  }
1133 
1134  /// Updates the contents of this option, first making sure it is
1135  /// unique. The provided operator should take a reference to
1136  /// a UT_Options that it will update.
1137  /// UT_OptionsHolder value;
1138  /// value.update([](UT_Options &opt) { opt.setOptionS("test", "bar"); });
1139  template <typename OP>
1140  void update(const OP &op)
1141  {
1142  UT_Options *opt = makeUnique();
1143  op(*opt);
1144  }
1145 
1146  /// Friend specialization of std::swap() to use UT_OptionsHolder::swap()
1147  /// @{
1148  friend void swap(UT_OptionsHolder& a, UT_OptionsRef& b) { a.swap(b); }
1149  friend void swap(UT_OptionsHolder& a, UT_OptionsHolder& b) { a.swap(b); }
1150  /// @}
1151 
1152  /// In some functions it's nice to be able to return a const-reference to a
1153  /// UT_OptionsHolder. However, in error cases, you likely want to return an
1154  /// empty options. This would mean that you'd have to return a real
1155  /// UT_OptionsHolder (not a const reference). This static lets you return a
1156  /// reference to an empty options.
1158 
1160 
1161 protected:
1162 };
1163 
1164 // For UT::ArraySet.
1165 namespace UT
1166 {
1167 template <typename T>
1168 struct DefaultClearer;
1169 
1170 template <>
1172 {
1173  static void clear(UT_OptionsHolder &v) { v.makeSentinel(); }
1174  static bool isClear(const UT_OptionsHolder &v) { return v.isSentinel(); }
1176  { new ((void *)p) UT_OptionsHolder(UT_OptionsRef::SENTINEL); }
1177  static const bool clearNeedsDestruction = false;
1178 };
1179 } // namespace UT
1180 
1181 UT_API size_t format(char *buffer, size_t buffer_size, const UT_Options &v);
1182 UT_API size_t format(char *buffer, size_t buffer_size, const UT_OptionsRef &v);
1183 
1184 // Most people only include UT_Options. But we can't include this at the start
1185 // as we are a pre-req.
1186 #include "UT_OptionEntry.h"
1187 
1188 #endif
GLint ref
Definition: glcorearb.h:124
bool operator==(const UT_OptionsRef &s) const
Definition: UT_Options.h:830
bool getOptionB(const UT_StringRef &name) const
const UT_Options & operator=(const UT_Options &src)
Assignment operator.
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
SYS_FORCE_INLINE UT_OptionsRef()
Definition: UT_Options.h:706
SYS_FORCE_INLINE bool isSentinel() const
Definition: UT_Options.h:755
GT_API const UT_StringHolder filename
const UT_Vector2D & getOptionV2(const UT_StringRef &name) const
UT_JSONValueMap stores a map/dictionary of UT_JSONValue objects.
int int32
Definition: SYS_Types.h:39
const UT_StringHolder & name() const
Definition: UT_Options.h:346
const UT_OptionEntry * operator*() const
Definition: UT_Options.h:296
int64 getMemoryUsage(bool inclusive) const
Definition: UT_Options.h:942
friend void swap(UT_OptionsRef &a, UT_OptionsRef &b)
Friend specialization of std::swap() to use UT_OptionsRef::swap()
Definition: UT_Options.h:895
SYS_FORCE_INLINE void swap(UT_OptionsRef &other)
Definition: UT_Options.h:887
bool isEqual(const UT_Options &src, fpreal64 tol) const
Comparison operator with a tolerance for float values.
void UTswap(T &a, T &b)
Definition: UT_Swap.h:35
const UT_StringArray & getOptionSArray(const UT_StringRef &) const
int myOrder
Definition: GT_CurveEval.h:263
SYS_FORCE_INLINE UT_OptionsHolder(UT_OptionsHolder &&a) noexcept
Move constructor. Steals the working data from the original.
Definition: UT_Options.h:1072
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
SYS_FORCE_INLINE const UT_Options & operator*() const
Definition: UT_Options.h:884
GLuint start
Definition: glcorearb.h:475
bool isEmpty() const
Definition: UT_Options.h:903
UT_Options & setOptionDictArray(const UT_StringHolder &name, const UT_OptionsHolder *values, size_t size)
Set dict array options.
SYS_FORCE_INLINE size_t hash_value(const UT_OptionsRef &opt)
Definition: UT_Options.h:1006
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
SYS_FORCE_INLINE T * SYSconst_cast(const T *foo)
Definition: SYS_Types.h:136
UT_OptionType
Definition: UT_Options.h:44
static const UT_OptionsHolder theSentinel
Definition: UT_Options.h:1159
GLenum const void GLuint GLint reference
Definition: glew.h:13927
void addError(const char *filename, int linecount, const char *error_str) const
UT_Options & setOptionUVW(const UT_StringHolder &name, const UT_Vector3F &value)
int64 exint
Definition: SYS_Types.h:125
bool operator!=(const UT_Options &src) const
Definition: UT_Options.h:656
UT_Options & setOptionV3(const UT_StringHolder &name, const UT_Vector3F &value)
exint size() const
Definition: UT_Options.h:276
int64 getOptionI(const UT_StringRef &name) const
void swap(T &lhs, T &rhs)
Definition: pugixml.cpp:7172
void setOption(const UT_StringHolder &name, UT_OptionEntryPtr value)
UT_OptionEntryPtr parsePyValue(const char *&value, char sep_delim, char close_delim= '\0')
fallback_uintptr uintptr_t
Definition: format.h:295
const UT_Vector3D & getOptionV3(const UT_StringRef &name) const
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:88
ordered_iterator oend() const
Definition: UT_Options.h:430
#define UT_API
Definition: UT_API.h:14
SYS_FORCE_INLINE UT_OptionsHolder(UT_OptionsReferenceType, const UT_Options *opt)
Will make a shallow reference.
Definition: UT_Options.h:1038
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:35
SYS_FORCE_INLINE UT_OptionsHolder()
Definition: UT_Options.h:1020
const UT_Matrix3D & getOptionM3(const UT_StringRef &name) const
GLuint const GLchar * name
Definition: glcorearb.h:786
SYS_FORCE_INLINE UT_OptionsHolder & operator=(const UT_OptionsHolder &s)
Makes a bit-wise copy of the options and adjust the reference count.
Definition: UT_Options.h:1079
GLenum src
Definition: glcorearb.h:1793
const UT_Fpreal64Array & getOptionFArray(const UT_StringRef &) const
static const UT_Options & emptyOptions()
Definition: UT_Options.h:952
float fpreal32
Definition: SYS_Types.h:200
bool atEnd() const
Definition: UT_Options.h:312
bool operator==(const UT_Options &src) const
Comparison operator.
Definition: UT_Options.h:654
UT_OptionsRef & operator=(const UT_OptionsRef &s)
Shares a reference with the source.
Definition: UT_Options.h:794
exint entries() const
Definition: UT_Options.h:277
UT_Options & setOptionM4(const UT_StringHolder &name, const UT_Matrix4F &value)
void setSendOptionChanges(bool f)
Definition: UT_Options.h:681
void reference(const UT_Options *src)
Definition: UT_Options.h:936
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
GLint GLenum GLint x
Definition: glcorearb.h:409
UT_Options & setOptionIArray(const UT_StringHolder &name, const int32 *values, size_t size)
SYS_FORCE_INLINE UT_OptionsHolder(UT_OptionsSentinelType sentinel)
Construct as a sentinel value.
Definition: UT_Options.h:1058
GLsizeiptr size
Definition: glcorearb.h:664
ordered_iterator & operator=(const ordered_iterator &i)
Definition: UT_Options.h:353
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
iterator end() const
Definition: UT_Options.h:426
double fpreal64
Definition: SYS_Types.h:201
const UT_StringHolder * findOptionS(const UT_StringRef &name) const
ordered_iterator(const ordered_iterator &src)
Definition: UT_Options.h:338
SYS_FORCE_INLINE const UT_Options * optionsOrNull() const
Definition: UT_Options.h:814
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
SYS_FORCE_INLINE UT_OptionsRef(UT_OptionsRef &&s) noexcept
Move constructor. Steals the working data from the original.
Definition: UT_Options.h:730
UT_Options & setOptionSArray(const UT_StringHolder &name, const UT_StringHolder *values, size_t size)
Set string array options.
GLuint64EXT * result
Definition: glew.h:14311
Definition: core.h:760
UT_Options & setOptionI(const UT_StringHolder &name, int64 value)
fpreal64 getOptionNum(const UT_StringRef &) const
SYS_FORCE_INLINE void clear()
Definition: UT_Options.h:898
UT_Options & setOptionUV(const UT_StringHolder &name, const UT_Vector2F &value)
void update(const OP &op)
Definition: UT_Options.h:1140
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
UT_Options value_type
Definition: UT_Options.h:703
const GLdouble * v
Definition: glcorearb.h:837
SYS_FORCE_INLINE void swap(UT_OptionsRef &other)
Definition: UT_Options.h:1101
unsigned hash() const
Get a hash code for the options.
UT_Options & setOptionQ(const UT_StringHolder &name, const UT_QuaternionF &value)
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
GLuint GLuint end
Definition: glcorearb.h:475
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
const UT_OptionEntry * operator*() const
Definition: UT_Options.h:351
ordered_iterator obegin() const
Definition: UT_Options.h:428
static const UT_OptionsHolder theEmptyOptions
Definition: UT_Options.h:1157
friend void swap(UT_OptionsHolder &a, UT_OptionsRef &b)
Definition: UT_Options.h:1148
SYS_FORCE_INLINE UT_OptionsRef(UT_OptionsSentinelType)
Definition: UT_Options.h:748
const UT_Vector3D & getOptionUVW(const UT_StringRef &name) const
const UT_Array< UT_OptionsHolder > & getOptionDictArray(const UT_StringRef &) const
UT_Options & setOptionV4(const UT_StringHolder &name, const UT_Vector4F &value)
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:848
UT_Options & setOptionB(const UT_StringHolder &name, bool value)
const UT_StringHolder & name() const
Definition: UT_Options.h:291
UT_Options & setOptionM3(const UT_StringHolder &name, const UT_Matrix3F &value)
virtual void optionChanged(const char *name)
long long int64
Definition: SYS_Types.h:116
GLfloat GLfloat p
Definition: glew.h:16656
SYS_FORCE_INLINE UT_OptionsRef(const UT_OptionsRef &s)
Shares a reference with the source.
Definition: UT_Options.h:721
const UT_Matrix2D & getOptionM2(const UT_StringRef &name) const
iterator & operator++()
Definition: UT_Options.h:311
UT_Options & setOptionM2(const UT_StringHolder &name, const UT_Matrix2F &value)
iterator(const iterator &i)
Definition: UT_Options.h:286
const UT_QuaternionD & getOptionQ(const UT_StringRef &name) const
bool operator!=(const UT_Options *s) const
Definition: UT_Options.h:877
bool operator!=(const iterator &i) const
Definition: UT_Options.h:309
bool operator==(const UT_Options *b) const
Definition: UT_Options.h:856
const UT_Int64Array & getOptionIArray(const UT_StringRef &) const
virtual int64 getMemoryUsage(bool inclusive) const
static bool isClear(const UT_OptionsHolder &v)
Definition: UT_Options.h:1174
SYS_FORCE_INLINE ~UT_OptionsRef()
Definition: UT_Options.h:739
bool isUnique() const
Returns true this object is the sole owner of the underlying options.
Definition: UT_Options.h:770
bool save(const char *filename) const
friend class UT_OptionsHolder
Definition: UT_Options.h:990
iterator begin() const
Definition: UT_Options.h:424
static void clear(UT_OptionsHolder &v)
Definition: UT_Options.h:1173
SYS_FORCE_INLINE UT_OptionsHolder(UT_OptionsReferenceType, const UT_OptionsRef &ref)
Makes a shallow reference to the contents of the UT_OptionsRef.
Definition: UT_Options.h:1045
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:108
A map of string to various well defined value types.
Definition: UT_Options.h:84
UT_Options * makeUnique()
Definition: UT_Options.h:1118
SYS_FORCE_INLINE UT_OptionsRef & operator=(UT_OptionsRef &&s)
Definition: UT_Options.h:806
SYS_FORCE_INLINE UT_OptionsHolder & operator=(UT_OptionsHolder &&s)
Definition: UT_Options.h:1088
exint getNumOptions() const
Definition: UT_Options.h:275
SYS_FORCE_INLINE void makeSentinel()
Definition: UT_Options.h:761
const UT_Vector4D & getOptionV4(const UT_StringRef &name) const
bool operator!=(const ordered_iterator &i) const
Definition: UT_Options.h:370
SYS_FORCE_INLINE const UT_Options * options() const
Definition: UT_Options.h:822
ordered_iterator & operator++()
Definition: UT_Options.h:372
bool operator!=(const UT_OptionsRef &s) const
Definition: UT_Options.h:875
fpreal64 fpreal
Definition: SYS_Types.h:277
SYS_FORCE_INLINE UT_OptionsHolder(const UT_OptionsHolder &str)
Makes a copy of the provided options.
Definition: UT_Options.h:1065
iterator & operator=(const iterator &i)
Definition: UT_Options.h:298
SYS_FORCE_INLINE UT_OptionsHolder(const UT_Options *opt)
Will make a copy of the provided options.
Definition: UT_Options.h:1027
GLuint index
Definition: glcorearb.h:786
UT_Options & setOptionS(const UT_StringHolder &name, const UT_StringHolder &value)
const UT_Vector2D & getOptionUV(const UT_StringRef &name) const
bool importElement(const UT_StringRef &name, fpreal &value, exint index=0) const
const UT_Matrix4D & getOptionM4(const UT_StringRef &name) const
UT_API size_t format(char *buffer, size_t buffer_size, const UT_Options &v)
Class to store JSON objects as C++ objects.
Definition: UT_JSONValue.h:77
friend void swap(UT_OptionsHolder &a, UT_OptionsHolder &b)
Definition: UT_Options.h:1149
GLfloat f
Definition: glcorearb.h:1926
unsigned int uint32
Definition: SYS_Types.h:40
bool sendOptionChanges() const
Definition: UT_Options.h:679
void merge(const UT_Options &src)
unsigned hash() const
Definition: UT_Options.h:917
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:153
Definition: core.h:1131
const UT_OptionEntry * entry() const
Definition: UT_Options.h:348
int use_count() const
Definition: UT_Options.h:784
#define const
Definition: zconf.h:214
UT_OptionFormat
String formatting options for getOptionString.
Definition: UT_Options.h:71
const UT_OptionEntry * entry() const
Definition: UT_Options.h:293
UT_Options & setOptionDict(const UT_StringHolder &name, const UT_OptionsHolder &value)
UT_Options & setOptionSRaw(const UT_StringHolder &name, const UT_StringHolder &value)
SYS_FORCE_INLINE UT_OptionsRef(const UT_Options *opt)
Will make a shallow reference.
Definition: UT_Options.h:713
type
Definition: core.h:1059
UT_Options & setOptionFArray(const UT_StringHolder &name, const fpreal32 *values, size_t size)
SYS_FORCE_INLINE void swap(UT_OptionsHolder &other)
Definition: UT_Options.h:1095
bool operator==(const iterator &i) const
Definition: UT_Options.h:305
bool operator==(const ordered_iterator &i) const
Definition: UT_Options.h:362
GLdouble s
Definition: glew.h:1395
UT_Options & setOptionF(const UT_StringHolder &name, fpreal64 value)
bool importOption(const UT_StringRef &name, int &value) const
GLint y
Definition: glcorearb.h:103
fpreal64 getOptionF(const UT_StringRef &name) const
UT_UniquePtr< UT_OptionEntry > UT_OptionEntryPtr
Definition: format.h:895
const UT_OptionsHolder & getOptionDict(const UT_StringRef &name) const
UT_Options & setOptionV2(const UT_StringHolder &name, const UT_Vector2F &value)
SYS_FORCE_INLINE const UT_Options * operator->() const
Definition: UT_Options.h:883
static void clearConstruct(UT_OptionsHolder *p)
Definition: UT_Options.h:1175
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.
Definition: node.h:450
const UT_StringHolder & getOptionS(const UT_StringRef &name) const