mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-18 02:08:09 +08:00
feat: Add a parse(FILE *) interface
The fstream classes are notorious for their non-existent error handling. This adds a C-style fILE * IO (fopen(), etc.) alternative interface, so that if a user needs reliable error handling, they can use that, albeit more inconvenient, but more robust approach.
This commit is contained in:
@@ -10,6 +10,18 @@
|
||||
namespace toml
|
||||
{
|
||||
|
||||
struct file_io_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
file_io_error(int errnum, const std::string& msg, const std::string& fname)
|
||||
: std::runtime_error(msg + " \"" + fname + "\": " + std::strerror(errnum)),
|
||||
errno_(errnum)
|
||||
{}
|
||||
int get_errno() {return errno_;}
|
||||
private:
|
||||
int errno_;
|
||||
};
|
||||
|
||||
struct exception : public std::exception
|
||||
{
|
||||
public:
|
||||
|
Reference in New Issue
Block a user