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  UT_Options(const char *type_and_name, ...);
173 
174  // This function does not call optionChanged.
175  void clear();
176 
177  // only returns false if the file encounters an error. true is returned on
178  // success or if the file didn't exist.
179  // The load methods can handle files saved either with this save
180  // or with saveAsJSON. saveAsJSON is preferable as it handles 64bit
181  // floats and ints, but can't be read before H10.5
182  bool load(const char *filename);
183  bool save(const char *filename) const;
184  bool saveOrdered(const char *filename) const;
185  bool load(const char *filename, UT_IStream &is);
186  bool save(const char *filename, std::ostream &os) const;
187  bool saveOrdered(const char *filename, std::ostream &os) const;
188 
189  bool saveAsJSON(const char *filename,
190  bool binary = true) const;
191  bool saveAsJSON(const char *filename, std::ostream &os,
192  bool binary = true) const;
193 
194  // Remove an option.
195  void removeOption(const UT_StringHolder &name);
196 
197  // Get the string representation of any of our options. Note that, if
198  // the value contains binary data with null characters, you can't determine
199  // the length of the data with UT_String version of these methods.
200  bool getOptionString(const UT_StringHolder &name,
202  UT_WorkBuffer &result) const;
203  bool getOptionString(const UT_StringHolder &name,
204  UT_OptionFormat format,
205  UT_String &result) const;
206 
207  // Append the python dictionary representation of ALL our options to the
208  // buffer
209  bool appendPyDictionary(UT_WorkBuffer &result,
210  bool sorted=false) const;
211 
212  // Parse a python dictionary string and merge the results into our
213  // options.
214  bool setFromPyDictionary(const char *dict);
215 
216  // Parse a python formatted value and set it as the named option.
217  bool setPyOptionString(const UT_StringHolder &name,
218  const char *value);
219 
220  /// Save a UT_Options to JSON format using UT_JSONWriter
221  bool save(UT_JSONWriter &w) const;
222  /// Save a UT_Options to a UT_JSONValue
223  void save(UT_JSONValueMap &map) const;
224 
225  /// Load a UT_Options from a JSON parser.
226  /// @param parser Parser
227  /// @param do_clear Clear existing map before loading
228  /// If true and the first object in the JSON stream is not a map object,
229  /// then the parser will fail (with an error). Otherwise a warning will
230  /// be added and the object will be skipped.
231  /// @param is If this is specified, then data will be read from that
232  /// stream rather than the stream associated with the parser.
233  bool load(UT_JSONParser &parser,
234  bool do_clear,
235  UT_IStream *is = 0);
236 
237  /// Loads a UT_Options from a JSONValue map.
238  /// allow_type controls if a map with "type" and "value" entries
239  /// will be interpreted as an explicit type request.
240  /// allow_dict controls if a map will be turned into a nested dictionary.
241  /// if both are set, things that look like types will be treated as such,
242  /// the rest as dictionaries.
243  bool load(UT_JSONValueMap &map,
244  bool do_clear,
245  bool allow_type = true,
246  bool allow_dict = false);
247 
248  /// Writes a JSON dump to ostream of the current options.
249  void dump(std::ostream &os) const;
250  /// Dump to stdout/cout
251  void dump() const;
252 
253  // Functions for accessing the options by name.
254  bool hasOption(const UT_StringRef &name) const;
255  UT_OptionType getOptionType(const UT_StringRef &name) const;
256  const UT_OptionEntry*getOptionEntry(const UT_StringRef &name) const;
257 
258  // Functions for accessing all options sequentially.
259  int getNumOptions() const;
261  {
262  public:
264  : myOptions(nullptr)
265  {}
266  iterator(const iterator &i)
267  : myOptions(i.myOptions)
268  , myIterator(i.myIterator)
269  , myEnd(i.myEnd)
270  {}
271  const UT_StringHolder &name() const
272  { return myIterator->first; }
273  const UT_OptionEntry *entry() const
274  { return myIterator->second.get(); }
275  UT_OptionType type() const;
276  const UT_OptionEntry *operator*() const { return entry(); }
277 
279  {
280  myOptions = i.myOptions;
281  myIterator = i.myIterator;
282  myEnd = i.myEnd;
283  return *this;
284  }
285  bool operator==(const iterator &i) const
286  {
287  return myIterator == i.myIterator;
288  }
289  bool operator!=(const iterator &i) const
290  { return !(*this == i); }
291  iterator &operator++() { advance(); return *this; }
292  bool atEnd() const { return myIterator == myEnd; }
293  void advance() { ++myIterator; }
294  private:
295  iterator(const UT_Options &opts, const MapType::const_iterator &it,
297  : myOptions(&opts)
298  , myIterator(it)
299  , myEnd(end)
300  {
301  }
302  const UT_Options *myOptions;
303  MapType::const_iterator myIterator;
304  MapType::const_iterator myEnd;
305  friend class UT_Options;
306  };
308  {
309  public:
311  : myKeys()
312  , myValues()
313  , myOrder()
314  , myPos(0)
315  , myCurr(0)
316  {
317  }
319  : myKeys(src.myKeys)
320  , myValues(src.myValues)
321  , myOrder(src.myOrder)
322  , myPos(src.myPos)
323  , myCurr(src.myCurr)
324  {
325  }
326  const UT_StringHolder &name() const
327  { return myKeys(myCurr); }
328  const UT_OptionEntry *entry() const
329  { return myValues(myCurr); }
330  UT_OptionType type() const;
331  const UT_OptionEntry *operator*() const { return entry(); }
332 
334  {
335  myKeys = i.myKeys;
336  myValues = i.myValues;
337  myOrder = i.myOrder;
338  myPos = i.myPos;
339  myCurr = i.myCurr;
340  return *this;
341  }
342  bool operator==(const ordered_iterator &i) const
343  {
344  if (i.atEnd() && atEnd())
345  return true;
346  // Iterators are only equal if they are both at
347  // the end.
348  return false;
349  }
350  bool operator!=(const ordered_iterator &i) const
351  { return !(*this == i); }
352  ordered_iterator &operator++() { advance(); return *this; }
353  bool atEnd() const { return myPos >= myOrder.entries(); }
354  void advance()
355  {
356  myPos++;
357  if (myPos < myOrder.entries())
358  myCurr = myOrder(myPos);
359  }
360  private:
361  class comparator
362  {
363  public:
364  comparator(const UT_ValArray<UT_StringHolder> &keys)
365  : myKeys(keys)
366  {
367  }
368  bool operator()(int a, int b) const
369  {
370  UT_ASSERT(a >= 0 && a < myKeys.entries());
371  UT_ASSERT(b >= 0 && b < myKeys.entries());
372  return myKeys(a) < myKeys(b);
373  }
374  private:
375  const UT_ValArray<UT_StringHolder> &myKeys;
376  };
377  // If you get an error here, maybe you meant to call obegin()?
378  explicit ordered_iterator(iterator it)
379  : myKeys()
380  , myValues()
381  , myOrder()
382  , myPos(0)
383  , myCurr(0)
384  {
385  int index = 0;
386  for (; !it.atEnd(); ++it, ++index)
387  {
388  myKeys.append(it.name());
389  myValues.append(it.entry());
390  myOrder.append(index);
391  }
392  myOrder.stdsort( comparator(myKeys) );
393  if (myOrder.entries())
394  myCurr = myOrder(0);
395  }
396 
400  int myPos;
401  int myCurr;
402  friend class UT_Options;
403  };
404  iterator begin() const
405  { return iterator(*this, myMap.begin(), myMap.end()); }
406  iterator end() const
407  { return iterator(*this, myMap.end(), myMap.end()); }
409  { return ordered_iterator(begin()); }
411  { return ordered_iterator(end()); }
412 
413  // Functions for accessing specific option values.
414  int64 getOptionI(const UT_StringRef &name) const;
415  bool getOptionB(const UT_StringRef &name) const;
416  fpreal64 getOptionF(const UT_StringRef &name) const;
417  const UT_Vector2D &getOptionV2(const UT_StringRef &name) const;
418  const UT_Vector3D &getOptionV3(const UT_StringRef &name) const;
419  const UT_Vector4D &getOptionV4(const UT_StringRef &name) const;
420  const UT_QuaternionD &getOptionQ(const UT_StringRef &name) const;
421  const UT_Matrix2D &getOptionM2(const UT_StringRef &name) const;
422  const UT_Matrix3D &getOptionM3(const UT_StringRef &name) const;
423  const UT_Matrix4D &getOptionM4(const UT_StringRef &name) const;
424  const UT_Vector2D &getOptionUV(const UT_StringRef &name) const;
425  const UT_Vector3D &getOptionUVW(const UT_StringRef &name) const;
426 
427  // Note that, if the string value contains binary data with null
428  // characters, the UT_String version of getOptionS will not be able to
429  // tell you the length of the data, since UT_String doesn't store the
430  // length.
431  const UT_StringHolder &getOptionS(const UT_StringRef &name) const;
432  void getOptionS(const UT_StringRef &name,
433  std::string &value) const;
434  void getOptionS(const UT_StringRef &name,
435  UT_String &value) const;
436  void getOptionS(const UT_StringRef &name,
437  UT_StringHolder &value) const;
438  void getOptionS(const UT_StringRef &,
439  UT_WorkBuffer &value) const;
440  const UT_OptionsHolder &getOptionDict(const UT_StringRef &name) const;
441 
442  const UT_Int64Array &getOptionIArray(const UT_StringRef &) const;
443  const UT_Fpreal64Array &getOptionFArray(const UT_StringRef &) const;
444  const UT_StringArray &getOptionSArray(const UT_StringRef &) const;
446 
447  // Returns a valid number if this option is a float or an int.
448  // In the case of an int, it is converted to a float.
449  fpreal64 getOptionNum(const UT_StringRef &) const;
450 
451  // Functions for accessing option values. These methods will perform some
452  // minimal "casting".
453  // importOption(... bool &value) - Tests integers and string options
454  // importOption(... fpreal &value) - Evaluates integer/bool options
455  // importOption(... UT_Vector2 &) - Evaluates Vector2 or UV
456  // importOption(... UT_Vector3 &) - Evaluates Vector3 or UVW
457  //
458  bool importOption(const UT_StringRef &name, int &value) const;
459  bool importOption(const UT_StringRef &name, int64 &value) const;
460  bool importOption(const UT_StringRef &name, bool &value) const;
461  bool importOption(const UT_StringRef &name,
462  fpreal32 &value) const;
463  bool importOption(const UT_StringRef &name,
464  fpreal64 &value) const;
465  bool importOption(const UT_StringRef &name,
466  std::string &value) const;
467  bool importOption(const UT_StringRef &name,
468  UT_String &value) const;
469  bool importOption(const UT_StringRef &name,
470  UT_StringHolder &value) const;
471  bool importOption(const UT_StringRef &name,
472  UT_OptionsHolder &value) const;
473  bool importOption(const UT_StringRef &name,
474  UT_Vector2F &value) const;
475  bool importOption(const UT_StringRef &name,
476  UT_Vector3F &value) const;
477  bool importOption(const UT_StringRef &name,
478  UT_Vector4F &value) const;
479  bool importOption(const UT_StringRef &name,
480  UT_QuaternionF &value) const;
481  bool importOption(const UT_StringRef &name,
482  UT_Matrix2F &value) const;
483  bool importOption(const UT_StringRef &name,
484  UT_Matrix3F &value) const;
485  bool importOption(const UT_StringRef &name,
486  UT_Matrix4F &value) const;
487  bool importOption(const UT_StringRef &name,
488  UT_Vector2D &value) const;
489  bool importOption(const UT_StringRef &name,
490  UT_Vector3D &value) const;
491  bool importOption(const UT_StringRef &name,
492  UT_Vector4D &value) const;
493  bool importOption(const UT_StringRef &name,
494  UT_QuaternionD &value) const;
495  bool importOption(const UT_StringRef &name,
496  UT_Matrix2D &value) const;
497  bool importOption(const UT_StringRef &name,
498  UT_Matrix3D &value) const;
499  bool importOption(const UT_StringRef &name,
500  UT_Matrix4D &value) const;
501 
502  // Generic import which handles arbitrary length int/float data
503  bool importOption(const UT_StringRef &name,
504  UT_Array<int32> &value) const;
505  bool importOption(const UT_StringRef &name,
506  UT_Array<int64> &value) const;
507  bool importOption(const UT_StringRef &name,
508  UT_Array<fpreal32> &value) const;
509  bool importOption(const UT_StringRef &name,
510  UT_Array<fpreal64> &value) const;
511 
512  // Import a string array
513  bool importOption(const UT_StringRef &name,
514  UT_StringArray &value) const;
515  bool importOption(const UT_StringRef &name,
516  UT_Array<UT_StringHolder> &value) const;
517 
518  // Import a dictionary array.
519  bool importOption(const UT_StringRef &name,
520  UT_Array<UT_OptionsHolder> &value) const;
521 
522  // Import a single element from a scalar, vector, matrix or array
523  bool importElement(const UT_StringRef &name,
524  fpreal &value,
525  exint index = 0) const;
526  bool importElement(const UT_StringRef &name,
527  int64 &value,
528  exint index = 0) const;
529 
530 
531  // All these functions cause optionChanged to be called.
533  int64 value);
535  bool value);
537  fpreal64 value);
538  // Note that you can store binary data (that can contain null characters
539  // or that isn't null-terminated) in a string option by passing in a
540  // UT_WorkBuffer, or std::string.
542  const UT_StringHolder &value);
543  // setOptionSRaw() is the same as setOptionS() instead of it being
544  // additionally tagged as a "raw" string so that getPyOptionString() and
545  // appendPyDictionary() won't add quotes around the value. To retrieve its
546  // value, use getOptionS().
548  const UT_StringHolder &value);
550  const UT_OptionsHolder &value);
552  const UT_Vector2F &value);
554  const UT_Vector2D &value);
556  fpreal64 x, fpreal64 y);
558  const UT_Vector3F &value);
560  const UT_Vector3D &value);
564  const UT_Vector4F &value);
566  const UT_Vector4D &value);
568  fpreal64 x, fpreal64 y,
569  fpreal64 z, fpreal64 w);
571  const UT_QuaternionF &value);
573  const UT_QuaternionD &value);
575  const UT_Matrix2F &value);
577  const UT_Matrix2D &value);
579  const UT_Matrix3F &value);
581  const UT_Matrix3D &value);
583  const UT_Matrix4F &value);
585  const UT_Matrix4D &value);
587  const UT_Vector2F &value);
589  const UT_Vector2D &value);
591  const UT_Vector3F &value);
593  const UT_Vector3D &value);
594  /// @{
595  /// Set integer array options
597  const int32 *values, size_t size);
599  const int64 *values, size_t size);
601  const UT_Array<int64> &value);
602  /// @}
603  /// @{
604  /// Set float/double array options
606  const fpreal32 *values, size_t size);
608  const fpreal64 *values, size_t size);
610  const UT_Array<fpreal64> &value);
611  /// @}
612 
613  /// Set string array options
615  const UT_StringHolder *values,
616  size_t size);
618  const char *const*values,
619  size_t size);
621  const UT_StringArray &value);
622 
623  /// Set dict array options
625  const UT_OptionsHolder *values,
626  size_t size);
628  const UT_Array<UT_OptionsHolder> &value);
629 
630  /// Get a hash code for the options
631  unsigned hash() const;
632 
633  /// Comparison operator
634  bool operator==(const UT_Options &src) const;
635  bool operator!=(const UT_Options &src) const
636  { return !(*this == src); }
637 
638  /// Assignment operator
639  const UT_Options &operator=(const UT_Options &src);
640  void merge(const UT_Options &src);
641  void merge(const UT_Options &src,
642  bool (*match)(const UT_StringHolder &name,
643  const UT_OptionEntry *, void *),
644  void *data);
645  virtual int64 getMemoryUsage(bool inclusive) const;
646 
647  // This will steal the option from the unique ptr.
648  void setOption(const UT_StringHolder &name,
649  UT_OptionEntryPtr value);
650 
651 protected:
652  const UT_StringHolder *findOptionS(const UT_StringRef &name) const;
653  void addError(const char *filename, int linecount,
654  const char *error_str) const;
655  bool sendOptionChanges() const
656  { return mySendOptionChanges; }
658  { mySendOptionChanges = f; }
659  virtual void optionChanged(const char *name);
660  UT_OptionEntryPtr parsePyValue(const char *&value,
661  char sep_delim,
662  char close_delim = '\0');
663 
664 private:
665  template <class ITER>
666  bool save(ITER start, const char *filename, std::ostream &os) const;
667 
668  MapType myMap;
669  bool mySendOptionChanges;
670 };
671 
672 /// A holder for a options, which caches the hash value.
673 /// A UT_OptionsRef does not necessarily own the options, and it is therefore
674 /// not safe to e.g. store a UT_OptionsRef in a container or member variable.
675 /// @see UT_OptionsHolder
677 {
678 public:
680 
683  {
684  init();
685  }
686 
687  /// Will make a shallow reference.
690  {
691  init();
692  reference(opt);
693  }
694 
695  /// Shares a reference with the source.
698  {
699  mySoftRef = s.mySoftRef;
700  mySharedRef = s.mySharedRef;
701  myHash = s.myHash;
702  }
703 
704  /// Move constructor. Steals the working data from the original.
707  {
708  mySoftRef = s.mySoftRef;
709  mySharedRef = std::move(s.mySharedRef);
710  myHash = s.myHash;
711  s.init();
712  }
713 
716  {
717  }
718 
719  /// Special sentinel value support
720  /// @{
721  enum UT_OptionsSentinelType { SENTINEL };
722 
723  SYS_FORCE_INLINE explicit
725  : mySoftRef((const UT_Options *)SENTINEL_DATA)
726  , myHash(SENTINEL_HASH)
727  {
728  }
729 
731  bool isSentinel() const
732  {
733  return uintptr_t(mySoftRef) == SENTINEL_DATA && myHash == SENTINEL_HASH;
734  }
735 
738  {
739  init();
740  myHash = SENTINEL_HASH;
741  mySoftRef = (const UT_Options *) SENTINEL_DATA;
742  }
743  /// @}
744 
745  /// Returns true this object is the sole owner of the underlying options
746  bool isUnique() const
747  {
748  // Soft references are not unique. (This includes sentinels)
749  if (mySoftRef)
750  return false;
751  // If the shared ref is null, it isn't unique.
752  if (!mySharedRef.get())
753  return false;
754 
755  return mySharedRef.unique();
756  }
757 
758  /// Returns the shared ptr use count. 0 if not a shared
759  /// pointer. (null or soft ref)
760  int use_count() const
761  {
762  if (mySoftRef)
763  return 0;
764  if (!mySharedRef.get())
765  return 0;
766  return mySharedRef.use_count();
767  }
768 
769  /// Shares a reference with the source.
771  {
772  // Can now blindly copy.
773  mySoftRef = s.mySoftRef;
774  mySharedRef = s.mySharedRef;
775  myHash = s.myHash;
776  return *this;
777  }
778 
779  /// Move the contents of about-to-be-destructed options
780  /// s to this string.
783  {
784  // Can just swap, since s is about to be destructed.
785  swap(s);
786  return *this;
787  }
788 
790  const UT_Options *optionsOrNull() const
791  {
792  if (isSentinel())
793  return nullptr;
794  return rawOptions();
795  }
796 
798  const UT_Options *options() const
799  {
800  const UT_Options *result = optionsOrNull();
801  if (result == nullptr)
802  return &theEmptyOptionsData;
803  return result;
804  }
805 
806  bool operator==(const UT_OptionsRef &s) const
807  {
808  const UT_Options *a = rawOptions();
809  const UT_Options *b = s.rawOptions();
810 
811  if (a == b)
812  return true;
813 
814  // If they are not equal, we have to test null and sentinel.
815  // If either one is null or sentinel, we know they must be
816  // unequal.
817  if (!a || !b || (uintptr_t(a) == SENTINEL_DATA) || (uintptr_t(b) == SENTINEL_DATA))
818  return false;
819 
820  // If we have hashes and they are unequal, we must
821  // be unequal.
822  if (myHash && s.myHash)
823  {
824  if (myHash != s.myHash)
825  return false;
826  }
827 
828  // Now we have de-referenceable options pointers.
829  return (*a == *b);
830  }
831 
832  bool operator==(const UT_Options *b) const
833  {
834  const UT_Options *a = rawOptions();
835 
836  if (a == b)
837  return true;
838 
839  // If they are not equal, we have to test null and sentinel.
840  // If either one is null or sentinel, we know they must be
841  // unequal.
842  if (!a || !b || (uintptr_t(a) == SENTINEL_DATA) || (uintptr_t(b) == SENTINEL_DATA))
843  return false;
844 
845  // Can't test hashes as we don't have it for a raw pointer.
846 
847  // Now we have de-referenceable options pointers.
848  return (*a == *b);
849  }
850 
851  bool operator!=(const UT_OptionsRef &s) const
852  { return !operator==(s); }
853  bool operator!=(const UT_Options *s) const
854  { return !operator==(s); }
855 
856  SYS_FORCE_INLINE const UT_Options *operator->() const { return options(); }
857  SYS_FORCE_INLINE const UT_Options &operator*() const { return *options(); }
858 
860  void swap( UT_OptionsRef &other )
861  {
862  UTswap(mySoftRef, other.mySoftRef);
863  UTswap(mySharedRef, other.mySharedRef);
864  UTswap(myHash, other.myHash);
865  }
866 
867  /// Friend specialization of std::swap() to use UT_OptionsRef::swap()
868  friend void swap(UT_OptionsRef& a, UT_OptionsRef& b) { a.swap(b); }
869 
871  void clear()
872  {
873  init();
874  }
875 
876  bool isEmpty() const
877  {
878  const UT_Options *opt = optionsOrNull();
879  if (!opt)
880  return true;
881 
882  if (opt->getNumOptions() == 0)
883  return true;
884 
885  return false;
886  }
887 
888  explicit operator bool() const { return !isEmpty(); }
889 
890  unsigned hash() const
891  {
892  if (myHash)
893  return myHash;
894 
895  const UT_Options *opt = optionsOrNull();
896  if (!opt)
897  return 0;
898 
899  unsigned localhash = opt->hash();
900  if (!localhash)
901  localhash++;
902  myHash = localhash;
903  return myHash;
904  }
905 
906  /// Make a light weight reference to the source.
907  /// Caller must make sure src lives for the duration of this object,
908  /// and any objects value copied from this!
909  void reference(const UT_Options *src)
910  {
911  init();
912  mySoftRef = src;
913  }
914 
915  int64 getMemoryUsage(bool inclusive) const
916  {
917  int64 mem = inclusive ? sizeof(*this) : 0;
918 
919  const UT_Options *opt = optionsOrNull();
920  if (opt)
921  mem += opt->getMemoryUsage(true);
922  return mem;
923  }
924 
925  static const UT_Options &emptyOptions() { return theEmptyOptionsData; }
926 
927 private:
928  void init()
929  {
930  mySoftRef = nullptr;
931  mySharedRef.reset();
932  myHash = 0;
933  }
934 
935  void copy(const UT_OptionsRef &s)
936  {
937  mySoftRef = s.mySoftRef;
938  mySharedRef = s.mySharedRef;
939  myHash = s.myHash;
940  }
941 
943  const UT_Options *rawOptions() const
944  {
945  if (mySoftRef)
946  return mySoftRef;
947  return mySharedRef.get();
948  }
949 
950 
951  /// Either softref or shared ref should be set, never both.
952  /// Note that this might be possible to collapse into a single
953  /// shared ptr using the semantic that use_count==0 means soft ref.
954  const UT_Options *mySoftRef;
955  UT_SharedPtr<UT_Options> mySharedRef;
956 
957  /// Optional hash, 0 if not computed yet.
958  mutable int myHash;
959 
960  // UT_OptionsHolder needs to be a friend class so that the
961  // UT_OptionsHolder(const UT_OptionsRef &) constructor can access myHash and
962  // getHolder() for the UT_OptionsRef that is passed in.
963  friend class UT_OptionsHolder;
964 
965  static constexpr uintptr_t SENTINEL_DATA = 1;
966  static constexpr uint32 SENTINEL_HASH = 0xdeadbeef;
967 
968  // Because we want a null options pointer to return an empty options,
969  // we need a canonical empty options to return.
970  static const UT_Options theEmptyOptionsData;
971 
972  template<typename T>
973  static SYS_FORCE_INLINE bool isSentinelOrNullPtr(const T *p)
974  {
975  return uintptr_t(p) <= SENTINEL_DATA;
976  }
977 };
978 
980 {
981  return opt.hash();
982 }
983 
984 
986 {
987 public:
988  /// UT_OptionsHolder can be constructed with UT_OptionsHolder::REFERENCE to
989  /// create a shallow reference to the const char *.
990  enum UT_OptionsReferenceType { REFERENCE };
991 
994  : UT_OptionsRef()
995  {
996  }
997 
998  /// Will make a copy of the provided options.
1001  {
1002  mySoftRef = nullptr;
1003  if (opt)
1004  mySharedRef = UTmakeShared<UT_Options>(*opt);
1005  else
1006  mySharedRef.reset();
1007  }
1008 
1009  /// Will make a shallow reference.
1012  : UT_OptionsRef(opt)
1013  {
1014  }
1015 
1016  /// Makes a shallow reference to the contents of the UT_OptionsRef.
1019  : UT_OptionsRef(ref)
1020  {
1021  }
1022 
1023  /// Makes a deep copy of the provided UT_OptionsRef.
1024  /// This constructor is not marked explicit since we often want this
1025  /// conversion (e.g. when inserting a UT_OptionsRef into a UT_OptionsMap, as
1026  /// with the const char* constructor).
1028 
1029  /// Construct as a sentinel value
1030  SYS_FORCE_INLINE explicit
1032  : UT_OptionsRef(sentinel)
1033  {
1034  }
1035 
1036  /// Makes a copy of the provided options.
1039  : UT_OptionsRef(str)
1040  {
1041  }
1042 
1043  /// Move constructor. Steals the working data from the original.
1046  : UT_OptionsRef(std::move(a))
1047  {
1048  }
1049 
1050  /// Makes a bit-wise copy of the options and adjust the reference count.
1053  {
1055  return *this;
1056  }
1057 
1058  /// Move the contents of about-to-be-destructed options
1059  /// s to this options.
1062  {
1063  UT_OptionsRef::operator=(std::move(s));
1064  return *this;
1065  }
1066 
1068  void swap(UT_OptionsHolder &other)
1069  {
1070  UT_OptionsRef::swap(other);
1071  }
1072 
1074  void swap(UT_OptionsRef &other)
1075  {
1076  UT_OptionsRef::swap(other);
1077  // harden ourselves like UT_OptionsHolder::operator=(UT_OptionsRef&)
1078  if (isSentinelOrNullPtr(mySoftRef))
1079  return; // already a holder
1080  mySharedRef = UTmakeShared<UT_Options>(*mySoftRef);
1081  mySoftRef = nullptr;
1082  }
1083 
1084  /// Returns a writeable UT_Options which will modify the contents
1085  /// of this options holder. When this is copied or deleted, the
1086  /// returned pointer must not be used any more. (Ideally we could
1087  /// erase ourself and return a UniquePtr for correct life time,
1088  /// but we can't steal from a shared pointer)
1089  ///
1090  /// Use update() whereever possible instead as it is much safer.
1092  {
1093  // Harden if soft.
1094  if (!isUnique())
1095  {
1096  mySharedRef = UTmakeShared<UT_Options>(*options());
1097  mySoftRef = nullptr;
1098  }
1099  UT_ASSERT(isUnique());
1100 
1101  // Since we are going to be edited, we must reset our hash.
1102  myHash = 0;
1103 
1104  return SYSconst_cast(options());
1105  }
1106 
1107  /// Updates the contents of this option, first making sure it is
1108  /// unique. The provided operator should take a reference to
1109  /// a UT_Options that it will update.
1110  /// UT_OptionsHolder value;
1111  /// value.update([](UT_Options &opt) { opt.setOptionS("test", "bar"); });
1112  template <typename OP>
1113  void update(const OP &op)
1114  {
1115  UT_Options *opt = makeUnique();
1116  op(*opt);
1117  }
1118 
1119  /// Friend specialization of std::swap() to use UT_OptionsHolder::swap()
1120  /// @{
1121  friend void swap(UT_OptionsHolder& a, UT_OptionsRef& b) { a.swap(b); }
1122  friend void swap(UT_OptionsHolder& a, UT_OptionsHolder& b) { a.swap(b); }
1123  /// @}
1124 
1125  /// In some functions it's nice to be able to return a const-reference to a
1126  /// UT_OptionsHolder. However, in error cases, you likely want to return an
1127  /// empty options. This would mean that you'd have to return a real
1128  /// UT_OptionsHolder (not a const reference). This static lets you return a
1129  /// reference to an empty options.
1131 
1133 
1134 protected:
1135 };
1136 
1137 // For UT::ArraySet.
1138 namespace UT
1139 {
1140 template <typename T>
1141 struct DefaultClearer;
1142 
1143 template <>
1145 {
1146  static void clear(UT_OptionsHolder &v) { v.makeSentinel(); }
1147  static bool isClear(const UT_OptionsHolder &v) { return v.isSentinel(); }
1149  { new ((void *)p) UT_OptionsHolder(UT_OptionsRef::SENTINEL); }
1150  static const bool clearNeedsDestruction = false;
1151 };
1152 } // namespace UT
1153 
1154 UT_API size_t format(char *buffer, size_t buffer_size, const UT_Options &v);
1155 UT_API size_t format(char *buffer, size_t buffer_size, const UT_OptionsRef &v);
1156 
1157 // Most people only include UT_Options. But we can't include this at the start
1158 // as we are a pre-req.
1159 #include "UT_OptionEntry.h"
1160 
1161 #endif
GLdouble s
Definition: glew.h:1390
bool operator==(const UT_OptionsRef &s) const
Definition: UT_Options.h:806
bool getOptionB(const UT_StringRef &name) const
const UT_Options & operator=(const UT_Options &src)
Assignment operator.
SYS_FORCE_INLINE UT_OptionsRef()
Definition: UT_Options.h:682
SYS_FORCE_INLINE bool isSentinel() const
Definition: UT_Options.h:731
GT_API const UT_StringHolder filename
const UT_Vector2D & getOptionV2(const UT_StringRef &name) const
GLsizeiptr size
Definition: glew.h:1681
UT_JSONValueMap stores a map/dictionary of UT_JSONValue objects.
GLenum src
Definition: glew.h:2410
int int32
Definition: SYS_Types.h:39
GLenum GLint ref
Definition: glew.h:1845
const UT_StringHolder & name() const
Definition: UT_Options.h:326
const UT_OptionEntry * operator*() const
Definition: UT_Options.h:276
int64 getMemoryUsage(bool inclusive) const
Definition: UT_Options.h:915
GLuint const GLchar * name
Definition: glew.h:1814
friend void swap(UT_OptionsRef &a, UT_OptionsRef &b)
Friend specialization of std::swap() to use UT_OptionsRef::swap()
Definition: UT_Options.h:868
SYS_FORCE_INLINE void swap(UT_OptionsRef &other)
Definition: UT_Options.h:860
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:1045
FMT_CONSTEXPR auto begin(const C &c) -> decltype(c.begin())
Definition: format.h:251
GLuint index
Definition: glew.h:1814
SYS_FORCE_INLINE const UT_Options & operator*() const
Definition: UT_Options.h:857
bool isEmpty() const
Definition: UT_Options.h:876
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:979
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:9477
int getNumOptions() const
SYS_FORCE_INLINE T * SYSconst_cast(const T *foo)
Definition: SYS_Types.h:136
GLint GLsizei const GLuint64 * values
Definition: glew.h:3612
UT_OptionType
Definition: UT_Options.h:44
static const UT_OptionsHolder theSentinel
Definition: UT_Options.h:1132
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:635
UT_Options & setOptionV3(const UT_StringHolder &name, const UT_Vector3F &value)
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')
const UT_Vector3D & getOptionV3(const UT_StringRef &name) const
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: glew.h:1254
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:76
ordered_iterator oend() const
Definition: UT_Options.h:410
#define UT_API
Definition: UT_API.h:13
SYS_FORCE_INLINE UT_OptionsHolder(UT_OptionsReferenceType, const UT_Options *opt)
Will make a shallow reference.
Definition: UT_Options.h:1011
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:34
SYS_FORCE_INLINE UT_OptionsHolder()
Definition: UT_Options.h:993
const GLdouble * v
Definition: glew.h:1391
const UT_Matrix3D & getOptionM3(const UT_StringRef &name) const
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:1052
const UT_Fpreal64Array & getOptionFArray(const UT_StringRef &) const
static const UT_Options & emptyOptions()
Definition: UT_Options.h:925
float fpreal32
Definition: SYS_Types.h:200
bool atEnd() const
Definition: UT_Options.h:292
UT_OptionsRef & operator=(const UT_OptionsRef &s)
Shares a reference with the source.
Definition: UT_Options.h:770
UT_Options & setOptionM4(const UT_StringHolder &name, const UT_Matrix4F &value)
void setSendOptionChanges(bool f)
Definition: UT_Options.h:657
void reference(const UT_Options *src)
Definition: UT_Options.h:909
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:33
GLdouble GLdouble z
Definition: glew.h:1559
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:1031
ordered_iterator & operator=(const ordered_iterator &i)
Definition: UT_Options.h:333
iterator end() const
Definition: UT_Options.h:406
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:318
SYS_FORCE_INLINE const UT_Options * optionsOrNull() const
Definition: UT_Options.h:790
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:706
UT_Options & setOptionSArray(const UT_StringHolder &name, const UT_StringHolder *values, size_t size)
Set string array options.
UT_Options & setOptionI(const UT_StringHolder &name, int64 value)
fpreal64 getOptionNum(const UT_StringRef &) const
SYS_FORCE_INLINE void clear()
Definition: UT_Options.h:871
UT_Options & setOptionUV(const UT_StringHolder &name, const UT_Vector2F &value)
GLclampf f
Definition: glew.h:3499
GLint GLint GLint GLint GLint x
Definition: glew.h:1252
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1252
void update(const OP &op)
Definition: UT_Options.h:1113
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:28
GLuint buffer
Definition: glew.h:1680
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
UT_Options value_type
Definition: UT_Options.h:679
const GLuint GLenum const void * binary
Definition: glew.h:3502
SYS_FORCE_INLINE void swap(UT_OptionsRef &other)
Definition: UT_Options.h:1074
unsigned hash() const
Get a hash code for the options.
UT_Options & setOptionQ(const UT_StringHolder &name, const UT_QuaternionF &value)
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1890
const UT_OptionEntry * operator*() const
Definition: UT_Options.h:331
GLuint GLuint end
Definition: glew.h:1253
ordered_iterator obegin() const
Definition: UT_Options.h:408
static const UT_OptionsHolder theEmptyOptions
Definition: UT_Options.h:1130
friend void swap(UT_OptionsHolder &a, UT_OptionsRef &b)
Definition: UT_Options.h:1121
SYS_FORCE_INLINE UT_OptionsRef(UT_OptionsSentinelType)
Definition: UT_Options.h:724
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:271
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:697
const UT_Matrix2D & getOptionM2(const UT_StringRef &name) const
iterator & operator++()
Definition: UT_Options.h:291
UT_Options & setOptionM2(const UT_StringHolder &name, const UT_Matrix2F &value)
iterator(const iterator &i)
Definition: UT_Options.h:266
const UT_QuaternionD & getOptionQ(const UT_StringRef &name) const
bool operator!=(const UT_Options *s) const
Definition: UT_Options.h:853
bool operator!=(const iterator &i) const
Definition: UT_Options.h:289
bool operator==(const UT_Options *b) const
Definition: UT_Options.h:832
const UT_Int64Array & getOptionIArray(const UT_StringRef &) const
GLuint start
Definition: glew.h:1253
virtual int64 getMemoryUsage(bool inclusive) const
static bool isClear(const UT_OptionsHolder &v)
Definition: UT_Options.h:1147
SYS_FORCE_INLINE ~UT_OptionsRef()
Definition: UT_Options.h:715
bool isUnique() const
Returns true this object is the sole owner of the underlying options.
Definition: UT_Options.h:746
bool save(const char *filename) const
friend class UT_OptionsHolder
Definition: UT_Options.h:963
iterator begin() const
Definition: UT_Options.h:404
GLdouble GLdouble GLdouble b
Definition: glew.h:9122
static void clear(UT_OptionsHolder &v)
Definition: UT_Options.h:1146
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:1018
GLfloat GLfloat p
Definition: glew.h:16321
GLsizei const GLchar *const * string
Definition: glew.h:1844
A map of string to various well defined value types.
Definition: UT_Options.h:84
UT_Options * makeUnique()
Definition: UT_Options.h:1091
SYS_FORCE_INLINE UT_OptionsRef & operator=(UT_OptionsRef &&s)
Definition: UT_Options.h:782
SYS_FORCE_INLINE UT_OptionsHolder & operator=(UT_OptionsHolder &&s)
Definition: UT_Options.h:1061
SYS_FORCE_INLINE void makeSentinel()
Definition: UT_Options.h:737
const UT_Vector4D & getOptionV4(const UT_StringRef &name) const
bool operator!=(const ordered_iterator &i) const
Definition: UT_Options.h:350
SYS_FORCE_INLINE const UT_Options * options() const
Definition: UT_Options.h:798
ordered_iterator & operator++()
Definition: UT_Options.h:352
bool operator!=(const UT_OptionsRef &s) const
Definition: UT_Options.h:851
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:1038
iterator & operator=(const iterator &i)
Definition: UT_Options.h:278
SYS_FORCE_INLINE UT_OptionsHolder(const UT_Options *opt)
Will make a copy of the provided options.
Definition: UT_Options.h:1000
OIIO_API bool copy(string_view from, string_view to, std::string &err)
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:1122
unsigned int uint32
Definition: SYS_Types.h:40
GLenum const void GLuint GLint reference
Definition: glew.h:13644
GLuint64EXT * result
Definition: glew.h:14007
bool sendOptionChanges() const
Definition: UT_Options.h:655
void merge(const UT_Options &src)
unsigned hash() const
Definition: UT_Options.h:890
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:135
const UT_OptionEntry * entry() const
Definition: UT_Options.h:328
int use_count() const
Definition: UT_Options.h:760
#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:273
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:689
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:1068
bool operator==(const iterator &i) const
Definition: UT_Options.h:285
bool operator==(const ordered_iterator &i) const
Definition: UT_Options.h:342
UT_Options & setOptionF(const UT_StringHolder &name, fpreal64 value)
GLsizei const GLfloat * value
Definition: glew.h:1849
bool importOption(const UT_StringRef &name, int &value) const
fpreal64 getOptionF(const UT_StringRef &name) const
UT_UniquePtr< UT_OptionEntry > UT_OptionEntryPtr
const UT_OptionsHolder & getOptionDict(const UT_StringRef &name) const
type
Definition: core.h:528
UT_Options & setOptionV2(const UT_StringHolder &name, const UT_Vector2F &value)
SYS_FORCE_INLINE const UT_Options * operator->() const
Definition: UT_Options.h:856
static void clearConstruct(UT_OptionsHolder *p)
Definition: UT_Options.h:1148
const UT_StringHolder & getOptionS(const UT_StringRef &name) const