MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / Object

Class Object

src/core/include/megbrain/utils/json.h:114–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112};
113
114class 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
119public:
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
152class Array final : public Value {
153 MGB_DYN_TYPE_OBJ_FINAL_DECL_WITH_EXPORT;

Callers

nothing calls this directly

Calls 4

makeFunction · 0.50
insertMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected