minor compilation speed and binary size improvements

also:
- minor documentation fixes
This commit is contained in:
Mark Gillard 2020-04-01 15:53:10 +03:00
parent 41d05792a5
commit e260f2df79
20 changed files with 689 additions and 311 deletions

View File

@ -7,13 +7,17 @@ If you wish to submit a PR, please be aware that:
(Visual Studio 2019). All three is a bonus.
- You should regenerate the single-header file as part of your PR (a CI check will fail if you don't).
### Regenerating toml.hpp
<br>
## Regenerating toml.hpp
1. Make your changes as necessary
2. If you've added a new header file that isn't going to be transitively included by one of the
others, add an include directive to `include/toml++/toml.h`
- If you've added a new header file that isn't going to be transitively included by one of the
others, add an include directive to `include/toml++/toml.h`
3. Run `python/generate_single_header.py`
### Building and running the tests
<br>
## Building and running the tests
Testing is done using [Catch2], included in the respository as a submodule under `extern/Catch2`.
The first time you want to begin testing you'll need to ensure submodules have been fetched:
```bash
@ -21,16 +25,16 @@ git submodule update --init extern/Catch2
git submodule update --init extern/tloptional
```
#### Testing on Windows with Visual Studio
### Testing on Windows with Visual Studio
Install [Visual Studio 2019] and [Test Adapter for Catch2], then open `vs/toml++.sln` and build the
projects in the `tests` solution folder. Visual Studio's Test Explorer should pick these up and
allow you to run the tests directly.
If test discovery fails you can usually fix it by clicking enabling
If test discovery fails you can usually fix it by enabling
`Auto Detect runsettings Files` (settings gear icon > `Configure Run Settings`).
#### Testing on Linux (and WSL)
### Testing on Linux (and WSL)
Install [meson] and [ninja] if necessary, then test with both gcc and clang:
```bash
CXX=g++ meson build-gcc

View File

@ -18,7 +18,7 @@
<br>
# Example
# Basic usage
Given a TOML file `configuration.toml` containing the following:
```toml
@ -145,6 +145,18 @@ If you wish to submit a pull request, please see [CONTRIBUTING] for all the deta
UTF-8 decoding is performed using a state machine based on Bjoern Hoehrmann's '[Flexible and Economical UTF-8 Decoder]'.
<br>
# Contact
For bug reports and feature requests please consider using the [issues] system here on GitHub. For anything else
though you're welcome to reach out via other means. In order of likely response time:
- Twitter: [marzer8789](https://twitter.com/marzer8789)
- Email: [mark.gillard@outlook.com.au](mailto:mark.gillard@outlook.com.au)
- Facebook: [marzer](https://www.facebook.com/marzer)
- LinkedIn: [marzer](https://www.linkedin.com/in/marzer/)
[API documentation]: https://marzer.github.io/tomlplusplus/
[unreleased TOML language features]: #unreleased-toml-features
[numbered version]: https://github.com/toml-lang/toml/releases
@ -158,6 +170,7 @@ UTF-8 decoding is performed using a state machine based on Bjoern Hoehrmann's '[
[Flexible and Economical UTF-8 Decoder]: http://bjoern.hoehrmann.de/utf-8/decoder/dfa/
[cpp_compilers]: https://en.cppreference.com/w/cpp/compiler_support
[reporting issues]: https://github.com/marzer/tomlplusplus/issues
[issues]: https://github.com/marzer/tomlplusplus/issues
[#356]: https://github.com/toml-lang/toml/issues/356
[#516]: https://github.com/toml-lang/toml/issues/516
[#562]: https://github.com/toml-lang/toml/issues/562

View File

@ -350,10 +350,9 @@ PREDEFINED = DOXYGEN=1 \
TOML_ALWAYS_INLINE=inline \
TOML_MAY_THROW= \
TOML_NODISCARD_CTOR= \
TOML_ASYMMETRICAL_EQUALITY_OPS= \
TOML_ALL_INLINE=0 \
TOML_IMPLEMENTATION=0 \
TOML_INLINE_FUNC_IMPL= \
TOML_FUNC_EXTERNAL_LINKAGE= \
TOML_API= \
__cpp_lib_char8_t=201811L
EXPAND_AS_DEFINED =

View File

@ -31,9 +31,11 @@ a.tpp-external
{
font-weight: normal;
}
pre a.tpp-external
pre a.tpp-external,
pre a.tpp-injected
{
color: inherit;
font-weight: inherit !important;
color: inherit !important;
}
.tpp-enable-if

View File

@ -43,6 +43,7 @@
#undef TOML_DISABLE_ALL_WARNINGS
#undef TOML_POP_WARNINGS
#undef TOML_ALWAYS_INLINE
#undef TOML_NEVER_INLINE
#undef TOML_ASSUME
#undef TOML_UNREACHABLE
#undef TOML_INTERFACE
@ -67,12 +68,13 @@
#undef TOML_ASYMMETRICAL_EQUALITY_OPS
#undef TOML_ALL_INLINE
#undef TOML_IMPLEMENTATION
#undef TOML_INLINE_FUNC_IMPL
#undef TOML_FUNC_EXTERNAL_LINKAGE
#undef TOML_COMPILER_EXCEPTIONS
#undef TOML_LAUNDER
#undef TOML_TRIVIAL_ABI
#undef TOML_ABI_NAMESPACES
#undef TOML_PARSER_TYPENAME
#undef TOML_HAS_API_ANNOTATION
#endif
/// \mainpage toml++
@ -330,7 +332,7 @@
///
/// \see
/// - toml::node
/// - toml::node_view
/// - toml::node_view
/// - toml::value
/// - toml::array
/// - toml::table
@ -357,9 +359,11 @@
/// },
/// }};
///
/// // serializing as TOML is just writing it to a stream
/// std::cout << "###### TOML ######"sv << std::endl;
/// std::cout << tbl << std::endl << std::endl;
///
///
/// // serializing as JSON is _also_ just writing it to a stream, but via a json_formatter:
/// std::cout << "###### JSON ######"sv << std::endl;
/// std::cout << toml::json_formatter{ tbl } << std::endl;
/// return 0;
@ -402,11 +406,45 @@
/// - toml::default_formatter
/// - toml::json_formatter
///
///////////////////////////////////
///
/// \subsection mainpage-example-speed-up-compilation Speeding up compilation
/// Because `toml++` is a header-only library of nontrivial size you might find that compilation times noticeably
/// increase after you add it to your project, especially if you add the library's header somewhere that's visible from
/// a large number of translation units. You can counter this by disabling 'all inline' mode and explicitly controlling
/// where the library's implementation is compiled.
///
/// <strong>Step 1: Set `TOML_ALL_INLINE` to `0` before including `toml++`</strong>
///
/// This must be the same everywhere, so either set it as a global `#define` in your build system, or
/// do it manually before including toml++ in some global header that's used everywhere in your project:
/// \cpp
/// // global_header_that_includes_toml++.h
///
/// #define TOML_ALL_INLINE 0
/// #include <toml.hpp>
/// \ecpp
///
/// <strong>Step 2: Define `TOML_IMPLEMENTATION` before including `toml++` in one specific translation unit</strong>
///
/// \cpp
/// // some_code_file.cpp
///
/// #define TOML_IMPLEMENTATION
/// #include "global_header_that_includes_toml++.h"
/// \ecpp
///
/// \m_class{m-note m-default}
///
/// Your project may already have a specific header/source file pair configured as a 'precompiled header'; if so,
/// that's the ideal place to put this machinery.
///
///////////////////////////////////////////////////////////////////////
///
/// \section mainpage-contributing Contributing
/// Contributions are very welcome! Either by [reporting issues](https://github.com/marzer/tomlplusplus/issues) or submitting pull requests.
/// If you wish to submit a pull request, please see [CONTRIBUTING](https://github.com/marzer/tomlplusplus/blob/master/CONTRIBUTING.md)
/// Contributions are very welcome! Either by [reporting issues](https://github.com/marzer/tomlplusplus/issues)
/// or submitting pull requests. If you wish to submit a pull request,
/// please see [CONTRIBUTING](https://github.com/marzer/tomlplusplus/blob/master/CONTRIBUTING.md)
/// for all the details you need to get going.
///
///////////////////////////////////////////////////////////////////////
@ -421,3 +459,14 @@
/// If you're using the single-header version of the library you don't need to explicitly distribute the license file;
/// it is embedded in the preamble at the top of the header.
///
///////////////////////////////////////////////////////////////////////
///
/// \section mainpage-contact Contacting the author
/// For bug reports and feature requests please consider using the
/// [GitHub issues](https://github.com/marzer/tomlplusplus/issues) system. For anything else though you're welcome
/// to reach out via other means. In order of likely response speed:
/// - Twitter: [marzer8789](https://twitter.com/marzer8789)
/// - Email: [mark.gillard@outlook.com.au](mailto:mark.gillard@outlook.com.au)
/// - Facebook: [marzer](https://www.facebook.com/marzer)
/// - LinkedIn: [marzer](https://www.linkedin.com/in/marzer/)
///

View File

@ -155,8 +155,10 @@ namespace toml::impl
}
};
template class array_iterator<true>;
template class array_iterator<false>;
#if !TOML_ALL_INLINE && !TOML_HAS_API_ANNOTATION
extern template class array_iterator<true>;
extern template class array_iterator<false>;
#endif
template <typename T>
[[nodiscard]] TOML_ALWAYS_INLINE
@ -796,7 +798,9 @@ namespace toml
{
return container_equality(lhs, rhs);
}
TOML_ASYMMETRICAL_EQUALITY_OPS(const array&, const std::initializer_list<T>&, template <typename T>)
#ifndef DOXYGEN
TOML_ASYMMETRICAL_EQUALITY_OPS(const array&, const std::initializer_list<T>&, template <typename T>)
#endif
/// \brief Vector equality operator.
template <typename T>
@ -804,7 +808,9 @@ namespace toml
{
return container_equality(lhs, rhs);
}
TOML_ASYMMETRICAL_EQUALITY_OPS(const array&, const std::vector<T>&, template <typename T>)
#ifndef DOXYGEN
TOML_ASYMMETRICAL_EQUALITY_OPS(const array&, const std::vector<T>&, template <typename T>)
#endif
/// \brief Flattens this array, recursively hoisting the contents of child arrays up into itself.
///
@ -831,3 +837,9 @@ namespace toml
};
}
#if !TOML_ALL_INLINE && !TOML_HAS_API_ANNOTATION
namespace std
{
extern template class unique_ptr<toml::array>;
}
#endif

View File

@ -4,10 +4,13 @@
#pragma once
#include "toml_array.h"
#if !defined(TOML_IMPLEMENTATION) || !TOML_IMPLEMENTATION
#error This is an implementation-only header.
#endif
namespace toml
{
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
void array::preinsertion_resize(size_t idx, size_t count) noexcept
{
const auto new_size = values.size() + count;
@ -20,16 +23,16 @@ namespace toml
}
}
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
array::array() noexcept = default;
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
array::array(array&& other) noexcept
: node{ std::move(other) },
values{ std::move(other.values) }
{}
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
array& array::operator= (array&& rhs) noexcept
{
node::operator=(std::move(rhs));
@ -37,66 +40,66 @@ namespace toml
return *this;
}
TOML_INLINE_FUNC_IMPL node_type array::type() const noexcept { return node_type::array; }
TOML_INLINE_FUNC_IMPL bool array::is_table() const noexcept { return false; }
TOML_INLINE_FUNC_IMPL bool array::is_array() const noexcept { return true; }
TOML_INLINE_FUNC_IMPL bool array::is_value() const noexcept { return false; }
TOML_INLINE_FUNC_IMPL array* array::as_array() noexcept { return this; }
TOML_INLINE_FUNC_IMPL const array* array::as_array() const noexcept { return this; }
TOML_FUNC_EXTERNAL_LINKAGE node_type array::type() const noexcept { return node_type::array; }
TOML_FUNC_EXTERNAL_LINKAGE bool array::is_table() const noexcept { return false; }
TOML_FUNC_EXTERNAL_LINKAGE bool array::is_array() const noexcept { return true; }
TOML_FUNC_EXTERNAL_LINKAGE bool array::is_value() const noexcept { return false; }
TOML_FUNC_EXTERNAL_LINKAGE array* array::as_array() noexcept { return this; }
TOML_FUNC_EXTERNAL_LINKAGE const array* array::as_array() const noexcept { return this; }
TOML_INLINE_FUNC_IMPL node& array::operator[] (size_t index) noexcept { return *values[index]; }
TOML_INLINE_FUNC_IMPL const node& array::operator[] (size_t index) const noexcept { return *values[index]; }
TOML_FUNC_EXTERNAL_LINKAGE node& array::operator[] (size_t index) noexcept { return *values[index]; }
TOML_FUNC_EXTERNAL_LINKAGE const node& array::operator[] (size_t index) const noexcept { return *values[index]; }
TOML_INLINE_FUNC_IMPL node& array::front() noexcept { return *values.front(); }
TOML_INLINE_FUNC_IMPL const node& array::front() const noexcept { return *values.front(); }
TOML_INLINE_FUNC_IMPL node& array::back() noexcept { return *values.back(); }
TOML_INLINE_FUNC_IMPL const node& array::back() const noexcept { return *values.back(); }
TOML_FUNC_EXTERNAL_LINKAGE node& array::front() noexcept { return *values.front(); }
TOML_FUNC_EXTERNAL_LINKAGE const node& array::front() const noexcept { return *values.front(); }
TOML_FUNC_EXTERNAL_LINKAGE node& array::back() noexcept { return *values.back(); }
TOML_FUNC_EXTERNAL_LINKAGE const node& array::back() const noexcept { return *values.back(); }
TOML_INLINE_FUNC_IMPL array::iterator array::begin() noexcept { return { values.begin() }; }
TOML_INLINE_FUNC_IMPL array::const_iterator array::begin() const noexcept { return { values.begin() }; }
TOML_INLINE_FUNC_IMPL array::const_iterator array::cbegin() const noexcept { return { values.cbegin() }; }
TOML_FUNC_EXTERNAL_LINKAGE array::iterator array::begin() noexcept { return { values.begin() }; }
TOML_FUNC_EXTERNAL_LINKAGE array::const_iterator array::begin() const noexcept { return { values.begin() }; }
TOML_FUNC_EXTERNAL_LINKAGE array::const_iterator array::cbegin() const noexcept { return { values.cbegin() }; }
TOML_INLINE_FUNC_IMPL array::iterator array::end() noexcept { return { values.end() }; }
TOML_INLINE_FUNC_IMPL array::const_iterator array::end() const noexcept { return { values.end() }; }
TOML_INLINE_FUNC_IMPL array::const_iterator array::cend() const noexcept { return { values.cend() }; }
TOML_FUNC_EXTERNAL_LINKAGE array::iterator array::end() noexcept { return { values.end() }; }
TOML_FUNC_EXTERNAL_LINKAGE array::const_iterator array::end() const noexcept { return { values.end() }; }
TOML_FUNC_EXTERNAL_LINKAGE array::const_iterator array::cend() const noexcept { return { values.cend() }; }
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) { values.reserve(new_capacity); }
TOML_INLINE_FUNC_IMPL void array::clear() noexcept { values.clear(); }
TOML_FUNC_EXTERNAL_LINKAGE bool array::empty() const noexcept { return values.empty(); }
TOML_FUNC_EXTERNAL_LINKAGE size_t array::size() const noexcept { return values.size(); }
TOML_FUNC_EXTERNAL_LINKAGE void array::reserve(size_t new_capacity) { values.reserve(new_capacity); }
TOML_FUNC_EXTERNAL_LINKAGE void array::clear() noexcept { values.clear(); }
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
array::iterator array::erase(const_iterator pos) noexcept
{
return { values.erase(pos.raw_) };
}
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
array::iterator array::erase(const_iterator first, const_iterator last) noexcept
{
return { values.erase(first.raw_, last.raw_) };
}
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
void array::pop_back() noexcept
{
values.pop_back();
}
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
node* array::get(size_t index) noexcept
{
return index < values.size() ? values[index].get() : nullptr;
}
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
const node* array::get(size_t index) const noexcept
{
return index < values.size() ? values[index].get() : nullptr;
}
TOML_API
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
bool operator == (const array& lhs, const array& rhs) noexcept
{
if (&lhs == &rhs)
@ -122,13 +125,13 @@ namespace toml
}
TOML_API
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
bool operator != (const array& lhs, const array& rhs) noexcept
{
return !(lhs == rhs);
}
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
size_t array::total_leaf_count() const noexcept
{
size_t leaves{};
@ -140,7 +143,7 @@ namespace toml
return leaves;
}
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
void array::flatten_child(array&& child, size_t& dest_index) noexcept
{
for (size_t i = 0, e = child.size(); i < e; i++)
@ -157,7 +160,7 @@ namespace toml
}
}
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
void array::flatten()
{
if (values.empty())

View File

@ -24,8 +24,11 @@
#define TOML_IMPLEMENTATION 0
#endif
#ifndef TOML_API
#ifdef TOML_API
#define TOML_HAS_API_ANNOTATION 1
#else
#define TOML_API
#define TOML_HAS_API_ANNOTATION 0
#endif
#ifndef TOML_CHAR_8_STRINGS
@ -70,12 +73,16 @@
#define TOML_EMPTY_BASES __declspec(empty_bases)
#endif
#define TOML_ALWAYS_INLINE __forceinline
#define TOML_NEVER_INLINE __declspec(noinline)
#endif
#endif
#ifdef __has_attribute
#if !defined(TOML_ALWAYS_INLINE) && __has_attribute(always_inline)
#define TOML_ALWAYS_INLINE __attribute__((__always_inline__)) inline
#endif
#if !defined(TOML_NEVER_INLINE) && __has_attribute(noinline)
#define TOML_NEVER_INLINE __attribute__((__noinline__))
#endif
#if !defined(TOML_TRIVIAL_ABI) && __has_attribute(trivial_abi)
#define TOML_TRIVIAL_ABI __attribute__((__trivial_abi__))
#endif
@ -100,6 +107,7 @@
__pragma(warning(push, 0))
#define TOML_POP_WARNINGS __pragma(warning(pop))
#define TOML_ALWAYS_INLINE __forceinline
#define TOML_NEVER_INLINE __declspec(noinline)
#define TOML_ASSUME(cond) __assume(cond)
#define TOML_UNREACHABLE __assume(0)
#define TOML_INTERFACE __declspec(novtable)
@ -127,6 +135,7 @@
#define TOML_POP_WARNINGS _Pragma("GCC diagnostic pop")
#define TOML_GNU_ATTR(attr) __attribute__((attr))
#define TOML_ALWAYS_INLINE __attribute__((__always_inline__)) inline
#define TOML_NEVER_INLINE __attribute__((__noinline__))
#define TOML_UNREACHABLE __builtin_unreachable()
#if !defined(TOML_RELOPS_REORDERING) && defined(__cpp_impl_three_way_comparison)
#define TOML_RELOPS_REORDERING 1
@ -210,6 +219,9 @@
#ifndef TOML_ALWAYS_INLINE
#define TOML_ALWAYS_INLINE inline
#endif
#ifndef TOML_NEVER_INLINE
#define TOML_NEVER_INLINE
#endif
#ifndef TOML_ASSUME
#define TOML_ASSUME(cond) (void)0
#endif
@ -257,9 +269,9 @@
__VA_ARGS__ [[nodiscard]] friend bool operator != (RHS rhs, LHS lhs) noexcept { return !(lhs == rhs); }
#endif
#if TOML_ALL_INLINE
#define TOML_INLINE_FUNC_IMPL inline
#define TOML_FUNC_EXTERNAL_LINKAGE inline
#else
#define TOML_INLINE_FUNC_IMPL
#define TOML_FUNC_EXTERNAL_LINKAGE
#endif
#include "toml_version.h"
@ -903,8 +915,8 @@ namespace toml::impl
};
#define TOML_P2S_DECL(linkage, type) \
template <typename CHAR> \
#define TOML_P2S_DECL(linkage, type) \
template <typename CHAR> \
linkage void print_to_stream(type, std::basic_ostream<CHAR>&)
TOML_P2S_DECL(TOML_ALWAYS_INLINE, int8_t);

View File

@ -5,9 +5,13 @@
#pragma once
#include "toml_value.h"
#include "toml_node_view.h"
#if !defined(TOML_IMPLEMENTATION) || !TOML_IMPLEMENTATION
#error This is an implementation-only header.
#endif
namespace toml
{
// value<>
template class TOML_API value<string>;
template class TOML_API value<int64_t>;
template class TOML_API value<double>;
@ -16,7 +20,38 @@ namespace toml
template class TOML_API value<time>;
template class TOML_API value<date_time>;
// node_view
template class TOML_API node_view<node>;
template class TOML_API node_view<const node>;
// table and array iterators
#if !TOML_ALL_INLINE && !TOML_HAS_API_ANNOTATION
namespace impl
{
template struct table_proxy_pair<true>;
template struct table_proxy_pair<false>;
template class table_iterator<true>;
template class table_iterator<false>;
template class array_iterator<true>;
template class array_iterator<false>;
}
#endif
}
// unique_ptrs to various things
#if !TOML_ALL_INLINE && !TOML_HAS_API_ANNOTATION
namespace std
{
template class unique_ptr<toml::node>;
template class unique_ptr<toml::table>;
template class unique_ptr<toml::array>;
template class unique_ptr<toml::value<toml::string>>;
template class unique_ptr<toml::value<int64_t>>;
template class unique_ptr<toml::value<double>>;
template class unique_ptr<toml::value<bool>>;
template class unique_ptr<toml::value<toml::date>>;
template class unique_ptr<toml::value<toml::time>>;
template class unique_ptr<toml::value<toml::date_time>>;
}
#endif

View File

@ -519,3 +519,9 @@ namespace toml
};
}
#if !TOML_ALL_INLINE && !TOML_HAS_API_ANNOTATION
namespace std
{
extern template class unique_ptr<toml::node>;
}
#endif

