MCPcopy Create free account
hub / github.com/Norbyte/bg3se / GetIntAttribute

Function GetIntAttribute

CoreLib/SymbolMapper.cpp:215–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213}
214
215std::optional<int> GetIntAttribute(tinyxml2::XMLElement* ele, char const* name)
216{
217 char const* value{ nullptr };
218 auto e = ele->QueryStringAttribute(name, &value);
219 if (e != tinyxml2::XML_SUCCESS) {
220 return {};
221 }
222
223 std::size_t readSize{ 0 };
224 int parsed;
225 try {
226 parsed = std::stoi(value, &readSize, 0);
227 } catch (std::exception const& e) {
228 ERR("Invalid int value in XML attribute '%s': '%s' (%s)", name, value, e.what());
229 return {};
230 }
231
232 if (readSize != strlen(value)) {
233 ERR("Invalid int value in XML attribute '%s': '%s' (garbage found at end of string)", name, value);
234 }
235
236 return parsed;
237}
238
239std::optional<int> GetOffsetAttribute(tinyxml2::XMLElement* ele, Pattern const& pattern, char const* name)
240{

Callers 1

LoadTargetMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected