40 const char*
what() const noexcept
override
50 exception(
int id_, const
char* what_arg) :
id(id_), m(what_arg) {}
52 static std::string
name(
const std::string& ename,
int id_)
62 template<
typename BasicJsonType>
63 static std::string
diagnostics(
const BasicJsonType* leaf_element)
66 std::vector<std::string> tokens;
67 for (
const auto* current = leaf_element; current !=
nullptr && current->m_parent !=
nullptr; current = current->m_parent)
69 switch (current->m_parent->type())
73 for (std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i)
75 if (¤t->m_parent->m_value.array->operator[](i) == current)
86 for (
const auto& element : *current->m_parent->m_value.object)
88 if (&element.second == current)
90 tokens.emplace_back(element.first.c_str());
115 auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
116 [](
const std::string & a,
const std::string &
b)
118 return concat(a,
'/', detail::escape(b));
120 return concat(
'(', str,
") ");
122 static_cast<void>(leaf_element);
129 std::runtime_error m;
146 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
154 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
155 static parse_error create(
int id_, std::size_t byte_,
const std::string& what_arg, BasicJsonContext context)
160 return {id_, byte_, w.c_str()};
175 parse_error(
int id_, std::size_t byte_,
const char* what_arg)
178 static std::string position_string(
const position_t& pos)
190 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
194 return {id_, w.c_str()};
208 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
212 return {id_, w.c_str()};
225 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
229 return {id_, w.c_str()};
242 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
246 return {id_, w.c_str()};
you may not use this file except in compliance with the License You may obtain a copy of the License at software distributed under the License is distributed on an AS IS WITHOUT WARRANTIES OR CONDITIONS OF ANY either express or implied See the License for the specific language governing permissions and limitations under the License LLVM Exceptions to the Apache License As an exception
Definition: ThirdPartyNotices.txt:289
#define WPI_JSON_NAMESPACE_END
Definition: abi_macros.h:59
#define WPI_JSON_NAMESPACE_BEGIN
Definition: abi_macros.h:53
general exception of the basic_json class
Definition: exceptions.h:37
const int id
the id of the exception
Definition: exceptions.h:46
static std::string diagnostics(std::nullptr_t)
Definition: exceptions.h:57
static std::string name(const std::string &ename, int id_)
Definition: exceptions.h:52
const char * what() const noexcept override
returns the explanatory string
Definition: exceptions.h:40
static std::string diagnostics(const BasicJsonType *leaf_element)
Definition: exceptions.h:63
exception indicating errors with iterators
Definition: exceptions.h:188
static invalid_iterator create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: exceptions.h:191
exception indicating other library errors
Definition: exceptions.h:240
static other_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: exceptions.h:243
exception indicating access out of the defined range
Definition: exceptions.h:223
static out_of_range create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: exceptions.h:226
exception indicating a parse error
Definition: exceptions.h:135
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, BasicJsonContext context)
create a parse error exception
Definition: exceptions.h:147
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, BasicJsonContext context)
Definition: exceptions.h:155
const std::size_t byte
byte index of the parse error
Definition: exceptions.h:172
exception indicating executing a member function with a wrong type
Definition: exceptions.h:206
static type_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: exceptions.h:209
#define JSON_HEDLEY_NON_NULL(...)
Definition: hedley.h:1288
detail namespace with internal helper functions
Definition: xchar.h:20
OutStringType concat(Args &&... args)
Definition: string_concat.h:137
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)
std::string to_string(const T &t)
Definition: base.h:92
struct to capture the start position of the current token
Definition: position_t.h:21
std::size_t chars_read_current_line
the number of characters read in the current line
Definition: position_t.h:25
std::size_t lines_read
the number of lines read
Definition: position_t.h:27
std::size_t chars_read_total
the total number of characters read
Definition: position_t.h:23