View File

@ -4,10 +4,13 @@
#pragma once
#include "toml_node.h"
#if !defined(TOML_IMPLEMENTATION) || !TOML_IMPLEMENTATION
#error This is an implementation-only header.
#endif
namespace toml
{
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
node::node(node && other) noexcept
: source_{ std::move(other.source_) }
{
@ -15,7 +18,7 @@ namespace toml
other.source_.end = {};
}
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
node & node::operator= (node && rhs) noexcept
{
source_ = std::move(rhs.source_);
@ -24,36 +27,36 @@ namespace toml
return *this;
}
TOML_INLINE_FUNC_IMPL bool node::is_string() const noexcept { return false; }
TOML_INLINE_FUNC_IMPL bool node::is_integer() const noexcept { return false; }
TOML_INLINE_FUNC_IMPL bool node::is_floating_point() const noexcept { return false; }
TOML_INLINE_FUNC_IMPL bool node::is_number() const noexcept { return false; }
TOML_INLINE_FUNC_IMPL bool node::is_boolean() const noexcept { return false; }
TOML_INLINE_FUNC_IMPL bool node::is_date() const noexcept { return false; }
TOML_INLINE_FUNC_IMPL bool node::is_time() const noexcept { return false; }
TOML_INLINE_FUNC_IMPL bool node::is_date_time() const noexcept { return false; }
TOML_INLINE_FUNC_IMPL bool node::is_array_of_tables() const noexcept { return false; }
TOML_FUNC_EXTERNAL_LINKAGE bool node::is_string() const noexcept { return false; }
TOML_FUNC_EXTERNAL_LINKAGE bool node::is_integer() const noexcept { return false; }
TOML_FUNC_EXTERNAL_LINKAGE bool node::is_floating_point() const noexcept { return false; }
TOML_FUNC_EXTERNAL_LINKAGE bool node::is_number() const noexcept { return false; }
TOML_FUNC_EXTERNAL_LINKAGE bool node::is_boolean() const noexcept { return false; }
TOML_FUNC_EXTERNAL_LINKAGE bool node::is_date() const noexcept { return false; }
TOML_FUNC_EXTERNAL_LINKAGE bool node::is_time() const noexcept { return false; }
TOML_FUNC_EXTERNAL_LINKAGE bool node::is_date_time() const noexcept { return false; }
TOML_FUNC_EXTERNAL_LINKAGE bool node::is_array_of_tables() const noexcept { return false; }
TOML_INLINE_FUNC_IMPL table* node::as_table() noexcept { return nullptr; }
TOML_INLINE_FUNC_IMPL array* node::as_array() noexcept { return nullptr; }
TOML_INLINE_FUNC_IMPL value<string>* node::as_string() noexcept { return nullptr; }
TOML_INLINE_FUNC_IMPL value<int64_t>* node::as_integer() noexcept { return nullptr; }
TOML_INLINE_FUNC_IMPL value<double>* node::as_floating_point() noexcept { return nullptr; }
TOML_INLINE_FUNC_IMPL value<bool>* node::as_boolean() noexcept { return nullptr; }
TOML_INLINE_FUNC_IMPL value<date>* node::as_date() noexcept { return nullptr; }
TOML_INLINE_FUNC_IMPL value<time>* node::as_time() noexcept { return nullptr; }
TOML_INLINE_FUNC_IMPL value<date_time>* node::as_date_time() noexcept { return nullptr; }
TOML_FUNC_EXTERNAL_LINKAGE table* node::as_table() noexcept { return nullptr; }
TOML_FUNC_EXTERNAL_LINKAGE array* node::as_array() noexcept { return nullptr; }
TOML_FUNC_EXTERNAL_LINKAGE value<string>* node::as_string() noexcept { return nullptr; }
TOML_FUNC_EXTERNAL_LINKAGE value<int64_t>* node::as_integer() noexcept { return nullptr; }
TOML_FUNC_EXTERNAL_LINKAGE value<double>* node::as_floating_point() noexcept { return nullptr; }
TOML_FUNC_EXTERNAL_LINKAGE value<bool>* node::as_boolean() noexcept { return nullptr; }
TOML_FUNC_EXTERNAL_LINKAGE value<date>* node::as_date() noexcept { return nullptr; }
TOML_FUNC_EXTERNAL_LINKAGE value<time>* node::as_time() noexcept { return nullptr; }
TOML_FUNC_EXTERNAL_LINKAGE value<date_time>* node::as_date_time() noexcept { return nullptr; }
TOML_INLINE_FUNC_IMPL const table* node::as_table() const noexcept { return nullptr; }
TOML_INLINE_FUNC_IMPL const array* node::as_array() const noexcept { return nullptr; }
TOML_INLINE_FUNC_IMPL const value<string>* node::as_string() const noexcept { return nullptr; }
TOML_INLINE_FUNC_IMPL const value<int64_t>* node::as_integer() const noexcept { return nullptr; }
TOML_INLINE_FUNC_IMPL const value<double>* node::as_floating_point() const noexcept { return nullptr; }
TOML_INLINE_FUNC_IMPL const value<bool>* node::as_boolean() const noexcept { return nullptr; }
TOML_INLINE_FUNC_IMPL const value<date>* node::as_date() const noexcept { return nullptr; }
TOML_INLINE_FUNC_IMPL const value<time>* node::as_time() const noexcept { return nullptr; }
TOML_INLINE_FUNC_IMPL const value<date_time>* node::as_date_time() const noexcept { return nullptr; }
TOML_FUNC_EXTERNAL_LINKAGE const table* node::as_table() const noexcept { return nullptr; }
TOML_FUNC_EXTERNAL_LINKAGE const array* node::as_array() const noexcept { return nullptr; }
TOML_FUNC_EXTERNAL_LINKAGE const value<string>* node::as_string() const noexcept { return nullptr; }
TOML_FUNC_EXTERNAL_LINKAGE const value<int64_t>* node::as_integer() const noexcept { return nullptr; }
TOML_FUNC_EXTERNAL_LINKAGE const value<double>* node::as_floating_point() const noexcept { return nullptr; }
TOML_FUNC_EXTERNAL_LINKAGE const value<bool>* node::as_boolean() const noexcept { return nullptr; }
TOML_FUNC_EXTERNAL_LINKAGE const value<date>* node::as_date() const noexcept { return nullptr; }
TOML_FUNC_EXTERNAL_LINKAGE const value<time>* node::as_time() const noexcept { return nullptr; }
TOML_FUNC_EXTERNAL_LINKAGE const value<date_time>* node::as_date_time() const noexcept { return nullptr; }
TOML_INLINE_FUNC_IMPL const source_region& node::source() const noexcept { return source_; }
TOML_FUNC_EXTERNAL_LINKAGE const source_region& node::source() const noexcept { return source_; }
}

