1#define CPP_UTILITIES_IOMISC_STRING_VIEW
30 file.exceptions(ios_base::failbit | ios_base::badbit);
31 file.open(path.data(), ios_base::in | ios_base::binary);
32 file.seekg(0, ios_base::end);
34 const auto size =
static_cast<string::size_type
>(
file.tellg());
36 throw ios_base::failure(
"File exceeds max size");
39 file.seekg(ios_base::beg);
42#pragma GCC diagnostic push
43#pragma GCC diagnostic ignored "-Wnull-dereference"
47#pragma GCC diagnostic pop
61 file.exceptions(ios_base::failbit | ios_base::badbit);
62 file.open(path.data(), ios_base::out | ios_base::trunc | ios_base::binary);
Contains all utilities provides by the c++utilities library.
CPP_UTILITIES_EXPORT std::string readFile(const std::string &path, std::string::size_type maxSize=std::string::npos)
Reads all contents of the specified file in a single call.
IntegralType stringToNumber(const StringType &string, BaseType base=10)
Converts the given string to an unsigned/signed number assuming string uses the specified base.
std::fstream NativeFileStream
CPP_UTILITIES_EXPORT void writeFile(std::string_view path, std::string_view contents)
Writes all contents to the specified file in a single call.