mirror of
https://github.com/marzer/tomlplusplus.git
synced 2025-02-22 15:40:00 +00:00
fixed formatter::print_inline causing compilation failures in windows DLL builds
This commit is contained in:
parent
9083b58fd5
commit
983e22978e
@ -38,6 +38,7 @@
|
||||
#include "toml_array.hpp"
|
||||
#include "toml_table.hpp"
|
||||
#include "toml_default_formatter.hpp"
|
||||
#include "toml_json_formatter.hpp"
|
||||
|
||||
#if TOML_PARSER
|
||||
#include "toml_parser.hpp"
|
||||
|
@ -343,41 +343,6 @@ namespace toml
|
||||
default_formatter(const array&) -> default_formatter<char>;
|
||||
template <typename T> default_formatter(const value<T>&) -> default_formatter<char>;
|
||||
|
||||
template <typename Char>
|
||||
inline void default_formatter<Char>::print_inline(const toml::table& tbl)
|
||||
{
|
||||
if (tbl.empty())
|
||||
impl::print_to_stream("{}"sv, base::stream());
|
||||
else
|
||||
{
|
||||
impl::print_to_stream("{ "sv, base::stream());
|
||||
|
||||
bool first = false;
|
||||
for (auto [k, v] : tbl)
|
||||
{
|
||||
if (first)
|
||||
impl::print_to_stream(", "sv, base::stream());
|
||||
first = true;
|
||||
|
||||
print_key_segment(k);
|
||||
impl::print_to_stream(" = "sv, base::stream());
|
||||
|
||||
const auto type = v.type();
|
||||
TOML_ASSUME(type != node_type::none);
|
||||
switch (type)
|
||||
{
|
||||
case node_type::table: print_inline(*reinterpret_cast<const table*>(&v)); break;
|
||||
case node_type::array: print(*reinterpret_cast<const array*>(&v)); break;
|
||||
default:
|
||||
base::print_value(v, type);
|
||||
}
|
||||
}
|
||||
|
||||
impl::print_to_stream(" }"sv, base::stream());
|
||||
}
|
||||
base::clear_naked_newline();
|
||||
}
|
||||
|
||||
/// \brief Prints the bound TOML object out to the stream as formatted TOML.
|
||||
template <typename T, typename U>
|
||||
TOML_EXTERNAL_LINKAGE
|
||||
|
@ -152,6 +152,45 @@ namespace toml::impl
|
||||
}
|
||||
}
|
||||
|
||||
namespace toml
|
||||
{
|
||||
template <typename Char>
|
||||
TOML_EXTERNAL_LINKAGE
|
||||
void default_formatter<Char>::print_inline(const toml::table& tbl)
|
||||
{
|
||||
if (tbl.empty())
|
||||
impl::print_to_stream("{}"sv, base::stream());
|
||||
else
|
||||
{
|
||||
impl::print_to_stream("{ "sv, base::stream());
|
||||
|
||||
bool first = false;
|
||||
for (auto [k, v] : tbl)
|
||||
{
|
||||
if (first)
|
||||
impl::print_to_stream(", "sv, base::stream());
|
||||
first = true;
|
||||
|
||||
print_key_segment(k);
|
||||
impl::print_to_stream(" = "sv, base::stream());
|
||||
|
||||
const auto type = v.type();
|
||||
TOML_ASSUME(type != node_type::none);
|
||||
switch (type)
|
||||
{
|
||||
case node_type::table: print_inline(*reinterpret_cast<const table*>(&v)); break;
|
||||
case node_type::array: print(*reinterpret_cast<const array*>(&v)); break;
|
||||
default:
|
||||
base::print_value(v, type);
|
||||
}
|
||||
}
|
||||
|
||||
impl::print_to_stream(" }"sv, base::stream());
|
||||
}
|
||||
base::clear_naked_newline();
|
||||
}
|
||||
}
|
||||
|
||||
TOML_POP_WARNINGS // TOML_DISABLE_SWITCH_WARNINGS, TOML_DISABLE_FLOAT_WARNINGS
|
||||
|
||||
//# {{
|
||||
|
@ -127,46 +127,6 @@ namespace toml
|
||||
json_formatter(const array&) -> json_formatter<char>;
|
||||
template <typename T> json_formatter(const value<T>&) -> json_formatter<char>;
|
||||
|
||||
template <typename Char>
|
||||
inline void json_formatter<Char>::print(const toml::table& tbl)
|
||||
{
|
||||
if (tbl.empty())
|
||||
impl::print_to_stream("{}"sv, base::stream());
|
||||
else
|
||||
{
|
||||
impl::print_to_stream('{', base::stream());
|
||||
base::increase_indent();
|
||||
bool first = false;
|
||||
for (auto [k, v] : tbl)
|
||||
{
|
||||
if (first)
|
||||
impl::print_to_stream(", "sv, base::stream());
|
||||
first = true;
|
||||
base::print_newline(true);
|
||||
base::print_indent();
|
||||
|
||||
base::print_quoted_string(k);
|
||||
impl::print_to_stream(" : "sv, base::stream());
|
||||
|
||||
const auto type = v.type();
|
||||
TOML_ASSUME(type != node_type::none);
|
||||
switch (type)
|
||||
{
|
||||
case node_type::table: print(*reinterpret_cast<const table*>(&v)); break;
|
||||
case node_type::array: print(*reinterpret_cast<const array*>(&v)); break;
|
||||
default:
|
||||
base::print_value(v, type);
|
||||
}
|
||||
|
||||
}
|
||||
base::decrease_indent();
|
||||
base::print_newline(true);
|
||||
base::print_indent();
|
||||
impl::print_to_stream('}', base::stream());
|
||||
}
|
||||
base::clear_naked_newline();
|
||||
}
|
||||
|
||||
/// \brief Prints the bound TOML object out to the stream as JSON.
|
||||
template <typename T, typename U>
|
||||
TOML_EXTERNAL_LINKAGE
|
||||
|
66
include/toml++/toml_json_formatter.hpp
Normal file
66
include/toml++/toml_json_formatter.hpp
Normal file
@ -0,0 +1,66 @@
|
||||
//# 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.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
#include "toml_json_formatter.h"
|
||||
//# {{
|
||||
#if !TOML_DOXYGEN
|
||||
#if !defined(TOML_IMPLEMENTATION) || !TOML_IMPLEMENTATION
|
||||
#error This is an implementation-only header.
|
||||
#endif
|
||||
//# }}
|
||||
|
||||
TOML_PUSH_WARNINGS
|
||||
TOML_DISABLE_SWITCH_WARNINGS
|
||||
|
||||
namespace toml
|
||||
{
|
||||
template <typename Char>
|
||||
TOML_EXTERNAL_LINKAGE
|
||||
void json_formatter<Char>::print(const toml::table& tbl)
|
||||
{
|
||||
if (tbl.empty())
|
||||
impl::print_to_stream("{}"sv, base::stream());
|
||||
else
|
||||
{
|
||||
impl::print_to_stream('{', base::stream());
|
||||
base::increase_indent();
|
||||
bool first = false;
|
||||
for (auto [k, v] : tbl)
|
||||
{
|
||||
if (first)
|
||||
impl::print_to_stream(", "sv, base::stream());
|
||||
first = true;
|
||||
base::print_newline(true);
|
||||
base::print_indent();
|
||||
|
||||
base::print_quoted_string(k);
|
||||
impl::print_to_stream(" : "sv, base::stream());
|
||||
|
||||
const auto type = v.type();
|
||||
TOML_ASSUME(type != node_type::none);
|
||||
switch (type)
|
||||
{
|
||||
case node_type::table: print(*reinterpret_cast<const table*>(&v)); break;
|
||||
case node_type::array: print(*reinterpret_cast<const array*>(&v)); break;
|
||||
default:
|
||||
base::print_value(v, type);
|
||||
}
|
||||
|
||||
}
|
||||
base::decrease_indent();
|
||||
base::print_newline(true);
|
||||
base::print_indent();
|
||||
impl::print_to_stream('}', base::stream());
|
||||
}
|
||||
base::clear_naked_newline();
|
||||
}
|
||||
}
|
||||
|
||||
TOML_POP_WARNINGS // TOML_DISABLE_SWITCH_WARNINGS
|
||||
|
||||
//# {{
|
||||
#endif // !TOML_DOXYGEN
|
||||
//# }}
|
177
toml.hpp
177
toml.hpp
@ -4762,41 +4762,6 @@ namespace toml
|
||||
default_formatter(const array&) -> default_formatter<char>;
|
||||
template <typename T> default_formatter(const value<T>&) -> default_formatter<char>;
|
||||
|
||||
template <typename Char>
|
||||
inline void default_formatter<Char>::print_inline(const toml::table& tbl)
|
||||
{
|
||||
if (tbl.empty())
|
||||
impl::print_to_stream("{}"sv, base::stream());
|
||||
else
|
||||
{
|
||||
impl::print_to_stream("{ "sv, base::stream());
|
||||
|
||||
bool first = false;
|
||||
for (auto [k, v] : tbl)
|
||||
{
|
||||
if (first)
|
||||
impl::print_to_stream(", "sv, base::stream());
|
||||
first = true;
|
||||
|
||||
print_key_segment(k);
|
||||
impl::print_to_stream(" = "sv, base::stream());
|
||||
|
||||
const auto type = v.type();
|
||||
TOML_ASSUME(type != node_type::none);
|
||||
switch (type)
|
||||
{
|
||||
case node_type::table: print_inline(*reinterpret_cast<const table*>(&v)); break;
|
||||
case node_type::array: print(*reinterpret_cast<const array*>(&v)); break;
|
||||
default:
|
||||
base::print_value(v, type);
|
||||
}
|
||||
}
|
||||
|
||||
impl::print_to_stream(" }"sv, base::stream());
|
||||
}
|
||||
base::clear_naked_newline();
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
TOML_EXTERNAL_LINKAGE
|
||||
std::basic_ostream<T>& operator << (std::basic_ostream<T>& lhs, default_formatter<U>& rhs)
|
||||
@ -4929,46 +4894,6 @@ namespace toml
|
||||
json_formatter(const array&) -> json_formatter<char>;
|
||||
template <typename T> json_formatter(const value<T>&) -> json_formatter<char>;
|
||||
|
||||
template <typename Char>
|
||||
inline void json_formatter<Char>::print(const toml::table& tbl)
|
||||
{
|
||||
if (tbl.empty())
|
||||
impl::print_to_stream("{}"sv, base::stream());
|
||||
else
|
||||
{
|
||||
impl::print_to_stream('{', base::stream());
|
||||
base::increase_indent();
|
||||
bool first = false;
|
||||
for (auto [k, v] : tbl)
|
||||
{
|
||||
if (first)
|
||||
impl::print_to_stream(", "sv, base::stream());
|
||||
first = true;
|
||||
base::print_newline(true);
|
||||
base::print_indent();
|
||||
|
||||
base::print_quoted_string(k);
|
||||
impl::print_to_stream(" : "sv, base::stream());
|
||||
|
||||
const auto type = v.type();
|
||||
TOML_ASSUME(type != node_type::none);
|
||||
switch (type)
|
||||
{
|
||||
case node_type::table: print(*reinterpret_cast<const table*>(&v)); break;
|
||||
case node_type::array: print(*reinterpret_cast<const array*>(&v)); break;
|
||||
default:
|
||||
base::print_value(v, type);
|
||||
}
|
||||
|
||||
}
|
||||
base::decrease_indent();
|
||||
base::print_newline(true);
|
||||
base::print_indent();
|
||||
impl::print_to_stream('}', base::stream());
|
||||
}
|
||||
base::clear_naked_newline();
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
TOML_EXTERNAL_LINKAGE
|
||||
std::basic_ostream<T>& operator << (std::basic_ostream<T>& lhs, json_formatter<U>& rhs)
|
||||
@ -6486,14 +6411,108 @@ namespace toml::impl
|
||||
}
|
||||
}
|
||||
|
||||
namespace toml
|
||||
{
|
||||
template <typename Char>
|
||||
TOML_EXTERNAL_LINKAGE
|
||||
void default_formatter<Char>::print_inline(const toml::table& tbl)
|
||||
{
|
||||
if (tbl.empty())
|
||||
impl::print_to_stream("{}"sv, base::stream());
|
||||
else
|
||||
{
|
||||
impl::print_to_stream("{ "sv, base::stream());
|
||||
|
||||
bool first = false;
|
||||
for (auto [k, v] : tbl)
|
||||
{
|
||||
if (first)
|
||||
impl::print_to_stream(", "sv, base::stream());
|
||||
first = true;
|
||||
|
||||
print_key_segment(k);
|
||||
impl::print_to_stream(" = "sv, base::stream());
|
||||
|
||||
const auto type = v.type();
|
||||
TOML_ASSUME(type != node_type::none);
|
||||
switch (type)
|
||||
{
|
||||
case node_type::table: print_inline(*reinterpret_cast<const table*>(&v)); break;
|
||||
case node_type::array: print(*reinterpret_cast<const array*>(&v)); break;
|
||||
default:
|
||||
base::print_value(v, type);
|
||||
}
|
||||
}
|
||||
|
||||
impl::print_to_stream(" }"sv, base::stream());
|
||||
}
|
||||
base::clear_naked_newline();
|
||||
}
|
||||
}
|
||||
|
||||
TOML_POP_WARNINGS // TOML_DISABLE_SWITCH_WARNINGS, TOML_DISABLE_FLOAT_WARNINGS
|
||||
|
||||
#pragma endregion
|
||||
//---------- ↑ toml_default_formatter.hpp ----------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------- ↓ toml_json_formatter.hpp ----------------------------------------------------
|
||||
#pragma region
|
||||
|
||||
TOML_PUSH_WARNINGS
|
||||
TOML_DISABLE_SWITCH_WARNINGS
|
||||
|
||||
namespace toml
|
||||
{
|
||||
template <typename Char>
|
||||
TOML_EXTERNAL_LINKAGE
|
||||
void json_formatter<Char>::print(const toml::table& tbl)
|
||||
{
|
||||
if (tbl.empty())
|
||||
impl::print_to_stream("{}"sv, base::stream());
|
||||
else
|
||||
{
|
||||
impl::print_to_stream('{', base::stream());
|
||||
base::increase_indent();
|
||||
bool first = false;
|
||||
for (auto [k, v] : tbl)
|
||||
{
|
||||
if (first)
|
||||
impl::print_to_stream(", "sv, base::stream());
|
||||
first = true;
|
||||
base::print_newline(true);
|
||||
base::print_indent();
|
||||
|
||||
base::print_quoted_string(k);
|
||||
impl::print_to_stream(" : "sv, base::stream());
|
||||
|
||||
const auto type = v.type();
|
||||
TOML_ASSUME(type != node_type::none);
|
||||
switch (type)
|
||||
{
|
||||
case node_type::table: print(*reinterpret_cast<const table*>(&v)); break;
|
||||
case node_type::array: print(*reinterpret_cast<const array*>(&v)); break;
|
||||
default:
|
||||
base::print_value(v, type);
|
||||
}
|
||||
|
||||
}
|
||||
base::decrease_indent();
|
||||
base::print_newline(true);
|
||||
base::print_indent();
|
||||
impl::print_to_stream('}', base::stream());
|
||||
}
|
||||
base::clear_naked_newline();
|
||||
}
|
||||
}
|
||||
|
||||
TOML_POP_WARNINGS // TOML_DISABLE_SWITCH_WARNINGS
|
||||
|
||||
#pragma endregion
|
||||
//------------------------------------- ↑ toml_json_formatter.hpp ----------------------------------------------------
|
||||
|
||||
#if TOML_PARSER
|
||||
|
||||
//----------------------------------------- ↓ toml_parser.hpp --------------------------------------------------------
|
||||
//------------------------------------------------------------------ ↓ toml_parser.hpp -------------------------------
|
||||
#pragma region
|
||||
|
||||
TOML_PUSH_WARNINGS
|
||||
@ -9330,12 +9349,12 @@ namespace toml
|
||||
TOML_POP_WARNINGS // TOML_DISABLE_SWITCH_WARNINGS, TOML_DISABLE_PADDING_WARNINGS
|
||||
|
||||
#pragma endregion
|
||||
//----------------------------------------- ↑ toml_parser.hpp --------------------------------------------------------
|
||||
//------------------------------------------------------------------ ↑ toml_parser.hpp -------------------------------
|
||||
|
||||
#endif // TOML_PARSER
|
||||
#if !TOML_ALL_INLINE
|
||||
|
||||
//-------------------------------------------------------------- ↓ toml_instantiations.hpp ---------------------------
|
||||
//--------------------------------------------------------------------------------------- ↓ toml_instantiations.hpp --
|
||||
#pragma region
|
||||
|
||||
TOML_PUSH_WARNINGS
|
||||
@ -9423,7 +9442,7 @@ namespace toml
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
//-------------------------------------------------------------- ↑ toml_instantiations.hpp ---------------------------
|
||||
//--------------------------------------------------------------------------------------- ↑ toml_instantiations.hpp --
|
||||
|
||||
#endif // !TOML_ALL_INLINE
|
||||
#endif // TOML_IMPLEMENTATION
|
||||
|
@ -65,6 +65,7 @@
|
||||
<ClInclude Include="..\include\toml++\toml_default_formatter.hpp" />
|
||||
<ClInclude Include="..\include\toml++\toml_formatter.h" />
|
||||
<ClInclude Include="..\include\toml++\toml_json_formatter.h" />
|
||||
<ClInclude Include="..\include\toml++\toml_json_formatter.hpp" />
|
||||
<ClInclude Include="..\include\toml++\toml_node.h" />
|
||||
<ClInclude Include="..\include\toml++\toml_node.hpp" />
|
||||
<ClInclude Include="..\include\toml++\toml_parser.h" />
|
||||
|
@ -79,6 +79,9 @@
|
||||
<ClInclude Include="..\include\toml++\toml_preprocessor.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\toml++\toml_json_formatter.hpp">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\.editorconfig" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user