View File

@ -258,7 +258,9 @@ namespace toml
const auto tbl = lhs.as<table>();
return tbl && *tbl == rhs;
}
TOML_ASYMMETRICAL_EQUALITY_OPS(const node_view&, const table&, )
#ifndef DOXYGEN
TOML_ASYMMETRICAL_EQUALITY_OPS(const node_view&, const table&, )
#endif
/// \brief Returns true if the viewed node is an array with the same contents as RHS.
[[nodiscard]] friend bool operator == (const node_view& lhs, const array& rhs) noexcept
@ -268,7 +270,9 @@ namespace toml
const auto arr = lhs.as<array>();
return arr && *arr == rhs;
}
TOML_ASYMMETRICAL_EQUALITY_OPS(const node_view&, const array&, )
#ifndef DOXYGEN
TOML_ASYMMETRICAL_EQUALITY_OPS(const node_view&, const array&, )
#endif
/// \brief Returns true if the viewed node is a value with the same value as RHS.
template <typename U>
@ -279,7 +283,9 @@ namespace toml
const auto val = lhs.as<U>();
return val && *val == rhs;
}
TOML_ASYMMETRICAL_EQUALITY_OPS(const node_view&, const toml::value<U>&, template <typename U>)
#ifndef DOXYGEN
TOML_ASYMMETRICAL_EQUALITY_OPS(const node_view&, const toml::value<U>&, template <typename U>)
#endif
/// \brief Returns true if the viewed node is a value with the same value as RHS.
template <typename U, typename = std::enable_if_t<impl::is_value_or_promotable<U>>>
@ -288,11 +294,13 @@ namespace toml
const auto val = lhs.as<impl::promoted<U>>();
return val && *val == rhs;
}
TOML_ASYMMETRICAL_EQUALITY_OPS(
const node_view&,
const U&,
template <typename U, typename = std::enable_if_t<impl::is_value_or_promotable<U>>>
)
#ifndef DOXYGEN
TOML_ASYMMETRICAL_EQUALITY_OPS(
const node_view&,
const U&,
template <typename U, typename = std::enable_if_t<impl::is_value_or_promotable<U>>>
)
#endif
/// \brief Returns true if the viewed node is an array with the same contents as the RHS initializer list.
template <typename U>
@ -301,7 +309,9 @@ namespace toml
const auto arr = lhs.as<array>();
return arr && *arr == rhs;
}
TOML_ASYMMETRICAL_EQUALITY_OPS(const node_view&, const std::initializer_list<U>&, template <typename U>)
#ifndef DOXYGEN
TOML_ASYMMETRICAL_EQUALITY_OPS(const node_view&, const std::initializer_list<U>&, template <typename U>)
#endif
/// \brief Returns true if the viewed node is an array with the same contents as the RHS vector.
template <typename U>
@ -310,7 +320,9 @@ namespace toml
const auto arr = lhs.as<array>();
return arr && *arr == rhs;
}
TOML_ASYMMETRICAL_EQUALITY_OPS(const node_view&, const std::vector<U>&, template <typename U>)
#ifndef DOXYGEN
TOML_ASYMMETRICAL_EQUALITY_OPS(const node_view&, const std::vector<U>&, template <typename U>)
#endif
/// \brief Returns a view of the selected subnode.
///

