Loading [MathJax]/extensions/tex2jax.js
Free Electron
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
anchordict.h
1 #ifndef ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
2 #define ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
3 
4 #if defined(_MSC_VER) || \
5  (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
6  (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
7 #pragma once
8 #endif
9 
10 #include <vector>
11 
12 #include "../anchor.h"
13 
14 namespace YAML {
15 /**
16  * An object that stores and retrieves values correlating to {@link anchor_t}
17  * values.
18  *
19  * <p>Efficient implementation that can make assumptions about how
20  * {@code anchor_t} values are assigned by the {@link Parser} class.
21  */
22 template <class T>
23 class AnchorDict {
24  public:
25  AnchorDict() : m_data{} {}
26  void Register(anchor_t anchor, T value) {
27  if (anchor > m_data.size()) {
28  m_data.resize(anchor);
29  }
30  m_data[anchor - 1] = value;
31  }
32 
33  T Get(anchor_t anchor) const { return m_data[anchor - 1]; }
34 
35  private:
36  std::vector<T> m_data;
37 };
38 } // namespace YAML
39 
40 #endif // ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
An object that stores and retrieves values correlating to anchor_t values.
Definition: anchordict.h:23
Definition: anchor.h:12