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