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

Function GetOffsetAttribute

CoreLib/SymbolMapper.cpp:239–271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237}
238
239std::optional<int> GetOffsetAttribute(tinyxml2::XMLElement* ele, Pattern const& pattern, char const* name)
240{
241 char const* value{ nullptr };
242 auto e = ele->QueryStringAttribute(name, &value);
243 if (e != tinyxml2::XML_SUCCESS) {
244 return {};
245 }
246
247 if (*value == '@') {
248 auto offset = pattern.GetAnchor(value + 1);
249 if (!offset) {
250 ERR("Invalid anchor reference in XML attribute '%s': '%s'", name, value);
251 return {};
252 } else {
253 return (int)*offset;
254 }
255 }
256
257 std::size_t readSize{ 0 };
258 int parsed;
259 try {
260 parsed = std::stoi(value, &readSize, 0);
261 } catch (std::exception const& e) {
262 ERR("Invalid offset value in XML attribute '%s': '%s' (%s)", name, value, e.what());
263 return {};
264 }
265
266 if (readSize != strlen(value)) {
267 ERR("Invalid offset value in XML attribute '%s': '%s' (garbage found at end of string)", name, value);
268 }
269
270 return parsed;
271}
272
273void SymbolMappingLoader::AddKnownModule(std::string const& name)
274{

Callers 2

LoadReferenceMethod · 0.85
LoadConditionMethod · 0.85

Calls 1

GetAnchorMethod · 0.80

Tested by

no test coverage detected