Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:59:27

0001 #ifndef ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
0002 #define ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
0003 
0004 #if defined(_MSC_VER) ||                                            \
0005     (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
0006      (__GNUC__ >= 4))  // GCC supports "pragma once" correctly since 3.4
0007 #pragma once
0008 #endif
0009 
0010 #include <vector>
0011 
0012 #include "../anchor.h"
0013 
0014 namespace YAML {
0015 /**
0016  * An object that stores and retrieves values correlating to {@link anchor_t}
0017  * values.
0018  *
0019  * <p>Efficient implementation that can make assumptions about how
0020  * {@code anchor_t} values are assigned by the {@link Parser} class.
0021  */
0022 template <class T>
0023 class AnchorDict {
0024  public:
0025   AnchorDict() : m_data{} {}
0026   void Register(anchor_t anchor, T value) {
0027     if (anchor > m_data.size()) {
0028       m_data.resize(anchor);
0029     }
0030     m_data[anchor - 1] = value;
0031   }
0032 
0033   T Get(anchor_t anchor) const { return m_data[anchor - 1]; }
0034 
0035  private:
0036   std::vector<T> m_data;
0037 };
0038 }  // namespace YAML
0039 
0040 #endif  // ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66