MCPcopy Create free account
hub / github.com/axmolengine/axmol / startElement

Method startElement

core/platform/FileUtils.cpp:150–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148 }
149
150 void startElement(void* ctx, const char* name, const char** atts) override
151 {
152 const std::string sName(name);
153 if (sName == "dict"sv)
154 {
155 if (_resultType == SAX_RESULT_DICT && _rootDict.empty())
156 {
157 _curDict = &_rootDict;
158 }
159
160 _state = SAX_DICT;
161
162 SAXState preState = SAX_NONE;
163 if (!_stateStack.empty())
164 {
165 preState = _stateStack.top();
166 }
167
168 if (SAX_ARRAY == preState)
169 {
170 // add a new dictionary into the array
171 _curArray->emplace_back(Value(ValueMap()));
172 _curDict = &(_curArray->rbegin())->asValueMap();
173 }
174 else if (SAX_DICT == preState)
175 {
176 // add a new dictionary into the pre dictionary
177 AXASSERT(!_dictStack.empty(), "The state is wrong!");
178 ValueMap* preDict = _dictStack.top();
179 auto& curVal = hlookup::set_item(*preDict, _curKey, Value(ValueMap()))->second;
180 _curDict = &curVal.asValueMap();
181 }
182
183 // record the dict state
184 _stateStack.push(_state);
185 _dictStack.push(_curDict);
186 }
187 else if (sName == "key"sv)
188 {
189 _state = SAX_KEY;
190 }
191 else if (sName == "integer"sv)
192 {
193 _state = SAX_INT;
194 }
195 else if (sName == "real"sv)
196 {
197 _state = SAX_REAL;
198 }
199 else if (sName == "string"sv)
200 {
201 _state = SAX_STRING;
202 }
203 else if (sName == "array"sv)
204 {
205 _state = SAX_ARRAY;
206
207 if (_resultType == SAX_RESULT_ARRAY && _rootArray.empty())

Callers

nothing calls this directly

Calls 7

set_itemFunction · 0.85
ValueClass · 0.50
emptyMethod · 0.45
topMethod · 0.45
emplace_backMethod · 0.45
rbeginMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected