From 40ccf1d9120fa2acb6878aaf07de38343eec0547 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Tue, 19 Mar 2019 23:25:26 +0900 Subject: [PATCH] feat: add argument to control top-level inlinization --- toml/serializer.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/toml/serializer.hpp b/toml/serializer.hpp index d3cbc48..248018b 100644 --- a/toml/serializer.hpp +++ b/toml/serializer.hpp @@ -483,17 +483,19 @@ struct serializer inline std::string format(const value& v, std::size_t w = 80, - int fprec = std::numeric_limits::max_digits10) + int fprec = std::numeric_limits::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::max_digits10) + int fprec = std::numeric_limits::max_digits10, + bool force_inline = false) { - return serializer(w, fprec, false)(t); + return serializer(w, fprec, force_inline)(t); } template