mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-19 03:18:09 +08:00
Merge pull request #47 from ToruNiina/format-table
`toml::format` and top-level table
This commit is contained in:
@@ -483,15 +483,19 @@ struct serializer
|
|||||||
|
|
||||||
inline std::string
|
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,
|
||||||
|
bool force_inline = false)
|
||||||
{
|
{
|
||||||
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()) || force_inline), 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,
|
||||||
|
bool force_inline = false)
|
||||||
{
|
{
|
||||||
return serializer(w, fprec, true)(t);
|
return serializer(w, fprec, force_inline)(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename charT, typename traits>
|
template<typename charT, typename traits>
|
||||||
|
Reference in New Issue
Block a user