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