mirror of
https://github.com/ToruNiina/toml11.git
synced 2024-11-09 22:30:07 +00:00
feat: add argument to control top-level inlinization
This commit is contained in:
parent
d6714ec450
commit
40ccf1d912
@ -483,17 +483,19 @@ struct serializer
|
||||
|
||||
inline std::string
|
||||
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)
|
||||
{
|
||||
// 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);
|
||||
return visit(serializer(w, fprec, (!v.is_table()) || force_inline), v);
|
||||
}
|
||||
inline std::string
|
||||
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, false)(t);
|
||||
return serializer(w, fprec, force_inline)(t);
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
|
Loading…
Reference in New Issue
Block a user