mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 17:58:09 +08:00
add a function to show a better error message
This commit is contained in:
@@ -15,6 +15,12 @@
|
|||||||
namespace toml
|
namespace toml
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
std::string // forward decl
|
||||||
|
format_error_for_value(const value&, const std::string&, const std::string&);
|
||||||
|
}// detail
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct value_traits
|
struct value_traits
|
||||||
{
|
{
|
||||||
@@ -555,6 +561,9 @@ class value
|
|||||||
return detail::format_underline(msg, *(this->region_info_), com);
|
return detail::format_underline(msg, *(this->region_info_), com);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
friend std::string detail::format_error_for_value(
|
||||||
|
const value&, const std::string&, const std::string&);
|
||||||
|
|
||||||
template<value_t T>
|
template<value_t T>
|
||||||
struct switch_cast;
|
struct switch_cast;
|
||||||
|
|
||||||
@@ -583,6 +592,16 @@ class value
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
inline std::string format_error_for_value(
|
||||||
|
const value& v, const std::string& m, const std::string& c)
|
||||||
|
{
|
||||||
|
return v.format_error(m, c);
|
||||||
|
}
|
||||||
|
}// detail
|
||||||
|
|
||||||
|
|
||||||
template<> struct value::switch_cast<value_t::Boolean>
|
template<> struct value::switch_cast<value_t::Boolean>
|
||||||
{
|
{
|
||||||
static Boolean& invoke(value& v) {return v.boolean_;}
|
static Boolean& invoke(value& v) {return v.boolean_;}
|
||||||
|
Reference in New Issue
Block a user