diff --git a/src/parser.hpp b/src/parser.hpp index 5f30ea3..524c0bb 100644 --- a/src/parser.hpp +++ b/src/parser.hpp @@ -3,6 +3,7 @@ #include "cantypes.hpp" #include +#include namespace CANdb { @@ -10,8 +11,19 @@ template struct Parser { bool parse(const std::string& data) noexcept { + // Store current LOCALE + std::string prevLocale = std::setlocale(LC_ALL, nullptr); + // To assure that std::stoX functions will produced the same results + // on systems with different LOCALE settings + std::setlocale(LC_ALL, "C"); + Derived* d = static_cast(this); - return d->parse(data); + auto ret = d->parse(data); + + // Restore previous LOCALE for the application + std::setlocale(LC_ALL, prevLocale.c_str()); + + return ret; } CANdb_t getDb() const noexcept { return can_db; }