MCPcopy Create free account
hub / github.com/MyGUI/mygui / _loadImplement

Method _loadImplement

MyGUIEngine/src/MyGUI_ResourceManager.cpp:134–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132 }
133
134 bool ResourceManager::_loadImplement(
135 const std::string& _file,
136 bool _match,
137 std::string_view _type,
138 std::string_view _instance)
139 {
140 DataStreamHolder data = DataManager::getInstance().getData(_file);
141 if (data.getData() == nullptr)
142 {
143 MYGUI_LOG(Error, _instance << " : '" << _file << "', not found");
144 return false;
145 }
146
147 xml::Document doc;
148 if (!doc.open(data.getData()))
149 {
150 MYGUI_LOG(Error, _instance << " : '" << _file << "', " << doc.getLastError());
151 return false;
152 }
153
154 xml::ElementPtr root = doc.getRoot();
155 if ((nullptr == root) || (root->getName() != "MyGUI"))
156 {
157 MYGUI_LOG(Error, _instance << " : '" << _file << "', tag 'MyGUI' not found");
158 return false;
159 }
160
161 std::string type;
162 if (root->findAttribute("type", type))
163 {
164 Version version = Version::parse(root->findAttribute("version"));
165 MapLoadXmlDelegate::iterator iter = mMapLoadXmlDelegate.find(type);
166 if (iter != mMapLoadXmlDelegate.end())
167 {
168 if ((!_match) || (type == _type))
169 (*iter).second(root, _file, version);
170 else
171 {
172 MYGUI_LOG(Error, _instance << " : '" << _file << "', type '" << _type << "' not found");
173 return false;
174 }
175 }
176 else
177 {
178 MYGUI_LOG(Error, _instance << " : '" << _file << "', delegate for type '" << type << "'not found");
179 return false;
180 }
181 }
182 // предпологаем что будут вложенные
183 else if (!_match)
184 {
185 xml::ElementEnumerator node = root->getElementEnumerator();
186 while (node.next("MyGUI"))
187 {
188 if (node->findAttribute("type", type))
189 {
190 Version version = Version::parse(root->findAttribute("version"));
191 MapLoadXmlDelegate::iterator iter = mMapLoadXmlDelegate.find(type);

Callers

nothing calls this directly

Calls 11

getLastErrorMethod · 0.80
findAttributeMethod · 0.80
getElementEnumeratorMethod · 0.80
parseFunction · 0.50
getDataMethod · 0.45
openMethod · 0.45
getRootMethod · 0.45
findMethod · 0.45
endMethod · 0.45
nextMethod · 0.45
currentMethod · 0.45

Tested by

no test coverage detected