Merge branch 'develop' into develop-simplify-istream
This commit is contained in:
commit
ef40673acb
6 changed files with 71 additions and 30 deletions
70
src/json.hpp
70
src/json.hpp
|
|
@ -206,9 +206,9 @@ class exception : public std::exception
|
|||
protected:
|
||||
exception(int id_, const char* what_arg) : id(id_), m(what_arg) {}
|
||||
|
||||
static std::string name(const std::string& ename, int id)
|
||||
static std::string name(const std::string& ename, int id_)
|
||||
{
|
||||
return "[json.exception." + ename + "." + std::to_string(id) + "] ";
|
||||
return "[json.exception." + ename + "." + std::to_string(id_) + "] ";
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -264,18 +264,18 @@ class parse_error : public exception
|
|||
public:
|
||||
/*!
|
||||
@brief create a parse error exception
|
||||
@param[in] id the id of the exception
|
||||
@param[in] id_ the id of the exception
|
||||
@param[in] byte_ the byte index where the error occurred (or 0 if the
|
||||
position cannot be determined)
|
||||
@param[in] what_arg the explanatory string
|
||||
@return parse_error object
|
||||
*/
|
||||
static parse_error create(int id, std::size_t byte_, const std::string& what_arg)
|
||||
static parse_error create(int id_, std::size_t byte_, const std::string& what_arg)
|
||||
{
|
||||
std::string w = exception::name("parse_error", id) + "parse error" +
|
||||
std::string w = exception::name("parse_error", id_) + "parse error" +
|
||||
(byte_ != 0 ? (" at " + std::to_string(byte_)) : "") +
|
||||
": " + what_arg;
|
||||
return parse_error(id, byte_, w.c_str());
|
||||
return parse_error(id_, byte_, w.c_str());
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -334,10 +334,10 @@ caught.,invalid_iterator}
|
|||
class invalid_iterator : public exception
|
||||
{
|
||||
public:
|
||||
static invalid_iterator create(int id, const std::string& what_arg)
|
||||
static invalid_iterator create(int id_, const std::string& what_arg)
|
||||
{
|
||||
std::string w = exception::name("invalid_iterator", id) + what_arg;
|
||||
return invalid_iterator(id, w.c_str());
|
||||
std::string w = exception::name("invalid_iterator", id_) + what_arg;
|
||||
return invalid_iterator(id_, w.c_str());
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -385,10 +385,10 @@ caught.,type_error}
|
|||
class type_error : public exception
|
||||
{
|
||||
public:
|
||||
static type_error create(int id, const std::string& what_arg)
|
||||
static type_error create(int id_, const std::string& what_arg)
|
||||
{
|
||||
std::string w = exception::name("type_error", id) + what_arg;
|
||||
return type_error(id, w.c_str());
|
||||
std::string w = exception::name("type_error", id_) + what_arg;
|
||||
return type_error(id_, w.c_str());
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -428,10 +428,10 @@ caught.,out_of_range}
|
|||
class out_of_range : public exception
|
||||
{
|
||||
public:
|
||||
static out_of_range create(int id, const std::string& what_arg)
|
||||
static out_of_range create(int id_, const std::string& what_arg)
|
||||
{
|
||||
std::string w = exception::name("out_of_range", id) + what_arg;
|
||||
return out_of_range(id, w.c_str());
|
||||
std::string w = exception::name("out_of_range", id_) + what_arg;
|
||||
return out_of_range(id_, w.c_str());
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -466,10 +466,10 @@ caught.,other_error}
|
|||
class other_error : public exception
|
||||
{
|
||||
public:
|
||||
static other_error create(int id, const std::string& what_arg)
|
||||
static other_error create(int id_, const std::string& what_arg)
|
||||
{
|
||||
std::string w = exception::name("other_error", id) + what_arg;
|
||||
return other_error(id, w.c_str());
|
||||
std::string w = exception::name("other_error", id_) + what_arg;
|
||||
return other_error(id_, w.c_str());
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -3008,11 +3008,19 @@ class parser
|
|||
{
|
||||
case token_type::begin_object:
|
||||
{
|
||||
if (keep and (not callback or ((keep = callback(depth++, parse_event_t::object_start, result)))))
|
||||
if (keep)
|
||||
{
|
||||
// explicitly set result to object to cope with {}
|
||||
result.m_type = value_t::object;
|
||||
result.m_value = value_t::object;
|
||||
if (callback)
|
||||
{
|
||||
keep = callback(depth++, parse_event_t::object_start, result);
|
||||
}
|
||||
|
||||
if (not callback or keep)
|
||||
{
|
||||
// explicitly set result to object to cope with {}
|
||||
result.m_type = value_t::object;
|
||||
result.m_value = value_t::object;
|
||||
}
|
||||
}
|
||||
|
||||
// read next token
|
||||
|
|
@ -3104,11 +3112,19 @@ class parser
|
|||
|
||||
case token_type::begin_array:
|
||||
{
|
||||
if (keep and (not callback or ((keep = callback(depth++, parse_event_t::array_start, result)))))
|
||||
if (keep)
|
||||
{
|
||||
// explicitly set result to object to cope with []
|
||||
result.m_type = value_t::array;
|
||||
result.m_value = value_t::array;
|
||||
if (callback)
|
||||
{
|
||||
keep = callback(depth++, parse_event_t::array_start, result);
|
||||
}
|
||||
|
||||
if (not callback or keep)
|
||||
{
|
||||
// explicitly set result to array to cope with []
|
||||
result.m_type = value_t::array;
|
||||
result.m_value = value_t::array;
|
||||
}
|
||||
}
|
||||
|
||||
// read next token
|
||||
|
|
@ -5250,7 +5266,7 @@ class binary_reader
|
|||
{
|
||||
get();
|
||||
check_eof();
|
||||
return current;
|
||||
return static_cast<char>(current);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue