bool TXmlStorage::ReadXml() { CNBFile xmlFile; if (!xmlFile.OpenRead(GetStorage().c_str())) { return false; } size_t buffSize = static_cast<size_t>(xmlFile.GetFileSize() + 1); if (buffSize > 1000000) { return false; } std::string buff(buffSize, 0); if (!xmlFile.Read(&buff[0], buffSize)) { return false; } FXmlDoc->Parse(buff.c_str()); if (FXmlDoc->Error()) { return false; } // Get and check root node tinyxml2::XMLElement * xmlRoot = FXmlDoc->RootElement(); if (!xmlRoot) return false; const char * Value = xmlRoot->Value(); if (!Value) return false; if (strcmp(Value, CONST_ROOT_NODE) != 0) return false; const char * Attr = xmlRoot->Attribute(CONST_VERSION_ATTR); if (!Attr) return false; uintptr_t Version = ::StrToVersionNumber(UnicodeString(Attr)); if (Version < MAKEVERSIONNUMBER(2,0,0)) return false; tinyxml2::XMLElement * Element = xmlRoot->FirstChildElement(ToStdString(FStoredSessionsSubKey).c_str()); if (Element != nullptr) { FCurrentElement = FXmlDoc->RootElement(); return true; } return false; }
uintptr_t inline GetVersionNumber2121() { return MAKEVERSIONNUMBER(2,1,21); }
uintptr_t inline GetVersionNumber2110() { return MAKEVERSIONNUMBER(2,1,10); }