HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dictionary.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_BASE_VT_DICTIONARY_H
8 #define PXR_BASE_VT_DICTIONARY_H
9 
10 /// \file vt/dictionary.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/base/vt/api.h"
14 #include "pxr/base/vt/value.h"
15 
16 #include "pxr/base/tf/diagnostic.h"
17 #include "pxr/base/tf/hash.h"
18 #include "pxr/base/tf/mallocTag.h"
19 
20 #include <initializer_list>
21 #include <iosfwd>
22 #include <map>
23 #include <memory>
24 
26 
27 /// \defgroup group_vtdict_functions VtDictionary Functions
28 /// Functions for manipulating VtDictionary objects.
29 
30 /// \class VtDictionary
31 ///
32 /// A map with string keys and VtValue values.
33 ///
34 /// VtDictionary converts to and from a python dictionary as long
35 /// as each element contains either
36 /// - another VtDictionary (converts to a nested dictionary)
37 /// - std::vector<VtValue> (converts to a nested list)
38 /// - VtValue with one of the supported Vt Types.
39 ///
40 /// For a list of functions that can manipulate VtDictionary objects, see the
41 /// \link group_vtdict_functions VtDictionary Functions \endlink group page .
42 ///
43 class VtDictionary {
44  typedef std::map<std::string, VtValue, std::less<>> _Map;
45  std::unique_ptr<_Map> _dictMap;
46 
47 public:
48  // The iterator class, used to make both const and non-const iterators.
49  // Currently only forward traversal is supported. In order to support lazy
50  // allocation, VtDictionary's Map pointer (_dictMap) must be nullable,
51  // but that would break the VtDictionary iterators. So instead, VtDictionary
52  // uses this Iterator class, which considers an iterator to an empty
53  // VtDictionary to be the same as an iterator at the end of a VtDictionary
54  // (i.e. if Iterator's _dictMap pointer is null, that either means that the
55  // VtDictionary is empty, or the Iterator is at the end of a VtDictionary
56  // that contains values).
57  template<class UnderlyingMapPtr, class UnderlyingIterator>
58  class Iterator {
59  public:
60  using iterator_category = std::bidirectional_iterator_tag;
64  using difference_type = typename UnderlyingIterator::difference_type;
65 
66 
67  // Default constructor creates an Iterator equivalent to end() (i.e.
68  // UnderlyingMapPtr is null)
69  Iterator() = default;
70 
71  // Copy constructor (also allows for converting non-const to const).
72  template <class OtherUnderlyingMapPtr, class OtherUnderlyingIterator>
73  Iterator(Iterator<OtherUnderlyingMapPtr,
74  OtherUnderlyingIterator> const &other)
75  : _underlyingIterator(other._underlyingIterator),
76  _underlyingMap(other._underlyingMap) {}
77 
78  reference operator*() const { return *_underlyingIterator; }
79  pointer operator->() const { return _underlyingIterator.operator->(); }
80 
82  increment();
83  return *this;
84  }
85 
87  Iterator result = *this;
88  increment();
89  return result;
90  }
91 
93  --_underlyingIterator;
94  return *this;
95  }
96 
98  Iterator result = *this;
99  --_underlyingIterator;
100  return result;
101  }
102 
103  template <class OtherUnderlyingMapPtr, class OtherUnderlyingIterator>
104  bool operator==(const Iterator<OtherUnderlyingMapPtr,
105  OtherUnderlyingIterator>& other) const {
106  return equal(other);
107  }
108 
109  template <class OtherUnderlyingMapPtr, class OtherUnderlyingIterator>
110  bool operator!=(const Iterator<OtherUnderlyingMapPtr,
111  OtherUnderlyingIterator>& other) const {
112  return !equal(other);
113  }
114 
115  private:
116 
117  // Private constructor allowing the find, begin and insert methods
118  // to create and return the proper Iterator.
119  Iterator(UnderlyingMapPtr m, UnderlyingIterator i)
120  : _underlyingIterator(i),
121  _underlyingMap(m) {
122  if (m && i == m->end())
123  _underlyingMap = nullptr;
124  }
125 
126  friend class VtDictionary;
127 
128  UnderlyingIterator GetUnderlyingIterator(UnderlyingMapPtr map)
129  const {
130  TF_AXIOM(!_underlyingMap || _underlyingMap == map);
131  return (!_underlyingMap) ? map->end() : _underlyingIterator;
132  }
133 
134  // Fundamental functionality to implement the iterator.
135  // These will be invoked these as necessary to implement
136  // the full iterator public interface.
137 
138  // Increments the underlying iterator, and sets the underlying map to
139  // null when the iterator reaches the end of the map.
140  void increment() {
141  if (!_underlyingMap) {
142  TF_FATAL_ERROR("Attempted invalid increment operation on a "
143  "VtDictionary iterator");
144  return;
145  }
146  if (++_underlyingIterator == _underlyingMap->end()) {
147  _underlyingMap = nullptr;
148  }
149  }
150 
151  // Equality comparison. Iterators are considered equal if:
152  // 1) They both point to empty VtDictionaries
153  // 2) They both point to the end() of a VtDictionary
154  // - or-
155  // 3) They both point to the same VtDictionary and their
156  // underlying iterators are the same
157  // In cases 1 and 2 above, _underlyingMap will be null
158  template <class OtherUnderlyingMapPtr, class OtherUnderlyingIterator>
159  bool equal(Iterator<OtherUnderlyingMapPtr,
160  OtherUnderlyingIterator> const& other) const {
161  if (_underlyingMap == other._underlyingMap)
162  if (!_underlyingMap ||
163  (_underlyingIterator == other._underlyingIterator))
164  return true;
165  return false;
166  }
167 
168  UnderlyingIterator _underlyingIterator;
169  UnderlyingMapPtr _underlyingMap = nullptr;
170  };
171 
172  TF_MALLOC_TAG_NEW("Vt", "VtDictionary");
173 
174  typedef _Map::key_type key_type;
175  typedef _Map::mapped_type mapped_type;
177  typedef _Map::allocator_type allocator_type;
178  typedef _Map::size_type size_type;
179 
182 
183  /// Creates an empty \p VtDictionary.
185 
186  /// Creates an empty \p VtDictionary with at least \p size buckets.
187  explicit VtDictionary(int size) {}
188 
189  /// Creates a \p VtDictionary with a copy of a range.
190  template<class _InputIterator>
191  VtDictionary(_InputIterator f, _InputIterator l){
192  TfAutoMallocTag2 tag("Vt", "VtDictionary::VtDictionary (range)");
193  insert(f, l);
194  }
195 
196  /// Creates a copy of the supplied \p VtDictionary
197  VT_API
198  VtDictionary(VtDictionary const& other);
199 
200  /// Creates a new VtDictionary by moving the supplied \p VtDictionary.
201  VT_API
202  VtDictionary(VtDictionary && other) = default;
203 
204  /// Creates a new VtDictionary from a braced initializer list.
205  VT_API
206  VtDictionary(std::initializer_list<value_type> init);
207 
208  /// Copy assignment operator
209  VT_API
210  VtDictionary& operator=(VtDictionary const& other);
211 
212  /// Move assignment operator
213  VT_API
214  VtDictionary& operator=(VtDictionary && other) = default;
215 
216  /// Returns a reference to the \p VtValue that is associated with a
217  /// particular key.
218  VT_API
219  VtValue& operator[](const std::string& key);
220 
221  /// Counts the number of elements whose key is \p key.
222  VT_API
223  size_type count(const std::string& key) const;
224 
225  /// Counts the number of elements whose key is \p key.
226  VT_API
227  size_type count(const char* key) const;
228 
229  /// Erases the element whose key is \p key.
230  VT_API
231  size_type erase(const std::string& key);
232 
233  /// Erases the element pointed to by \p it.
234  VT_API
235  iterator erase(iterator it);
236 
237  /// Erases all elements in a range.
238  VT_API
240 
241  /// Erases all of the elements.
242  VT_API
243  void clear();
244 
245  /// Finds an element whose key is \p key.
246  VT_API
247  iterator find(const std::string& key);
248 
249  /// Finds an element whose key is \p key.
250  VT_API
251  iterator find(const char* key);
252 
253  /// Finds an element whose key is \p key.
254  VT_API
255  const_iterator find(const std::string& key) const;
256 
257  /// Finds an element whose key is \p key.
258  VT_API
259  const_iterator find(const char* key) const;
260 
261  /// Returns an \p iterator pointing to the beginning of the \p VtDictionary.
262  VT_API
263  iterator begin();
264 
265  /// Returns an \p iterator pointing to the beginning of the \p VtDictionary.
266  VT_API
267  const_iterator begin() const;
268 
269  /// Returns an \p iterator pointing to the end of the \p VtDictionary.
270  VT_API
271  iterator end();
272 
273  /// Returns an \p iterator pointing to the end of the \p VtDictionary.
274  VT_API
275  const_iterator end() const;
276 
277  /// Returns the size of the VtDictionary.
278  VT_API
279  size_type size() const;
280 
281  /// \c true if the \p VtDictionary's size is 0.
282  VT_API
283  bool empty() const;
284 
285  /// Swaps the contents of two \p VtDictionaries.
286  VT_API
287  void swap(VtDictionary& dict);
288 
289  // Global overload for swap for unqualified calls in generic code.
290  friend void swap(VtDictionary &lhs, VtDictionary &rhs) {
291  lhs.swap(rhs);
292  }
293 
294  friend size_t hash_value(VtDictionary const &dict) {
295  // Hash empty dict as zero.
296  if (dict.empty())
297  return 0;
298  // Otherwise hash the map.
299  return TfHash()(*dict._dictMap);
300  }
301 
302  /// Inserts a range into the \p VtDictionary.
303  template<class _InputIterator>
304  void insert(_InputIterator f, _InputIterator l) {
305  TfAutoMallocTag2 tag("Vt", "VtDictionary::insert (range)");
306  if (f != l) {
307  _CreateDictIfNeeded();
308  _dictMap->insert(f, l);
309  }
310  }
311 
312  /// Inserts \p obj into the \p VtDictionary.
313  VT_API
314  std::pair<iterator, bool> insert(const value_type& obj);
315 
316  /// Return a pointer to the value at \p keyPath if one exists. \p keyPath
317  /// is a delimited string of sub-dictionary names. Key path elements are
318  /// produced by calling TfStringTokenize() with \p keyPath and
319  /// \p delimiters. \p keyPath may identify a leaf element or an entire
320  /// sub-dictionary. Return null if no such element at \p keyPath exists.
321  VT_API
322  VtValue const *
323  GetValueAtPath(std::string const &keyPath,
324  char const *delimiters = ":") const;
325 
326  /// Return a pointer to the value at \p keyPath if one exists. \p keyPath
327  /// may identify a leaf element or an entire sub-dictionary. Return null if
328  /// no such element at \p keyPath exists.
329  VT_API
330  VtValue const *
331  GetValueAtPath(std::vector<std::string> const &keyPath) const;
332 
333  /// Set the value at \p keyPath to \p value. \p keyPath is a delimited
334  /// string of sub-dictionary names. Key path elements are produced by
335  /// calling TfStringTokenize() with \p keyPath and \p delimiters. Create
336  /// sub-dictionaries as necessary according to the path elements in
337  /// \p keyPath. If \p keyPath identifies a full sub-dictionary, replace the
338  /// entire sub-dictionary with \p value.
339  VT_API
340  void SetValueAtPath(std::string const &keyPath,
341  VtValue const &value, char const *delimiters = ":");
342 
343  /// Set the value at \p keyPath to \p value. Create sub-dictionaries as
344  /// necessary according to the path elements in \p keyPath. If \p keyPath
345  /// identifies a full sub-dictionary, replace the entire sub-dictionary with
346  /// \p value.
347  VT_API
348  void SetValueAtPath(std::vector<std::string> const &keyPath,
349  VtValue const &value);
350 
351  /// Erase the value at \a keyPath. \p keyPath is a delimited string of
352  /// sub-dictionary names. Key path elements are produced by calling
353  /// TfStringTokenize() with \p keyPath and \p delimiters. If no such
354  /// element exists at \p keyPath, do nothing. If \p keyPath identifies a
355  /// sub-dictionary, erase the entire sub-dictionary.
356  VT_API
357  void EraseValueAtPath(std::string const &keyPath,
358  char const *delimiters = ":");
359 
360  /// Erase the value at \a keyPath. If no such element exists at \p keyPath,
361  /// do nothing. If \p keyPath identifies a sub-dictionary, erase the entire
362  /// sub-dictionary.
363  VT_API
364  void EraseValueAtPath(std::vector<std::string> const &keyPath);
365 
366 private:
367  void
368  _SetValueAtPathImpl(std::vector<std::string>::const_iterator curKeyElem,
369  std::vector<std::string>::const_iterator keyElemEnd,
370  VtValue const &value);
371 
372  void _EraseValueAtPathImpl(
373  std::vector<std::string>::const_iterator curKeyElem,
374  std::vector<std::string>::const_iterator keyElemEnd);
375 
376  void _CreateDictIfNeeded();
377 
378 };
379 
380 /// Equality comparison.
381 VT_API bool operator==(VtDictionary const &, VtDictionary const &);
382 VT_API bool operator!=(VtDictionary const &, VtDictionary const &);
383 
384 /// Write the contents of a VtDictionary to a stream, formatted like "{ 'key1':
385 /// value1, 'key2': value2 }".
386 VT_API std::ostream &operator<<(std::ostream &, VtDictionary const &);
387 
388 //
389 // Return a const reference to an empty VtDictionary.
390 //
392 
393 /// Returns true if \p dictionary contains \p key and the corresponding value
394 /// is of type \p T.
395 /// \ingroup group_vtdict_functions
396 ///
397 template <typename T>
398 bool
400  const std::string &key )
401 {
402  VtDictionary::const_iterator i = dictionary.find(key);
403  if ( i == dictionary.end() ) {
404  return false;
405  }
406 
407  return i->second.IsHolding<T>();
408 }
409 
410 /// \overload
411 template <typename T>
412 bool
414  const char *key )
415 {
416  VtDictionary::const_iterator i = dictionary.find(key);
417  if ( i == dictionary.end() ) {
418  return false;
419  }
420 
421  return i->second.IsHolding<T>();
422 }
423 
424 
425 /// Return a value held in a VtDictionary by reference.
426 ///
427 /// If \p key is in \p dictionary and the corresponding value is of type
428 /// \p T, returns a reference to the value.
429 ///
430 /// \remark If \p key is not in \p dictionary, or the value for \p key is of
431 /// the wrong type, a fatal error occurs, so clients should always call
432 /// VtDictionaryIsHolding first.
433 ///
434 /// \ingroup group_vtdict_functions
435 template <typename T>
436 const T &
437 VtDictionaryGet( const VtDictionary &dictionary,
438  const std::string &key )
439 {
440  VtDictionary::const_iterator i = dictionary.find(key);
441  if (ARCH_UNLIKELY(i == dictionary.end())) {
442  TF_FATAL_ERROR("Attempted to get value for key '" + key +
443  "', which is not in the dictionary.");
444  }
445 
446  return i->second.Get<T>();
447 }
448 
449 /// \overload
450 template <typename T>
451 const T &
452 VtDictionaryGet( const VtDictionary &dictionary,
453  const char *key )
454 {
455  VtDictionary::const_iterator i = dictionary.find(key);
456  if (ARCH_UNLIKELY(i == dictionary.end())) {
457  TF_FATAL_ERROR("Attempted to get value for key '%s', "
458  "which is not in the dictionary.", key);
459  }
460 
461  return i->second.Get<T>();
462 }
463 
464 
465 // This is an internal holder class that is used in the version of
466 // VtDictionaryGet that takes a default.
467 template <class T>
469  explicit Vt_DefaultHolder(T const &t) : val(t) {}
470  T const &val;
471 };
472 
473 // This internal class has a very unusual assignment operator that returns an
474 // instance of Vt_DefaultHolder, holding any type T. This is used to get the
475 // "VtDefault = X" syntax for VtDictionaryGet.
477  template <class T>
479  return Vt_DefaultHolder<T>(t);
480  }
481 };
482 
483 // This is a global stateless variable used to get the VtDefault = X syntax in
484 // VtDictionaryGet.
486 
487 /// Return a value held in a VtDictionary, or a default value either if the
488 /// supplied key is missing or if the types do not match.
489 ///
490 /// For example, this code will get a bool value under key "key" if "key" has a
491 /// boolean value in the dictionary. If there is no such key, or the value
492 /// under the key is not a bool, the specified default (false) is returned.
493 ///
494 /// \code
495 /// bool val = VtDictionaryGet<bool>(dict, "key", VtDefault = false);
496 /// \endcode
497 ///
498 /// \ingroup group_vtdict_functions
499 template <class T, class U>
500 T VtDictionaryGet( const VtDictionary &dictionary,
501  const std::string &key,
502  Vt_DefaultHolder<U> const &def )
503 {
504  VtDictionary::const_iterator i = dictionary.find(key);
505  if (i == dictionary.end() || !i->second.IsHolding<T>())
506  return def.val;
507  return i->second.UncheckedGet<T>();
508 }
509 
510 /// \overload
511 template <class T, class U>
512 T VtDictionaryGet( const VtDictionary &dictionary,
513  const char *key,
514  Vt_DefaultHolder<U> const &def )
515 {
516  VtDictionary::const_iterator i = dictionary.find(key);
517  if (i == dictionary.end() || !i->second.IsHolding<T>())
518  return def.val;
519  return i->second.UncheckedGet<T>();
520 }
521 
522 
523 
524 /// Creates a dictionary containing \p strong composed over \p weak.
525 ///
526 /// The new dictionary will contain all key-value pairs from \p strong
527 /// together with the key-value pairs from \p weak whose keys are not in \p
528 /// strong.
529 ///
530 /// If \p coerceToWeakerOpinionType is \c true then coerce a strong value to
531 /// the weaker value's type, if there is a weaker value. This is mainly
532 /// intended to promote to enum types.
533 ///
534 /// \ingroup group_vtdict_functions
536 VtDictionaryOver(const VtDictionary &strong, const VtDictionary &weak,
537  bool coerceToWeakerOpinionType = false);
538 
539 /// Updates \p strong to become \p strong composed over \p weak.
540 ///
541 /// The updated contents of \p strong will be all key-value pairs from \p
542 /// strong together with the key-value pairs from \p weak whose keys are not in
543 /// \p strong.
544 ///
545 /// If \p coerceToWeakerOpinionType is \c true then coerce a strong value to
546 /// the weaker value's type, if there is a weaker value. This is mainly
547 /// intended to promote to enum types.
548 ///
549 /// \ingroup group_vtdict_functions
550 VT_API void
551 VtDictionaryOver(VtDictionary *strong, const VtDictionary &weak,
552  bool coerceToWeakerOpinionType = false);
553 
554 /// Updates \p weak to become \p strong composed over \p weak.
555 ///
556 /// The updated contents of \p weak will be all key-value pairs from \p strong
557 /// together with the key-value pairs from \p weak whose keys are not in \p
558 /// strong.
559 ///
560 /// If \p coerceToWeakerOpinionType is \c true then coerce a strong value to
561 /// the weaker value's type, if there is a weaker value. This is mainly
562 /// intended to promote to enum types.
563 ///
564 /// \ingroup group_vtdict_functions
565 VT_API void
566 VtDictionaryOver(const VtDictionary &strong, VtDictionary *weak,
567  bool coerceToWeakerOpinionType = false);
568 
569 /// Returns a dictionary containing \p strong recursively composed over \p
570 /// weak.
571 ///
572 /// The new dictionary will be all key-value pairs from \p strong together
573 /// with the key-value pairs from \p weak whose keys are not in \p strong.
574 ///
575 /// If a value for a key is in turn a dictionary, and both \a strong and \a
576 /// weak have values for that key, then the result may not contain strong's
577 /// exact value for the subdict. Rather, the result will contain a subdict
578 /// that is the result of a recursive call to this method. Hence, the
579 /// subdict, too, will contain values from \a weak that are not found in \a
580 /// strong.
581 ///
582 /// If \p coerceToWeakerOpinionType is \c true then coerce a strong value to
583 /// the weaker value's type, if there is a weaker value. This is mainly
584 /// intended to promote to enum types.
585 ///
586 /// \ingroup group_vtdict_functions
588 VtDictionaryOverRecursive(const VtDictionary &strong, const VtDictionary &weak,
589  bool coerceToWeakerOpinionType = false);
590 
591 /// Updates \p strong to become \p strong composed recursively over \p weak.
592 ///
593 /// The updated contents of \p strong will be all key-value pairs from \p
594 /// strong together with the key-value pairs from \p weak whose keys are not
595 /// in \p strong.
596 ///
597 /// If a value for a key is in turn a dictionary, and both \a strong and \a
598 /// weak have values for that key, then \a strong's subdict may not be left
599 /// untouched. Rather, the dictionary will be replaced by the result of a
600 /// recursive call to this method in which \a strong's subdictionary will have
601 /// entries added if they are contained in \a weak but not in \a strong
602 ///
603 /// If \p coerceToWeakerOpinionType is \c true then coerce a strong value to
604 /// the weaker value's type, if there is a weaker value. This is mainly
605 /// intended to promote to enum types.
606 ///
607 /// \ingroup group_vtdict_functions
608 VT_API void
610  bool coerceToWeakerOpinionType = false);
611 
612 /// Updates \p weak to become \p strong composed recursively over \p weak.
613 ///
614 /// The updated contents of \p weak will be all key-value pairs from \p strong
615 /// together with the key-value pairs from \p weak whose keys are not in \p
616 /// strong.
617 ///
618 /// If a value is in turn a dictionary, the dictionary in \a weak may not be
619 /// replaced wholesale by that of \a strong. Rather, the dictionary will be
620 /// replaced by the result of a recursive call to this method in which \a
621 /// weak's subdictionary is recursively overlayed by \a strong's
622 /// subdictionary.
623 ///
624 /// The result is that no key/value pairs of \a will be lost in nested
625 /// dictionaries. Rather, only non-dictionary values will be overwritten
626 ///
627 /// If \p coerceToWeakerOpinionType is \c true then coerce a strong value to
628 /// the weaker value's type, if there is a weaker value. This is mainly
629 /// intended to promote to enum types.
630 ///
631 /// \ingroup group_vtdict_functions
632 VT_API void
634  bool coerceToWeakerOpinionType = false);
635 
636 
638  inline size_t operator()(VtDictionary const &dict) const {
639  return hash_value(dict);
640  }
641 };
642 
644 
645 #endif /* PXR_BASE_VT_DICTIONARY_H */
VT_API size_type erase(const std::string &key)
Erases the element whose key is key.
VT_API VtDictionary const & VtGetEmptyDictionary()
VtDictionary(_InputIterator f, _InputIterator l)
Creates a VtDictionary with a copy of a range.
Definition: dictionary.h:191
Iterator(Iterator< OtherUnderlyingMapPtr, OtherUnderlyingIterator > const &other)
Definition: dictionary.h:73
VT_API VtDictionary VtDictionaryOverRecursive(const VtDictionary &strong, const VtDictionary &weak, bool coerceToWeakerOpinionType=false)
bool operator!=(const Iterator< OtherUnderlyingMapPtr, OtherUnderlyingIterator > &other) const
Definition: dictionary.h:110
GLsizei const GLfloat * value
Definition: glcorearb.h:824
Iterator & operator--()
Definition: dictionary.h:92
bool operator==(const Iterator< OtherUnderlyingMapPtr, OtherUnderlyingIterator > &other) const
Definition: dictionary.h:104
Iterator operator++(int)
Definition: dictionary.h:86
#define VT_API
Definition: api.h:23
VT_API VtValue & operator[](const std::string &key)
IMATH_HOSTDEVICE constexpr bool equal(T1 a, T2 b, T3 t) IMATH_NOEXCEPT
Definition: ImathFun.h:105
friend size_t hash_value(VtDictionary const &dict)
Definition: dictionary.h:294
**But if you need a result
Definition: thread.h:622
VtDictionary()
Creates an empty VtDictionary.
Definition: dictionary.h:184
uint64 value_type
Definition: GA_PrimCompat.h:29
_Map::allocator_type allocator_type
Definition: dictionary.h:177
const T & VtDictionaryGet(const VtDictionary &dictionary, const std::string &key)
Definition: dictionary.h:437
pointer operator->() const
Definition: dictionary.h:79
typename UnderlyingIterator::reference reference
Definition: dictionary.h:62
T const & val
Definition: dictionary.h:470
Vt_DefaultHolder(T const &t)
Definition: dictionary.h:469
Definition: hash.h:472
TF_MALLOC_TAG_NEW("Vt","VtDictionary")
reference operator*() const
Definition: dictionary.h:78
Iterator< _Map *, _Map::iterator > iterator
Definition: dictionary.h:180
#define ARCH_UNLIKELY(x)
Definition: hints.h:30
GLfloat f
Definition: glcorearb.h:1926
VT_API iterator find(const std::string &key)
Finds an element whose key is key.
typename UnderlyingIterator::value_type value_type
Definition: dictionary.h:61
#define TF_FATAL_ERROR
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:556
VT_API std::ostream & operator<<(std::ostream &, VtDictionary const &)
Iterator & operator++()
Definition: dictionary.h:81
Iterator operator--(int)
Definition: dictionary.h:97
VT_API bool empty() const
true if the VtDictionary's size is 0.
void insert(_InputIterator f, _InputIterator l)
Inserts a range into the VtDictionary.
Definition: dictionary.h:304
VT_API VtDictionary VtDictionaryOver(const VtDictionary &strong, const VtDictionary &weak, bool coerceToWeakerOpinionType=false)
GLdouble t
Definition: glad.h:2397
_Map::key_type key_type
Definition: dictionary.h:174
size_t operator()(VtDictionary const &dict) const
Definition: dictionary.h:638
Vt_DefaultHolder< T > operator=(T const &t)
Definition: dictionary.h:478
GLsizeiptr size
Definition: glcorearb.h:664
VT_API void clear()
Erases all of the elements.
#define TF_AXIOM(cond)
GLenum void ** pointer
Definition: glcorearb.h:810
std::bidirectional_iterator_tag iterator_category
Definition: dictionary.h:60
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
VT_API iterator begin()
Returns an iterator pointing to the beginning of the VtDictionary.
typename UnderlyingIterator::pointer pointer
Definition: dictionary.h:63
Iterator< _Map const *, _Map::const_iterator > const_iterator
Definition: dictionary.h:181
VT_API VtDictionary & operator=(VtDictionary const &other)
Copy assignment operator.
friend void swap(VtDictionary &lhs, VtDictionary &rhs)
Definition: dictionary.h:290
GLuint GLfloat * val
Definition: glcorearb.h:1608
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
VT_API void EraseValueAtPath(std::string const &keyPath, char const *delimiters=":")
VT_API size_type count(const std::string &key) const
Counts the number of elements whose key is key.
VT_API iterator end()
Returns an iterator pointing to the end of the VtDictionary.
_Map::mapped_type mapped_type
Definition: dictionary.h:175
VT_API void SetValueAtPath(std::string const &keyPath, VtValue const &value, char const *delimiters=":")
VT_API void swap(VtDictionary &dict)
Swaps the contents of two VtDictionaries.
that also have some descendant prim *whose name begins with which in turn has a child named baz where *the predicate and *a name There is also one special expression reference
VT_API size_type size() const
Returns the size of the VtDictionary.
size_t hash_value(const CH_ChannelRef &ref)
_Map::value_type value_type
Definition: dictionary.h:176
typename UnderlyingIterator::difference_type difference_type
Definition: dictionary.h:64
VT_API Vt_DefaultGenerator VtDefault
Definition: value.h:146
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542
_Map::size_type size_type
Definition: dictionary.h:178
VT_API VtValue const * GetValueAtPath(std::string const &keyPath, char const *delimiters=":") const
VtDictionary(int size)
Creates an empty VtDictionary with at least size buckets.
Definition: dictionary.h:187
bool VtDictionaryIsHolding(const VtDictionary &dictionary, const std::string &key)
Definition: dictionary.h:399