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 #include <utility>
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 w The writer stream used to save the options
230  /// @param compact If true, the type info is not explicitly saved.
231  bool save(UT_JSONWriter &w, bool compact = false) const;
232 
233  /// Save a UT_Options to a UT_JSONValue
234  /// @param map The value used to store the UT_Options
235  /// @param compact If true, the type info is not explicitly saved.
236  void save(UT_JSONValueMap &map, bool compact = false) const;
237 
238  /// Load a UT_Options from a JSON parser.
239  /// @param parser Parser
240  /// @param do_clear Clear existing map before loading
241  /// If true and the first object in the JSON stream is not a map object,
242  /// then the parser will fail (with an error). Otherwise a warning will
243  /// be added and the object will be skipped.
244  /// @param is If this is specified, then data will be read from that
245  /// stream rather than the stream associated with the parser.
246  /// @param require_type If true, the JSON input must contain option entries
247  /// in a format that explicitly specifies both the 'type' and the 'value'.
248  /// Otherwise, JSON may specify value directly, and the type will be
249  /// deduced implicitly from the value.
250  bool load(UT_JSONParser &parser,
251  bool do_clear,
252  UT_IStream *is = 0,
253  bool require_type = true);
254 
255  /// Loads a UT_Options from a JSONValue map.
256  /// @param map The source map
257  /// @param do_clear Clear the UT_Options before loading values from the map
258  /// @param allow_type Controls if a map with "type" and "value" entries
259  /// will be interpreted as an explicit type request.
260  /// @param allow_dict Controls if a map will be turned into a nested
261  /// dictionary.
262  /// Note: if both 'allow_type' and 'allow_dict' are true , things that
263  /// look like types will be treated as such; the rest as dictionaries.
264  bool load(const UT_JSONValueMap &map,
265  bool do_clear,
266  bool allow_type = true,
267  bool allow_dict = false);
268 
269  /// Writes a JSON dump to ostream of the current options.
270  void dump(std::ostream &os) const;
271  /// Dump to stdout/cout
272  void dump() const;
273 
274  // Functions for accessing the options by name.
275  bool hasOption(const UT_StringRef &name) const;
276  UT_OptionType getOptionType(const UT_StringRef &name) const;
277  const UT_OptionEntry*getOptionEntry(const UT_StringRef &name) const;
278 
279  exint getNumOptions() const { return myMap.size(); }
280  exint size() const { return getNumOptions(); }
281  exint entries() const { return getNumOptions(); }
282 
283  // Functions for accessing all options sequentially.
285  {
286  public:
288  : myOptions(nullptr)
289  {}
290  iterator(const iterator &i)
291  : myOptions(i.myOptions)
292  , myIterator(i.myIterator)
293  , myEnd(i.myEnd)
294  {}
295  const UT_StringHolder &name() const
296  { return myIterator->first; }
297  const UT_OptionEntry *entry() const
298  { return myIterator->second.get(); }
299  UT_OptionType type() const;
300  const UT_OptionEntry *operator*() const { return entry(); }
301 
303  {
304  myOptions = i.myOptions;
305  myIterator = i.myIterator;
306  myEnd = i.myEnd;
307  return *this;
308  }
309  bool operator==(const iterator &i) const
310  {
311  return myIterator == i.myIterator;
312  }
313  bool operator!=(const iterator &i) const
314  { return !(*this == i); }
315  iterator &operator++() { advance(); return *this; }
316  bool atEnd() const { return myIterator == myEnd; }
317  void advance() { ++myIterator; }
318  private:
319  iterator(const UT_Options &opts, const MapType::const_iterator &it,
321  : myOptions(&opts)
322  , myIterator(it)
323  , myEnd(end)
324  {
325  }
326  const UT_Options *myOptions;
327  MapType::const_iterator myIterator;
328  MapType::const_iterator myEnd;
329  friend class UT_Options;
330  };
332  {
333  public:
335  : myKeys()
336  , myValues()
337  , myOrder()
338  , myPos(0)
339  , myCurr(0)
340  {
341  }
343  : myKeys(src.myKeys)
344  , myValues(src.myValues)
345  , myOrder(src.myOrder)
346  , myPos(src.myPos)
347  , myCurr(src.myCurr)
348  {
349  }
350  const UT_StringHolder &name() const
351  { return myKeys(myCurr); }
352  const UT_OptionEntry *entry() const
353  { return myValues(myCurr); }
354  UT_OptionType type() const;
355  const UT_OptionEntry *operator*() const { return entry(); }
356 
358  {
359  myKeys = i.myKeys;
360  myValues = i.myValues;
361  myOrder = i.myOrder;
362  myPos = i.myPos;
363  myCurr = i.myCurr;
364  return *this;
365  }
366  bool operator==(const ordered_iterator &i) const
367  {
368  if (i.atEnd() && atEnd())
369  return true;
370  // Iterators are only equal if they are both at
371  // the end.
372  return false;
373  }
374  bool operator!=(const ordered_iterator &i) const
375  { return !(*this == i); }
376  ordered_iterator &operator++() { advance(); return *this; }
377  bool atEnd() const { return myPos >= myOrder.entries(); }
378  void advance()
379  {
380  myPos++;
381  if (myPos < myOrder.entries())
382  myCurr = myOrder(myPos);
383  }
384  private:
385  class comparator
386  {
387  public:
388  comparator(const UT_ValArray<UT_StringHolder> &keys)
389  : myKeys(keys)
390  {
391  }
392  bool operator()(int a, int b) const
393  {
394  UT_ASSERT(a >= 0 && a < myKeys.entries());
395  UT_ASSERT(b >= 0 && b < myKeys.entries());
396  return myKeys(a) < myKeys(b);
397  }
398  private:
399  const UT_ValArray<UT_StringHolder> &myKeys;
400  };
401  // If you get an error here, maybe you meant to call obegin()?
402  explicit ordered_iterator(iterator it)
403  : myKeys()
404  , myValues()
405  , myOrder()
406  , myPos(0)
407  , myCurr(0)
408  {
409  int index = 0;
410  for (; !it.atEnd(); ++it, ++index)
411  {
412  myKeys.append(it.name());
413  myValues.append(it.entry());
414  myOrder.append(index);
415  }
416  myOrder.sort(comparator(myKeys));
417  if (myOrder.entries())
418  myCurr = myOrder(0);
419  }
420 
424  int myPos;
425  int myCurr;
426  friend class UT_Options;
427  };
428  iterator begin() const
429  { return iterator(*this, myMap.begin(), myMap.end()); }
430  iterator end() const
431  { return iterator(*this, myMap.end(), myMap.end()); }
433  { return ordered_iterator(begin()); }
435  { return ordered_iterator(end()); }
436 
437  // Functions for accessing specific option values.
438  int64 getOptionI(const UT_StringRef &name) const;
439  bool getOptionB(const UT_StringRef &name) const;
440  fpreal64 getOptionF(const UT_StringRef &name) const;
441  const UT_Vector2D &getOptionV2(const UT_StringRef &name) const;
442  const UT_Vector3D &getOptionV3(const UT_StringRef &name) const;
443  const UT_Vector4D &getOptionV4(const UT_StringRef &name) const;
444  const UT_QuaternionD &getOptionQ(const UT_StringRef &name) const;
445  const UT_Matrix2D &getOptionM2(const UT_StringRef &name) const;
446  const UT_Matrix3D &getOptionM3(const UT_StringRef &name) const;
447  const UT_Matrix4D &getOptionM4(const UT_StringRef &name) const;
448  const UT_Vector2D &getOptionUV(const UT_StringRef &name) const;
449  const UT_Vector3D &getOptionUVW(const UT_StringRef &name) const;
450 
451  // Note that, if the string value contains binary data with null
452  // characters, the UT_String version of getOptionS will not be able to
453  // tell you the length of the data, since UT_String doesn't store the
454  // length.
455  const UT_StringHolder &getOptionS(const UT_StringRef &name) const;
456  void getOptionS(const UT_StringRef &name,
457  std::string &value) const;
458  void getOptionS(const UT_StringRef &name,
459  UT_String &value) const;
460  void getOptionS(const UT_StringRef &name,
461  UT_StringHolder &value) const;
462  void getOptionS(const UT_StringRef &,
463  UT_WorkBuffer &value) const;
464  const UT_OptionsHolder &getOptionDict(const UT_StringRef &name) const;
465 
466  const UT_Int64Array &getOptionIArray(const UT_StringRef &) const;
467  const UT_Fpreal64Array &getOptionFArray(const UT_StringRef &) const;
468  const UT_StringArray &getOptionSArray(const UT_StringRef &) const;
470 
471  // Returns a valid number if this option is a float or an int.
472  // In the case of an int, it is converted to a float.
473  fpreal64 getOptionNum(const UT_StringRef &) const;
474 
475  // Functions for accessing option values. These methods will perform some
476  // minimal "casting".
477  // importOption(... bool &value) - Tests integers and string options
478  // importOption(... fpreal &value) - Evaluates integer/bool options
479  // importOption(... UT_Vector2 &) - Evaluates Vector2 or UV
480  // importOption(... UT_Vector3 &) - Evaluates Vector3 or UVW
481  //
482  bool importOption(const UT_StringRef &name, int &value) const;
483  bool importOption(const UT_StringRef &name, int64 &value) const;
484  bool importOption(const UT_StringRef &name, bool &value) const;
485  bool importOption(const UT_StringRef &name,
486  fpreal32 &value) const;
487  bool importOption(const UT_StringRef &name,
488  fpreal64 &value) const;
489  bool importOption(const UT_StringRef &name,
490  std::string &value) const;
491  bool importOption(const UT_StringRef &name,
492  UT_String &value) const;
493  bool importOption(const UT_StringRef &name,
494  UT_StringHolder &value) const;
495  bool importOption(const UT_StringRef &name,
496  UT_OptionsHolder &value) const;
497  bool importOption(const UT_StringRef &name,
498  UT_Vector2F &value) const;
499  bool importOption(const UT_StringRef &name,
500  UT_Vector3F &value) const;
501  bool importOption(const UT_StringRef &name,
502  UT_Vector4F &value) const;
503  bool importOption(const UT_StringRef &name,
504  UT_QuaternionF &value) const;
505  bool importOption(const UT_StringRef &name,
506  UT_Matrix2F &value) const;
507  bool importOption(const UT_StringRef &name,
508  UT_Matrix3F &value) const;
509  bool importOption(const UT_StringRef &name,
510  UT_Matrix4F &value) const;
511  bool importOption(const UT_StringRef &name,
512  UT_Vector2D &value) const;
513  bool importOption(const UT_StringRef &name,
514  UT_Vector3D &value) const;
515  bool importOption(const UT_StringRef &name,
516  UT_Vector4D &value) const;
517  bool importOption(const UT_StringRef &name,
518  UT_QuaternionD &value) const;
519  bool importOption(const UT_StringRef &name,
520  UT_Matrix2D &value) const;
521  bool importOption(const UT_StringRef &name,
522  UT_Matrix3D &value) const;
523  bool importOption(const UT_StringRef &name,
524  UT_Matrix4D &value) const;
525 
526  // Generic import which handles arbitrary length int/float data
527  bool importOption(const UT_StringRef &name,
528  UT_Array<int32> &value) const;
529  bool importOption(const UT_StringRef &name,
530  UT_Array<int64> &value) const;
531  bool importOption(const UT_StringRef &name,
532  UT_Array<fpreal32> &value) const;
533  bool importOption(const UT_StringRef &name,
534  UT_Array<fpreal64> &value) const;
535 
536  // Import a string array
537  bool importOption(const UT_StringRef &name,
538  UT_StringArray &value) const;
539  bool importOption(const UT_StringRef &name,
540  UT_Array<UT_StringHolder> &value) const;
541 
542  // Import a dictionary array.
543  bool importOption(const UT_StringRef &name,
544  UT_Array<UT_OptionsHolder> &value) const;
545 
546  // Import a single element from a scalar, vector, matrix or array
547  bool importElement(const UT_StringRef &name,
548  fpreal &value,
549  exint index = 0) const;
550  bool importElement(const UT_StringRef &name,
551  int64 &value,
552  exint index = 0) const;
553 
554 
555  // All these functions cause optionChanged to be called.
557  int64 value);
559  bool value);
561  fpreal64 value);
562  // Note that you can store binary data (that can contain null characters
563  // or that isn't null-terminated) in a string option by passing in a
564  // UT_WorkBuffer, or std::string.
566  const UT_StringHolder &value);
567  // setOptionSRaw() is the same as setOptionS() instead of it being
568  // additionally tagged as a "raw" string so that getPyOptionString() and
569  // appendPyDictionary() won't add quotes around the value. To retrieve its
570  // value, use getOptionS().
572  const UT_StringHolder &value);
574  const UT_OptionsHolder &value);
576  const UT_Vector2F &value);
578  const UT_Vector2D &value);
580  fpreal64 x, fpreal64 y);
582  const UT_Vector3F &value);
584  const UT_Vector3D &value);
588  const UT_Vector4F &value);
590  const UT_Vector4D &value);
592  fpreal64 x, fpreal64 y,
593  fpreal64 z, fpreal64 w);
595  const UT_QuaternionF &value);
597  const UT_QuaternionD &value);
599  const UT_Matrix2F &value);
601  const UT_Matrix2D &value);
603  const UT_Matrix3F &value);
605  const UT_Matrix3D &value);
607  const UT_Matrix4F &value);
609  const UT_Matrix4D &value);
611  const UT_Vector2F &value);
613  const UT_Vector2D &value);
615  const UT_Vector3F &value);
617  const UT_Vector3D &value);
618  /// @{
619  /// Set integer array options
621  const int32 *values, size_t size);
623  const int64 *values, size_t size);
625  const UT_Array<int64> &value);
626  /// @}
627  /// @{
628  /// Set float/double array options
630  const fpreal32 *values, size_t size);
632  const fpreal64 *values, size_t size);
634  const UT_Array<fpreal64> &value);
635  /// @}
636 
637  /// Set string array options
639  const UT_StringHolder *values,
640  size_t size);
642  const char *const*values,
643  size_t size);
645  const UT_StringArray &value);
646 
647  /// Set dict array options
649  const UT_OptionsHolder *values,
650  size_t size);
652  const UT_Array<UT_OptionsHolder> &value);
653 
654  /// Get a hash code for the options
655  unsigned hash() const;
656 
657  /// Comparison operator
658  bool operator==(const UT_Options &src) const
659  { return isEqual(src, 0.0); }
660  bool operator!=(const UT_Options &src) const
661  { return !(*this == src); }
662 
663  /// Comparison operator with a tolerance for float values.
664  bool isEqual(const UT_Options &src, fpreal64 tol) const;
665 
666  /// Assignment operator
667  const UT_Options &operator=(const UT_Options &src);
668  void merge(const UT_Options &src);
669  void merge(const UT_Options &src,
670  bool (*match)(const UT_StringHolder &name,
671  const UT_OptionEntry *, void *),
672  void *data);
673  virtual int64 getMemoryUsage(bool inclusive) const;
674 
675  // This will steal the option from the unique ptr.
676  void setOption(const UT_StringHolder &name,
677  UT_OptionEntryPtr value);
678 
679 protected:
680  const UT_StringHolder *findOptionS(const UT_StringRef &name) const;
681  void addError(const char *filename, int linecount,
682  const char *error_str) const;
683  bool sendOptionChanges() const
684  { return mySendOptionChanges; }
686  { mySendOptionChanges = f; }
687  virtual void optionChanged(const char *name);
688  UT_OptionEntryPtr parsePyValue(const char *&value,
689  char sep_delim,
690  char close_delim = '\0');
691 
692 private:
693  template <class ITER>
694  bool save(ITER start, const char *filename, std::ostream &os) const;
695 
696  MapType myMap;
697  bool mySendOptionChanges;
698 };
699 
700 /// A holder for a options, which caches the hash value.
701 /// A UT_OptionsRef does not necessarily own the options, and it is therefore
702 /// not safe to e.g. store a UT_OptionsRef in a container or member variable.
703 /// @see UT_OptionsHolder
705 {
706 public:
708 
711  {
712  init();
713  }
714 
715  /// Will make a shallow reference.
718  {
719  init();
720  reference(opt);
721  }
722 
723  /// Shares a reference with the source.
726  {
727  mySoftRef = s.mySoftRef;
728  mySharedRef = s.mySharedRef;
729  myHash = s.myHash;
730  }
731 
732  /// Move constructor. Steals the working data from the original.
735  {
736  mySoftRef = s.mySoftRef;
737  mySharedRef = std::move(s.mySharedRef);
738  myHash = s.myHash;
739  s.init();
740  }
741 
744  {
745  }
746 
747  /// Special sentinel value support
748  /// @{
749  enum UT_OptionsSentinelType { SENTINEL };
750 
751  SYS_FORCE_INLINE explicit
753  : mySoftRef((const UT_Options *)SENTINEL_DATA)
754  , myHash(SENTINEL_HASH)
755  {
756  }
757 
759  bool isSentinel() const
760  {
761  return uintptr_t(mySoftRef) == SENTINEL_DATA && myHash == SENTINEL_HASH;
762  }
763 
766  {
767  init();
768  myHash = SENTINEL_HASH;
769  mySoftRef = (const UT_Options *) SENTINEL_DATA;
770  }
771  /// @}
772 
773  /// Returns true this object is the sole owner of the underlying options
774  bool isUnique() const
775  {
776  // Soft references are not unique. (This includes sentinels)
777  if (mySoftRef)
778  return false;
779  // If the shared ref is null, it isn't unique.
780  if (!mySharedRef.get())
781  return false;
782 
783  return mySharedRef.unique();
784  }
785 
786  /// Returns the shared ptr use count. 0 if not a shared
787  /// pointer. (null or soft ref)
788  int use_count() const
789  {
790  if (mySoftRef)
791  return 0;
792  if (!mySharedRef.get())
793  return 0;
794  return mySharedRef.use_count();
795  }
796 
797  /// Shares a reference with the source.
799  {
800  // Can now blindly copy.
801  mySoftRef = s.mySoftRef;
802  mySharedRef = s.mySharedRef;
803  myHash = s.myHash;
804  return *this;
805  }
806 
807  /// Move the contents of about-to-be-destructed options
808  /// s to this string.
811  {
812  // Can just swap, since s is about to be destructed.
813  swap(s);
814  return *this;
815  }
816 
818  const UT_Options *optionsOrNull() const
819  {
820  if (isSentinel())
821  return nullptr;
822  return rawOptions();
823  }
824 
826  const UT_Options *options() const
827  {
828  const UT_Options *result = optionsOrNull();
829  if (result == nullptr)
830  return &theEmptyOptionsData;
831  return result;
832  }
833 
834  bool operator==(const UT_OptionsRef &s) const
835  {
836  const UT_Options *a = rawOptions();
837  const UT_Options *b = s.rawOptions();
838 
839  if (a == b)
840  return true;
841 
842  // If they are not equal, we have to test null and sentinel.
843  // If either one is null or sentinel, we know they must be
844  // unequal.
845  if (!a || !b || (uintptr_t(a) == SENTINEL_DATA) || (uintptr_t(b) == SENTINEL_DATA))
846  return false;
847 
848  // If we have hashes and they are unequal, we must
849  // be unequal.
850  if (myHash && s.myHash)
851  {
852  if (myHash != s.myHash)
853  return false;
854  }
855 
856  // Now we have de-referenceable options pointers.
857  return (*a == *b);
858  }
859 
860  bool operator==(const UT_Options *b) const
861  {
862  const UT_Options *a = rawOptions();
863 
864  if (a == b)
865  return true;
866 
867  // If they are not equal, we have to test null and sentinel.
868  // If either one is null or sentinel, we know they must be
869  // unequal.
870  if (!a || !b || (uintptr_t(a) == SENTINEL_DATA) || (uintptr_t(b) == SENTINEL_DATA))
871  return false;
872 
873  // Can't test hashes as we don't have it for a raw pointer.
874 
875  // Now we have de-referenceable options pointers.
876  return (*a == *b);
877  }
878 
879  bool operator!=(const UT_OptionsRef &s) const
880  { return !operator==(s); }
881  bool operator!=(const UT_Options *s) const
882  { return !operator==(s); }
883 
884  /// Comparison operator with a tolerance for float values.
885  bool isEqual(const UT_OptionsRef &s, fpreal64 tol) const;
886 
887  SYS_FORCE_INLINE const UT_Options *operator->() const { return options(); }
888  SYS_FORCE_INLINE const UT_Options &operator*() const { return *options(); }
889 
891  void swap( UT_OptionsRef &other )
892  {
893  UTswap(mySoftRef, other.mySoftRef);
894  UTswap(mySharedRef, other.mySharedRef);
895  UTswap(myHash, other.myHash);
896  }
897 
898  /// Friend specialization of std::swap() to use UT_OptionsRef::swap()
899  friend void swap(UT_OptionsRef& a, UT_OptionsRef& b) { a.swap(b); }
900 
902  void clear()
903  {
904  init();
905  }
906 
907  bool isEmpty() const
908  {
909  const UT_Options *opt = optionsOrNull();
910  if (!opt)
911  return true;
912 
913  if (opt->getNumOptions() == 0)
914  return true;
915 
916  return false;
917  }
918 
919  explicit operator bool() const { return !isEmpty(); }
920 
921  unsigned hash() const
922  {
923  if (myHash)
924  return myHash;
925 
926  const UT_Options *opt = optionsOrNull();
927  if (!opt)
928  return 0;
929 
930  unsigned localhash = opt->hash();
931  if (!localhash)
932  localhash++;
933  myHash = localhash;
934  return myHash;
935  }
936 
937  /// Make a light weight reference to the source.
938  /// Caller must make sure src lives for the duration of this object,
939  /// and any objects value copied from this!
940  void reference(const UT_Options *src)
941  {
942  init();
943  mySoftRef = src;
944  }
945 
946  int64 getMemoryUsage(bool inclusive) const
947  {
948  int64 mem = inclusive ? sizeof(*this) : 0;
949 
950  const UT_Options *opt = optionsOrNull();
951  if (opt)
952  mem += opt->getMemoryUsage(true);
953  return mem;
954  }
955 
956  static const UT_Options &emptyOptions() { return theEmptyOptionsData; }
957 
958 private:
959  void init()
960  {
961  mySoftRef = nullptr;
962  mySharedRef.reset();
963  myHash = 0;
964  }
965 
966  void copy(const UT_OptionsRef &s)
967  {
968  mySoftRef = s.mySoftRef;
969  mySharedRef = s.mySharedRef;
970  myHash = s.myHash;
971  }
972 
974  const UT_Options *rawOptions() const
975  {
976  if (mySoftRef)
977  return mySoftRef;
978  return mySharedRef.get();
979  }
980 
981 
982  /// Either softref or shared ref should be set, never both.
983  /// Note that this might be possible to collapse into a single
984  /// shared ptr using the semantic that use_count==0 means soft ref.
985  const UT_Options *mySoftRef;
986  UT_SharedPtr<UT_Options> mySharedRef;
987 
988  /// Optional hash, 0 if not computed yet.
989  mutable int myHash;
990 
991  // UT_OptionsHolder needs to be a friend class so that the
992  // UT_OptionsHolder(const UT_OptionsRef &) constructor can access myHash and
993  // getHolder() for the UT_OptionsRef that is passed in.
994  friend class UT_OptionsHolder;
995 
996  static constexpr uintptr_t SENTINEL_DATA = 1;
997  static constexpr uint32 SENTINEL_HASH = 0xdeadbeef;
998 
999  // Because we want a null options pointer to return an empty options,
1000  // we need a canonical empty options to return.
1001  static const UT_Options theEmptyOptionsData;
1002 
1003  template<typename T>
1004  static SYS_FORCE_INLINE bool isSentinelOrNullPtr(const T *p)
1005  {
1006  return uintptr_t(p) <= SENTINEL_DATA;
1007  }
1008 };
1009 
1011 {
1012  return opt.hash();
1013 }
1014 
1015 
1017 {
1018 public:
1019  /// UT_OptionsHolder can be constructed with UT_OptionsHolder::REFERENCE to
1020  /// create a shallow reference to the const char *.
1021  enum UT_OptionsReferenceType { REFERENCE };
1022 
1025  : UT_OptionsRef()
1026  {
1027  }
1028 
1029  /// Will make a copy of the provided options.
1032  {
1033  mySoftRef = nullptr;
1034  if (opt)
1035  mySharedRef = UTmakeShared<UT_Options>(*opt);
1036  else
1037  mySharedRef.reset();
1038  }
1039 
1042  {
1043  mySoftRef = nullptr;
1044  mySharedRef = std::move(opts);
1045  }
1046 
1047  /// Will make a shallow reference.
1050  : UT_OptionsRef(opt)
1051  {
1052  }
1053 
1054  /// Makes a shallow reference to the contents of the UT_OptionsRef.
1057  : UT_OptionsRef(ref)
1058  {
1059  }
1060 
1061  /// Makes a deep copy of the provided UT_OptionsRef.
1062  /// This constructor is not marked explicit since we often want this
1063  /// conversion (e.g. when inserting a UT_OptionsRef into a UT_OptionsMap, as
1064  /// with the const char* constructor).
1066 
1067  /// Construct as a sentinel value
1068  SYS_FORCE_INLINE explicit
1070  : UT_OptionsRef(sentinel)
1071  {
1072  }
1073 
1074  /// Makes a copy of the provided options.
1077  : UT_OptionsRef(str)
1078  {
1079  }
1080 
1081  /// Move constructor. Steals the working data from the original.
1084  : UT_OptionsRef(std::move(a))
1085  {
1086  }
1087 
1088  /// Makes a bit-wise copy of the options and adjust the reference count.
1091  {
1093  return *this;
1094  }
1095 
1096  /// Move the contents of about-to-be-destructed options
1097  /// s to this options.
1100  {
1101  UT_OptionsRef::operator=(std::move(s));
1102  return *this;
1103  }
1104 
1106  void swap(UT_OptionsHolder &other)
1107  {
1108  UT_OptionsRef::swap(other);
1109  }
1110 
1112  void swap(UT_OptionsRef &other)
1113  {
1114  UT_OptionsRef::swap(other);
1115  // harden ourselves like UT_OptionsHolder::operator=(UT_OptionsRef&)
1116  if (isSentinelOrNullPtr(mySoftRef))
1117  return; // already a holder
1118  mySharedRef = UTmakeShared<UT_Options>(*mySoftRef);
1119  mySoftRef = nullptr;
1120  }
1121 
1122  /// Returns a writeable UT_Options which will modify the contents
1123  /// of this options holder. When this is copied or deleted, the
1124  /// returned pointer must not be used any more. (Ideally we could
1125  /// erase ourself and return a UniquePtr for correct life time,
1126  /// but we can't steal from a shared pointer)
1127  ///
1128  /// Use update() whereever possible instead as it is much safer.
1130  {
1131  // Harden if soft.
1132  if (!isUnique())
1133  {
1134  mySharedRef = UTmakeShared<UT_Options>(*options());
1135  mySoftRef = nullptr;
1136  }
1137  UT_ASSERT(isUnique());
1138 
1139  // Since we are going to be edited, we must reset our hash.
1140  myHash = 0;
1141 
1142  return SYSconst_cast(options());
1143  }
1144 
1145  /// Updates the contents of this option, first making sure it is
1146  /// unique. The provided operator should take a reference to
1147  /// a UT_Options that it will update.
1148  /// UT_OptionsHolder value;
1149  /// value.update([](UT_Options &opt) { opt.setOptionS("test", "bar"); });
1150  template <typename OP>
1151  void update(const OP &op)
1152  {
1153  UT_Options *opt = makeUnique();
1154  op(*opt);
1155  }
1156 
1157  /// Friend specialization of std::swap() to use UT_OptionsHolder::swap()
1158  /// @{
1159  friend void swap(UT_OptionsHolder& a, UT_OptionsRef& b) { a.swap(b); }
1160  friend void swap(UT_OptionsHolder& a, UT_OptionsHolder& b) { a.swap(b); }
1161  /// @}
1162 
1163  /// In some functions it's nice to be able to return a const-reference to a
1164  /// UT_OptionsHolder. However, in error cases, you likely want to return an
1165  /// empty options. This would mean that you'd have to return a real
1166  /// UT_OptionsHolder (not a const reference). This static lets you return a
1167  /// reference to an empty options.
1169 
1171 
1172 protected:
1173 };
1174 
1175 // For UT::ArraySet.
1176 namespace UT
1177 {
1178 template <typename T>
1179 struct DefaultClearer;
1180 
1181 template <>
1183 {
1184  static void clear(UT_OptionsHolder &v) { v.makeSentinel(); }
1185  static bool isClear(const UT_OptionsHolder &v) { return v.isSentinel(); }
1187  { new ((void *)p) UT_OptionsHolder(UT_OptionsRef::SENTINEL); }
1188  static const bool clearNeedsDestruction = false;
1189 };
1190 } // namespace UT
1191 
1192 UT_API size_t format(char *buffer, size_t buffer_size, const UT_Options &v);
1193 UT_API size_t format(char *buffer, size_t buffer_size, const UT_OptionsRef &v);
1194 
1195 // Most people only include UT_Options. But we can't include this at the start
1196 // as we are a pre-req.
1197 #include "UT_OptionEntry.h"
1198 
1199 #endif
SYS_FORCE_INLINE UT_OptionsHolder(UT_UniquePtr< UT_Options > opts)
Definition: UT_Options.h:1041
bool operator==(const UT_OptionsRef &s) const
Definition: UT_Options.h:834
bool getOptionB(const UT_StringRef &name) const
SYS_FORCE_INLINE UT_OptionsRef()
Definition: UT_Options.h:710
SYS_FORCE_INLINE bool isSentinel() const
Definition: UT_Options.h:759
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:350
const UT_OptionEntry * operator*() const
Definition: UT_Options.h:300
int64 getMemoryUsage(bool inclusive) const
Definition: UT_Options.h:946
friend void swap(UT_OptionsRef &a, UT_OptionsRef &b)
Friend specialization of std::swap() to use UT_OptionsRef::swap()
Definition: UT_Options.h:899
SYS_FORCE_INLINE void swap(UT_OptionsRef &other)
Definition: UT_Options.h:891
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:1083
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:888
const GLdouble * v
Definition: glcorearb.h:837
GLuint start
Definition: glcorearb.h:475
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
bool isEmpty() const
Definition: UT_Options.h:907
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:1010
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
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:848
static const UT_OptionsHolder theSentinel
Definition: UT_Options.h:1170
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:660
UT_Options & setOptionV3(const UT_StringHolder &name, const UT_Vector3F &value)
exint size() const
Definition: UT_Options.h:280
int64 getOptionI(const UT_StringRef &name) const
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
GLdouble s
Definition: glad.h:3009
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:87
ordered_iterator oend() const
Definition: UT_Options.h:434
#define UT_API
Definition: UT_API.h:14
GLint y
Definition: glcorearb.h:103
SYS_FORCE_INLINE UT_OptionsHolder(UT_OptionsReferenceType, const UT_Options *opt)
Will make a shallow reference.
Definition: UT_Options.h:1049
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
SYS_FORCE_INLINE UT_OptionsHolder()
Definition: UT_Options.h:1024
const UT_Matrix3D & getOptionM3(const UT_StringRef &name) const
**But if you need a result
Definition: thread.h:613
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:1090
const UT_Fpreal64Array & getOptionFArray(const UT_StringRef &) const
static const UT_Options & emptyOptions()
Definition: UT_Options.h:956
float fpreal32
Definition: SYS_Types.h:200
bool atEnd() const
Definition: UT_Options.h:316
bool operator==(const UT_Options &src) const
Comparison operator.
Definition: UT_Options.h:658
UT_OptionsRef & operator=(const UT_OptionsRef &s)
Shares a reference with the source.
Definition: UT_Options.h:798
exint entries() const
Definition: UT_Options.h:281
UT_Options & setOptionM4(const UT_StringHolder &name, const UT_Matrix4F &value)
void setSendOptionChanges(bool f)
Definition: UT_Options.h:685
void reference(const UT_Options *src)
Definition: UT_Options.h:940
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
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:1069
ordered_iterator & operator=(const ordered_iterator &i)
Definition: UT_Options.h:357
iterator end() const
Definition: UT_Options.h:430
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:342
SYS_FORCE_INLINE const UT_Options * optionsOrNull() const
Definition: UT_Options.h:818
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:734
UT_Options & setOptionSArray(const UT_StringHolder &name, const UT_StringHolder *values, size_t size)
Set string array options.
GLfloat f
Definition: glcorearb.h:1926
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:902
UT_Options & setOptionUV(const UT_StringHolder &name, const UT_Vector2F &value)
GLint ref
Definition: glcorearb.h:124
void update(const OP &op)
Definition: UT_Options.h:1151
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
UT_Options value_type
Definition: UT_Options.h:707
SYS_FORCE_INLINE void swap(UT_OptionsRef &other)
Definition: UT_Options.h:1112
unsigned hash() const
Get a hash code for the options.
UT_Options & setOptionQ(const UT_StringHolder &name, const UT_QuaternionF &value)
GLuint GLuint end
Definition: glcorearb.h:475
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
const UT_OptionEntry * operator*() const
Definition: UT_Options.h:355
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:108
ordered_iterator obegin() const
Definition: UT_Options.h:432
static const UT_OptionsHolder theEmptyOptions
Definition: UT_Options.h:1168
friend void swap(UT_OptionsHolder &a, UT_OptionsRef &b)
Definition: UT_Options.h:1159
SYS_FORCE_INLINE UT_OptionsRef(UT_OptionsSentinelType)
Definition: UT_Options.h:752
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)
UT_Options & setOptionB(const UT_StringHolder &name, bool value)
const UT_StringHolder & name() const
Definition: UT_Options.h:295
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
SYS_FORCE_INLINE UT_OptionsRef(const UT_OptionsRef &s)
Shares a reference with the source.
Definition: UT_Options.h:725
const UT_Matrix2D & getOptionM2(const UT_StringRef &name) const
iterator & operator++()
Definition: UT_Options.h:315
UT_Options & setOptionM2(const UT_StringHolder &name, const UT_Matrix2F &value)
iterator(const iterator &i)
Definition: UT_Options.h:290
const UT_QuaternionD & getOptionQ(const UT_StringRef &name) const
GLuint const GLchar * name
Definition: glcorearb.h:786
bool operator!=(const UT_Options *s) const
Definition: UT_Options.h:881
bool operator!=(const iterator &i) const
Definition: UT_Options.h:313
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
GLint GLenum GLint x
Definition: glcorearb.h:409
bool operator==(const UT_Options *b) const
Definition: UT_Options.h:860
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:1185
SYS_FORCE_INLINE ~UT_OptionsRef()
Definition: UT_Options.h:743
bool isUnique() const
Returns true this object is the sole owner of the underlying options.
Definition: UT_Options.h:774
bool save(const char *filename) const
friend class UT_OptionsHolder
Definition: UT_Options.h:994
iterator begin() const
Definition: UT_Options.h:428
static void clear(UT_OptionsHolder &v)
Definition: UT_Options.h:1184
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:1056
GLsizeiptr size
Definition: glcorearb.h:664
A map of string to various well defined value types.
Definition: UT_Options.h:84
UT_Options * makeUnique()
Definition: UT_Options.h:1129
SYS_FORCE_INLINE UT_OptionsRef & operator=(UT_OptionsRef &&s)
Definition: UT_Options.h:810
SYS_FORCE_INLINE UT_OptionsHolder & operator=(UT_OptionsHolder &&s)
Definition: UT_Options.h:1099
exint getNumOptions() const
Definition: UT_Options.h:279
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
SYS_FORCE_INLINE void makeSentinel()
Definition: UT_Options.h:765
const UT_Vector4D & getOptionV4(const UT_StringRef &name) const
bool operator!=(const ordered_iterator &i) const
Definition: UT_Options.h:374
SYS_FORCE_INLINE const UT_Options * options() const
Definition: UT_Options.h:826
ordered_iterator & operator++()
Definition: UT_Options.h:376
bool operator!=(const UT_OptionsRef &s) const
Definition: UT_Options.h:879
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:1076
LeafData & operator=(const LeafData &)=delete
iterator & operator=(const iterator &i)
Definition: UT_Options.h:302
SYS_FORCE_INLINE UT_OptionsHolder(const UT_Options *opt)
Will make a copy of the provided options.
Definition: UT_Options.h:1031
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:99
friend void swap(UT_OptionsHolder &a, UT_OptionsHolder &b)
Definition: UT_Options.h:1160
unsigned int uint32
Definition: SYS_Types.h:40
bool sendOptionChanges() const
Definition: UT_Options.h:683
void merge(const UT_Options &src)
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
unsigned hash() const
Definition: UT_Options.h:921
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
Definition: core.h:1131
const UT_OptionEntry * entry() const
Definition: UT_Options.h:352
int use_count() const
Definition: UT_Options.h:788
UT_OptionFormat
String formatting options for getOptionString.
Definition: UT_Options.h:71
const UT_OptionEntry * entry() const
Definition: UT_Options.h:297
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:717
UT_Options & setOptionFArray(const UT_StringHolder &name, const fpreal32 *values, size_t size)
that also have some descendant prim *whose name begins with which in turn has a child named baz where *the predicate and *a name There is also one special expression reference
SYS_FORCE_INLINE void swap(UT_OptionsHolder &other)
Definition: UT_Options.h:1106
type
Definition: core.h:1059
bool operator==(const iterator &i) const
Definition: UT_Options.h:309
bool operator==(const ordered_iterator &i) const
Definition: UT_Options.h:366
UT_Options & setOptionF(const UT_StringHolder &name, fpreal64 value)
bool importOption(const UT_StringRef &name, int &value) const
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:887
GLenum src
Definition: glcorearb.h:1793
static void clearConstruct(UT_OptionsHolder *p)
Definition: UT_Options.h:1186
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.
Definition: node.h:558
const UT_StringHolder & getOptionS(const UT_StringRef &name) const