| 112 | }; |
| 113 | |
| 114 | class Object final : public Value { |
| 115 | MGB_DYN_TYPE_OBJ_FINAL_DECL_WITH_EXPORT; |
| 116 | |
| 117 | std::unordered_map<String, std::shared_ptr<Value>, StdHashAdaptor<String>> m_val; |
| 118 | |
| 119 | public: |
| 120 | MGE_WIN_DECLSPEC_FUC static std::shared_ptr<Object> make() { |
| 121 | return std::make_shared<Object>(); |
| 122 | } |
| 123 | |
| 124 | MGE_WIN_DECLSPEC_FUC static std::shared_ptr<Object> make( |
| 125 | const std::vector<std::pair<String, std::shared_ptr<Value>>>& val) { |
| 126 | for (auto&& i : val) |
| 127 | mgb_assert(i.second); |
| 128 | auto rst = make(); |
| 129 | rst->m_val.insert(val.begin(), val.end()); |
| 130 | return rst; |
| 131 | } |
| 132 | |
| 133 | MGE_WIN_DECLSPEC_FUC std::shared_ptr<Value>& operator[](const String& s) { |
| 134 | return m_val[s]; |
| 135 | } |
| 136 | |
| 137 | MGE_WIN_DECLSPEC_FUC std::shared_ptr<Value>& operator[](const std::string& s) { |
| 138 | return m_val[s]; |
| 139 | } |
| 140 | |
| 141 | MGE_WIN_DECLSPEC_FUC std::shared_ptr<Value>& operator[](const char* s) { |
| 142 | return m_val[std::string(s)]; |
| 143 | } |
| 144 | |
| 145 | MGE_WIN_DECLSPEC_FUC void writeto(std::string& fout, int indent = 0) const override; |
| 146 | |
| 147 | auto&& get_impl() { return m_val; } |
| 148 | |
| 149 | auto&& get_impl() const { return m_val; } |
| 150 | }; |
| 151 | |
| 152 | class Array final : public Value { |
| 153 | MGB_DYN_TYPE_OBJ_FINAL_DECL_WITH_EXPORT; |