| 34 | |
| 35 | |
| 36 | class JSON |
| 37 | { |
| 38 | public: |
| 39 | enum class Class { |
| 40 | Null, |
| 41 | Object, |
| 42 | Array, |
| 43 | String, |
| 44 | Floating, |
| 45 | Integral, |
| 46 | Boolean |
| 47 | }; |
| 48 | |
| 49 | private: |
| 50 | |
| 51 | struct QuickFlatMap |
| 52 | { |
| 53 | auto find(const std::string &s) { |
| 54 | return std::find_if(std::begin(data), std::end(data), [&s](const auto &d) { return d.first == s; }); |
| 55 | } |
| 56 | |
| 57 | auto find(const std::string &s) const { |
| 58 | return std::find_if(std::begin(data), std::end(data), [&s](const auto &d) { return d.first == s; }); |
| 59 | } |
| 60 | |
| 61 | auto size() const { |
| 62 | return data.size(); |
| 63 | } |
| 64 | |
| 65 | auto begin() const { |
| 66 | return data.begin(); |
| 67 | } |
| 68 | |
| 69 | auto end() const { |
| 70 | return data.end(); |
| 71 | } |
| 72 | |
| 73 | |
| 74 | auto begin() { |
| 75 | return data.begin(); |
| 76 | } |
| 77 | |
| 78 | auto end() { |
| 79 | return data.end(); |
| 80 | } |
| 81 | |
| 82 | |
| 83 | JSON &operator[](const std::string &s) { |
| 84 | const auto itr = find(s); |
| 85 | if (itr != data.end()) { |
| 86 | return itr->second; |
| 87 | } else { |
| 88 | data.emplace_back(s, JSON()); |
| 89 | return data.back().second; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | JSON &at(const std::string &s) { |
no test coverage detected