mirror of
https://github.com/ToruNiina/toml11.git
synced 2024-11-26 06:10:06 +00:00
feat: detect value type and format as a file
in toml::format
This commit is contained in:
parent
773c3816be
commit
d6714ec450
@ -485,13 +485,15 @@ inline std::string
|
|||||||
format(const value& v, std::size_t w = 80,
|
format(const value& v, std::size_t w = 80,
|
||||||
int fprec = std::numeric_limits<toml::floating>::max_digits10)
|
int fprec = std::numeric_limits<toml::floating>::max_digits10)
|
||||||
{
|
{
|
||||||
return visit(serializer(w, fprec, true), v);
|
// if value is a table, it is considered to be a root object.
|
||||||
|
// the root object can't be an inline table. so pass false. otherwise, true.
|
||||||
|
return visit(serializer(w, fprec, !v.is_table()), v);
|
||||||
}
|
}
|
||||||
inline std::string
|
inline std::string
|
||||||
format(const table& t, std::size_t w = 80,
|
format(const table& t, std::size_t w = 80,
|
||||||
int fprec = std::numeric_limits<toml::floating>::max_digits10)
|
int fprec = std::numeric_limits<toml::floating>::max_digits10)
|
||||||
{
|
{
|
||||||
return serializer(w, fprec, true)(t);
|
return serializer(w, fprec, false)(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename charT, typename traits>
|
template<typename charT, typename traits>
|
||||||
|
Loading…
Reference in New Issue
Block a user