HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_Variant.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_Variant.h ( UT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __UT_Variant__
12 #define __UT_Variant__
13 
14 #include "UT_API.h"
15 
16 #include "UT_Array.h"
17 #include "UT_SharedPtr.h"
18 #include "UT_StringMap.h"
19 #include "UT_VectorTypes.h"
20 
21 #include <array>
22 #include <type_traits>
23 #include <memory>
24 
25 class UT_Variant;
26 
27 // ============================================================================
28 /// Wrapper around a shared variant array container.
29 /// Modifications are shared among all wrappers referring to the same container.
31 {
32 public:
36 
37  /// Construct a variant array of a given size. The constructed variants
38  /// will all be of the unknown type.
40 
41  /// Construct a variant array from an initializer list.
42  UT_VariantArray(std::initializer_list<UT_Variant> init);
43 
44  /// Construct a variant array by referencing the variant array container
45  /// from another. Only the pointer to the underlying array is copied.
46  /// The two wrappers will share the same array.
47  UT_VariantArray(const UT_VariantArray &) = default;
48 
49  /// Move the variant array container from another variant array.
50  UT_VariantArray(UT_VariantArray &&) = default;
51 
52  /// Copy a variant array by referencing the variant array container from
53  /// another. The two variant arrays will share the same list container.
54  UT_VariantArray &operator=(const UT_VariantArray &) = default;
55 
56  /// Move the variant array container from another variant array.
57  UT_VariantArray &operator=(UT_VariantArray &&) = default;
58 
59  /// Item-wise equality comparison of the variants of the two arrays.
60  bool operator==(const UT_VariantArray &o) const { return m_array->operator==(*o.m_array); }
61 
62  /// Item-wise non-equality comparison of the variants of the two arrays.
63  bool operator!=(const UT_VariantArray &o) const { return !operator==(o); }
64 
65  /// Make a deep copy of another array container. This array wrapper will not
66  /// share the array container with the other.
67  void deepCopy(const UT_VariantArray &);
68 
69  /// Returns the number of items in the array container.
70  exint size() const { return m_array->size(); }
71 
72  /// Returns a read-only variant at index @c index. No bound-checking is
73  /// performed.
74  const UT_Variant &operator[](exint index) const { return m_array->operator [](index); }
75 
76  /// Returns a writable variant at index @c index. No bound-checking is
77  /// performed.
78  UT_Variant &operator[](exint index) { return m_array->operator [](index); }
79 
80  /// Add a new variant to the array container. All instances of a array
81  /// wrapper that use the same array container will see the new item.
82  exint append(const UT_Variant &t) { return m_array->append(t); }
83 
84  /// Add a new variant to the array container. All instances of a array
85  /// wrapper that use the same array container will see the new item.
86  exint append(UT_Variant &&t) { return m_array->append(t); }
87 
88  /// Return a writable iterator to the beginning of the array container.
89  iterator begin() { return m_array->begin(); }
90 
91  /// Return a read-only iterator to the beginning of the array container.
92  const_iterator begin() const { return m_array->begin(); }
93 
94  /// Return a writable iterator to the end of the array container.
95  iterator end() { return m_array->end(); }
96 
97  /// Return a read-only iterator to the end of the array container.
98  const_iterator end() const { return m_array->end(); }
99 
100  /// Returns a read-only reference to the underlying array container.
101  const container_type &container() const { return *m_array.get(); }
102 
103  /// Returns a writable reference to the underlying array container.
104  container_type &container() { return *m_array.get(); }
105 private:
107 };
108 
109 // ============================================================================
110 /// Wrapper around a shared variant map container.
111 /// Modifications are shared among all wrappers referring to the same container.
113 {
114 public:
118 
119  /// Construct a default, empty container.
120  UT_VariantMap();
121 
122  /// Construct a new container from a list of key/value pairs.
123  UT_VariantMap(std::initializer_list<container_type::value_type> init);
124 
125  /// Construct a variant map by referencing the variant map container
126  /// from another. The two map wrappers will share the same map.
127  UT_VariantMap(const UT_VariantMap &) = default;
128 
129  /// Move the variant map container from another variant map wrapper.
130  UT_VariantMap(UT_VariantMap &&) = default;
131 
132  /// Copy a variant map by referencing the variant map container from
133  /// another. The two map wrappers will share the same map container.
134  UT_VariantMap &operator=(const UT_VariantMap &) = default;
135 
136  /// Move the variant map container from another variant map wrapper.
137  UT_VariantMap &operator=(UT_VariantMap &&) = default;
138 
139  /// Item-wise equality comparison of the keys and variants of the two maps.
140  bool operator==(const UT_VariantMap &o) const;
141 
142  /// Item-wise non-equality comparison of the keys and variants of the two
143  /// maps.
144  bool operator!=(const UT_VariantMap &o) const { return !operator==(o); }
145 
146  /// Make a deep copy of another array container. This array wrapper will not
147  /// share the array container with the other.
148  void deepCopy(const UT_VariantMap &);
149 
150  /// Returns a read-only variant associated with @c key. No error checking
151  /// is performed. If the key doesn't exist, the behavior is undefined.
152  const UT_Variant &operator[](const UT_StringRef &key) const;
153 
154  /// Returns a writable variant associated with @c key. No error checking
155  /// is performed. If the key doesn't exist, the behavior is undefined.
156  UT_Variant &operator[](const UT_StringHolder &key);
157 
158  /// Returns a read-only iterator pointing to the item associated with @c key.
159  /// If the item doesn't exist, this will be the value of @end.
160  const_iterator find(const UT_StringRef &key) const;
161 
162  /// Returns a writable iterator pointing to the item associated with @c key.
163  /// If the item doesn't exist, this will be the value of @end.
164  iterator find(const UT_StringRef &key);
165 
166  /// Returns @c true if the item associated with @c key exists in the map
167  /// container.
168  bool contains(const UT_StringRef &key) const { return m_map->contains(key); }
169 
170  /// Erase the item associated with the key @key. If the item existed and
171  /// was successfully erased, this function returns @true.
172  bool erase(const UT_StringRef &key);
173 
174  /// Erase the item pointed to by the iterator @c it. The returned
175  /// @c iterator will point to the next item after the one deleted.
176  iterator erase(const_iterator it);
177 
178  /// Return a writable iterator to the beginning of the map container.
179  iterator begin();
180 
181  /// Return a read-only iterator to the beginning of the map container.
182  const_iterator begin() const;
183 
184  /// Return a writable iterator to the end of the map container.
185  iterator end();
186 
187  /// Return a read-only iterator to the end of the map container.
188  const_iterator end() const;
189 
190  /// Returns a read-only reference to the underlying map container.
191  const container_type &container() const { return *m_map.get(); }
192 
193  /// Returns a writable reference to the underlying map container.
194  container_type &container() { return *m_map.get(); }
195 
196 private:
198 };
199 
200 // ============================================================================
201 
202 /// UT_Variant is a container that can hold a single value of many different
203 /// types.
205 {
206 public:
207  ///
208  enum class Type
209  {
210  Unknown, ///< Uninitialized variant. This is distinct from a null variant.
211  Null, ///< A null variant. A null variant holds no value.
212  Bool, ///< A boolean.
213  Int, ///< A 64-bit signed integer.
214  UInt, ///< A 64-bit unsigned integer.
215  Float, ///< A 64-bit float value.
216  String, ///< A shared string.
217  Vector2, ///< @c UT_Vector2D
218  Vector3, ///< @c UT_Vector3D
219  Vector4, ///< @c UT_Vector4D
220  Matrix2, ///< @c UT_Matrix2D
221  Matrix3, ///< @c UT_Matrix3D
222  Matrix4, ///< @c UT_Matrix4D
223  Pointer, ///< An arbitrary @c void pointer value.
224  Array, ///< A @c UT_VariantArray value
225  Map ///< A @c UT_VariantMap value
226  };
227 
228  /// A keystone type used to indicate that a variant should be initialized
229  /// as a null variant.
230  enum NullType { Null };
231 
232  template<typename T>
233  struct TypeInfo { static constexpr Type typeId = Type::Unknown;
234  static constexpr bool is_trivial = false;
235  static constexpr bool is_complex = false; };
236 
237  template<typename T>
239  {
240  static constexpr bool value = TypeInfo<T>::is_trivial;
241  };
242 
243  template<typename T>
245  {
246  static constexpr bool value = TypeInfo<T>::is_complex;
247  };
248 
249  template<typename U> struct TypeConversion { using To = U; using From = void; };
250  template<typename T> struct IsConvertibleType
251  {
252  static constexpr bool value =
253  !std::is_same<typename TypeConversion<T>::From, void>::value;
254  };
255 
256  /// Construct an unknown variant.
257  UT_Variant() : m_type(Type::Unknown) {}
258 
259  /// Construct a null variant. Call like so:
260  /// @code
261  /// UT_Variant null(UT_Variant::Null);
262  /// @endcode
263  UT_Variant(NullType) : m_type(Type::Null) {}
264 
265  /// Construct a boolean variant with the given value.
266  UT_Variant(bool v) : m_type(Type::Bool) { m_value.m_bool = v; }
267 
268  /// Construct an integer variant with the given value.
269  UT_Variant(int32 v) : m_type(Type::Int) { m_value.m_int = v; }
270 
271  /// Construct an integer variant with the given value.
272  UT_Variant(int64 v) : m_type(Type::Int) { m_value.m_int = v; }
273 
274  /// Construct an unsigned integer variant with the given value.
275  UT_Variant(uint32 v) : m_type(Type::UInt) { m_value.m_int = int64(v); }
276 
277  /// Construct an unsigned integer variant with the given value.
278  UT_Variant(uint64 v) : m_type(Type::UInt) { m_value.m_int = int64(v); }
279 
280  /// Construct a float variant with the given value.
281  UT_Variant(fpreal32 v) : m_type(Type::Float) { m_value.m_float = v; }
282 
283  /// Construct a float variant with the given value.
284  UT_Variant(fpreal64 v) : m_type(Type::Float) { m_value.m_float = v; }
285 
286  /// Construct a string variant with the given value.
287  UT_Variant(const char *v);
288 
289  /// Construct a @c Type::String variant with the given value.
290  UT_Variant(const UT_StringHolder &v);
291 
292  /// Construct a @c Type::String variant with the given value.
293  UT_Variant(const UT_StringRef &v);
294 
295  /// Construct a @c Type::Vector2 variant with the given value.
296  UT_Variant(const UT_Vector2F &v);
297 
298  /// Construct a @c Type::Vector2 variant with the given value.
299  UT_Variant(const UT_Vector2D &v);
300 
301  /// Construct a @c Type::Vector3 variant with the given value.
302  UT_Variant(const UT_Vector3F &v);
303 
304  /// Construct a @c Type::Vector3 variant with the given value.
305  UT_Variant(const UT_Vector3D &v);
306 
307  /// Construct a @c Type::Vector4 variant with the given value.
308  UT_Variant(const UT_Vector4F &v);
309 
310  /// Construct a @c Type::Vector4 variant with the given value.
311  UT_Variant(const UT_Vector4D &v);
312 
313  /// Construct a @c Type::Matrix2 variant with the given value.
314  UT_Variant(const UT_Matrix2F &v);
315 
316  /// Construct a @c Type::Matrix2 variant with the given value.
317  UT_Variant(const UT_Matrix2D &v);
318 
319  /// Construct a @c Type::Matrix3 variant with the given value.
320  UT_Variant(const UT_Matrix3F &v);
321 
322  /// Construct a @c Type::Matrix3 variant with the given value.
323  UT_Variant(const UT_Matrix3D &v);
324 
325  /// Construct a @c Type::Matrix4 variant with the given value.
326  UT_Variant(const UT_Matrix4F &v);
327 
328  /// Construct a @c Type::Matrix4 variant with the given value.
329  UT_Variant(const UT_Matrix4D &v);
330 
331  /// Construct a @c Type::Pointer variant with the given value.
332  UT_Variant(void *v) : m_type(Type::Pointer) { m_value.m_ptr = v; }
333 
334  /// Construct a @c Type::Array variant with the given value.
335  UT_Variant(const UT_VariantArray &v);
336 
337  /// Construct a @c Type::Array variant with the given value.
339 
340  /// Construct a @c Type::Map variant with the given value.
341  UT_Variant(const UT_VariantMap &v);
342 
343  /// Construct a @c Type::Map variant with the given value.
345 
346  /// Copy construct a variant with the given value.
347  UT_Variant(const UT_Variant &v);
348 
349  /// Move construct a variant with the given value.
351 
352  /// Variant destructor. For shared items, it only decreases reference
353  /// counts.
354  ~UT_Variant();
355 
356  /// Copy assignment operator. For shared data, it only adds a reference to
357  /// them.
358  UT_Variant &operator=(const UT_Variant &v);
359 
360  /// Move assignment operator. The passed-in variant is cleared out and left
361  /// as an unknown type.
362  UT_Variant &operator=(UT_Variant &&v);
363 
364  ///
365  bool operator==(const UT_Variant &v) const;
366 
367  Type type() const { return m_type; }
368  const char *typeName() const { return typeName(m_type); }
369  static const char *typeName(Type type);
370 
371  /// Convert this variant to a different type, in-place. Returns @c true
372  /// if the conversion succeeded. If the conversion failed, the variant
373  /// is left as-is.
374  bool convert(Type type);
375 
376  /// An explicit method of setting the variant type to null.
377  void setNull() { convert(Type::Null); }
378 
379  /// @{
380  /// Return the type requested by the template argument. If the contained
381  /// type is not of the requested type, a conversion is attempted.
382  /// If the conversion fails, the default instance of the return type is
383  /// returned and the value of @c ok is set to @c false.
384  /// Compound values, such as the vector and matrix types are returned by
385  /// reference, whereas all the others are returned by value.
386  template<typename T>
389  get(bool &ok) const;
390 
391  template<typename T>
394  get(bool &ok) const;
395 
396  template<typename T>
400  get(bool &ok) const;
401  /// @}
402 
403  /// @{
404  /// Return the type requested by the template argument. If the contained
405  /// type is not of the requested type, a conversion is attempted.
406  /// If the conversion fails, a default value is returned for the type
407  /// requested.
408  template<typename T>
411  get() const { bool ok; return get<T>(ok); }
412 
413  template<typename T>
416  get() const { bool ok; return get<T>(ok); }
417 
418  template<typename T>
422  get() const { bool ok; return get<T>(ok); }
423  /// @}
424 
425  /// Set the value and type of this variant to match the type and value of
426  /// the argument passed in.
427  template<typename T> void set(const T &v)
428  {
429  move(UT_Variant(v));
430  }
431 
432 private:
433  void copy(const UT_Variant &v);
434  void move(UT_Variant &&v);
435  void destroy();
436 
437  template<typename T>
438  const T *valueGet() const;
439 
440  template<typename T>
441  T &valueAlloc();
442 
443  template<typename T>
444  void valueDelete();
445 
446  template<typename T>
447  T valueConvert(bool &ok) const;
448 
449  bool parseBool(bool &ok) const;
450  int64 parseInt(bool &ok) const;
451  uint64 parseUInt(bool &ok) const;
452  fpreal64 parseFloat(bool &ok) const;
453  UT_StringHolder formatString(bool &ok) const;
454  UT_StringHolder formatInt() const;
455  UT_StringHolder formatUInt() const;
456  UT_StringHolder formatFloat() const;
457 
458  union
459  {
460  bool m_bool;
463  void *m_ptr;
464 
465  // Any type, same size or smaller than this, will be aliased into this
466  // storage. Otherwise it will be allocated on the heap.
467  // std::array is a trivial type and so is allowed in a union with no
468  // special considerations.
469  std::array<unsigned char, 24> m_storage;
470  } m_value;
471  Type m_type;
472 };
473 
474 // ============================================================================
475 // UT_VariantArray implementation
476 
477 inline
478 UT_VariantArray::UT_VariantArray(std::initializer_list<UT_Variant> init) :
479  UT_VariantArray(init.size())
480 {
481  for (auto &&v: init)
482  m_array->append(v);
483 }
484 
485 
486 // ============================================================================
487 // UT_VariantMap implementation
488 
489 inline
491  std::initializer_list<container_type::value_type> init) :
492  UT_VariantMap()
493 {
494  for (auto &&v: init)
495  m_map->insert(v);
496 }
497 
498 inline bool
500 {
501  return *m_map == *o.m_map;
502 }
503 
504 inline const UT_Variant &
506 {
507  return m_map->operator [](key);
508 }
509 
510 inline UT_Variant &
512 {
513  return m_map->operator [](key);
514 }
515 
518 {
519  return m_map->find(key);
520 }
521 
524 {
525  return m_map->find(key);
526 }
527 
528 inline bool
530 {
531  return m_map->erase(key);
532 }
533 
536 {
537  return m_map->erase(it);
538 }
539 
542 {
543  return m_map->begin();
544 }
545 
548 {
549  return m_map->begin();
550 }
551 
554 {
555  return m_map->end();
556 }
557 
560 {
561  return m_map->end();
562 }
563 
564 // ============================================================================
565 // UT_Variant implementation
566 
567 #define UT_VARIANT_TYPE_ID(_T_, _ID_, _TRV_, _CPL_) \
568  template<> struct UT_Variant::TypeInfo<_T_> { \
569  static constexpr UT_Variant::Type typeId = UT_Variant::Type::_ID_; \
570  static constexpr bool is_trivial = _TRV_; \
571  static constexpr bool is_complex = _CPL_; \
572  }
573 
574 UT_VARIANT_TYPE_ID(void, Null, false, false);
575 UT_VARIANT_TYPE_ID(bool, Bool, true, false);
576 UT_VARIANT_TYPE_ID(int64, Int, true, false);
577 UT_VARIANT_TYPE_ID(uint64, UInt, true, false);
578 UT_VARIANT_TYPE_ID(fpreal64, Float, true, false);
579 UT_VARIANT_TYPE_ID(UT_StringHolder, String, true, false);
580 UT_VARIANT_TYPE_ID(UT_Vector2D, Vector2, false, true);
581 UT_VARIANT_TYPE_ID(UT_Vector3D, Vector3, false, true);
582 UT_VARIANT_TYPE_ID(UT_Vector4D, Vector4, false, true);
583 UT_VARIANT_TYPE_ID(UT_Matrix2D, Matrix2, false, true);
584 UT_VARIANT_TYPE_ID(UT_Matrix3D, Matrix3, false, true);
585 UT_VARIANT_TYPE_ID(UT_Matrix4D, Matrix4, false, true);
586 UT_VARIANT_TYPE_ID(void *, Pointer, true, false);
588 UT_VARIANT_TYPE_ID(UT_VariantMap, Map, true, false);
589 
590 #undef UT_VARIANT_TYPE_ID
591 
592 template<>
593 inline bool
594 UT_Variant::valueConvert<bool>(bool &ok) const
595 {
596  ok = true;
597  if (m_type == Type::Bool)
598  return m_value.m_bool;
599  else if (m_type == Type::Int || m_type == Type::UInt)
600  return m_value.m_int != 0;
601  else if (m_type == Type::Float)
602  return m_value.m_float != 0;
603  else if (m_type == Type::String)
604  return parseBool(ok);
605  else
606  {
607  ok = false;
608  return false;
609  }
610 }
611 
612 template<>
613 inline int64
614 UT_Variant::valueConvert<int64>(bool &ok) const
615 {
616  ok = true;
617  if (m_type == Type::Bool)
618  return m_value.m_bool ? 1 : 0;
619  else if (m_type == Type::Int || m_type == Type::UInt)
620  return m_value.m_int;
621  else if (m_type == Type::Float)
622  return static_cast<int64>(m_value.m_float);
623  else if (m_type == Type::String)
624  return parseInt(ok);
625  else
626  {
627  ok = false;
628  return false;
629  }
630 }
631 
632 template<>
633 inline uint64
634 UT_Variant::valueConvert<uint64>(bool &ok) const
635 {
636  ok = true;
637  if (m_type == Type::Bool)
638  return m_value.m_bool ? 1 : 0;
639  else if (m_type == Type::Int || m_type == Type::UInt)
640  return uint64(m_value.m_int);
641  else if (m_type == Type::Float)
642  return static_cast<uint64>(m_value.m_float);
643  else if (m_type == Type::String)
644  return uint64(parseInt(ok));
645  else
646  {
647  ok = false;
648  return false;
649  }
650 }
651 
652 template<>
653 inline fpreal64
654 UT_Variant::valueConvert<fpreal64>(bool &ok) const
655 {
656  ok = true;
657  if (m_type == Type::Bool)
658  return m_value.m_bool ? 1 : 0;
659  else if (m_type == Type::Int)
660  return fpreal64(m_value.m_int);
661  else if (m_type == Type::UInt)
662  return fpreal64(uint64(m_value.m_int));
663  else if (m_type == Type::Float)
664  return m_value.m_float;
665  else if (m_type == Type::String)
666  return parseFloat(ok);
667  else
668  {
669  ok = false;
670  return false;
671  }
672 }
673 
674 template<>
675 inline UT_StringHolder
676 UT_Variant::valueConvert<UT_StringHolder>(bool &ok) const
677 {
678  ok = true;
679  if (m_type == Type::Bool)
680  return UT_StringHolder(m_value.m_bool ? "true" : "false");
681  else if (m_type == Type::Int)
682  return formatInt();
683  else if (m_type == Type::UInt)
684  return formatUInt();
685  else if (m_type == Type::Float)
686  return formatFloat();
687  else if (m_type == Type::String)
688  return *valueGet<UT_StringHolder>();
689  else
690  {
691  ok = false;
692  return UT_StringHolder();
693  }
694 }
695 
696 
697 template<>
698 inline void *
699 UT_Variant::valueConvert<void *>(bool &ok) const
700 {
701  if (m_type == Type::Pointer)
702  {
703  ok = true;
704  return m_value.m_ptr;
705  }
706  else
707  {
708  ok = false;
709  return nullptr;
710  }
711 }
712 
713 
714 template<>
715 inline UT_VariantArray
716 UT_Variant::valueConvert<UT_VariantArray>(bool &ok) const
717 {
718  if (m_type == Type::Array)
719  {
720  ok = true;
721  return *valueGet<UT_VariantArray>();
722  }
723  else
724  {
725  ok = false;
726  return UT_VariantArray();
727  }
728 }
729 
730 template<>
731 inline UT_VariantMap
732 UT_Variant::valueConvert<UT_VariantMap>(bool &ok) const
733 {
734  if (m_type == Type::Map)
735  {
736  ok = true;
737  return *valueGet<UT_VariantMap>();
738  }
739  else
740  {
741  ok = false;
742  return UT_VariantMap();
743  }
744 }
745 
746 
747 template<typename T>
750 UT_Variant::get(bool &ok) const
751 {
752  return valueConvert<T>(ok);
753 }
754 
755 template<typename T>
758 UT_Variant::get(bool &ok) const
759 {
760  const T *v = this->valueGet<T>();
761  if (v)
762  {
763  ok = true;
764  return *v;
765  }
766  else
767  {
768  static T s_default;
769  ok = false;
770  return s_default;
771  }
772 }
773 
774 // Conversion templates
775 template<> struct UT_Variant::TypeConversion<int32> { using From = int64; };
776 template<> struct UT_Variant::TypeConversion<uint32> { using From = uint64; };
777 template<> struct UT_Variant::TypeConversion<fpreal32> { using From = fpreal64; };
778 template<> struct UT_Variant::TypeConversion<UT_Vector2F> { using From = UT_Vector2D; };
779 template<> struct UT_Variant::TypeConversion<UT_Vector3F> { using From = UT_Vector3D; };
780 template<> struct UT_Variant::TypeConversion<UT_Vector4F> { using From = UT_Vector4D; };
781 template<> struct UT_Variant::TypeConversion<UT_Matrix2F> { using From = UT_Matrix2D; };
782 template<> struct UT_Variant::TypeConversion<UT_Matrix3F> { using From = UT_Matrix3D; };
783 template<> struct UT_Variant::TypeConversion<UT_Matrix4F> { using From = UT_Matrix4D; };
784 template<> struct UT_Variant::TypeConversion<const char *> { using From = UT_StringHolder; };
785 
786 
787 template<typename T>
791 UT_Variant::get(bool &ok) const
792 {
793  return static_cast<T>(this->get<typename TypeConversion<T>::From>(ok));
794 }
795 
796 UT_API size_t format(char *buffer, size_t buffer_size, const UT_Variant &v);
797 
798 
799 #endif // __UT_Variant__
UT_Matrix4T< fpreal64 > UT_Matrix4D
Definition: ImfArray.h:77
UT_Variant(NullType)
Definition: UT_Variant.h:263
UT_Variant()
Construct an unknown variant.
Definition: UT_Variant.h:257
iterator begin()
Return a writable iterator to the beginning of the map container.
Definition: UT_Variant.h:541
UT_Variant(void *v)
Construct a Type::Pointer variant with the given value.
Definition: UT_Variant.h:332
const UT_Variant & operator[](exint index) const
Definition: UT_Variant.h:74
UT_Variant(fpreal32 v)
Construct a float variant with the given value.
Definition: UT_Variant.h:281
const GLdouble * v
Definition: glcorearb.h:836
UT_Vector2T< fpreal64 > UT_Vector2D
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
UT_Variant(int32 v)
Construct an integer variant with the given value.
Definition: UT_Variant.h:269
const_iterator begin() const
Return a read-only iterator to the beginning of the array container.
Definition: UT_Variant.h:92
iterator begin()
Return a writable iterator to the beginning of the array container.
Definition: UT_Variant.h:89
void setNull()
An explicit method of setting the variant type to null.
Definition: UT_Variant.h:377
iterator end()
Return a writable iterator to the end of the map container.
Definition: UT_Variant.h:553
bool erase(const UT_StringRef &key)
Definition: UT_Variant.h:529
exint append(const UT_Variant &t)
Definition: UT_Variant.h:82
container_type::iterator iterator
Definition: UT_Variant.h:116
bool m_bool
Definition: UT_Variant.h:460
#define UT_API
Definition: UT_API.h:13
UT_VariantMap()
Construct a default, empty container.
GLuint buffer
Definition: glcorearb.h:659
const container_type & container() const
Returns a read-only reference to the underlying map container.
Definition: UT_Variant.h:191
UT_Variant(uint32 v)
Construct an unsigned integer variant with the given value.
Definition: UT_Variant.h:275
GLsizeiptr size
Definition: glcorearb.h:663
std::array< unsigned char, 24 > m_storage
Definition: UT_Variant.h:469
Parent::iterator iterator
Definition: UT_StringMap.h:52
bool operator!=(const UT_VariantArray &o) const
Item-wise non-equality comparison of the variants of the two arrays.
Definition: UT_Variant.h:63
int64 m_int
Definition: UT_Variant.h:461
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
long long int64
Definition: SYS_Types.h:107
UT_Variant(uint64 v)
Construct an unsigned integer variant with the given value.
Definition: UT_Variant.h:278
std::enable_if< IsTrivialType< T >::value &&!IsConvertibleType< T >::value, T >::type get() const
Definition: UT_Variant.h:411
exint append(UT_Variant &&t)
Definition: UT_Variant.h:86
unsigned long long uint64
Definition: SYS_Types.h:108
const char * typeName() const
Definition: UT_Variant.h:368
bool operator==(const UT_VariantArray &o) const
Item-wise equality comparison of the variants of the two arrays.
Definition: UT_Variant.h:60
UT_VariantArray(exint size=0)
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:28
int64 exint
Definition: SYS_Types.h:116
container_type & container()
Returns a writable reference to the underlying map container.
Definition: UT_Variant.h:194
iterator end()
Return a writable iterator to the end of the array container.
Definition: UT_Variant.h:95
bool operator==(const UT_VariantMap &o) const
Item-wise equality comparison of the keys and variants of the two maps.
Definition: UT_Variant.h:499
double fpreal64
Definition: SYS_Types.h:192
GLuint GLuint end
Definition: glcorearb.h:474
exint size() const
Returns the number of items in the array container.
Definition: UT_Variant.h:70
void * m_ptr
Definition: UT_Variant.h:463
UT_Vector3T< fpreal64 > UT_Vector3D
UT_Variant & operator[](exint index)
Definition: UT_Variant.h:78
container_type::const_iterator const_iterator
Definition: UT_Variant.h:117
container_type & container()
Returns a writable reference to the underlying array container.
Definition: UT_Variant.h:104
int int32
Definition: SYS_Types.h:35
Parent::const_iterator const_iterator
Definition: UT_StringMap.h:51
UT_Matrix2T< fpreal64 > UT_Matrix2D
GLsizei const GLfloat * value
Definition: glcorearb.h:823
bool operator!=(const UT_VariantMap &o) const
Definition: UT_Variant.h:144
const container_type & container() const
Returns a read-only reference to the underlying array container.
Definition: UT_Variant.h:101
bool contains(const UT_StringRef &key) const
Definition: UT_Variant.h:168
GLuint index
Definition: glcorearb.h:785
void set(const T &v)
Definition: UT_Variant.h:427
Type type() const
Definition: UT_Variant.h:367
png_infop png_bytep png_size_t buffer_size
Definition: png.h:2124
UT_Variant(bool v)
Construct a boolean variant with the given value.
Definition: UT_Variant.h:266
const UT_Variant & operator[](const UT_StringRef &key) const
Definition: UT_Variant.h:505
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
UT_Variant(fpreal64 v)
Construct a float variant with the given value.
Definition: UT_Variant.h:284
#define UT_VARIANT_TYPE_ID(_T_, _ID_, _TRV_, _CPL_)
Definition: UT_Variant.h:567
#define const
Definition: zconf.h:214
const_iterator find(const UT_StringRef &key) const
Definition: UT_Variant.h:523
UT_Variant(int64 v)
Construct an integer variant with the given value.
Definition: UT_Variant.h:272
UT_Vector4T< fpreal64 > UT_Vector4D
UT_API size_t format(char *buffer, size_t buffer_size, const UT_Variant &v)
const_iterator end() const
Return a read-only iterator to the end of the array container.
Definition: UT_Variant.h:98
float fpreal32
Definition: SYS_Types.h:191
fpreal64 m_float
Definition: UT_Variant.h:462
UT_Matrix3T< fpreal64 > UT_Matrix3D
unsigned int uint32
Definition: SYS_Types.h:36