Signed-off-by: faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-07-15 19:49:57 +03:00
1 parent 01362d2e51
commit 39aff68d8d
29 files changed
+2061 -1818

No files matched your search

+6 -27
View File
@@ -101,33 +101,12 @@ namespace Echoion::Core
uint32_t StateSerializer::extractVersion(const std::string& jsonStr)
{
// Quick extraction without full parse
// Look for "version": N pattern
size_t pos = jsonStr.find("\"version\"");
if (pos != std::string::npos) {
pos = jsonStr.find(':', pos);
if (pos != std::string::npos) {
// Skip whitespace
pos++;
while (pos < jsonStr.size() &&
std::isspace(static_cast<unsigned char>(jsonStr[pos]))) {
pos++;
}
// Parse number
if (pos < jsonStr.size() &&
std::isdigit(static_cast<unsigned char>(jsonStr[pos]))) {
try {
return static_cast<uint32_t>(
std::stoul(jsonStr.substr(pos)));
} catch (const std::exception&) {
return 0;
}
}
}
}
// Default to 0 (unknown/legacy)
return 0;
// Read only the root field. A textual search can accidentally select a
// nested schema version (for example an extension plugin's state).
auto parsed = Void::Json::parse(jsonStr);
if (!parsed || !parsed->is_object()) return 0;
const auto version = parsed->get_num("version", 0);
return version > 0 ? static_cast<uint32_t>(version) : 0;
}
} // namespace Echoion::Core