1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-21 09:09:43 +00:00

Avoid the inclusion of <charconv> header due to Ubuntu Bionic (18.04) which as gcc version less than 8.1

Partially reverts commit fd67ebde25
This commit is contained in:
cc9cii 2021-08-04 06:47:14 +10:00
parent 31e5fd91d1
commit 99e691fbe3
3 changed files with 7 additions and 14 deletions

View file

@ -1,7 +1,5 @@
#include "refcollection.hpp"
#include <charconv>
#include <components/esm/loadcell.hpp>
#include "ref.hpp"
@ -183,19 +181,14 @@ std::string CSMWorld::RefCollection::getNewId()
return "ref#" + std::to_string(mNextId++);
}
unsigned int CSMWorld::RefCollection::extractIdNum(std::string_view id) const
unsigned int CSMWorld::RefCollection::extractIdNum (const std::string& id) const
{
const auto separator = id.find_last_of('#');
std::string::size_type separator = id.find_last_of('#');
if (separator == std::string_view::npos)
throw std::runtime_error("invalid ref ID: " + std::string(id));
if (separator == std::string::npos)
throw std::runtime_error("invalid ref ID: " + id);
const std::string_view number = id.substr(separator + 1);
unsigned int result;
if (std::from_chars(number.data(), number.data() + number.size(), result).ec != std::errc())
throw std::runtime_error("invalid ref ID number: " + std::string(number));
return result;
return static_cast<unsigned int>(std::stoi(id.substr(separator+1)));
}
int CSMWorld::RefCollection::getIntIndex (unsigned int id) const

View file

@ -29,7 +29,7 @@ namespace CSMWorld
int mNextId;
unsigned int extractIdNum(std::string_view id) const;
unsigned int extractIdNum(const std::string& id) const;
int getIntIndex (unsigned int id) const;

View file

@ -17,7 +17,7 @@ void CSVDoc::LoadingDocument::closeEvent (QCloseEvent *event)
}
CSVDoc::LoadingDocument::LoadingDocument (CSMDoc::Document *document)
: mDocument (document), mAborted (false), mMessages (nullptr), mRecordsLabel (0), mTotalRecordsLabel (0)
: mDocument (document), mTotalRecordsLabel (0), mRecordsLabel (0), mAborted (false), mMessages (nullptr), mRecords(0)
{
setWindowTitle (QString::fromUtf8((std::string("Opening ") + document->getSavePath().filename().string()).c_str()));