View File

@ -4,6 +4,9 @@
#pragma once
#include "toml_parser.h"
#if !defined(TOML_IMPLEMENTATION) || !TOML_IMPLEMENTATION
#error This is an implementation-only header.
#endif
namespace toml::impl
{
@ -179,6 +182,7 @@ namespace toml::impl
}
}
TOML_NEVER_INLINE
void go_back(size_t count = 1_sz) noexcept
{
TOML_ERROR_CHECK();
@ -188,6 +192,7 @@ namespace toml::impl
prev_pos = cp->position;
}
TOML_NEVER_INLINE
void advance() TOML_MAY_THROW
{
TOML_ERROR_CHECK();
@ -208,6 +213,7 @@ namespace toml::impl
recording_buffer.append(cp->as_view<char>());
}
TOML_NEVER_INLINE
void start_recording(bool include_current = true) noexcept
{
TOML_ERROR_CHECK();
@ -218,6 +224,7 @@ namespace toml::impl
recording_buffer.append(cp->as_view<char>());
}
TOML_NEVER_INLINE
void stop_recording(size_t pop_bytes = 0_sz) noexcept
{
TOML_ERROR_CHECK();
@ -235,6 +242,7 @@ namespace toml::impl
}
}
TOML_NEVER_INLINE
bool consume_leading_whitespace() TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -249,6 +257,7 @@ namespace toml::impl
return consumed;
}
TOML_NEVER_INLINE
bool consume_line_break() TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -272,6 +281,7 @@ namespace toml::impl
return true;
}
TOML_NEVER_INLINE
bool consume_rest_of_line() TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -292,6 +302,7 @@ namespace toml::impl
return true;
}
TOML_NEVER_INLINE
bool consume_comment() TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -327,6 +338,7 @@ namespace toml::impl
}
[[nodiscard]]
TOML_NEVER_INLINE
bool consume_expected_sequence(std::u32string_view seq) TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -344,6 +356,7 @@ namespace toml::impl
template <typename T, size_t N>
[[nodiscard]]
TOML_NEVER_INLINE
bool consume_digit_sequence(T(&digits)[N]) TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -361,6 +374,7 @@ namespace toml::impl
template <typename T, size_t N>
[[nodiscard]]
TOML_NEVER_INLINE
size_t consume_variable_length_digit_sequence(T(&buffer)[N]) TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -379,6 +393,7 @@ namespace toml::impl
template <bool MULTI_LINE>
[[nodiscard]]
TOML_NEVER_INLINE
string parse_basic_string() TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -642,6 +657,7 @@ namespace toml::impl
template <bool MULTI_LINE>
[[nodiscard]]
TOML_NEVER_INLINE
string parse_literal_string() TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -740,6 +756,7 @@ namespace toml::impl
}
[[nodiscard]]
TOML_NEVER_INLINE
string parse_string() TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -788,6 +805,7 @@ namespace toml::impl
}
[[nodiscard]]
TOML_NEVER_INLINE
string parse_bare_key_segment() TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -809,6 +827,7 @@ namespace toml::impl
}
[[nodiscard]]
TOML_NEVER_INLINE
bool parse_bool() TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -841,6 +860,7 @@ namespace toml::impl
}
[[nodiscard]]
TOML_NEVER_INLINE
double parse_inf_or_nan() TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -891,6 +911,7 @@ namespace toml::impl
TOML_DISABLE_INIT_WARNINGS
[[nodiscard]]
TOML_NEVER_INLINE
double parse_float() TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -1052,6 +1073,7 @@ namespace toml::impl
#if TOML_LANG_HIGHER_THAN(0, 5, 0) // toml/issues/562
[[nodiscard]]
TOML_NEVER_INLINE
double parse_hex_float() TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -1250,6 +1272,7 @@ namespace toml::impl
template <int base>
[[nodiscard]]
TOML_NEVER_INLINE
int64_t parse_integer() TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -1437,6 +1460,7 @@ namespace toml::impl
}
[[nodiscard]]
TOML_NEVER_INLINE
date parse_date(bool part_of_datetime = false) TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -1545,6 +1569,7 @@ namespace toml::impl
}
[[nodiscard]]
TOML_NEVER_INLINE
time parse_time(bool part_of_datetime = false) TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -1708,6 +1733,7 @@ namespace toml::impl
}
[[nodiscard]]
TOML_NEVER_INLINE
date_time parse_date_time() TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -1825,12 +1851,13 @@ namespace toml::impl
TOML_POP_WARNINGS
[[nodiscard]]
inline std::unique_ptr<toml::array> parse_array() TOML_MAY_THROW;
std::unique_ptr<toml::array> parse_array() TOML_MAY_THROW;
[[nodiscard]]
inline std::unique_ptr<toml::table> parse_inline_table() TOML_MAY_THROW;
std::unique_ptr<toml::table> parse_inline_table() TOML_MAY_THROW;
[[nodiscard]]
TOML_NEVER_INLINE
std::unique_ptr<node> parse_value() TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -2206,6 +2233,7 @@ namespace toml::impl
};
[[nodiscard]]
TOML_NEVER_INLINE
key parse_key() TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -2269,6 +2297,7 @@ namespace toml::impl
};
[[nodiscard]]
TOML_NEVER_INLINE
key_value_pair parse_key_value_pair() TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -2312,6 +2341,7 @@ namespace toml::impl
}
[[nodiscard]]
TOML_NEVER_INLINE
table* parse_table_header() TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
@ -2523,6 +2553,7 @@ namespace toml::impl
TOML_UNREACHABLE;
}
TOML_NEVER_INLINE
void parse_key_value_pair_and_insert(table* tab) TOML_MAY_THROW
{
TOML_ERROR_CHECK();
@ -2576,6 +2607,7 @@ namespace toml::impl
);
}
TOML_NEVER_INLINE
void parse_document() TOML_MAY_THROW
{
TOML_ASSERT(cp);
@ -2724,7 +2756,8 @@ namespace toml::impl
TOML_POP_WARNINGS
};
inline std::unique_ptr<toml::array> parser::parse_array() TOML_MAY_THROW
TOML_FUNC_EXTERNAL_LINKAGE
std::unique_ptr<toml::array> parser::parse_array() TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
TOML_ASSERT(cp && *cp == U'[');
@ -2805,7 +2838,8 @@ namespace toml::impl
return arr;
}
inline std::unique_ptr<toml::table> parser::parse_inline_table() TOML_MAY_THROW
TOML_FUNC_EXTERNAL_LINKAGE
std::unique_ptr<toml::table> parser::parse_inline_table() TOML_MAY_THROW
{
TOML_ERROR_CHECK({});
TOML_ASSERT(cp && *cp == U'{');
@ -2927,7 +2961,7 @@ namespace toml::impl
#undef TOML_NORETURN
TOML_API
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
parse_result do_parse(utf8_reader_interface&& reader) TOML_MAY_THROW
{
return impl::parser{ std::move(reader) };
@ -2949,14 +2983,14 @@ namespace toml
#endif
TOML_API
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
parse_result parse(std::string_view doc, std::string_view source_path) TOML_MAY_THROW
{
return impl::do_parse(impl::utf8_reader{ doc, source_path });
}
TOML_API
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
parse_result parse(std::string_view doc, std::string&& source_path) TOML_MAY_THROW
{
return impl::do_parse(impl::utf8_reader{ doc, std::move(source_path) });
@ -2965,14 +2999,14 @@ namespace toml
#if defined(__cpp_lib_char8_t)
TOML_API
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
parse_result parse(std::u8string_view doc, std::string_view source_path) TOML_MAY_THROW
{
return impl::do_parse(impl::utf8_reader{ doc, source_path });
}
TOML_API
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
parse_result parse(std::u8string_view doc, std::string&& source_path) TOML_MAY_THROW
{
return impl::do_parse(impl::utf8_reader{ doc, std::move(source_path) });
@ -2995,7 +3029,7 @@ namespace toml
#endif
TOML_API
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
parse_result operator"" _toml(const char* str, size_t len) TOML_MAY_THROW
{
return parse(std::string_view{ str, len });
@ -3004,7 +3038,7 @@ namespace toml
#if defined(__cpp_lib_char8_t)
TOML_API
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
parse_result operator"" _toml(const char8_t* str, size_t len) TOML_MAY_THROW
{
return parse(std::u8string_view{ str, len });

View File

@ -16,6 +16,11 @@ namespace toml::impl
value_type& value;
};
#if !TOML_ALL_INLINE && !TOML_HAS_API_ANNOTATION
extern template struct table_proxy_pair<true>;
extern template struct table_proxy_pair<false>;
#endif
template <bool is_const>
class table_iterator final
{
@ -89,10 +94,10 @@ namespace toml::impl
}
};
template struct table_proxy_pair<true>;
template struct table_proxy_pair<false>;
template class table_iterator<true>;
template class table_iterator<false>;
#if !TOML_ALL_INLINE && !TOML_HAS_API_ANNOTATION
extern template class table_iterator<true>;
extern template class table_iterator<false>;
#endif
struct table_init_pair final
{
@ -737,3 +742,9 @@ namespace toml
};
}
#if !TOML_ALL_INLINE && !TOML_HAS_API_ANNOTATION
namespace std
{
extern template class unique_ptr<toml::table>;
}
#endif

View File

@ -5,10 +5,13 @@
#pragma once
#include "toml_table.h"
#include "toml_node_view.h"
#if !defined(TOML_IMPLEMENTATION) || !TOML_IMPLEMENTATION
#error This is an implementation-only header.
#endif
namespace toml
{
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
table::table(impl::table_init_pair* pairs, size_t count) noexcept
{
for (size_t i = 0; i < count; i++)
@ -20,17 +23,17 @@ namespace toml
}
}
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
table::table() noexcept {}
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
table::table(table&& other) noexcept
: node{ std::move(other) },
values{ std::move(other.values) },
inline_{ other.inline_ }
{}
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
table& table::operator = (table&& rhs) noexcept
{
node::operator=(std::move(rhs));
@ -39,57 +42,57 @@ namespace toml
return *this;
}
TOML_INLINE_FUNC_IMPL node_type table::type() const noexcept { return node_type::table; }
TOML_INLINE_FUNC_IMPL bool table::is_table() const noexcept { return true; }
TOML_INLINE_FUNC_IMPL bool table::is_array() const noexcept { return false; }
TOML_INLINE_FUNC_IMPL bool table::is_value() const noexcept { return false; }
TOML_INLINE_FUNC_IMPL table* table::as_table() noexcept { return this; }
TOML_INLINE_FUNC_IMPL const table* table::as_table() const noexcept { return this; }
TOML_INLINE_FUNC_IMPL bool table::is_inline() const noexcept { return inline_; }
TOML_INLINE_FUNC_IMPL void table::is_inline(bool val) noexcept { inline_ = val; }
TOML_FUNC_EXTERNAL_LINKAGE node_type table::type() const noexcept { return node_type::table; }
TOML_FUNC_EXTERNAL_LINKAGE bool table::is_table() const noexcept { return true; }
TOML_FUNC_EXTERNAL_LINKAGE bool table::is_array() const noexcept { return false; }
TOML_FUNC_EXTERNAL_LINKAGE bool table::is_value() const noexcept { return false; }
TOML_FUNC_EXTERNAL_LINKAGE table* table::as_table() noexcept { return this; }
TOML_FUNC_EXTERNAL_LINKAGE const table* table::as_table() const noexcept { return this; }
TOML_FUNC_EXTERNAL_LINKAGE bool table::is_inline() const noexcept { return inline_; }
TOML_FUNC_EXTERNAL_LINKAGE void table::is_inline(bool val) noexcept { inline_ = val; }
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
node_view<node> table::operator[] (string_view key) noexcept
{
return { this->get(key) };
}
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
node_view<const node> table::operator[] (string_view key) const noexcept
{
return { this->get(key) };
}
TOML_INLINE_FUNC_IMPL table::iterator table::begin() noexcept { return { values.begin() }; }
TOML_INLINE_FUNC_IMPL table::const_iterator table::begin() const noexcept { return { values.begin() }; }
TOML_INLINE_FUNC_IMPL table::const_iterator table::cbegin() const noexcept { return { values.cbegin() }; }
TOML_FUNC_EXTERNAL_LINKAGE table::iterator table::begin() noexcept { return { values.begin() }; }
TOML_FUNC_EXTERNAL_LINKAGE table::const_iterator table::begin() const noexcept { return { values.begin() }; }
TOML_FUNC_EXTERNAL_LINKAGE table::const_iterator table::cbegin() const noexcept { return { values.cbegin() }; }
TOML_INLINE_FUNC_IMPL table::iterator table::end() noexcept { return { values.end() }; }
TOML_INLINE_FUNC_IMPL table::const_iterator table::end() const noexcept { return { values.end() }; }
TOML_INLINE_FUNC_IMPL table::const_iterator table::cend() const noexcept { return { values.cend() }; }
TOML_FUNC_EXTERNAL_LINKAGE table::iterator table::end() noexcept { return { values.end() }; }
TOML_FUNC_EXTERNAL_LINKAGE table::const_iterator table::end() const noexcept { return { values.end() }; }
TOML_FUNC_EXTERNAL_LINKAGE table::const_iterator table::cend() const noexcept { return { values.cend() }; }
TOML_INLINE_FUNC_IMPL bool table::empty() const noexcept { return values.empty(); }
TOML_INLINE_FUNC_IMPL size_t table::size() const noexcept { return values.size(); }
TOML_INLINE_FUNC_IMPL void table::clear() noexcept { values.clear(); }
TOML_FUNC_EXTERNAL_LINKAGE bool table::empty() const noexcept { return values.empty(); }
TOML_FUNC_EXTERNAL_LINKAGE size_t table::size() const noexcept { return values.size(); }
TOML_FUNC_EXTERNAL_LINKAGE void table::clear() noexcept { values.clear(); }
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
table::iterator table::erase(iterator pos) noexcept
{
return { values.erase(pos.raw_) };
}
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
table::iterator table::erase(const_iterator pos) noexcept
{
return { values.erase(pos.raw_) };
}
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
table::iterator table::erase(const_iterator first, const_iterator last) noexcept
{
return { values.erase(first.raw_, last.raw_) };
}
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
bool table::erase(string_view key) noexcept
{
if (auto it = values.find(key); it != values.end())
@ -100,38 +103,38 @@ namespace toml
return false;
}
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
node* table::get(string_view key) noexcept
{
return do_get(values, key);
}
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
const node* table::get(string_view key) const noexcept
{
return do_get(values, key);
}
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
table::iterator table::find(string_view key) noexcept
{
return { values.find(key) };
}
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
table::const_iterator table::find(string_view key) const noexcept
{
return { values.find(key) };
}
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
bool table::contains(string_view key) const noexcept
{
return do_contains(values, key);
}
TOML_API
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
bool operator == (const table& lhs, const table& rhs) noexcept
{
if (&lhs == &rhs)
@ -161,7 +164,7 @@ namespace toml
}
TOML_API
TOML_INLINE_FUNC_IMPL
TOML_FUNC_EXTERNAL_LINKAGE
bool operator != (const table& lhs, const table& rhs) noexcept
{
return !(lhs == rhs);

View File

@ -189,7 +189,9 @@ namespace toml
/// \brief Value equality operator.
[[nodiscard]] friend bool operator == (const value& lhs, value_arg rhs) noexcept { return lhs.val_ == rhs; }
TOML_ASYMMETRICAL_EQUALITY_OPS(const value&, value_arg, )
#ifndef DOXYGEN
TOML_ASYMMETRICAL_EQUALITY_OPS(const value&, value_arg, )
#endif
/// \brief Value less-than operator.
[[nodiscard]] friend bool operator < (const value& lhs, value_arg rhs) noexcept { return lhs.val_ < rhs; }
@ -302,15 +304,31 @@ namespace toml
};
#if !TOML_ALL_INLINE
extern template class TOML_API value<string>;
extern template class TOML_API value<int64_t>;
extern template class TOML_API value<double>;
extern template class TOML_API value<bool>;
extern template class TOML_API value<date>;
extern template class TOML_API value<time>;
extern template class TOML_API value<date_time>;
extern template class TOML_API value<string>;
extern template class TOML_API value<int64_t>;
extern template class TOML_API value<double>;
extern template class TOML_API value<bool>;
extern template class TOML_API value<date>;
extern template class TOML_API value<time>;
extern template class TOML_API value<date_time>;
#endif
}
#if !TOML_ALL_INLINE && !TOML_HAS_API_ANNOTATION
namespace std
{
extern template class unique_ptr<toml::value<toml::string>>;
extern template class unique_ptr<toml::value<int64_t>>;
extern template class unique_ptr<toml::value<double>>;
extern template class unique_ptr<toml::value<bool>>;
extern template class unique_ptr<toml::value<toml::date>>;
extern template class unique_ptr<toml::value<toml::time>>;
extern template class unique_ptr<toml::value<toml::date_time>>;
}
#endif
namespace toml
{
template <size_t N> value(const string_char(&)[N]) -> value<string>;
template <size_t N> value(const string_char(&&)[N]) -> value<string>;
value(const string_char*) -> value<string>;
@ -333,10 +351,10 @@ namespace toml
value(time) -> value<time>;
value(date_time) -> value<date_time>;
#ifdef TOML_SMALL_FLOAT_TYPE
value(TOML_SMALL_FLOAT_TYPE) -> value<double>;
value(TOML_SMALL_FLOAT_TYPE) -> value<double>;
#endif
#ifdef TOML_SMALL_INT_TYPE
value(TOML_SMALL_INT_TYPE) -> value<int64_t>;
value(TOML_SMALL_INT_TYPE) -> value<int64_t>;
#endif
/// \brief Prints the value out to a stream.

View File

@ -6,7 +6,7 @@
#define TOML_LIB_MAJOR 1
#define TOML_LIB_MINOR 0
#define TOML_LIB_PATCH 0
#define TOML_LIB_PATCH 1
#define TOML_LANG_MAJOR 0
#define TOML_LANG_MINOR 5

View File

@ -1,7 +1,7 @@
project(
'tomlplusplus',
'cpp',
version : '1.0.0',
version : '1.0.1',
license : 'MIT',
default_options : [
'cpp_std=c++17',

456
toml.hpp

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
<RunSettings>
<!-- Configurations that affect the Test Framework -->
<RunConfiguration>
<MaxCpuCount>1</MaxCpuCount>
<MaxCpuCount>0</MaxCpuCount>
<ResultsDirectory>..\build\TestResults</ResultsDirectory><!-- Path relative to solution directory -->
<TestSessionTimeout>60000</TestSessionTimeout><!-- Milliseconds -->
</RunConfiguration>