narrowed scope of abi namespacing
also - simplified `noexcept` specifiers (removed `TOML_MAY_THROW_UNLESS`) - minor documentation fixes
This commit is contained in:
parent
d44e61b640
commit
41d05792a5
@ -14,6 +14,7 @@
|
||||
- Doesn't require RTTI
|
||||
- First-class support for serializing to JSON
|
||||
- Tested on Clang, GCC and MSVC (VS2019)
|
||||
- Tested on x64, x86 and ARM
|
||||
|
||||
<br>
|
||||
|
||||
@ -100,6 +101,8 @@ won't need to mess with these at all, but if you do, set them before including t
|
||||
| `TOML_UNDEF_MACROS` | boolean | `1` | `#undefs` the library's internal macros at the end of the header. |
|
||||
| `TOML_UNRELEASED_FEATURES` | boolean | `1` | Enables support for [unreleased TOML language features] not yet part of a [numbered version]. |
|
||||
|
||||
_A number of these have ABI implications; the library uses inline namespaces to prevent you from accidentally linking incompatible combinations together._
|
||||
|
||||
<br>
|
||||
|
||||
# TOML Language Support
|
||||
|
@ -351,8 +351,6 @@ PREDEFINED = DOXYGEN=1 \
|
||||
TOML_MAY_THROW= \
|
||||
TOML_NODISCARD_CTOR= \
|
||||
TOML_ASYMMETRICAL_EQUALITY_OPS= \
|
||||
TOML_START="namespace toml" \
|
||||
TOML_END= \
|
||||
TOML_ALL_INLINE=0 \
|
||||
TOML_IMPLEMENTATION=0 \
|
||||
TOML_INLINE_FUNC_IMPL= \
|
||||
|
@ -31,6 +31,10 @@ a.tpp-external
|
||||
{
|
||||
font-weight: normal;
|
||||
}
|
||||
pre a.tpp-external
|
||||
{
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.tpp-enable-if
|
||||
{
|
||||
|
@ -49,7 +49,6 @@
|
||||
#undef TOML_EMPTY_BASES
|
||||
#undef TOML_CPP_VERSION
|
||||
#undef TOML_CPP
|
||||
#undef TOML_MAY_THROW_UNLESS
|
||||
#undef TOML_MAY_THROW
|
||||
#undef TOML_NO_DEFAULT_CASE
|
||||
#undef TOML_CONSTEVAL
|
||||
@ -66,23 +65,14 @@
|
||||
#undef TOML_UNDEF_MACROS
|
||||
#undef TOML_RELOPS_REORDERING
|
||||
#undef TOML_ASYMMETRICAL_EQUALITY_OPS
|
||||
#undef TOML_NS1_EX
|
||||
#undef TOML_NS2_OPT
|
||||
#undef TOML_NS3_CHAR8
|
||||
#undef TOML_NS4
|
||||
#undef TOML_NS5
|
||||
#undef TOML_START
|
||||
#undef TOML_START_2
|
||||
#undef TOML_START_1
|
||||
#undef TOML_END
|
||||
#undef TOML_IMPL_START
|
||||
#undef TOML_IMPL_END
|
||||
#undef TOML_ALL_INLINE
|
||||
#undef TOML_IMPLEMENTATION
|
||||
#undef TOML_INLINE_FUNC_IMPL
|
||||
#undef TOML_COMPILER_EXCEPTIONS
|
||||
#undef TOML_LAUNDER
|
||||
#undef TOML_TRIVIAL_ABI
|
||||
#undef TOML_ABI_NAMESPACES
|
||||
#undef TOML_PARSER_TYPENAME
|
||||
#endif
|
||||
|
||||
/// \mainpage toml++
|
||||
@ -101,7 +91,8 @@
|
||||
/// - Works with or without exceptions
|
||||
/// - Doesn't require RTTI
|
||||
/// - First-class support for serializing to JSON
|
||||
/// - Tested on Clang, GCC and MSVC (VS2019)
|
||||
/// - Tested on Clang, GCC and MSVC (VS2019)
|
||||
/// - Tested on x64, x86 and ARM
|
||||
///
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
|
@ -5,7 +5,7 @@
|
||||
#pragma once
|
||||
#include "toml_value.h"
|
||||
|
||||
TOML_IMPL_START
|
||||
namespace toml::impl
|
||||
{
|
||||
template <bool is_const>
|
||||
class array_iterator final
|
||||
@ -181,14 +181,14 @@ TOML_IMPL_START
|
||||
}
|
||||
}
|
||||
}
|
||||
TOML_IMPL_END
|
||||
|
||||
TOML_START
|
||||
|
||||
namespace toml
|
||||
{
|
||||
[[nodiscard]] TOML_API bool operator == (const array& lhs, const array& rhs) noexcept;
|
||||
[[nodiscard]] TOML_API bool operator != (const array& lhs, const array& rhs) noexcept;
|
||||
template <typename CHAR>
|
||||
std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>&, const array&) TOML_MAY_THROW;
|
||||
std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>&, const array&);
|
||||
|
||||
/// \brief A TOML array.
|
||||
///
|
||||
@ -233,7 +233,7 @@ TOML_START
|
||||
: public node
|
||||
{
|
||||
private:
|
||||
friend class impl::parser;
|
||||
friend class TOML_PARSER_TYPENAME;
|
||||
std::vector<std::unique_ptr<node>> values;
|
||||
|
||||
void preinsertion_resize(size_t idx, size_t count) noexcept;
|
||||
@ -277,7 +277,7 @@ TOML_START
|
||||
/// \param vals The values used to initialize nodes 1...N.
|
||||
template <typename U, typename... V>
|
||||
TOML_NODISCARD_CTOR
|
||||
explicit array(U&& val, V&&... vals) TOML_MAY_THROW
|
||||
explicit array(U&& val, V&&... vals)
|
||||
{
|
||||
values.reserve(sizeof...(V) + 1_sz);
|
||||
values.emplace_back(impl::make_node(std::forward<U>(val)));
|
||||
@ -394,7 +394,7 @@ TOML_START
|
||||
/// \brief Returns the number of nodes in the array.
|
||||
[[nodiscard]] size_t size() const noexcept;
|
||||
/// \brief Reserves internal storage capacity up to a pre-determined number of nodes.
|
||||
void reserve(size_t new_capacity) TOML_MAY_THROW;
|
||||
void reserve(size_t new_capacity);
|
||||
/// \brief Removes all nodes from the array.
|
||||
void clear() noexcept;
|
||||
|
||||
@ -824,10 +824,10 @@ TOML_START
|
||||
/// \eout
|
||||
///
|
||||
/// \remarks Arrays inside child tables are not flattened.
|
||||
void flatten() TOML_MAY_THROW;
|
||||
void flatten();
|
||||
|
||||
template <typename CHAR>
|
||||
friend std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>&, const array&) TOML_MAY_THROW;
|
||||
friend std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>&, const array&);
|
||||
};
|
||||
}
|
||||
TOML_END
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#pragma once
|
||||
#include "toml_array.h"
|
||||
|
||||
TOML_START
|
||||
namespace toml
|
||||
{
|
||||
TOML_INLINE_FUNC_IMPL
|
||||
void array::preinsertion_resize(size_t idx, size_t count) noexcept
|
||||
@ -62,7 +62,7 @@ TOML_START
|
||||
|
||||
TOML_INLINE_FUNC_IMPL bool array::empty() const noexcept { return values.empty(); }
|
||||
TOML_INLINE_FUNC_IMPL size_t array::size() const noexcept { return values.size(); }
|
||||
TOML_INLINE_FUNC_IMPL void array::reserve(size_t new_capacity) TOML_MAY_THROW { values.reserve(new_capacity); }
|
||||
TOML_INLINE_FUNC_IMPL void array::reserve(size_t new_capacity) { values.reserve(new_capacity); }
|
||||
TOML_INLINE_FUNC_IMPL void array::clear() noexcept { values.clear(); }
|
||||
|
||||
TOML_INLINE_FUNC_IMPL
|
||||
@ -158,7 +158,7 @@ TOML_START
|
||||
}
|
||||
|
||||
TOML_INLINE_FUNC_IMPL
|
||||
void array::flatten() TOML_MAY_THROW
|
||||
void array::flatten()
|
||||
{
|
||||
if (values.empty())
|
||||
return;
|
||||
@ -204,4 +204,4 @@ TOML_START
|
||||
}
|
||||
}
|
||||
}
|
||||
TOML_END
|
||||
|
||||
|
@ -180,12 +180,8 @@
|
||||
#endif
|
||||
#if TOML_EXCEPTIONS
|
||||
#define TOML_MAY_THROW
|
||||
#define TOML_MAY_THROW_UNLESS(...) noexcept(__VA_ARGS__)
|
||||
#define TOML_NS1_EX
|
||||
#else
|
||||
#define TOML_MAY_THROW noexcept
|
||||
#define TOML_MAY_THROW_UNLESS(...) noexcept
|
||||
#define TOML_NS1_EX _noex
|
||||
#endif
|
||||
#ifndef TOML_DISABLE_INIT_WARNINGS
|
||||
#define TOML_DISABLE_INIT_WARNINGS
|
||||
@ -288,40 +284,6 @@
|
||||
#define TOML_LANG_EXACTLY(maj, min, rev) \
|
||||
(TOML_LANG_EFFECTIVE_VERSION == TOML_MAKE_VERSION(maj, min, rev))
|
||||
|
||||
#ifdef TOML_OPTIONAL_TYPE
|
||||
#define TOML_NS2_OPT _opt
|
||||
#else
|
||||
#define TOML_NS2_OPT
|
||||
#endif
|
||||
|
||||
#if TOML_CHAR_8_STRINGS
|
||||
#define TOML_NS3_CHAR8 _char8
|
||||
#else
|
||||
#define TOML_NS3_CHAR8
|
||||
#endif
|
||||
|
||||
#define TOML_NS4
|
||||
#define TOML_NS5
|
||||
|
||||
#ifndef DOXYGEN
|
||||
|
||||
#define TOML_START_2(VER, ARG1, ARG2, ARG3, ARG4, ARG5) \
|
||||
namespace toml { inline namespace v##VER##ARG1##ARG2##ARG3##ARG4##ARG5
|
||||
|
||||
#define TOML_START_1(VER, ARG1, ARG2, ARG3, ARG4, ARG5) \
|
||||
TOML_START_2(VER, ARG1, ARG2, ARG3, ARG4, ARG5)
|
||||
|
||||
#define TOML_START \
|
||||
TOML_START_1( \
|
||||
TOML_LIB_MAJOR, TOML_NS1_EX, TOML_NS2_OPT, \
|
||||
TOML_NS3_CHAR8, TOML_NS4, TOML_NS5 \
|
||||
)
|
||||
|
||||
#define TOML_END }
|
||||
|
||||
#endif
|
||||
#define TOML_IMPL_START TOML_START { namespace impl
|
||||
#define TOML_IMPL_END } TOML_END
|
||||
|
||||
////////// INCLUDES
|
||||
|
||||
@ -377,13 +339,17 @@ TOML_POP_WARNINGS
|
||||
#define TOML_LAUNDER(x) x
|
||||
#endif
|
||||
|
||||
#if !defined(DOXYGEN) && !defined(__INTELLISENSE__)
|
||||
#define TOML_ABI_NAMESPACES 1
|
||||
#else
|
||||
#define TOML_ABI_NAMESPACES 0
|
||||
#endif
|
||||
|
||||
////////// FORWARD DECLARATIONS & TYPEDEFS
|
||||
// clang-format on
|
||||
|
||||
/// \brief The root namespace for all toml++ functions and types.
|
||||
namespace toml { }
|
||||
|
||||
TOML_START
|
||||
namespace toml
|
||||
{
|
||||
using namespace std::string_literals;
|
||||
using namespace std::string_view_literals;
|
||||
@ -425,7 +391,6 @@ TOML_START
|
||||
struct date;
|
||||
struct time;
|
||||
struct time_offset;
|
||||
struct date_time;
|
||||
class node;
|
||||
class array;
|
||||
class table;
|
||||
@ -434,6 +399,20 @@ TOML_START
|
||||
template <typename> class default_formatter;
|
||||
template <typename> class json_formatter;
|
||||
|
||||
#if TOML_ABI_NAMESPACES
|
||||
#ifdef TOML_OPTIONAL_TYPE
|
||||
inline namespace abi_custopt {
|
||||
#else
|
||||
inline namespace abi_stdopt {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct date_time;
|
||||
|
||||
#if TOML_ABI_NAMESPACES
|
||||
} //end abi namespace for TOML_OPTIONAL_TYPE
|
||||
#endif
|
||||
|
||||
#endif // !DOXYGEN
|
||||
|
||||
/// \brief TOML node type identifiers.
|
||||
@ -451,18 +430,6 @@ TOML_START
|
||||
date_time ///< The node is a toml::value<date_time>.
|
||||
};
|
||||
|
||||
#if TOML_LARGE_FILES
|
||||
|
||||
using source_index = uint32_t;
|
||||
|
||||
#else
|
||||
|
||||
/// \brief The integer type used to tally line numbers and columns.
|
||||
/// \remarks This will be an alias for uint32_t if `TOML_LARGE_FILES` is `1`.
|
||||
using source_index = uint16_t;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TOML_OPTIONAL_TYPE
|
||||
|
||||
template <typename T>
|
||||
@ -479,6 +446,29 @@ TOML_START
|
||||
|
||||
#endif
|
||||
|
||||
#if TOML_LARGE_FILES
|
||||
|
||||
using source_index = uint32_t;
|
||||
|
||||
#else
|
||||
|
||||
/// \brief The integer type used to tally line numbers and columns.
|
||||
/// \remarks This will be an alias for uint32_t if `TOML_LARGE_FILES` is `1`.
|
||||
using source_index = uint16_t;
|
||||
|
||||
#endif
|
||||
|
||||
/// \brief A pointer to a shared string resource containing a source path.
|
||||
using source_path_ptr = std::shared_ptr<const std::string>;
|
||||
|
||||
#if TOML_ABI_NAMESPACES
|
||||
#if TOML_LARGE_FILES
|
||||
inline namespace abi_lf {
|
||||
#else
|
||||
inline namespace abi_sf {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/// \brief A source document line-and-column pair.
|
||||
///
|
||||
/// \detail \cpp
|
||||
@ -549,34 +539,8 @@ TOML_START
|
||||
return lhs.line < rhs.line
|
||||
|| (lhs.line == rhs.line && lhs.column <= rhs.column);
|
||||
}
|
||||
|
||||
/// \brief Prints a source_position to a stream.
|
||||
///
|
||||
/// \detail \cpp
|
||||
/// auto tbl = toml::parse("bar = 42"sv);
|
||||
///
|
||||
/// std::cout << "The value for 'bar' was found on "sv
|
||||
/// << tbl.get("bar")->source()
|
||||
/// << std::endl;
|
||||
///
|
||||
/// \ecpp
|
||||
///
|
||||
/// \out
|
||||
/// The value for 'bar' was found on line 1, column 7
|
||||
/// \eout
|
||||
///
|
||||
/// \param lhs The stream.
|
||||
/// \param rhs The source_position.
|
||||
///
|
||||
/// \returns The input stream.
|
||||
template <typename CHAR>
|
||||
friend std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const source_position& rhs)
|
||||
TOML_MAY_THROW;
|
||||
};
|
||||
|
||||
/// \brief A pointer to a shared string resource containing a source path.
|
||||
using source_path_ptr = std::shared_ptr<const std::string>;
|
||||
|
||||
/// \brief A source document region.
|
||||
///
|
||||
/// \detail \cpp
|
||||
@ -618,29 +582,6 @@ TOML_START
|
||||
///
|
||||
/// \remarks This will be `nullptr` if no path was provided to toml::parse().
|
||||
source_path_ptr path;
|
||||
|
||||
/// \brief Prints a source_region to a stream.
|
||||
///
|
||||
/// \detail \cpp
|
||||
/// auto tbl = toml::parse("bar = 42", "config.toml");
|
||||
///
|
||||
/// std::cout << "The value for 'bar' was found on "sv
|
||||
/// << tbl.get("bar")->source()
|
||||
/// << std::endl;
|
||||
///
|
||||
/// \ecpp
|
||||
///
|
||||
/// \out
|
||||
/// The value for 'bar' was found on line 1, column 7 of 'config.toml'
|
||||
/// \eout
|
||||
///
|
||||
/// \param lhs The stream.
|
||||
/// \param rhs The source_position.
|
||||
///
|
||||
/// \returns The input stream.
|
||||
template <typename CHAR>
|
||||
friend std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const source_region& rhs)
|
||||
TOML_MAY_THROW;
|
||||
};
|
||||
|
||||
TOML_PUSH_WARNINGS
|
||||
@ -648,6 +589,10 @@ TOML_START
|
||||
|
||||
#if defined(DOXYGEN) || !TOML_EXCEPTIONS
|
||||
|
||||
#if TOML_ABI_NAMESPACES
|
||||
inline namespace abi_noex {
|
||||
#endif
|
||||
|
||||
/// \brief An error thrown/returned when parsing fails.
|
||||
///
|
||||
/// \remarks This class inherits from std::runtime_error when exceptions are enabled.
|
||||
@ -690,37 +635,14 @@ TOML_START
|
||||
{
|
||||
return source_;
|
||||
}
|
||||
|
||||
/// \brief Prints a parse_error to a stream.
|
||||
///
|
||||
/// \detail \cpp
|
||||
/// try
|
||||
/// {
|
||||
/// auto tbl = toml::parse("enabled = trUe"sv);
|
||||
/// }
|
||||
/// catch (const toml::parse_error & err)
|
||||
/// {
|
||||
/// std::cerr << "Parsing failed:\n"sv << err << std::endl;
|
||||
/// }
|
||||
/// \ecpp
|
||||
///
|
||||
/// \out
|
||||
/// Parsing failed:
|
||||
/// Encountered unexpected character while parsing boolean; expected 'true', saw 'trU'
|
||||
/// (error occurred at line 1, column 13)
|
||||
/// \eout
|
||||
///
|
||||
/// \param lhs The stream.
|
||||
/// \param rhs The parse_error.
|
||||
///
|
||||
/// \returns The input stream.
|
||||
template <typename CHAR>
|
||||
friend std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const parse_error& rhs)
|
||||
TOML_MAY_THROW;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
#if TOML_ABI_NAMESPACES
|
||||
inline namespace abi_ex {
|
||||
#endif
|
||||
|
||||
class parse_error final
|
||||
: public std::runtime_error
|
||||
{
|
||||
@ -756,19 +678,19 @@ TOML_START
|
||||
{
|
||||
return source_;
|
||||
}
|
||||
|
||||
template <typename CHAR>
|
||||
friend std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const parse_error& rhs)
|
||||
TOML_MAY_THROW;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
TOML_POP_WARNINGS
|
||||
}
|
||||
TOML_END
|
||||
|
||||
TOML_IMPL_START
|
||||
#if TOML_ABI_NAMESPACES
|
||||
} //end abi namespace for TOML_EXCEPTIONS
|
||||
} //end abi namespace for TOML_LARGE_FILES
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace toml::impl
|
||||
{
|
||||
template <typename T>
|
||||
using string_map = std::map<string, T, std::less<>>; //heterogeneous lookup
|
||||
@ -820,8 +742,24 @@ TOML_IMPL_START
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#if TOML_ABI_NAMESPACES
|
||||
#if TOML_EXCEPTIONS
|
||||
inline namespace abi_impl_ex {
|
||||
#define TOML_PARSER_TYPENAME ::toml::impl::abi_impl_ex::parser
|
||||
#else
|
||||
inline namespace abi_impl_noex {
|
||||
#define TOML_PARSER_TYPENAME ::toml::impl::abi_impl_noex::parser
|
||||
#endif
|
||||
#else
|
||||
#define TOML_PARSER_TYPENAME ::toml::impl::parser
|
||||
#endif
|
||||
|
||||
class parser;
|
||||
|
||||
#if TOML_ABI_NAMESPACES
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
inline constexpr bool is_value =
|
||||
std::is_same_v<T, string>
|
||||
@ -967,7 +905,7 @@ TOML_IMPL_START
|
||||
|
||||
#define TOML_P2S_DECL(linkage, type) \
|
||||
template <typename CHAR> \
|
||||
linkage void print_to_stream(type, std::basic_ostream<CHAR>&) TOML_MAY_THROW
|
||||
linkage void print_to_stream(type, std::basic_ostream<CHAR>&)
|
||||
|
||||
TOML_P2S_DECL(TOML_ALWAYS_INLINE, int8_t);
|
||||
TOML_P2S_DECL(TOML_ALWAYS_INLINE, int16_t);
|
||||
@ -986,9 +924,8 @@ TOML_IMPL_START
|
||||
|
||||
#undef TOML_P2S_DECL
|
||||
}
|
||||
TOML_IMPL_END
|
||||
|
||||
TOML_START
|
||||
namespace toml
|
||||
{
|
||||
/// \brief Metafunction for determining if a type is a toml::table.
|
||||
template <typename T>
|
||||
@ -1037,7 +974,7 @@ TOML_START
|
||||
/// Element [3] is: boolean
|
||||
/// \eout
|
||||
template <typename CHAR>
|
||||
inline std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, node_type rhs) TOML_MAY_THROW
|
||||
inline std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, node_type rhs)
|
||||
{
|
||||
using underlying_t = std::underlying_type_t<node_type>;
|
||||
const auto str = impl::node_type_friendly_names[static_cast<underlying_t>(rhs)];
|
||||
@ -1052,4 +989,3 @@ TOML_START
|
||||
}
|
||||
}
|
||||
}
|
||||
TOML_END
|
||||
|
@ -5,7 +5,7 @@
|
||||
#pragma once
|
||||
#include "toml_common.h"
|
||||
|
||||
TOML_START
|
||||
namespace toml
|
||||
{
|
||||
/// \brief A local date.
|
||||
struct TOML_TRIVIAL_ABI date final
|
||||
@ -85,7 +85,7 @@ TOML_START
|
||||
/// 1987-03-16
|
||||
/// \eout
|
||||
template <typename CHAR>
|
||||
inline std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const date& rhs) TOML_MAY_THROW
|
||||
inline std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const date& rhs)
|
||||
{
|
||||
impl::print_to_stream(rhs, lhs);
|
||||
return lhs;
|
||||
@ -173,7 +173,7 @@ TOML_START
|
||||
/// 10:20:34.5
|
||||
/// \eout
|
||||
template <typename CHAR>
|
||||
inline std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const time& rhs) TOML_MAY_THROW
|
||||
inline std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const time& rhs)
|
||||
{
|
||||
impl::print_to_stream(rhs, lhs);
|
||||
return lhs;
|
||||
@ -275,12 +275,20 @@ TOML_START
|
||||
/// -02:30
|
||||
/// \eout
|
||||
template <typename CHAR>
|
||||
inline std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const time_offset& rhs) TOML_MAY_THROW
|
||||
inline std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const time_offset& rhs)
|
||||
{
|
||||
impl::print_to_stream(rhs, lhs);
|
||||
return lhs;
|
||||
}
|
||||
|
||||
#if TOML_ABI_NAMESPACES
|
||||
#ifdef TOML_OPTIONAL_TYPE
|
||||
inline namespace abi_custopt {
|
||||
#else
|
||||
inline namespace abi_stdopt {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/// \brief A date-time.
|
||||
struct date_time final
|
||||
{
|
||||
@ -382,6 +390,10 @@ TOML_START
|
||||
}
|
||||
};
|
||||
|
||||
#if TOML_ABI_NAMESPACES
|
||||
} //end abi namespace for TOML_OPTIONAL_TYPE
|
||||
#endif
|
||||
|
||||
/// \brief Prints a date_time out to a stream in RFC 3339 format.
|
||||
/// \detail \cpp
|
||||
/// std::cout << toml::date_time{ { 1987, 3, 16 }, { 10, 20, 34 } } << std::endl;
|
||||
@ -395,10 +407,10 @@ TOML_START
|
||||
/// 1987-03-16T10:20:34Z
|
||||
/// \eout
|
||||
template <typename CHAR>
|
||||
inline std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const date_time& rhs) TOML_MAY_THROW
|
||||
inline std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const date_time& rhs)
|
||||
{
|
||||
impl::print_to_stream(rhs, lhs);
|
||||
return lhs;
|
||||
}
|
||||
}
|
||||
TOML_END
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "toml_array.h"
|
||||
#include "toml_utf8.h"
|
||||
|
||||
TOML_IMPL_START
|
||||
namespace toml::impl
|
||||
{
|
||||
TOML_PUSH_WARNINGS
|
||||
TOML_DISABLE_ALL_WARNINGS
|
||||
@ -151,14 +151,14 @@ TOML_IMPL_START
|
||||
return (default_formatter_inline_columns(node) + starting_column_bias) > 120_sz;
|
||||
}
|
||||
}
|
||||
TOML_IMPL_END
|
||||
|
||||
TOML_START
|
||||
|
||||
namespace toml
|
||||
{
|
||||
template <typename T, typename U>
|
||||
std::basic_ostream<T>& operator << (std::basic_ostream<T>&, default_formatter<U>&) TOML_MAY_THROW;
|
||||
std::basic_ostream<T>& operator << (std::basic_ostream<T>&, default_formatter<U>&);
|
||||
template <typename T, typename U>
|
||||
std::basic_ostream<T>& operator << (std::basic_ostream<T>&, default_formatter<U>&&) TOML_MAY_THROW;
|
||||
std::basic_ostream<T>& operator << (std::basic_ostream<T>&, default_formatter<U>&&);
|
||||
|
||||
/// \brief A wrapper for printing TOML objects out to a stream as formatted TOML.
|
||||
///
|
||||
@ -196,7 +196,7 @@ TOML_START
|
||||
using base = impl::formatter<CHAR>;
|
||||
std::vector<toml::string> key_path;
|
||||
|
||||
void print_key_segment(const toml::string& str) TOML_MAY_THROW
|
||||
void print_key_segment(const toml::string& str)
|
||||
{
|
||||
if (str.empty())
|
||||
impl::print_to_stream("''"sv, base::stream());
|
||||
@ -223,7 +223,7 @@ TOML_START
|
||||
base::clear_naked_newline();
|
||||
}
|
||||
|
||||
void print_key_path() TOML_MAY_THROW
|
||||
void print_key_path()
|
||||
{
|
||||
for (const auto& segment : key_path)
|
||||
{
|
||||
@ -234,9 +234,9 @@ TOML_START
|
||||
base::clear_naked_newline();
|
||||
}
|
||||
|
||||
inline void print_inline(const table& /*tbl*/) TOML_MAY_THROW;
|
||||
inline void print_inline(const table& /*tbl*/);
|
||||
|
||||
void print(const array& arr) TOML_MAY_THROW
|
||||
void print(const array& arr)
|
||||
{
|
||||
if (arr.empty())
|
||||
impl::print_to_stream("[]"sv, base::stream());
|
||||
@ -296,7 +296,7 @@ TOML_START
|
||||
base::clear_naked_newline();
|
||||
}
|
||||
|
||||
void print(const table& tbl) TOML_MAY_THROW
|
||||
void print(const table& tbl)
|
||||
{
|
||||
static constexpr auto is_non_inline_array_of_tables = [](auto&& nde) noexcept
|
||||
{
|
||||
@ -416,7 +416,7 @@ TOML_START
|
||||
}
|
||||
}
|
||||
|
||||
void print() TOML_MAY_THROW
|
||||
void print()
|
||||
{
|
||||
switch (auto source_type = base::source().type())
|
||||
{
|
||||
@ -454,9 +454,9 @@ TOML_START
|
||||
{}
|
||||
|
||||
template <typename T, typename U>
|
||||
friend std::basic_ostream<T>& operator << (std::basic_ostream<T>&, default_formatter<U>&) TOML_MAY_THROW;
|
||||
friend std::basic_ostream<T>& operator << (std::basic_ostream<T>&, default_formatter<U>&);
|
||||
template <typename T, typename U>
|
||||
friend std::basic_ostream<T>& operator << (std::basic_ostream<T>&, default_formatter<U>&&) TOML_MAY_THROW;
|
||||
friend std::basic_ostream<T>& operator << (std::basic_ostream<T>&, default_formatter<U>&&);
|
||||
};
|
||||
|
||||
default_formatter(const table&) -> default_formatter<char>;
|
||||
@ -464,7 +464,7 @@ TOML_START
|
||||
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) TOML_MAY_THROW
|
||||
inline void default_formatter<CHAR>::print_inline(const toml::table& tbl)
|
||||
{
|
||||
if (tbl.empty())
|
||||
impl::print_to_stream("{}"sv, base::stream());
|
||||
@ -499,7 +499,7 @@ TOML_START
|
||||
|
||||
/// \brief Prints the bound TOML object out to the stream as formatted TOML.
|
||||
template <typename T, typename U>
|
||||
inline std::basic_ostream<T>& operator << (std::basic_ostream<T>& lhs, default_formatter<U>& rhs) TOML_MAY_THROW
|
||||
inline std::basic_ostream<T>& operator << (std::basic_ostream<T>& lhs, default_formatter<U>& rhs)
|
||||
{
|
||||
rhs.attach(lhs);
|
||||
rhs.key_path.clear();
|
||||
@ -510,21 +510,21 @@ TOML_START
|
||||
|
||||
/// \brief Prints the bound TOML object out to the stream as formatted TOML (rvalue overload).
|
||||
template <typename T, typename U>
|
||||
inline std::basic_ostream<T>& operator << (std::basic_ostream<T>& lhs, default_formatter<U>&& rhs) TOML_MAY_THROW
|
||||
inline std::basic_ostream<T>& operator << (std::basic_ostream<T>& lhs, default_formatter<U>&& rhs)
|
||||
{
|
||||
return lhs << rhs; //as lvalue
|
||||
}
|
||||
|
||||
template <typename CHAR>
|
||||
inline std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const table& rhs) TOML_MAY_THROW
|
||||
inline std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const table& rhs)
|
||||
{
|
||||
return lhs << default_formatter<CHAR>{ rhs };
|
||||
}
|
||||
|
||||
template <typename CHAR>
|
||||
inline std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const array& rhs) TOML_MAY_THROW
|
||||
inline std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const array& rhs)
|
||||
{
|
||||
return lhs << default_formatter<CHAR>{ rhs };
|
||||
}
|
||||
}
|
||||
TOML_END
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#pragma once
|
||||
#include "toml_print_to_stream.h"
|
||||
|
||||
TOML_START
|
||||
namespace toml
|
||||
{
|
||||
/// \brief Format flags for modifying how TOML data is printed to streams.
|
||||
enum class format_flags : uint8_t
|
||||
@ -22,9 +22,9 @@ TOML_START
|
||||
return static_cast<format_flags>( impl::unbox_enum(lhs) | impl::unbox_enum(rhs) );
|
||||
}
|
||||
}
|
||||
TOML_END
|
||||
|
||||
TOML_IMPL_START
|
||||
|
||||
namespace toml::impl
|
||||
{
|
||||
template <typename CHAR = char>
|
||||
class formatter
|
||||
@ -63,7 +63,7 @@ TOML_IMPL_START
|
||||
stream_ = nullptr;
|
||||
}
|
||||
|
||||
void print_newline(bool force = false) TOML_MAY_THROW
|
||||
void print_newline(bool force = false)
|
||||
{
|
||||
if (!naked_newline_ || force)
|
||||
{
|
||||
@ -72,7 +72,7 @@ TOML_IMPL_START
|
||||
}
|
||||
}
|
||||
|
||||
void print_indent() TOML_MAY_THROW
|
||||
void print_indent()
|
||||
{
|
||||
for (int8_t i = 0; i < indent_; i++)
|
||||
{
|
||||
@ -81,7 +81,7 @@ TOML_IMPL_START
|
||||
}
|
||||
}
|
||||
|
||||
void print_quoted_string(toml::string_view str) TOML_MAY_THROW
|
||||
void print_quoted_string(toml::string_view str)
|
||||
{
|
||||
if (str.empty())
|
||||
print_to_stream("\"\""sv, *stream_);
|
||||
@ -95,7 +95,7 @@ TOML_IMPL_START
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void print(const value<T>& val) TOML_MAY_THROW
|
||||
void print(const value<T>& val)
|
||||
{
|
||||
if constexpr (std::is_same_v<T, string>)
|
||||
{
|
||||
@ -126,7 +126,7 @@ TOML_IMPL_START
|
||||
}
|
||||
}
|
||||
|
||||
void print(const node& val_node, node_type type) TOML_MAY_THROW
|
||||
void print(const node& val_node, node_type type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
@ -147,4 +147,4 @@ TOML_IMPL_START
|
||||
{}
|
||||
};
|
||||
}
|
||||
TOML_IMPL_END
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "toml_value.h"
|
||||
#include "toml_node_view.h"
|
||||
|
||||
TOML_START
|
||||
namespace toml
|
||||
{
|
||||
template class TOML_API value<string>;
|
||||
template class TOML_API value<int64_t>;
|
||||
@ -19,4 +19,4 @@ TOML_START
|
||||
template class TOML_API node_view<node>;
|
||||
template class TOML_API node_view<const node>;
|
||||
}
|
||||
TOML_END
|
||||
|
||||
|
@ -5,12 +5,12 @@
|
||||
#pragma once
|
||||
#include "toml_formatter.h"
|
||||
|
||||
TOML_START
|
||||
namespace toml
|
||||
{
|
||||
template <typename T, typename U>
|
||||
std::basic_ostream<T>& operator << (std::basic_ostream<T>&, json_formatter<U>&) TOML_MAY_THROW;
|
||||
std::basic_ostream<T>& operator << (std::basic_ostream<T>&, json_formatter<U>&);
|
||||
template <typename T, typename U>
|
||||
std::basic_ostream<T>& operator << (std::basic_ostream<T>&, json_formatter<U>&&) TOML_MAY_THROW;
|
||||
std::basic_ostream<T>& operator << (std::basic_ostream<T>&, json_formatter<U>&&);
|
||||
|
||||
/// \brief A wrapper for printing TOML objects out to a stream as formatted JSON.
|
||||
///
|
||||
@ -50,9 +50,9 @@ TOML_START
|
||||
private:
|
||||
using base = impl::formatter<CHAR>;
|
||||
|
||||
inline void print(const toml::table& tbl) TOML_MAY_THROW;
|
||||
inline void print(const toml::table& tbl);
|
||||
|
||||
void print(const array& arr) TOML_MAY_THROW
|
||||
void print(const array& arr)
|
||||
{
|
||||
if (arr.empty())
|
||||
impl::print_to_stream("[]"sv, base::stream());
|
||||
@ -86,7 +86,7 @@ TOML_START
|
||||
base::clear_naked_newline();
|
||||
}
|
||||
|
||||
void print() TOML_MAY_THROW
|
||||
void print()
|
||||
{
|
||||
switch (auto source_type = base::source().type())
|
||||
{
|
||||
@ -108,9 +108,9 @@ TOML_START
|
||||
{}
|
||||
|
||||
template <typename T, typename U>
|
||||
friend std::basic_ostream<T>& operator << (std::basic_ostream<T>&, json_formatter<U>&) TOML_MAY_THROW;
|
||||
friend std::basic_ostream<T>& operator << (std::basic_ostream<T>&, json_formatter<U>&);
|
||||
template <typename T, typename U>
|
||||
friend std::basic_ostream<T>& operator << (std::basic_ostream<T>&, json_formatter<U>&&) TOML_MAY_THROW;
|
||||
friend std::basic_ostream<T>& operator << (std::basic_ostream<T>&, json_formatter<U>&&);
|
||||
};
|
||||
|
||||
json_formatter(const table&) -> json_formatter<char>;
|
||||
@ -118,7 +118,7 @@ TOML_START
|
||||
template <typename T> json_formatter(const value<T>&) -> json_formatter<char>;
|
||||
|
||||
template <typename CHAR>
|
||||
inline void json_formatter<CHAR>::print(const toml::table& tbl) TOML_MAY_THROW
|
||||
inline void json_formatter<CHAR>::print(const toml::table& tbl)
|
||||
{
|
||||
if (tbl.empty())
|
||||
impl::print_to_stream("{}"sv, base::stream());
|
||||
@ -158,7 +158,7 @@ TOML_START
|
||||
|
||||
/// \brief Prints the bound TOML object out to the stream as JSON.
|
||||
template <typename T, typename U>
|
||||
inline std::basic_ostream<T>& operator << (std::basic_ostream<T>& lhs, json_formatter<U>& rhs) TOML_MAY_THROW
|
||||
inline std::basic_ostream<T>& operator << (std::basic_ostream<T>& lhs, json_formatter<U>& rhs)
|
||||
{
|
||||
rhs.attach(lhs);
|
||||
rhs.print();
|
||||
@ -168,9 +168,9 @@ TOML_START
|
||||
|
||||
/// \brief Prints the bound TOML object out to the stream as JSON (rvalue overload).
|
||||
template <typename T, typename U>
|
||||
inline std::basic_ostream<T>& operator << (std::basic_ostream<T>& lhs, json_formatter<U>&& rhs) TOML_MAY_THROW
|
||||
inline std::basic_ostream<T>& operator << (std::basic_ostream<T>& lhs, json_formatter<U>&& rhs)
|
||||
{
|
||||
return lhs << rhs; //as lvalue
|
||||
}
|
||||
}
|
||||
TOML_END
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#pragma once
|
||||
#include "toml_common.h"
|
||||
|
||||
TOML_START
|
||||
namespace toml
|
||||
{
|
||||
/// \brief A TOML node.
|
||||
///
|
||||
@ -14,7 +14,7 @@ TOML_START
|
||||
class TOML_INTERFACE TOML_API node
|
||||
{
|
||||
private:
|
||||
friend class impl::parser;
|
||||
friend class TOML_PARSER_TYPENAME;
|
||||
source_region source_{};
|
||||
|
||||
protected:
|
||||
@ -290,8 +290,6 @@ TOML_START
|
||||
&& can_visit<FUNC, N, time>
|
||||
&& can_visit<FUNC, N, date_time>;
|
||||
|
||||
#if TOML_EXCEPTIONS
|
||||
|
||||
template <typename FUNC, typename N, typename T>
|
||||
static constexpr bool visit_is_nothrow_one =
|
||||
!can_visit<FUNC, N, T>
|
||||
@ -309,8 +307,6 @@ TOML_START
|
||||
&& visit_is_nothrow_one<FUNC, N, time>
|
||||
&& visit_is_nothrow_one<FUNC, N, date_time>;
|
||||
|
||||
#endif
|
||||
|
||||
template <typename FUNC, typename N, typename T, bool = can_visit<FUNC, N, T>>
|
||||
struct visit_return_type final
|
||||
{
|
||||
@ -331,7 +327,7 @@ TOML_START
|
||||
|
||||
template <typename N, typename FUNC>
|
||||
static decltype(auto) do_visit(N&& n, FUNC&& visitor)
|
||||
TOML_MAY_THROW_UNLESS(visit_is_nothrow<FUNC&&, N&&>)
|
||||
noexcept(visit_is_nothrow<FUNC&&, N&&>)
|
||||
{
|
||||
static_assert(
|
||||
can_visit_any<FUNC&&, N&&>,
|
||||
@ -465,19 +461,19 @@ TOML_START
|
||||
///
|
||||
/// \see https://en.wikipedia.org/wiki/Visitor_pattern
|
||||
template <typename FUNC>
|
||||
decltype(auto) visit(FUNC&& visitor) & TOML_MAY_THROW_UNLESS(visit_is_nothrow<FUNC&&, node&>)
|
||||
decltype(auto) visit(FUNC&& visitor) & noexcept(visit_is_nothrow<FUNC&&, node&>)
|
||||
{
|
||||
return do_visit(*this, std::forward<FUNC>(visitor));
|
||||
}
|
||||
|
||||
template <typename FUNC>
|
||||
decltype(auto) visit(FUNC&& visitor) && TOML_MAY_THROW_UNLESS(visit_is_nothrow<FUNC&&, node&&>)
|
||||
decltype(auto) visit(FUNC&& visitor) && noexcept(visit_is_nothrow<FUNC&&, node&&>)
|
||||
{
|
||||
return do_visit(std::move(*this), std::forward<FUNC>(visitor));
|
||||
}
|
||||
|
||||
template <typename FUNC>
|
||||
decltype(auto) visit(FUNC&& visitor) const& TOML_MAY_THROW_UNLESS(visit_is_nothrow<FUNC&&, const node&>)
|
||||
decltype(auto) visit(FUNC&& visitor) const& noexcept(visit_is_nothrow<FUNC&&, const node&>)
|
||||
{
|
||||
return do_visit(*this, std::forward<FUNC>(visitor));
|
||||
}
|
||||
@ -522,4 +518,4 @@ TOML_START
|
||||
}
|
||||
};
|
||||
}
|
||||
TOML_END
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#pragma once
|
||||
#include "toml_node.h"
|
||||
|
||||
TOML_START
|
||||
namespace toml
|
||||
{
|
||||
TOML_INLINE_FUNC_IMPL
|
||||
node::node(node && other) noexcept
|
||||
@ -56,4 +56,4 @@ TOML_START
|
||||
|
||||
TOML_INLINE_FUNC_IMPL const source_region& node::source() const noexcept { return source_; }
|
||||
}
|
||||
TOML_END
|
||||
|
||||
|
@ -7,10 +7,10 @@
|
||||
#include "toml_array.h"
|
||||
#include "toml_value.h"
|
||||
|
||||
TOML_START
|
||||
namespace toml
|
||||
{
|
||||
template <typename CHAR, typename T>
|
||||
inline std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>&, const node_view<T>&) TOML_MAY_THROW;
|
||||
inline std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>&, const node_view<T>&);
|
||||
|
||||
/// \brief A view of a node.
|
||||
///
|
||||
@ -204,7 +204,7 @@ TOML_START
|
||||
/// \see node::visit()
|
||||
template <typename FUNC>
|
||||
decltype(auto) visit(FUNC&& visitor) const
|
||||
TOML_MAY_THROW_UNLESS(visit_is_nothrow<FUNC&&>)
|
||||
noexcept(visit_is_nothrow<FUNC&&>)
|
||||
{
|
||||
using return_type = decltype(node_->visit(std::forward<FUNC>(visitor)));
|
||||
if (node_)
|
||||
@ -339,7 +339,7 @@ TOML_START
|
||||
}
|
||||
|
||||
template <typename CHAR, typename U>
|
||||
friend std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>&, const node_view<U>&) TOML_MAY_THROW;
|
||||
friend std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>&, const node_view<U>&);
|
||||
};
|
||||
|
||||
#if !TOML_ALL_INLINE
|
||||
@ -349,16 +349,16 @@ TOML_START
|
||||
|
||||
/// \brief Prints the viewed node out to a stream.
|
||||
template <typename CHAR, typename T>
|
||||
inline std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& os, const node_view<T>& nv) TOML_MAY_THROW
|
||||
inline std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& os, const node_view<T>& nv)
|
||||
{
|
||||
if (nv.node_)
|
||||
{
|
||||
nv.node_->visit([&os](const auto& n) TOML_MAY_THROW
|
||||
{
|
||||
os << n;
|
||||
});
|
||||
nv.node_->visit([&os](const auto& n)
|
||||
{
|
||||
os << n;
|
||||
});
|
||||
}
|
||||
return os;
|
||||
}
|
||||
}
|
||||
TOML_END
|
||||
|
||||
|
@ -6,10 +6,14 @@
|
||||
#include "toml_table.h"
|
||||
#include "toml_utf8.h"
|
||||
|
||||
TOML_START
|
||||
namespace toml
|
||||
{
|
||||
#if defined(DOXYGEN) || !TOML_EXCEPTIONS
|
||||
|
||||
#if TOML_ABI_NAMESPACES
|
||||
inline namespace abi_parse_noex {
|
||||
#endif
|
||||
|
||||
/// \brief The result of a parsing operation.
|
||||
///
|
||||
/// \detail A parse_result is effectively a discriminated union containing either a toml::table
|
||||
@ -173,23 +177,47 @@ TOML_START
|
||||
}
|
||||
};
|
||||
|
||||
#if TOML_ABI_NAMESPACES
|
||||
} //end abi namespace for TOML_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
using parse_result = table;
|
||||
|
||||
#endif
|
||||
}
|
||||
TOML_END
|
||||
|
||||
TOML_IMPL_START
|
||||
|
||||
namespace toml::impl
|
||||
{
|
||||
#if TOML_ABI_NAMESPACES
|
||||
#if TOML_EXCEPTIONS
|
||||
inline namespace abi_impl_ex {
|
||||
#else
|
||||
inline namespace abi_impl_noex {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
[[nodiscard]] TOML_API
|
||||
parse_result do_parse(utf8_reader_interface&&) TOML_MAY_THROW;
|
||||
}
|
||||
TOML_IMPL_END
|
||||
|
||||
TOML_START
|
||||
#if TOML_ABI_NAMESPACES
|
||||
} //end abi namespace for TOML_EXCEPTIONS
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
namespace toml
|
||||
{
|
||||
#if TOML_ABI_NAMESPACES
|
||||
#if TOML_EXCEPTIONS
|
||||
inline namespace abi_parse_ex {
|
||||
#else
|
||||
inline namespace abi_parse_noex {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/// \brief Parses a TOML document from a string view.
|
||||
///
|
||||
/// \detail \cpp
|
||||
@ -400,6 +428,10 @@ TOML_START
|
||||
return parse_file(std::basic_string_view<CHAR>{ file_path });
|
||||
}
|
||||
|
||||
#if TOML_ABI_NAMESPACES
|
||||
} //end abi namespace for TOML_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
/// \brief Convenience literal operators for working with TOML++.
|
||||
///
|
||||
/// \detail This namespace exists so you can safely hoist the UDL operators into another scope
|
||||
@ -420,6 +452,14 @@ TOML_START
|
||||
///
|
||||
inline namespace literals
|
||||
{
|
||||
#if TOML_ABI_NAMESPACES
|
||||
#if TOML_EXCEPTIONS
|
||||
inline namespace abi_lit_ex {
|
||||
#else
|
||||
inline namespace abi_lit_noex {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/// \brief Parses TOML data from a string.
|
||||
///
|
||||
/// \detail \cpp
|
||||
@ -440,7 +480,7 @@ TOML_START
|
||||
/// \returns <strong><em>With exceptions:</em></strong> A toml::table. <br>
|
||||
/// <strong><em>Without exceptions:</em></strong> A toml::parse_result detailing the parsing outcome.
|
||||
[[nodiscard]] TOML_API
|
||||
parse_result operator"" _toml(const char* str, size_t len) noexcept;
|
||||
parse_result operator"" _toml(const char* str, size_t len) TOML_MAY_THROW;
|
||||
|
||||
#if defined(__cpp_lib_char8_t)
|
||||
|
||||
@ -466,10 +506,13 @@ TOML_START
|
||||
///
|
||||
/// \attention This overload is not available if your compiler does not support char8_t-based strings.
|
||||
[[nodiscard]] TOML_API
|
||||
parse_result operator"" _toml(const char8_t* str, size_t len) noexcept;
|
||||
parse_result operator"" _toml(const char8_t* str, size_t len) TOML_MAY_THROW;
|
||||
|
||||
#endif
|
||||
|
||||
#if TOML_ABI_NAMESPACES
|
||||
} //end abi namespace for TOML_EXCEPTIONS
|
||||
#endif
|
||||
}
|
||||
}
|
||||
TOML_END
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#pragma once
|
||||
#include "toml_parser.h"
|
||||
|
||||
TOML_IMPL_START
|
||||
namespace toml::impl
|
||||
{
|
||||
#if TOML_EXCEPTIONS
|
||||
#define TOML_ERROR_CHECK(...) (void)0
|
||||
@ -57,6 +57,14 @@ TOML_IMPL_START
|
||||
static constexpr char prefix = 'x';
|
||||
};
|
||||
|
||||
#if TOML_ABI_NAMESPACES
|
||||
#if TOML_EXCEPTIONS
|
||||
inline namespace abi_impl_ex {
|
||||
#else
|
||||
inline namespace abi_impl_noex {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
class parser final
|
||||
{
|
||||
private:
|
||||
@ -2924,11 +2932,22 @@ TOML_IMPL_START
|
||||
{
|
||||
return impl::parser{ std::move(reader) };
|
||||
}
|
||||
}
|
||||
TOML_IMPL_END
|
||||
|
||||
TOML_START
|
||||
#if TOML_ABI_NAMESPACES
|
||||
} //end abi namespace for TOML_EXCEPTIONS
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace toml
|
||||
{
|
||||
#if TOML_ABI_NAMESPACES
|
||||
#if TOML_EXCEPTIONS
|
||||
inline namespace abi_parse_ex {
|
||||
#else
|
||||
inline namespace abi_parse_noex {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
TOML_API
|
||||
TOML_INLINE_FUNC_IMPL
|
||||
parse_result parse(std::string_view doc, std::string_view source_path) TOML_MAY_THROW
|
||||
@ -2961,11 +2980,23 @@ TOML_START
|
||||
|
||||
#endif // defined(__cpp_lib_char8_t)
|
||||
|
||||
#if TOML_ABI_NAMESPACES
|
||||
} //end abi namespace for TOML_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
inline namespace literals
|
||||
{
|
||||
#if TOML_ABI_NAMESPACES
|
||||
#if TOML_EXCEPTIONS
|
||||
inline namespace abi_lit_ex {
|
||||
#else
|
||||
inline namespace abi_lit_noex {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
TOML_API
|
||||
TOML_INLINE_FUNC_IMPL
|
||||
parse_result operator"" _toml(const char* str, size_t len) noexcept
|
||||
parse_result operator"" _toml(const char* str, size_t len) TOML_MAY_THROW
|
||||
{
|
||||
return parse(std::string_view{ str, len });
|
||||
}
|
||||
@ -2974,12 +3005,16 @@ TOML_START
|
||||
|
||||
TOML_API
|
||||
TOML_INLINE_FUNC_IMPL
|
||||
parse_result operator"" _toml(const char8_t* str, size_t len) noexcept
|
||||
parse_result operator"" _toml(const char8_t* str, size_t len) TOML_MAY_THROW
|
||||
{
|
||||
return parse(std::u8string_view{ str, len });
|
||||
}
|
||||
|
||||
#endif // defined(__cpp_lib_char8_t)
|
||||
|
||||
#if TOML_ABI_NAMESPACES
|
||||
} //end abi namespace for TOML_EXCEPTIONS
|
||||
#endif
|
||||
}
|
||||
}
|
||||
TOML_END
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#pragma once
|
||||
#include "toml_date_time.h"
|
||||
|
||||
TOML_IMPL_START
|
||||
namespace toml::impl
|
||||
{
|
||||
// Q: "why does print_to_stream() exist? why not just use ostream::write(), ostream::put() etc?"
|
||||
// A: - I'm supporting C++20's char8_t as well; wrapping streams allows switching string modes transparently.
|
||||
@ -21,7 +21,7 @@ TOML_IMPL_START
|
||||
|
||||
template <typename CHAR1, typename CHAR2>
|
||||
TOML_ALWAYS_INLINE
|
||||
void print_to_stream(std::basic_string_view<CHAR1> str, std::basic_ostream<CHAR2>& stream) TOML_MAY_THROW
|
||||
void print_to_stream(std::basic_string_view<CHAR1> str, std::basic_ostream<CHAR2>& stream)
|
||||
{
|
||||
static_assert(sizeof(CHAR1) == 1);
|
||||
static_assert(sizeof(CHAR2) == 1);
|
||||
@ -30,7 +30,7 @@ TOML_IMPL_START
|
||||
|
||||
template <typename CHAR1, typename CHAR2>
|
||||
TOML_ALWAYS_INLINE
|
||||
void print_to_stream(const std::basic_string<CHAR1>& str, std::basic_ostream<CHAR2>& stream) TOML_MAY_THROW
|
||||
void print_to_stream(const std::basic_string<CHAR1>& str, std::basic_ostream<CHAR2>& stream)
|
||||
{
|
||||
static_assert(sizeof(CHAR1) == 1);
|
||||
static_assert(sizeof(CHAR2) == 1);
|
||||
@ -39,7 +39,7 @@ TOML_IMPL_START
|
||||
|
||||
template <typename CHAR>
|
||||
TOML_ALWAYS_INLINE
|
||||
void print_to_stream(char character, std::basic_ostream<CHAR>& stream) TOML_MAY_THROW
|
||||
void print_to_stream(char character, std::basic_ostream<CHAR>& stream)
|
||||
{
|
||||
static_assert(sizeof(CHAR) == 1);
|
||||
stream.put(static_cast<CHAR>(character));
|
||||
@ -47,7 +47,7 @@ TOML_IMPL_START
|
||||
|
||||
template <typename CHAR>
|
||||
TOML_GNU_ATTR(nonnull) TOML_ALWAYS_INLINE
|
||||
void print_to_stream(const char* str, size_t len, std::basic_ostream<CHAR>& stream) TOML_MAY_THROW
|
||||
void print_to_stream(const char* str, size_t len, std::basic_ostream<CHAR>& stream)
|
||||
{
|
||||
static_assert(sizeof(CHAR) == 1);
|
||||
stream.write(reinterpret_cast<const CHAR*>(str), static_cast<std::streamsize>(len));
|
||||
@ -57,7 +57,7 @@ TOML_IMPL_START
|
||||
|
||||
template <typename CHAR>
|
||||
TOML_ALWAYS_INLINE
|
||||
void print_to_stream(char8_t character, std::basic_ostream<CHAR>& stream) TOML_MAY_THROW
|
||||
void print_to_stream(char8_t character, std::basic_ostream<CHAR>& stream)
|
||||
{
|
||||
static_assert(sizeof(CHAR) == 1);
|
||||
stream.put(static_cast<CHAR>(character));
|
||||
@ -65,7 +65,7 @@ TOML_IMPL_START
|
||||
|
||||
template <typename CHAR>
|
||||
TOML_GNU_ATTR(nonnull) TOML_ALWAYS_INLINE
|
||||
void print_to_stream(const char8_t* str, size_t len, std::basic_ostream<CHAR>& stream) TOML_MAY_THROW
|
||||
void print_to_stream(const char8_t* str, size_t len, std::basic_ostream<CHAR>& stream)
|
||||
{
|
||||
static_assert(sizeof(CHAR) == 1);
|
||||
stream.write(reinterpret_cast<const CHAR*>(str), static_cast<std::streamsize>(len));
|
||||
@ -86,7 +86,7 @@ TOML_IMPL_START
|
||||
template <> inline constexpr size_t charconv_buffer_length<uint8_t> = 3; // strlen("255")
|
||||
|
||||
template <typename T, typename CHAR>
|
||||
inline void print_integer_to_stream(T val, std::basic_ostream<CHAR>& stream) TOML_MAY_THROW
|
||||
inline void print_integer_to_stream(T val, std::basic_ostream<CHAR>& stream)
|
||||
{
|
||||
static_assert(
|
||||
sizeof(CHAR) == 1,
|
||||
@ -98,13 +98,13 @@ TOML_IMPL_START
|
||||
print_to_stream(buf, static_cast<size_t>(res.ptr - buf), stream);
|
||||
}
|
||||
|
||||
#define TOML_P2S_OVERLOAD(type) \
|
||||
template <typename CHAR> \
|
||||
TOML_ALWAYS_INLINE \
|
||||
void print_to_stream(type val, std::basic_ostream<CHAR>& stream) TOML_MAY_THROW \
|
||||
{ \
|
||||
static_assert(sizeof(CHAR) == 1); \
|
||||
print_integer_to_stream(val, stream); \
|
||||
#define TOML_P2S_OVERLOAD(type) \
|
||||
template <typename CHAR> \
|
||||
TOML_ALWAYS_INLINE \
|
||||
void print_to_stream(type val, std::basic_ostream<CHAR>& stream) \
|
||||
{ \
|
||||
static_assert(sizeof(CHAR) == 1); \
|
||||
print_integer_to_stream(val, stream); \
|
||||
}
|
||||
|
||||
TOML_P2S_OVERLOAD(int8_t)
|
||||
@ -119,7 +119,7 @@ TOML_IMPL_START
|
||||
#undef TOML_P2S_OVERLOAD
|
||||
|
||||
template <typename T, typename CHAR>
|
||||
inline void print_floating_point_to_stream(T val, std::basic_ostream<CHAR>& stream, bool hexfloat = false) TOML_MAY_THROW
|
||||
inline void print_floating_point_to_stream(T val, std::basic_ostream<CHAR>& stream, bool hexfloat = false)
|
||||
{
|
||||
static_assert(
|
||||
sizeof(CHAR) == 1,
|
||||
@ -160,13 +160,13 @@ TOML_IMPL_START
|
||||
#endif
|
||||
}
|
||||
|
||||
#define TOML_P2S_OVERLOAD(type) \
|
||||
template <typename CHAR> \
|
||||
TOML_ALWAYS_INLINE \
|
||||
void print_to_stream(type val, std::basic_ostream<CHAR>& stream) TOML_MAY_THROW \
|
||||
{ \
|
||||
static_assert(sizeof(CHAR) == 1); \
|
||||
print_floating_point_to_stream(val, stream); \
|
||||
#define TOML_P2S_OVERLOAD(type) \
|
||||
template <typename CHAR> \
|
||||
TOML_ALWAYS_INLINE \
|
||||
void print_to_stream(type val, std::basic_ostream<CHAR>& stream) \
|
||||
{ \
|
||||
static_assert(sizeof(CHAR) == 1); \
|
||||
print_floating_point_to_stream(val, stream); \
|
||||
}
|
||||
|
||||
TOML_P2S_OVERLOAD(float)
|
||||
@ -176,14 +176,14 @@ TOML_IMPL_START
|
||||
|
||||
template <typename CHAR>
|
||||
TOML_ALWAYS_INLINE
|
||||
void print_to_stream(bool val, std::basic_ostream<CHAR>& stream) TOML_MAY_THROW
|
||||
void print_to_stream(bool val, std::basic_ostream<CHAR>& stream)
|
||||
{
|
||||
static_assert(sizeof(CHAR) == 1);
|
||||
print_to_stream(val ? "true"sv : "false"sv, stream);
|
||||
}
|
||||
|
||||
template <typename T, typename CHAR>
|
||||
inline void print_to_stream(T val, std::basic_ostream<CHAR>& stream, size_t zero_pad_to_digits) TOML_MAY_THROW
|
||||
inline void print_to_stream(T val, std::basic_ostream<CHAR>& stream, size_t zero_pad_to_digits)
|
||||
{
|
||||
static_assert(sizeof(CHAR) == 1);
|
||||
char buf[charconv_buffer_length<T>];
|
||||
@ -195,7 +195,7 @@ TOML_IMPL_START
|
||||
}
|
||||
|
||||
template <typename CHAR>
|
||||
inline void print_to_stream(const toml::date& val, std::basic_ostream<CHAR>& stream) TOML_MAY_THROW
|
||||
inline void print_to_stream(const toml::date& val, std::basic_ostream<CHAR>& stream)
|
||||
{
|
||||
static_assert(sizeof(CHAR) == 1);
|
||||
print_to_stream(val.year, stream, 4_sz);
|
||||
@ -206,7 +206,7 @@ TOML_IMPL_START
|
||||
}
|
||||
|
||||
template <typename CHAR>
|
||||
inline void print_to_stream(const toml::time& val, std::basic_ostream<CHAR>& stream) TOML_MAY_THROW
|
||||
inline void print_to_stream(const toml::time& val, std::basic_ostream<CHAR>& stream)
|
||||
{
|
||||
static_assert(sizeof(CHAR) == 1);
|
||||
print_to_stream(val.hour, stream, 2_sz);
|
||||
@ -229,7 +229,7 @@ TOML_IMPL_START
|
||||
}
|
||||
|
||||
template <typename CHAR>
|
||||
inline void print_to_stream(toml::time_offset val, std::basic_ostream<CHAR>& stream) TOML_MAY_THROW
|
||||
inline void print_to_stream(toml::time_offset val, std::basic_ostream<CHAR>& stream)
|
||||
{
|
||||
static_assert(sizeof(CHAR) == 1);
|
||||
if (!val.minutes)
|
||||
@ -258,7 +258,7 @@ TOML_IMPL_START
|
||||
}
|
||||
|
||||
template <typename CHAR>
|
||||
inline void print_to_stream(const toml::date_time& val, std::basic_ostream<CHAR>& stream) TOML_MAY_THROW
|
||||
inline void print_to_stream(const toml::date_time& val, std::basic_ostream<CHAR>& stream)
|
||||
{
|
||||
static_assert(sizeof(CHAR) == 1);
|
||||
print_to_stream(val.date, stream);
|
||||
@ -272,7 +272,7 @@ TOML_IMPL_START
|
||||
TOML_DISABLE_ALL_WARNINGS
|
||||
|
||||
template <typename T, typename CHAR>
|
||||
void print_to_stream_with_escapes(T && str, std::basic_ostream<CHAR>& stream) TOML_MAY_THROW
|
||||
void print_to_stream_with_escapes(T && str, std::basic_ostream<CHAR>& stream)
|
||||
{
|
||||
static_assert(sizeof(CHAR) == 1);
|
||||
for (auto c : str)
|
||||
@ -292,13 +292,32 @@ TOML_IMPL_START
|
||||
|
||||
TOML_POP_WARNINGS
|
||||
}
|
||||
TOML_IMPL_END
|
||||
|
||||
TOML_START
|
||||
|
||||
namespace toml
|
||||
{
|
||||
/// \brief Prints a source_position to a stream.
|
||||
///
|
||||
/// \detail \cpp
|
||||
/// auto tbl = toml::parse("bar = 42"sv);
|
||||
///
|
||||
/// std::cout << "The value for 'bar' was found on "sv
|
||||
/// << tbl.get("bar")->source()
|
||||
/// << std::endl;
|
||||
///
|
||||
/// \ecpp
|
||||
///
|
||||
/// \out
|
||||
/// The value for 'bar' was found on line 1, column 7
|
||||
/// \eout
|
||||
///
|
||||
/// \tparam CHAR The output stream's underlying character type. Must be 1 byte in size.
|
||||
/// \param lhs The stream.
|
||||
/// \param rhs The source_position.
|
||||
///
|
||||
/// \returns The input stream.
|
||||
template <typename CHAR>
|
||||
std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const source_position& rhs)
|
||||
TOML_MAY_THROW
|
||||
{
|
||||
static_assert(
|
||||
sizeof(CHAR) == 1,
|
||||
@ -311,9 +330,28 @@ TOML_START
|
||||
return lhs;
|
||||
}
|
||||
|
||||
/// \brief Prints a source_region to a stream.
|
||||
///
|
||||
/// \detail \cpp
|
||||
/// auto tbl = toml::parse("bar = 42", "config.toml");
|
||||
///
|
||||
/// std::cout << "The value for 'bar' was found on "sv
|
||||
/// << tbl.get("bar")->source()
|
||||
/// << std::endl;
|
||||
///
|
||||
/// \ecpp
|
||||
///
|
||||
/// \out
|
||||
/// The value for 'bar' was found on line 1, column 7 of 'config.toml'
|
||||
/// \eout
|
||||
///
|
||||
/// \tparam CHAR The output stream's underlying character type. Must be 1 byte in size.
|
||||
/// \param lhs The stream.
|
||||
/// \param rhs The source_position.
|
||||
///
|
||||
/// \returns The input stream.
|
||||
template <typename CHAR>
|
||||
std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const source_region& rhs)
|
||||
TOML_MAY_THROW
|
||||
{
|
||||
static_assert(
|
||||
sizeof(CHAR) == 1,
|
||||
@ -329,9 +367,32 @@ TOML_START
|
||||
return lhs;
|
||||
}
|
||||
|
||||
/// \brief Prints a parse_error to a stream.
|
||||
///
|
||||
/// \detail \cpp
|
||||
/// try
|
||||
/// {
|
||||
/// auto tbl = toml::parse("enabled = trUe"sv);
|
||||
/// }
|
||||
/// catch (const toml::parse_error & err)
|
||||
/// {
|
||||
/// std::cerr << "Parsing failed:\n"sv << err << std::endl;
|
||||
/// }
|
||||
/// \ecpp
|
||||
///
|
||||
/// \out
|
||||
/// Parsing failed:
|
||||
/// Encountered unexpected character while parsing boolean; expected 'true', saw 'trU'
|
||||
/// (error occurred at line 1, column 13)
|
||||
/// \eout
|
||||
///
|
||||
/// \tparam CHAR The output stream's underlying character type. Must be 1 byte in size.
|
||||
/// \param lhs The stream.
|
||||
/// \param rhs The parse_error.
|
||||
///
|
||||
/// \returns The input stream.
|
||||
template <typename CHAR>
|
||||
std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const parse_error& rhs)
|
||||
TOML_MAY_THROW
|
||||
{
|
||||
impl::print_to_stream(rhs.description(), lhs);
|
||||
impl::print_to_stream("\n\t(error occurred at "sv, lhs);
|
||||
@ -340,4 +401,4 @@ TOML_START
|
||||
return lhs;
|
||||
}
|
||||
}
|
||||
TOML_END
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#pragma once
|
||||
#include "toml_array.h"
|
||||
|
||||
TOML_IMPL_START
|
||||
namespace toml::impl
|
||||
{
|
||||
template <bool is_const>
|
||||
struct table_proxy_pair final
|
||||
@ -118,14 +118,14 @@ TOML_IMPL_START
|
||||
{}
|
||||
};
|
||||
}
|
||||
TOML_IMPL_END
|
||||
|
||||
TOML_START
|
||||
|
||||
namespace toml
|
||||
{
|
||||
[[nodiscard]] TOML_API bool operator == (const table& lhs, const table& rhs) noexcept;
|
||||
[[nodiscard]] TOML_API bool operator != (const table& lhs, const table& rhs) noexcept;
|
||||
template <typename CHAR>
|
||||
std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>&, const table&) TOML_MAY_THROW;
|
||||
std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>&, const table&);
|
||||
|
||||
/// \brief A TOML table.
|
||||
///
|
||||
@ -137,7 +137,7 @@ TOML_START
|
||||
: public node
|
||||
{
|
||||
private:
|
||||
friend class impl::parser;
|
||||
friend class TOML_PARSER_TYPENAME;
|
||||
|
||||
impl::string_map<std::unique_ptr<node>> values;
|
||||
bool inline_ = false;
|
||||
@ -733,7 +733,7 @@ TOML_START
|
||||
friend bool operator != (const table& lhs, const table& rhs) noexcept;
|
||||
|
||||
template <typename CHAR>
|
||||
friend std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>&, const table&) TOML_MAY_THROW;
|
||||
friend std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>&, const table&);
|
||||
};
|
||||
}
|
||||
TOML_END
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "toml_table.h"
|
||||
#include "toml_node_view.h"
|
||||
|
||||
TOML_START
|
||||
namespace toml
|
||||
{
|
||||
TOML_INLINE_FUNC_IMPL
|
||||
table::table(impl::table_init_pair* pairs, size_t count) noexcept
|
||||
@ -167,4 +167,4 @@ TOML_START
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
}
|
||||
TOML_END
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "toml_common.h"
|
||||
#include "toml_utf8_generated.h"
|
||||
|
||||
TOML_IMPL_START
|
||||
namespace toml::impl
|
||||
{
|
||||
[[nodiscard]] TOML_ALWAYS_INLINE
|
||||
constexpr bool is_ascii_whitespace(char32_t codepoint) noexcept
|
||||
@ -258,7 +258,7 @@ TOML_IMPL_START
|
||||
std::basic_istream<CHAR>* source;
|
||||
|
||||
public:
|
||||
explicit utf8_byte_stream(std::basic_istream<CHAR>& stream) TOML_MAY_THROW
|
||||
explicit utf8_byte_stream(std::basic_istream<CHAR>& stream)
|
||||
: source{ &stream }
|
||||
{
|
||||
if (*source)
|
||||
@ -296,7 +296,7 @@ TOML_IMPL_START
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
optional<uint8_t> operator() () TOML_MAY_THROW
|
||||
optional<uint8_t> operator() ()
|
||||
{
|
||||
auto val = source->get();
|
||||
if (val == std::basic_istream<CHAR>::traits_type::eof())
|
||||
@ -343,9 +343,15 @@ TOML_IMPL_START
|
||||
#if TOML_EXCEPTIONS
|
||||
#define TOML_ERROR_CHECK (void)0
|
||||
#define TOML_ERROR throw parse_error
|
||||
#if TOML_ABI_NAMESPACES
|
||||
inline namespace abi_impl_ex {
|
||||
#endif
|
||||
#else
|
||||
#define TOML_ERROR_CHECK if (err) return nullptr
|
||||
#define TOML_ERROR err.emplace
|
||||
#if TOML_ABI_NAMESPACES
|
||||
inline namespace abi_impl_noex {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct TOML_INTERFACE utf8_reader_interface
|
||||
@ -354,7 +360,7 @@ TOML_IMPL_START
|
||||
virtual const source_path_ptr& source_path() const noexcept = 0;
|
||||
|
||||
[[nodiscard]]
|
||||
virtual const utf8_codepoint* read_next() TOML_MAY_THROW = 0;
|
||||
virtual const utf8_codepoint* read_next() = 0;
|
||||
|
||||
#if !TOML_EXCEPTIONS
|
||||
|
||||
@ -385,7 +391,7 @@ TOML_IMPL_START
|
||||
|
||||
template <typename U, typename STR = std::string_view>
|
||||
explicit utf8_reader(U && source, STR&& source_path = {})
|
||||
TOML_MAY_THROW_UNLESS(std::is_nothrow_constructible_v<utf8_byte_stream<T>, U&&>)
|
||||
noexcept(std::is_nothrow_constructible_v<utf8_byte_stream<T>, U&&>)
|
||||
: stream{ std::forward<U>(source) }
|
||||
{
|
||||
std::memset(codepoints, 0, sizeof(codepoints));
|
||||
@ -403,7 +409,7 @@ TOML_IMPL_START
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
const utf8_codepoint* read_next() TOML_MAY_THROW override
|
||||
const utf8_codepoint* read_next() override
|
||||
{
|
||||
TOML_ERROR_CHECK;
|
||||
|
||||
@ -421,7 +427,7 @@ TOML_IMPL_START
|
||||
while (true)
|
||||
{
|
||||
optional<uint8_t> nextByte;
|
||||
if constexpr (!TOML_EXCEPTIONS || noexcept(stream()))
|
||||
if constexpr (noexcept(stream()) || !TOML_EXCEPTIONS)
|
||||
{
|
||||
nextByte = stream();
|
||||
}
|
||||
@ -547,7 +553,7 @@ TOML_IMPL_START
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
const utf8_codepoint* read_next() TOML_MAY_THROW override
|
||||
const utf8_codepoint* read_next() override
|
||||
{
|
||||
TOML_ERROR_CHECK;
|
||||
|
||||
@ -611,5 +617,8 @@ TOML_IMPL_START
|
||||
|
||||
#undef TOML_ERROR_CHECK
|
||||
#undef TOML_ERROR
|
||||
#if TOML_ABI_NAMESPACES
|
||||
} //end abi namespace for TOML_EXCEPTIONS
|
||||
#endif
|
||||
}
|
||||
TOML_IMPL_END
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
TOML_ASSUME(codepoint >= first); \
|
||||
TOML_ASSUME(codepoint <= last)
|
||||
|
||||
TOML_IMPL_START
|
||||
namespace toml::impl
|
||||
{
|
||||
//# Returns true if a codepoint belongs to any of these categories: Ll, Lm, Lo, Lt, Lu
|
||||
[[nodiscard]]
|
||||
@ -911,7 +911,7 @@ TOML_IMPL_START
|
||||
//# chunk summary: 2282 codepoints from 293 ranges (spanning a search area of 917232)
|
||||
}
|
||||
}
|
||||
TOML_IMPL_END
|
||||
|
||||
|
||||
#undef TOML_ASSUME_CODEPOINT_BETWEEN
|
||||
|
||||
|
@ -6,10 +6,10 @@
|
||||
#include "toml_node.h"
|
||||
#include "toml_print_to_stream.h"
|
||||
|
||||
TOML_START
|
||||
namespace toml
|
||||
{
|
||||
template <typename CHAR, typename T>
|
||||
std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>&, const value<T>&) TOML_MAY_THROW;
|
||||
std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>&, const value<T>&);
|
||||
|
||||
/// \brief A TOML value.
|
||||
///
|
||||
@ -30,7 +30,7 @@ TOML_START
|
||||
);
|
||||
|
||||
private:
|
||||
friend class impl::parser;
|
||||
friend class TOML_PARSER_TYPENAME;
|
||||
|
||||
template <typename U, typename V>
|
||||
[[nodiscard]] TOML_ALWAYS_INLINE
|
||||
@ -66,7 +66,7 @@ TOML_START
|
||||
/// \param args Arguments to forward to the internal value's constructor.
|
||||
template <typename... U>
|
||||
TOML_NODISCARD_CTOR
|
||||
explicit value(U&&... args) TOML_MAY_THROW_UNLESS(std::is_nothrow_constructible_v<T, U &&...>)
|
||||
explicit value(U&&... args) noexcept(std::is_nothrow_constructible_v<T, U&&...>)
|
||||
: val_{ std::forward<U>(args)... }
|
||||
{}
|
||||
|
||||
@ -168,7 +168,7 @@ TOML_START
|
||||
[[nodiscard]] explicit operator const T& () const& noexcept { return val_; }
|
||||
|
||||
template <typename CHAR, typename U>
|
||||
friend std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const value<U>& rhs) TOML_MAY_THROW;
|
||||
friend std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const value<U>& rhs);
|
||||
|
||||
/// \brief Value-assignment operator.
|
||||
value& operator= (value_arg rhs) noexcept
|
||||
@ -341,7 +341,7 @@ TOML_START
|
||||
|
||||
/// \brief Prints the value out to a stream.
|
||||
template <typename CHAR, typename T>
|
||||
inline std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const value<T>& rhs) TOML_MAY_THROW
|
||||
inline std::basic_ostream<CHAR>& operator << (std::basic_ostream<CHAR>& lhs, const value<T>& rhs)
|
||||
{
|
||||
// this is the same behaviour as default_formatter, but it's so simple that there's
|
||||
// no need to spin up a new instance of it just for individual values.
|
||||
@ -459,4 +459,4 @@ TOML_START
|
||||
return return_type{ std::forward<T>(default_value) };
|
||||
}
|
||||
}
|
||||
TOML_END
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define TOML_LIB_MAJOR 0
|
||||
#define TOML_LIB_MINOR 6
|
||||
#define TOML_LIB_MAJOR 1
|
||||
#define TOML_LIB_MINOR 0
|
||||
#define TOML_LIB_PATCH 0
|
||||
|
||||
#define TOML_LANG_MAJOR 0
|
||||
|
@ -1,7 +1,7 @@
|
||||
project(
|
||||
'tomlplusplus',
|
||||
'cpp',
|
||||
version : '0.6.0',
|
||||
version : '1.0.0',
|
||||
license : 'MIT',
|
||||
default_options : [
|
||||
'cpp_std=c++17',
|
||||
@ -40,6 +40,7 @@ if build_tests or build_examples
|
||||
add_project_arguments([
|
||||
'-g0',
|
||||
'-fmax-errors=5',
|
||||
'-march=native',
|
||||
'-Wno-init-list-lifetime'
|
||||
],
|
||||
language : 'cpp'
|
||||
@ -50,6 +51,7 @@ if build_tests or build_examples
|
||||
add_project_arguments([
|
||||
'-g0',
|
||||
'-ferror-limit=5',
|
||||
'-march=native',
|
||||
'-fchar8_t',
|
||||
# '-Weverything',
|
||||
'-Wno-c++98-compat',
|
||||
|
@ -184,12 +184,14 @@ class HTMLDocument(object):
|
||||
|
||||
|
||||
|
||||
def html_find_parent(tag,name,cutoff=None):
|
||||
def html_find_parent(tag, names, cutoff=None):
|
||||
if not is_collection(names):
|
||||
names = [ names ]
|
||||
parent = tag.parent
|
||||
while (parent is not None):
|
||||
if (cutoff is not None and parent is cutoff):
|
||||
return None
|
||||
if (parent.name == name):
|
||||
if parent.name in names:
|
||||
return parent;
|
||||
parent = parent.parent
|
||||
return parent
|
||||
|
@ -595,14 +595,14 @@ def main():
|
||||
TOML_ASSUME(codepoint >= first); \\
|
||||
TOML_ASSUME(codepoint <= last)
|
||||
|
||||
TOML_IMPL_START
|
||||
namespace toml::impl
|
||||
{''', file=output_file, end='')
|
||||
emit_function('is_unicode_letter', ('Ll', 'Lm', 'Lo', 'Lt', 'Lu'), output_file, codepoints)
|
||||
emit_function('is_unicode_number', ('Nd', 'Nl'), output_file, codepoints)
|
||||
emit_function('is_unicode_combining_mark', ('Mn', 'Mc'), output_file, codepoints)
|
||||
print(
|
||||
'''}
|
||||
TOML_IMPL_END
|
||||
|
||||
|
||||
#undef TOML_ASSUME_CODEPOINT_BETWEEN
|
||||
|
||||
|
@ -9,39 +9,39 @@ template void parse_expected_value(std::string_view, const float&) noexcept;
|
||||
template void parse_expected_value(std::string_view, const double&) noexcept;
|
||||
template void parse_expected_value(std::string_view, const toml::string_view&) noexcept;
|
||||
|
||||
TOML_IMPL_START
|
||||
namespace toml::impl
|
||||
{
|
||||
template class formatter<char>;
|
||||
}
|
||||
TOML_IMPL_END
|
||||
|
||||
TOML_START
|
||||
|
||||
namespace toml
|
||||
{
|
||||
template class default_formatter<char>;
|
||||
|
||||
template std::ostream& operator<< (std::ostream&, const table&) TOML_MAY_THROW;
|
||||
template std::ostream& operator<< (std::ostream&, const array&) TOML_MAY_THROW;
|
||||
template std::ostream& operator<< (std::ostream&, const value<string>&) TOML_MAY_THROW;
|
||||
template std::ostream& operator<< (std::ostream&, const value<int64_t>&) TOML_MAY_THROW;
|
||||
template std::ostream& operator<< (std::ostream&, const value<double>&) TOML_MAY_THROW;
|
||||
template std::ostream& operator<< (std::ostream&, const value<bool>&) TOML_MAY_THROW;
|
||||
template std::ostream& operator<< (std::ostream&, const value<date>&) TOML_MAY_THROW;
|
||||
template std::ostream& operator<< (std::ostream&, const value<time>&) TOML_MAY_THROW;
|
||||
template std::ostream& operator<< (std::ostream&, const value<date_time>&) TOML_MAY_THROW;
|
||||
template std::ostream& operator<< (std::ostream&, const node_view<node>&) TOML_MAY_THROW;
|
||||
template std::ostream& operator<< (std::ostream&, const node_view<const node>&) TOML_MAY_THROW;
|
||||
template std::ostream& operator<< (std::ostream&, node_type) TOML_MAY_THROW;
|
||||
template std::ostream& operator<< (std::ostream&, const source_region&) TOML_MAY_THROW;
|
||||
template std::ostream& operator<< (std::ostream&, const source_position&) TOML_MAY_THROW;
|
||||
template std::ostream& operator<< (std::ostream&, const parse_error&) TOML_MAY_THROW;
|
||||
template std::ostream& operator<< (std::ostream&, const date&) TOML_MAY_THROW;
|
||||
template std::ostream& operator<< (std::ostream&, const time&) TOML_MAY_THROW;
|
||||
template std::ostream& operator<< (std::ostream&, const time_offset&) TOML_MAY_THROW;
|
||||
template std::ostream& operator<< (std::ostream&, const date_time&) TOML_MAY_THROW;
|
||||
template std::ostream& operator<< (std::ostream&, default_formatter<char>&) TOML_MAY_THROW;
|
||||
template std::ostream& operator<< (std::ostream&, default_formatter<char>&&) TOML_MAY_THROW;
|
||||
template std::ostream& operator<< (std::ostream&, const table&);
|
||||
template std::ostream& operator<< (std::ostream&, const array&);
|
||||
template std::ostream& operator<< (std::ostream&, const value<string>&);
|
||||
template std::ostream& operator<< (std::ostream&, const value<int64_t>&);
|
||||
template std::ostream& operator<< (std::ostream&, const value<double>&);
|
||||
template std::ostream& operator<< (std::ostream&, const value<bool>&);
|
||||
template std::ostream& operator<< (std::ostream&, const value<date>&);
|
||||
template std::ostream& operator<< (std::ostream&, const value<time>&);
|
||||
template std::ostream& operator<< (std::ostream&, const value<date_time>&);
|
||||
template std::ostream& operator<< (std::ostream&, const node_view<node>&);
|
||||
template std::ostream& operator<< (std::ostream&, const node_view<const node>&);
|
||||
template std::ostream& operator<< (std::ostream&, node_type);
|
||||
template std::ostream& operator<< (std::ostream&, const source_region&);
|
||||
template std::ostream& operator<< (std::ostream&, const source_position&);
|
||||
template std::ostream& operator<< (std::ostream&, const parse_error&);
|
||||
template std::ostream& operator<< (std::ostream&, const date&);
|
||||
template std::ostream& operator<< (std::ostream&, const time&);
|
||||
template std::ostream& operator<< (std::ostream&, const time_offset&);
|
||||
template std::ostream& operator<< (std::ostream&, const date_time&);
|
||||
template std::ostream& operator<< (std::ostream&, default_formatter<char>&);
|
||||
template std::ostream& operator<< (std::ostream&, default_formatter<char>&&);
|
||||
}
|
||||
TOML_END
|
||||
|
||||
|
||||
template class std::unique_ptr<const Catch::IExceptionTranslator>;
|
||||
namespace Catch
|
||||
@ -59,7 +59,7 @@ namespace Catch
|
||||
|
||||
#endif // TESTS_MANUAL_INSTANTIATIONS
|
||||
|
||||
TOML_START
|
||||
namespace toml
|
||||
{
|
||||
using std::declval;
|
||||
using std::is_same_v;
|
||||
@ -87,4 +87,4 @@ TOML_START
|
||||
static_assert(is_same_v<decltype(declval<node_view<const node>>().ref<array>()), const array&>);
|
||||
|
||||
}
|
||||
TOML_END
|
||||
|
||||
|
@ -311,39 +311,39 @@ extern template void parse_expected_value(std::string_view, const float&) noexce
|
||||
extern template void parse_expected_value(std::string_view, const double&) noexcept;
|
||||
extern template void parse_expected_value(std::string_view, const toml::string_view&) noexcept;
|
||||
|
||||
TOML_IMPL_START
|
||||
namespace toml::impl
|
||||
{
|
||||
extern template class formatter<char>;
|
||||
}
|
||||
TOML_IMPL_END
|
||||
|
||||
TOML_START
|
||||
|
||||
namespace toml
|
||||
{
|
||||
extern template class default_formatter<char>;
|
||||
|
||||
extern template std::ostream& operator<< (std::ostream&, const table&) TOML_MAY_THROW;
|
||||
extern template std::ostream& operator<< (std::ostream&, const array&) TOML_MAY_THROW;
|
||||
extern template std::ostream& operator<< (std::ostream&, const value<string>&) TOML_MAY_THROW;
|
||||
extern template std::ostream& operator<< (std::ostream&, const value<int64_t>&) TOML_MAY_THROW;
|
||||
extern template std::ostream& operator<< (std::ostream&, const value<double>&) TOML_MAY_THROW;
|
||||
extern template std::ostream& operator<< (std::ostream&, const value<bool>&) TOML_MAY_THROW;
|
||||
extern template std::ostream& operator<< (std::ostream&, const value<date>&) TOML_MAY_THROW;
|
||||
extern template std::ostream& operator<< (std::ostream&, const value<time>&) TOML_MAY_THROW;
|
||||
extern template std::ostream& operator<< (std::ostream&, const value<date_time>&) TOML_MAY_THROW;
|
||||
extern template std::ostream& operator<< (std::ostream&, const node_view<node>&) TOML_MAY_THROW;
|
||||
extern template std::ostream& operator<< (std::ostream&, const node_view<const node>&) TOML_MAY_THROW;
|
||||
extern template std::ostream& operator<< (std::ostream&, node_type) TOML_MAY_THROW;
|
||||
extern template std::ostream& operator<< (std::ostream&, const source_region&) TOML_MAY_THROW;
|
||||
extern template std::ostream& operator<< (std::ostream&, const source_position&) TOML_MAY_THROW;
|
||||
extern template std::ostream& operator<< (std::ostream&, const parse_error&) TOML_MAY_THROW;
|
||||
extern template std::ostream& operator<< (std::ostream&, const date&) TOML_MAY_THROW;
|
||||
extern template std::ostream& operator<< (std::ostream&, const time&) TOML_MAY_THROW;
|
||||
extern template std::ostream& operator<< (std::ostream&, const time_offset&) TOML_MAY_THROW;
|
||||
extern template std::ostream& operator<< (std::ostream&, const date_time&) TOML_MAY_THROW;
|
||||
extern template std::ostream& operator<< (std::ostream&, default_formatter<char>&) TOML_MAY_THROW;
|
||||
extern template std::ostream& operator<< (std::ostream&, default_formatter<char>&&) TOML_MAY_THROW;
|
||||
extern template std::ostream& operator<< (std::ostream&, const table&);
|
||||
extern template std::ostream& operator<< (std::ostream&, const array&);
|
||||
extern template std::ostream& operator<< (std::ostream&, const value<string>&);
|
||||
extern template std::ostream& operator<< (std::ostream&, const value<int64_t>&);
|
||||
extern template std::ostream& operator<< (std::ostream&, const value<double>&);
|
||||
extern template std::ostream& operator<< (std::ostream&, const value<bool>&);
|
||||
extern template std::ostream& operator<< (std::ostream&, const value<date>&);
|
||||
extern template std::ostream& operator<< (std::ostream&, const value<time>&);
|
||||
extern template std::ostream& operator<< (std::ostream&, const value<date_time>&);
|
||||
extern template std::ostream& operator<< (std::ostream&, const node_view<node>&);
|
||||
extern template std::ostream& operator<< (std::ostream&, const node_view<const node>&);
|
||||
extern template std::ostream& operator<< (std::ostream&, node_type);
|
||||
extern template std::ostream& operator<< (std::ostream&, const source_region&);
|
||||
extern template std::ostream& operator<< (std::ostream&, const source_position&);
|
||||
extern template std::ostream& operator<< (std::ostream&, const parse_error&);
|
||||
extern template std::ostream& operator<< (std::ostream&, const date&);
|
||||
extern template std::ostream& operator<< (std::ostream&, const time&);
|
||||
extern template std::ostream& operator<< (std::ostream&, const time_offset&);
|
||||
extern template std::ostream& operator<< (std::ostream&, const date_time&);
|
||||
extern template std::ostream& operator<< (std::ostream&, default_formatter<char>&);
|
||||
extern template std::ostream& operator<< (std::ostream&, default_formatter<char>&&);
|
||||
}
|
||||
TOML_END
|
||||
|
||||
|
||||
extern template class std::unique_ptr<const Catch::IExceptionTranslator>;
|
||||
namespace Catch
|
||||
|
Loading…
Reference in New Issue
Block a user