|
rapidyaml
0.11.1
parse and emit YAML, and do it fast
|
Utilities to report handle errors, and to build and report error messages. More...
Classes | |
| struct | c4::yml::Location |
| holds a source or yaml file position, for example when an error is detected; See also location_format() and location_format_with_context(). More... | |
| struct | c4::yml::ErrorDataBasic |
| Data for a basic error. More... | |
| struct | c4::yml::ErrorDataParse |
| Data for a parse error. More... | |
| struct | c4::yml::ErrorDataVisit |
| Data for a visit error. More... | |
| struct | c4::yml::ExceptionBasic |
| Exception thrown by the default basic error implementation. More... | |
| struct | c4::yml::ExceptionParse |
| Exception thrown by the default parse error implementation. More... | |
| struct | c4::yml::ExceptionVisit |
| Exception thrown by the default visit error implementation. More... | |
Functions | |
| template<class DumpFn > | |
| size_t | c4::yml::location_format (DumpFn &&dumpfn, Location const &loc) |
| generic formatting of a location More... | |
| template<class DumpFn > | |
| void | c4::yml::location_format_with_context (DumpFn &&dumpfn, Location const &location, csubstr source_buffer, csubstr call="", size_t num_lines_before=3, size_t num_lines_after=0, size_t first_col_highlight=0, size_t last_col_highlight=0, size_t maxlen=80u) |
| Generic formatting of a location, printing the source code buffer region around the location. More... | |
| template<class DumpFn > | |
| void | c4::yml::err_basic_format (DumpFn &&dumpfn, csubstr msg, ErrorDataBasic const &errdata) |
| Given an error message and associated basic error data, format it fully as a basic error message. More... | |
| void | c4::yml::err_basic (Callbacks const &callbacks, ErrorDataBasic const &errdata, const char *msg_) |
| trigger a basic error to its respective handler, with a non-formatted error message. More... | |
| void | c4::yml::err_basic (ErrorDataBasic const &errdata, const char *msg) |
| trigger a basic error to its respective handler, with a non-formatted error message. More... | |
| template<class ... Args> | |
| void | c4::yml::err_basic (Callbacks const &callbacks, ErrorDataBasic const &errdata, const char *fmt, Args const &...args) |
| trigger a basic error to its respective handler, with a formatted error message. More... | |
| template<class ... Args> | |
| void | c4::yml::err_basic (ErrorDataBasic const &errdata, const char *fmt, Args const &...args) |
| trigger a basic error to its respective handler, with a formatted error message. More... | |
| template<class DumpFn > | |
| void | c4::yml::err_parse_format (DumpFn &&dumpfn, csubstr msg, ErrorDataParse const &errdata) |
| Given an error message and associated parse error data, format it fully as a parse error message. More... | |
| void | c4::yml::err_parse (Callbacks const &callbacks, ErrorDataParse const &errdata, const char *msg) |
| trigger a parse error to its respective handler, with a non-formatted error message More... | |
| void | c4::yml::err_parse (ErrorDataParse const &errdata, const char *msg) |
| trigger a parse error to its respective handler, with a non-formatted error message. More... | |
| template<class ... Args> | |
| void | c4::yml::err_parse (Callbacks const &callbacks, ErrorDataParse const &errdata, const char *fmt, Args const &...args) |
| trigger a parse error to its respective handler, with a formatted error message More... | |
| template<class ... Args> | |
| void | c4::yml::err_parse (ErrorDataParse const &errdata, const char *fmt, Args const &...args) |
| trigger a parse error to its respective handler, with a formatted error message. More... | |
| template<class DumpFn > | |
| void | c4::yml::err_visit_format (DumpFn &&dumpfn, csubstr msg, ErrorDataVisit const &errdata) |
| Given an error message and associated visit error data, format it fully as a visit error message. More... | |
| void | c4::yml::err_visit (Callbacks const &callbacks, ErrorDataVisit const &errdata, const char *msg) |
| trigger a visit error to its respective handler, with a non-formatted error message More... | |
| void | c4::yml::err_visit (ErrorDataVisit const &errdata, const char *msg) |
| trigger a visit error to its respective handler, with a non-formatted error message. More... | |
| template<class ... Args> | |
| void | c4::yml::err_visit (Callbacks const &callbacks, ErrorDataVisit const &errdata, const char *fmt, Args const &...args) |
| trigger a visit error to its respective handler, with a formatted error message More... | |
| template<class ... Args> | |
| void | c4::yml::err_visit (ErrorDataVisit const &errdata, const char *fmt, Args const &...args) |
| trigger a visit error to its respective handler, with a formatted error message. More... | |
| template<class CharContainer > | |
| void | c4::yml::format_exc (CharContainer *out, ExceptionBasic const &exc) |
| Format a basic exception to an existing char container. More... | |
| template<class CharContainer > | |
| void | c4::yml::format_exc (CharContainer *out, ExceptionParse const &exc) |
| Format a parse exception to an existing char container. More... | |
| template<class CharContainer > | |
| void | c4::yml::format_exc (CharContainer *out, ExceptionVisit const &exc) |
| Format a visit exception to an existing char container. More... | |
| template<class CharContainer , class ExceptionT > | |
| CharContainer | c4::yml::format_exc (ExceptionT const &exc) |
| Format a parse exception, and return a newly-created char container. More... | |
Utilities to report handle errors, and to build and report error messages.
| size_t c4::yml::location_format | ( | DumpFn && | dumpfn, |
| Location const & | loc | ||
| ) |
generic formatting of a location
| dumpfn | function taking a csubstr and abstracting a string concatenation operation, such as appending to a std::string or printing to terminal. |
| loc | the location to be formatted |
For example:
Definition at line 15 of file error.def.hpp.
References c4::yml::Location::col, c4::yml::Location::line, c4::yml::Location::name, c4::yml::npos, and c4::yml::Location::offset.
| void c4::yml::location_format_with_context | ( | DumpFn && | dumpfn, |
| Location const & | location, | ||
| csubstr | source_buffer, | ||
| csubstr | call = "", |
||
| size_t | num_lines_before = 3, |
||
| size_t | num_lines_after = 0, |
||
| size_t | first_col_highlight = 0, |
||
| size_t | last_col_highlight = 0, |
||
| size_t | maxlen = 80u |
||
| ) |
Generic formatting of a location, printing the source code buffer region around the location.
| dumpfn | function taking a csubstr and abstracting a string concatenation operation, such as appending to a std::string or printing to terminal. |
| location | the location |
| source_buffer | the source buffer |
| call | a string with a call of attention to print in the message (see examples below) |
| num_lines_before | how many source buffer lines to print before the location line |
| num_lines_after | how many source buffer lines to print after the location line |
| first_col_highlight | the first column to highlight around the location line |
| last_col_highlight | the last column to highlight around the location line |
| maxlen | the maximum number of columns to show in the error message; source buffer lines will have at most this number of columns shown; if the line is longer than this, the line will be trimmed as needed at the end and/or beginning, and only the relevant columns around the location are shown |
For example:
will result in this string:
If an empty string is passed for the call of attention,
the returned string becomes:
Definition at line 83 of file error.def.hpp.
References c4::yml::detail::_get_text_region(), c4::yml::Location::col, c4::yml::location_format(), c4::yml::npos, and c4::yml::Location::offset.
| void c4::yml::err_basic_format | ( | DumpFn && | dumpfn, |
| csubstr | msg, | ||
| ErrorDataBasic const & | errdata | ||
| ) |
Given an error message and associated basic error data, format it fully as a basic error message.
| dumpfn | function taking a csubstr and abstracting a string concatenation operation, such as appending to a std::string or printing to terminal. |
| msg | the error message |
| errdata | the error data |
For example:
Definition at line 315 of file error.def.hpp.
References c4::yml::ErrorDataBasic::location, and c4::yml::location_format().
| void c4::yml::err_basic | ( | Callbacks const & | callbacks, |
| ErrorDataBasic const & | errdata, | ||
| const char * | msg_ | ||
| ) |
trigger a basic error to its respective handler, with a non-formatted error message.
Definition at line 201 of file common.cpp.
References c4::yml::Callbacks::m_error_basic, c4::yml::Callbacks::m_user_data, and c4::to_csubstr().
| void c4::yml::err_basic | ( | ErrorDataBasic const & | errdata, |
| const char * | msg | ||
| ) |
trigger a basic error to its respective handler, with a non-formatted error message.
Like (1), but use the current global callbacks.
Definition at line 196 of file common.cpp.
References c4::yml::get_callbacks().
| void c4::yml::err_basic | ( | Callbacks const & | callbacks, |
| ErrorDataBasic const & | errdata, | ||
| const char * | fmt, | ||
| Args const &... | args | ||
| ) |
trigger a basic error to its respective handler, with a formatted error message.
Definition at line 306 of file error.hpp.
References c4::yml::Callbacks::m_error_basic, c4::yml::Callbacks::m_user_data, RYML_ERRMSG_SIZE, and c4::to_csubstr().
| void c4::yml::err_basic | ( | ErrorDataBasic const & | errdata, |
| const char * | fmt, | ||
| Args const &... | args | ||
| ) |
trigger a basic error to its respective handler, with a formatted error message.
Like (1), but use the current global callbacks.
Definition at line 316 of file error.hpp.
References c4::yml::err_basic(), and c4::yml::get_callbacks().
| void c4::yml::err_parse_format | ( | DumpFn && | dumpfn, |
| csubstr | msg, | ||
| ErrorDataParse const & | errdata | ||
| ) |
Given an error message and associated parse error data, format it fully as a parse error message.
| dumpfn | function taking a csubstr and abstracting a string concatenation operation, such as appending to a std::string or printing to terminal. |
| msg | the error message |
| errdata | the error data |
For example:
Definition at line 328 of file error.def.hpp.
References c4::yml::ErrorDataParse::cpploc, c4::yml::location_format(), and c4::yml::ErrorDataParse::ymlloc.
| void c4::yml::err_parse | ( | Callbacks const & | callbacks, |
| ErrorDataParse const & | errdata, | ||
| const char * | msg_ | ||
| ) |
trigger a parse error to its respective handler, with a non-formatted error message
Definition at line 215 of file common.cpp.
References c4::yml::Callbacks::m_error_basic, c4::yml::Callbacks::m_error_parse, c4::yml::Callbacks::m_user_data, c4::to_csubstr(), and c4::yml::ErrorDataParse::ymlloc.
| void c4::yml::err_parse | ( | ErrorDataParse const & | errdata, |
| const char * | msg | ||
| ) |
trigger a parse error to its respective handler, with a non-formatted error message.
Like (1), but use the current global callbacks.
Definition at line 210 of file common.cpp.
References c4::yml::get_callbacks().
| void c4::yml::err_parse | ( | Callbacks const & | callbacks, |
| ErrorDataParse const & | errdata, | ||
| const char * | fmt, | ||
| Args const &... | args | ||
| ) |
trigger a parse error to its respective handler, with a formatted error message
Definition at line 361 of file error.hpp.
References c4::yml::Callbacks::m_error_basic, c4::yml::Callbacks::m_error_parse, c4::yml::Callbacks::m_user_data, RYML_ERRMSG_SIZE, c4::to_csubstr(), and c4::yml::ErrorDataParse::ymlloc.
| void c4::yml::err_parse | ( | ErrorDataParse const & | errdata, |
| const char * | fmt, | ||
| Args const &... | args | ||
| ) |
trigger a parse error to its respective handler, with a formatted error message.
Like (1), but use the current global callbacks.
Definition at line 375 of file error.hpp.
References c4::yml::err_parse(), and c4::yml::get_callbacks().
| void c4::yml::err_visit_format | ( | DumpFn && | dumpfn, |
| csubstr | msg, | ||
| ErrorDataVisit const & | errdata | ||
| ) |
Given an error message and associated visit error data, format it fully as a visit error message.
| dumpfn | function taking a csubstr and abstracting a string concatenation operation, such as appending to a std::string or printing to terminal. |
| msg | the error message |
| errdata | the error data |
For example:
Definition at line 347 of file error.def.hpp.
References c4::yml::ErrorDataVisit::cpploc, c4::yml::location_format(), c4::yml::ErrorDataVisit::node, c4::yml::NONE, and c4::yml::ErrorDataVisit::tree.
| void c4::yml::err_visit | ( | Callbacks const & | callbacks, |
| ErrorDataVisit const & | errdata, | ||
| const char * | msg_ | ||
| ) |
trigger a visit error to its respective handler, with a non-formatted error message
Definition at line 233 of file common.cpp.
References c4::yml::ErrorDataVisit::cpploc, c4::yml::Callbacks::m_error_basic, c4::yml::Callbacks::m_error_visit, c4::yml::Callbacks::m_user_data, and c4::to_csubstr().
| void c4::yml::err_visit | ( | ErrorDataVisit const & | errdata, |
| const char * | msg | ||
| ) |
trigger a visit error to its respective handler, with a non-formatted error message.
Like (1), but uses the current global callbacks.
Definition at line 228 of file common.cpp.
References c4::yml::get_callbacks().
| void c4::yml::err_visit | ( | Callbacks const & | callbacks, |
| ErrorDataVisit const & | errdata, | ||
| const char * | fmt, | ||
| Args const &... | args | ||
| ) |
trigger a visit error to its respective handler, with a formatted error message
Definition at line 423 of file error.hpp.
References c4::yml::ErrorDataVisit::cpploc, c4::yml::Callbacks::m_error_basic, c4::yml::Callbacks::m_error_visit, c4::yml::Callbacks::m_user_data, RYML_ERRMSG_SIZE, and c4::to_csubstr().
| void c4::yml::err_visit | ( | ErrorDataVisit const & | errdata, |
| const char * | fmt, | ||
| Args const &... | args | ||
| ) |
trigger a visit error to its respective handler, with a formatted error message.
Like (1), but use the current global callbacks.
Definition at line 437 of file error.hpp.
References c4::yml::err_visit(), and c4::yml::get_callbacks().
| void c4::yml::format_exc | ( | CharContainer * | out, |
| ExceptionBasic const & | exc | ||
| ) |
Format a basic exception to an existing char container.
Definition at line 504 of file error.hpp.
References c4::yml::err_basic_format(), c4::yml::ExceptionBasic::errdata_basic, and c4::yml::ExceptionBasic::msg.
| void c4::yml::format_exc | ( | CharContainer * | out, |
| ExceptionParse const & | exc | ||
| ) |
Format a parse exception to an existing char container.
Definition at line 517 of file error.hpp.
References c4::yml::err_parse_format(), c4::yml::ExceptionParse::errdata_parse, and c4::yml::ExceptionBasic::msg.
| void c4::yml::format_exc | ( | CharContainer * | out, |
| ExceptionVisit const & | exc | ||
| ) |
Format a visit exception to an existing char container.
Definition at line 530 of file error.hpp.
References c4::yml::err_visit_format(), c4::yml::ExceptionVisit::errdata_visit, and c4::yml::ExceptionBasic::msg.
| CharContainer c4::yml::format_exc | ( | ExceptionT const & | exc | ) |
Format a parse exception, and return a newly-created char container.
Definition at line 544 of file error.hpp.
References c4::yml::format_exc().