Function format

Synopsis

#include <toml/serializer.hpp>

template <typename C, template< typename ... > class M, template< typename ... > class V>
std::string format(const basic_value< C, M, V > &v, std::size_t w=80u, int fprec=std::numeric_limits< toml::floating >::max_digits10, bool no_comment=false, bool force_inline=false)

Description

No description yet.

Mentioned in

Source

Lines 749-772 in toml/serializer.hpp.

template<typename C,
         template<typename ...> class M, template<typename ...> class V>
std::string
format(const basic_value<C, M, V>& v, std::size_t w = 80u,
       int fprec = std::numeric_limits<toml::floating>::max_digits10,
       bool no_comment = false, bool force_inline = false)
{
    using value_type = basic_value<C, M, V>;
    // if value is a table, it is considered to be a root object.
    // the root object can't be an inline table.
    if(v.is_table())
    {
        std::ostringstream oss;
        if(!v.comments().empty())
        {
            oss << v.comments();
            oss << '\n'; // to split the file comment from the first element
        }
        const auto serialized = visit(serializer<value_type>(w, fprec, no_comment, false), v);
        oss << serialized;
        return oss.str();
    }
    return visit(serializer<value_type>(w, fprec, force_inline), v);
}





Add Discussion as Guest

Log in