2020-03-12 15:23:25 +00:00
|
|
|
//# This file is a part of toml++ and is subject to the the terms of the MIT license.
|
|
|
|
//# Copyright (c) 2019-2020 Mark Gillard <mark.gillard@outlook.com.au>
|
|
|
|
//# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
|
|
|
|
|
2020-01-06 18:21:16 +00:00
|
|
|
#pragma once
|
|
|
|
#include "toml_formatter.h"
|
|
|
|
#include "toml_table.h"
|
|
|
|
#include "toml_array.h"
|
|
|
|
#include "toml_utf8.h"
|
|
|
|
|
2020-03-28 16:56:59 +00:00
|
|
|
namespace toml::impl
|
2020-01-06 18:21:16 +00:00
|
|
|
{
|
2020-04-02 21:39:21 +00:00
|
|
|
[[nodiscard]] TOML_API
|
|
|
|
toml::string default_formatter_make_key_segment(const toml::string& str) noexcept;
|
2020-01-12 15:37:02 +00:00
|
|
|
|
2020-04-02 21:39:21 +00:00
|
|
|
[[nodiscard]] TOML_API
|
|
|
|
size_t default_formatter_inline_columns(const node& node) noexcept;
|
2020-02-29 20:34:08 +00:00
|
|
|
|
2020-04-02 21:39:21 +00:00
|
|
|
[[nodiscard]] TOML_API
|
|
|
|
bool default_formatter_forces_multiline(const node& node, size_t starting_column_bias = 0) noexcept;
|
2020-01-07 15:52:50 +00:00
|
|
|
}
|
|
|
|
|
2020-03-28 16:56:59 +00:00
|
|
|
|
|
|
|
namespace toml
|
2020-01-07 15:52:50 +00:00
|
|
|
{
|
2020-03-03 08:10:07 +00:00
|
|
|
template <typename T, typename U>
|
2020-03-28 16:56:59 +00:00
|
|
|
std::basic_ostream<T>& operator << (std::basic_ostream<T>&, default_formatter<U>&);
|
2020-03-03 08:10:07 +00:00
|
|
|
template <typename T, typename U>
|
2020-03-28 16:56:59 +00:00
|
|
|
std::basic_ostream<T>& operator << (std::basic_ostream<T>&, default_formatter<U>&&);
|
2020-03-03 08:10:07 +00:00
|
|
|
|
2020-02-03 09:12:43 +00:00
|
|
|
/// \brief A wrapper for printing TOML objects out to a stream as formatted TOML.
|
|
|
|
///
|
|
|
|
/// \remarks You generally don't need to create an instance of this class explicitly; the stream
|
|
|
|
/// operators of the TOML node types already print themselves out using this formatter.
|
|
|
|
///
|
|
|
|
/// \detail \cpp
|
|
|
|
/// auto tbl = toml::table{{
|
|
|
|
/// { "description", "This is some TOML, yo." },
|
|
|
|
/// { "fruit", toml::array{ "apple", "orange", "pear" } },
|
|
|
|
/// { "numbers", toml::array{ 1, 2, 3, 4, 5 } },
|
|
|
|
/// { "table", toml::table{{ { "foo", "bar" } }} }
|
|
|
|
/// }};
|
|
|
|
///
|
|
|
|
/// // these two lines are equivalent:
|
|
|
|
/// std::cout << toml::default_formatter{ tbl } << std::endl;
|
|
|
|
/// std::cout << tbl << std::endl;
|
|
|
|
///
|
|
|
|
/// \ecpp
|
|
|
|
///
|
2020-02-18 21:29:59 +00:00
|
|
|
/// \out
|
|
|
|
/// description = "This is some TOML, yo."
|
|
|
|
/// fruit = ["apple", "orange", "pear"]
|
|
|
|
/// numbers = [1, 2, 3, 4, 5]
|
|
|
|
///
|
|
|
|
/// [table]
|
|
|
|
/// foo = "bar"
|
|
|
|
/// \eout
|
|
|
|
///
|
2020-04-02 21:39:21 +00:00
|
|
|
/// \tparam Char The underlying character type of the output stream. Must be 1 byte in size.
|
|
|
|
template <typename Char = char>
|
|
|
|
class TOML_API default_formatter final : impl::formatter<Char>
|
2020-01-07 15:52:50 +00:00
|
|
|
{
|
|
|
|
private:
|
2020-04-02 21:39:21 +00:00
|
|
|
using base = impl::formatter<Char>;
|
2020-01-07 15:52:50 +00:00
|
|
|
std::vector<toml::string> key_path;
|
2020-01-06 18:21:16 +00:00
|
|
|
|
2020-03-28 16:56:59 +00:00
|
|
|
void print_key_segment(const toml::string& str)
|
2020-01-06 18:21:16 +00:00
|
|
|
{
|
|
|
|
if (str.empty())
|
2020-01-07 15:52:50 +00:00
|
|
|
impl::print_to_stream("''"sv, base::stream());
|
2020-01-06 18:21:16 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
bool requiresQuotes = false;
|
|
|
|
{
|
|
|
|
impl::utf8_decoder decoder;
|
|
|
|
for (size_t i = 0; i < str.length() && !requiresQuotes; i++)
|
|
|
|
{
|
|
|
|
decoder(static_cast<uint8_t>(str[i]));
|
|
|
|
if (decoder.error())
|
|
|
|
requiresQuotes = true;
|
|
|
|
else if (decoder.has_code_point())
|
|
|
|
requiresQuotes = !impl::is_bare_key_character(decoder.codepoint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (requiresQuotes)
|
2020-01-07 15:52:50 +00:00
|
|
|
base::print_quoted_string(str);
|
2020-01-06 18:21:16 +00:00
|
|
|
else
|
2020-01-07 15:52:50 +00:00
|
|
|
impl::print_to_stream(str, base::stream());
|
2020-01-06 18:21:16 +00:00
|
|
|
}
|
2020-01-07 15:52:50 +00:00
|
|
|
base::clear_naked_newline();
|
2020-01-06 18:21:16 +00:00
|
|
|
}
|
|
|
|
|
2020-03-28 16:56:59 +00:00
|
|
|
void print_key_path()
|
2020-01-06 18:21:16 +00:00
|
|
|
{
|
|
|
|
for (const auto& segment : key_path)
|
|
|
|
{
|
|
|
|
if (std::addressof(segment) > key_path.data())
|
2020-01-07 15:52:50 +00:00
|
|
|
impl::print_to_stream('.', base::stream());
|
|
|
|
impl::print_to_stream(segment, base::stream());
|
2020-01-06 18:21:16 +00:00
|
|
|
}
|
2020-01-07 15:52:50 +00:00
|
|
|
base::clear_naked_newline();
|
2020-01-06 18:21:16 +00:00
|
|
|
}
|
|
|
|
|
2020-03-28 16:56:59 +00:00
|
|
|
inline void print_inline(const table& /*tbl*/);
|
2020-01-06 18:21:16 +00:00
|
|
|
|
2020-03-28 16:56:59 +00:00
|
|
|
void print(const array& arr)
|
2020-01-06 18:21:16 +00:00
|
|
|
{
|
|
|
|
if (arr.empty())
|
2020-01-07 15:52:50 +00:00
|
|
|
impl::print_to_stream("[]"sv, base::stream());
|
2020-01-06 18:21:16 +00:00
|
|
|
else
|
|
|
|
{
|
2020-01-07 15:52:50 +00:00
|
|
|
const auto original_indent = base::indent();
|
|
|
|
const auto multiline = impl::default_formatter_forces_multiline(
|
2020-01-06 18:21:16 +00:00
|
|
|
arr,
|
2020-01-12 15:37:02 +00:00
|
|
|
base::indent_columns * static_cast<size_t>(original_indent < 0 ? 0 : original_indent)
|
2020-01-06 18:21:16 +00:00
|
|
|
);
|
2020-01-07 15:52:50 +00:00
|
|
|
impl::print_to_stream("["sv, base::stream());
|
2020-01-06 18:21:16 +00:00
|
|
|
if (multiline)
|
|
|
|
{
|
2020-01-07 15:52:50 +00:00
|
|
|
if (original_indent < 0)
|
|
|
|
base::indent(0);
|
|
|
|
base::increase_indent();
|
2020-01-06 18:21:16 +00:00
|
|
|
}
|
|
|
|
else
|
2020-01-07 15:52:50 +00:00
|
|
|
impl::print_to_stream(' ', base::stream());
|
2020-01-06 18:21:16 +00:00
|
|
|
|
|
|
|
for (size_t i = 0; i < arr.size(); i++)
|
|
|
|
{
|
|
|
|
if (i > 0_sz)
|
|
|
|
{
|
2020-01-07 15:52:50 +00:00
|
|
|
impl::print_to_stream(',', base::stream());
|
2020-01-06 18:21:16 +00:00
|
|
|
if (!multiline)
|
2020-01-07 15:52:50 +00:00
|
|
|
impl::print_to_stream(' ', base::stream());
|
2020-01-06 18:21:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (multiline)
|
|
|
|
{
|
2020-01-07 15:52:50 +00:00
|
|
|
base::print_newline(true);
|
|
|
|
base::print_indent();
|
2020-01-06 18:21:16 +00:00
|
|
|
}
|
|
|
|
|
2020-01-07 15:52:50 +00:00
|
|
|
auto& v = arr[i];
|
|
|
|
const auto type = v.type();
|
2020-01-06 18:21:16 +00:00
|
|
|
switch (type)
|
|
|
|
{
|
2020-01-07 15:52:50 +00:00
|
|
|
case node_type::table: print_inline(*reinterpret_cast<const table*>(&v)); break;
|
|
|
|
case node_type::array: print(*reinterpret_cast<const array*>(&v)); break;
|
2020-01-06 18:21:16 +00:00
|
|
|
default:
|
2020-01-07 15:52:50 +00:00
|
|
|
base::print(v, type);
|
2020-01-06 18:21:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if (multiline)
|
|
|
|
{
|
2020-01-07 15:52:50 +00:00
|
|
|
base::indent(original_indent);
|
|
|
|
base::print_newline(true);
|
|
|
|
base::print_indent();
|
2020-01-06 18:21:16 +00:00
|
|
|
}
|
|
|
|
else
|
2020-01-07 15:52:50 +00:00
|
|
|
impl::print_to_stream(' ', base::stream());
|
|
|
|
impl::print_to_stream("]"sv, base::stream());
|
2020-01-06 18:21:16 +00:00
|
|
|
}
|
2020-01-07 15:52:50 +00:00
|
|
|
base::clear_naked_newline();
|
2020-01-06 18:21:16 +00:00
|
|
|
}
|
|
|
|
|
2020-03-28 16:56:59 +00:00
|
|
|
void print(const table& tbl)
|
2020-01-06 18:21:16 +00:00
|
|
|
{
|
2020-02-03 09:12:43 +00:00
|
|
|
static constexpr auto is_non_inline_array_of_tables = [](auto&& nde) noexcept
|
|
|
|
{
|
|
|
|
auto arr = nde.as_array();
|
|
|
|
return arr
|
|
|
|
&& arr->is_array_of_tables()
|
|
|
|
&& !arr->template get_as<table>(0_sz)->is_inline();
|
|
|
|
};
|
|
|
|
|
|
|
|
//values, arrays, and inline tables/table arrays
|
2020-04-03 13:33:02 +00:00
|
|
|
for (auto&& [k, v] : tbl)
|
2020-01-06 18:21:16 +00:00
|
|
|
{
|
2020-01-07 15:52:50 +00:00
|
|
|
const auto type = v.type();
|
|
|
|
if ((type == node_type::table && !reinterpret_cast<const table*>(&v)->is_inline())
|
2020-02-03 09:12:43 +00:00
|
|
|
|| (type == node_type::array && is_non_inline_array_of_tables(v)))
|
2020-01-06 18:21:16 +00:00
|
|
|
continue;
|
|
|
|
|
2020-01-07 15:52:50 +00:00
|
|
|
base::print_newline();
|
|
|
|
base::print_indent();
|
|
|
|
print_key_segment(k);
|
|
|
|
impl::print_to_stream(" = "sv, base::stream());
|
2020-01-06 18:21:16 +00:00
|
|
|
switch (type)
|
|
|
|
{
|
2020-01-07 15:52:50 +00:00
|
|
|
case node_type::table: print_inline(*reinterpret_cast<const table*>(&v)); break;
|
|
|
|
case node_type::array: print(*reinterpret_cast<const array*>(&v)); break;
|
2020-01-06 18:21:16 +00:00
|
|
|
default:
|
2020-01-07 15:52:50 +00:00
|
|
|
base::print(v, type);
|
2020-01-06 18:21:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//non-inline tables
|
2020-04-03 13:33:02 +00:00
|
|
|
for (auto&& [k, v] : tbl)
|
2020-01-06 18:21:16 +00:00
|
|
|
{
|
2020-01-07 15:52:50 +00:00
|
|
|
const auto type = v.type();
|
|
|
|
if (type != node_type::table || reinterpret_cast<const table*>(&v)->is_inline())
|
2020-01-06 18:21:16 +00:00
|
|
|
continue;
|
2020-01-07 15:52:50 +00:00
|
|
|
auto& child_tbl = *reinterpret_cast<const table*>(&v);
|
2020-01-06 18:21:16 +00:00
|
|
|
|
|
|
|
//we can skip indenting and emitting the headers for tables that only contain other tables
|
|
|
|
//(so we don't over-nest)
|
|
|
|
size_t child_value_count{}; //includes inline tables and non-table arrays
|
|
|
|
size_t child_table_count{};
|
|
|
|
size_t child_table_array_count{};
|
2020-04-03 13:33:02 +00:00
|
|
|
for (auto&& [child_k, child_v] : child_tbl)
|
2020-01-06 18:21:16 +00:00
|
|
|
{
|
2020-04-06 12:57:49 +00:00
|
|
|
(void)child_k;
|
2020-01-07 15:52:50 +00:00
|
|
|
const auto child_type = child_v.type();
|
2020-01-06 18:21:16 +00:00
|
|
|
switch (child_type)
|
|
|
|
{
|
|
|
|
case node_type::table:
|
2020-01-07 15:52:50 +00:00
|
|
|
if (reinterpret_cast<const table*>(&child_v)->is_inline())
|
2020-01-06 18:21:16 +00:00
|
|
|
child_value_count++;
|
|
|
|
else
|
|
|
|
child_table_count++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case node_type::array:
|
2020-02-03 09:12:43 +00:00
|
|
|
if (is_non_inline_array_of_tables(child_v))
|
2020-01-06 18:21:16 +00:00
|
|
|
child_table_array_count++;
|
|
|
|
else
|
|
|
|
child_value_count++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
child_value_count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool skip_self = false;
|
|
|
|
if (child_value_count == 0_sz && (child_table_count > 0_sz || child_table_array_count > 0_sz))
|
|
|
|
skip_self = true;
|
|
|
|
|
|
|
|
if (!skip_self)
|
2020-01-07 15:52:50 +00:00
|
|
|
base::increase_indent();
|
|
|
|
key_path.push_back(impl::default_formatter_make_key_segment(k));
|
2020-01-06 18:21:16 +00:00
|
|
|
|
|
|
|
if (!skip_self)
|
|
|
|
{
|
2020-01-07 15:52:50 +00:00
|
|
|
base::print_newline();
|
|
|
|
base::print_newline(true);
|
|
|
|
base::print_indent();
|
|
|
|
impl::print_to_stream("["sv, base::stream());
|
|
|
|
print_key_path();
|
|
|
|
impl::print_to_stream("]"sv, base::stream());
|
|
|
|
base::print_newline(true);
|
2020-01-06 18:21:16 +00:00
|
|
|
}
|
|
|
|
|
2020-01-07 15:52:50 +00:00
|
|
|
print(child_tbl);
|
2020-01-06 18:21:16 +00:00
|
|
|
|
|
|
|
key_path.pop_back();
|
|
|
|
if (!skip_self)
|
2020-01-07 15:52:50 +00:00
|
|
|
base::decrease_indent();
|
2020-01-06 18:21:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//table arrays
|
2020-04-03 13:33:02 +00:00
|
|
|
for (auto&& [k, v] : tbl)
|
2020-01-06 18:21:16 +00:00
|
|
|
{
|
2020-02-03 09:12:43 +00:00
|
|
|
if (!is_non_inline_array_of_tables(v))
|
2020-01-06 18:21:16 +00:00
|
|
|
continue;
|
2020-01-07 15:52:50 +00:00
|
|
|
auto& arr = *reinterpret_cast<const array*>(&v);
|
2020-01-06 18:21:16 +00:00
|
|
|
|
2020-01-07 15:52:50 +00:00
|
|
|
base::increase_indent();
|
|
|
|
key_path.push_back(impl::default_formatter_make_key_segment(k));
|
2020-01-06 18:21:16 +00:00
|
|
|
|
|
|
|
for (size_t i = 0; i < arr.size(); i++)
|
|
|
|
{
|
2020-01-07 15:52:50 +00:00
|
|
|
base::print_newline();
|
|
|
|
base::print_newline(true);
|
|
|
|
base::print_indent();
|
|
|
|
impl::print_to_stream("[["sv, base::stream());
|
|
|
|
print_key_path();
|
|
|
|
impl::print_to_stream("]]"sv, base::stream());
|
|
|
|
base::print_newline(true);
|
|
|
|
print(*reinterpret_cast<const table*>(&arr[i]));
|
2020-01-06 18:21:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
key_path.pop_back();
|
2020-01-07 15:52:50 +00:00
|
|
|
base::decrease_indent();
|
2020-01-06 18:21:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-28 16:56:59 +00:00
|
|
|
void print()
|
2020-01-12 15:37:02 +00:00
|
|
|
{
|
|
|
|
switch (auto source_type = base::source().type())
|
|
|
|
{
|
|
|
|
case node_type::table:
|
|
|
|
{
|
|
|
|
auto& tbl = *reinterpret_cast<const table*>(&base::source());
|
2020-02-18 21:29:59 +00:00
|
|
|
if (tbl.is_inline())
|
2020-01-12 15:37:02 +00:00
|
|
|
print_inline(tbl);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
base::decrease_indent(); // so root kvps and tables have the same indent
|
|
|
|
print(tbl);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case node_type::array:
|
|
|
|
print(*reinterpret_cast<const array*>(&base::source()));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
base::print(base::source(), source_type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-06 18:21:16 +00:00
|
|
|
public:
|
|
|
|
|
2020-02-03 09:12:43 +00:00
|
|
|
/// \brief Constructs a default formatter and binds it to a TOML object.
|
|
|
|
///
|
|
|
|
/// \param source The source TOML object.
|
|
|
|
/// \param flags Format option flags.
|
2020-01-06 18:21:16 +00:00
|
|
|
TOML_NODISCARD_CTOR
|
2020-01-12 15:37:02 +00:00
|
|
|
explicit default_formatter(const toml::node& source, format_flags flags = {}) noexcept
|
|
|
|
: base{ source, flags }
|
2020-01-06 18:21:16 +00:00
|
|
|
{}
|
|
|
|
|
2020-03-03 08:10:07 +00:00
|
|
|
template <typename T, typename U>
|
2020-03-28 16:56:59 +00:00
|
|
|
friend std::basic_ostream<T>& operator << (std::basic_ostream<T>&, default_formatter<U>&);
|
2020-03-03 08:10:07 +00:00
|
|
|
template <typename T, typename U>
|
2020-03-28 16:56:59 +00:00
|
|
|
friend std::basic_ostream<T>& operator << (std::basic_ostream<T>&, default_formatter<U>&&);
|
2020-01-06 18:21:16 +00:00
|
|
|
};
|
|
|
|
|
2020-04-02 21:39:21 +00:00
|
|
|
#if !TOML_ALL_INLINE
|
|
|
|
extern template class TOML_API default_formatter<char>;
|
|
|
|
#endif
|
|
|
|
|
2020-03-18 13:28:00 +00:00
|
|
|
default_formatter(const table&) -> default_formatter<char>;
|
|
|
|
default_formatter(const array&) -> default_formatter<char>;
|
|
|
|
template <typename T> default_formatter(const value<T>&) -> default_formatter<char>;
|
|
|
|
|
2020-04-02 21:39:21 +00:00
|
|
|
template <typename Char>
|
|
|
|
inline void default_formatter<Char>::print_inline(const toml::table& tbl)
|
2020-01-06 18:21:16 +00:00
|
|
|
{
|
2020-01-07 15:52:50 +00:00
|
|
|
if (tbl.empty())
|
|
|
|
impl::print_to_stream("{}"sv, base::stream());
|
2020-01-06 18:21:16 +00:00
|
|
|
else
|
|
|
|
{
|
2020-01-07 15:52:50 +00:00
|
|
|
impl::print_to_stream("{ "sv, base::stream());
|
2020-01-06 18:21:16 +00:00
|
|
|
|
|
|
|
bool first = false;
|
2020-04-03 13:33:02 +00:00
|
|
|
for (auto&& [k, v] : tbl)
|
2020-01-06 18:21:16 +00:00
|
|
|
{
|
|
|
|
if (first)
|
2020-01-07 15:52:50 +00:00
|
|
|
impl::print_to_stream(", "sv, base::stream());
|
2020-01-06 18:21:16 +00:00
|
|
|
first = true;
|
|
|
|
|
2020-01-07 15:52:50 +00:00
|
|
|
print_key_segment(k);
|
|
|
|
impl::print_to_stream(" = "sv, base::stream());
|
2020-01-06 18:21:16 +00:00
|
|
|
|
2020-01-07 15:52:50 +00:00
|
|
|
const auto type = v.type();
|
2020-01-06 18:21:16 +00:00
|
|
|
switch (type)
|
|
|
|
{
|
2020-01-07 15:52:50 +00:00
|
|
|
case node_type::table: print_inline(*reinterpret_cast<const table*>(&v)); break;
|
|
|
|
case node_type::array: print(*reinterpret_cast<const array*>(&v)); break;
|
2020-01-06 18:21:16 +00:00
|
|
|
default:
|
2020-01-07 15:52:50 +00:00
|
|
|
base::print(v, type);
|
2020-01-06 18:21:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-07 15:52:50 +00:00
|
|
|
impl::print_to_stream(" }"sv, base::stream());
|
2020-01-06 18:21:16 +00:00
|
|
|
}
|
2020-01-07 15:52:50 +00:00
|
|
|
base::clear_naked_newline();
|
2020-01-06 18:21:16 +00:00
|
|
|
}
|
|
|
|
|
2020-03-03 08:10:07 +00:00
|
|
|
/// \brief Prints the bound TOML object out to the stream as formatted TOML.
|
|
|
|
template <typename T, typename U>
|
2020-04-02 21:39:21 +00:00
|
|
|
TOML_FUNC_EXTERNAL_LINKAGE
|
|
|
|
std::basic_ostream<T>& operator << (std::basic_ostream<T>& lhs, default_formatter<U>& rhs)
|
2020-03-03 08:10:07 +00:00
|
|
|
{
|
|
|
|
rhs.attach(lhs);
|
|
|
|
rhs.key_path.clear();
|
|
|
|
rhs.print();
|
|
|
|
rhs.detach();
|
|
|
|
return lhs;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Prints the bound TOML object out to the stream as formatted TOML (rvalue overload).
|
|
|
|
template <typename T, typename U>
|
2020-04-02 21:39:21 +00:00
|
|
|
TOML_FUNC_EXTERNAL_LINKAGE
|
|
|
|
std::basic_ostream<T>& operator << (std::basic_ostream<T>& lhs, default_formatter<U>&& rhs)
|
2020-03-03 08:10:07 +00:00
|
|
|
{
|
|
|
|
return lhs << rhs; //as lvalue
|
|
|
|
}
|
|
|
|
|
2020-04-02 21:39:21 +00:00
|
|
|
template <typename Char>
|
|
|
|
TOML_FUNC_EXTERNAL_LINKAGE
|
|
|
|
std::basic_ostream<Char>& operator << (std::basic_ostream<Char>& lhs, const table& rhs)
|
2020-01-06 18:21:16 +00:00
|
|
|
{
|
2020-04-02 21:39:21 +00:00
|
|
|
return lhs << default_formatter<Char>{ rhs };
|
2020-01-06 18:21:16 +00:00
|
|
|
}
|
2020-01-12 15:37:02 +00:00
|
|
|
|
2020-04-02 21:39:21 +00:00
|
|
|
template <typename Char>
|
|
|
|
TOML_FUNC_EXTERNAL_LINKAGE
|
|
|
|
std::basic_ostream<Char>& operator << (std::basic_ostream<Char>& lhs, const array& rhs)
|
2020-01-12 15:37:02 +00:00
|
|
|
{
|
2020-04-02 21:39:21 +00:00
|
|
|
return lhs << default_formatter<Char>{ rhs };
|
2020-01-12 15:37:02 +00:00
|
|
|
}
|
2020-04-02 21:39:21 +00:00
|
|
|
|
|
|
|
#if !TOML_ALL_INLINE
|
|
|
|
extern template TOML_API std::ostream& operator << (std::ostream&, default_formatter<char>&);
|
|
|
|
extern template TOML_API std::ostream& operator << (std::ostream&, default_formatter<char>&&);
|
|
|
|
extern template TOML_API std::ostream& operator << (std::ostream&, const table&);
|
|
|
|
extern template TOML_API std::ostream& operator << (std::ostream&, const array&);
|
|
|
|
#endif
|
2020-01-06 18:21:16 +00:00
|
|
|
}
|
2020-03-28 16:56:59 +00:00
|
|
|
|