Skip to content

Commit

Permalink
fixed inconsistent error messages for overlong ints/floats (closes #133)
Browse files Browse the repository at this point in the history
also:
- added `at_path()` (closes #118)
- added `node_view::operator==`
- updated conformance tests
  • Loading branch information
marzer committed Jan 7, 2022
1 parent 47241d0 commit 3f4a540
Show file tree
Hide file tree
Showing 61 changed files with 1,392 additions and 336 deletions.
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ AttributeMacros:
- TOML_CLOSED_FLAGS_ENUM
- TOML_EMPTY_BASES
- TOML_FLAGS_ENUM
- TOML_LIKELY_CASE
- TOML_OPEN_ENUM
- TOML_OPEN_FLAGS_ENUM
- TOML_TRIVIAL_ABI
- TOML_UNLIKELY_CASE
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
Expand Down
39 changes: 21 additions & 18 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,35 @@ template:

## Unreleased

This release will be a major version bump, so it's ABI breaks all around. Any API changes that might necessitate
code changes at callsites or in build systems are indicated with ⚠️.
This release will be a major version bump, so it's ABI breaks all around.
Any changes that might cause code or build systems to break are indicated with ⚠️.

Highlights are indicated with ❤️.

#### Fixes:
-️ fixed incorrect `noexcept` specifications on many functions
-️ fixed `toml::table` init-list constructor requiring double-brackets
-️ fixed `TOML_API` + extern templates causing linker errors in some circumstances
-️ fixed incorrect `noexcept` specifications on many functions
-️ fixed missing `TOML_API` on some interfaces
- fixed `toml::json_formatter` not formatting inf and nan incorrectly
- fixed `TOML_API` + extern templates causing linker errors in some circumstances
- fixed a number of spec conformance issues (#127, #128, #129, #130, #131, #132) (@moorereason)
- fixed an illegal table redefinition edge case (#112) (@python36)
- fixed documentation issues
- fixed incorrect source position in redefinition error messages
- fixed incorrect handling of vertical whitespace in keys when printing TOML to streams
- fixed incorrect source position in redefinition error messages
- fixed memory leak during parse failures when compiled using GCC (#123, #124) (@rsmmr, @ronalabraham)
- fixed missing `#include <initializer_list>`
- fixed missing `#include <utility>`
- fixed missing `TOML_API` on interfaces
- fixed parser not correctly round-tripping the format of binary and octal integers in some cases
- fixed strong exception guarantee edge-cases in `toml::table` and `toml::array`
- fixed some incorrect unicode scalar sequence transformations (#125)
- fixed a number of spec conformance issues (#127, #128, #129, #130, #131, #132) (@moorereason)
- fixed strong exception guarantee edge-cases in `toml::table` and `toml::array`

#### Additions:
- added `operator->` to `toml::value` for class types
-&#xFE0F; added `operator->` to `toml::value` for class types
-&#xFE0F; added `toml::at_path()`, `toml::node::at_path()` and `toml::node_view::at_path()` for qualified path-based lookups (#118) (@ben-crowhurst)
-&#xFE0F; added `toml::key` - provides a facility to access the source_regions of parsed keys (#82) (@vaartis)
-&#xFE0F; added `toml::yaml_formatter`
-&#xFE0F; added support for Unicode 14.0
- added `parse_benchmark` example
- added `toml::array::at()` (same semantics as `std::vector::at()`)
- added `toml::array::prune()`
Expand All @@ -51,22 +57,19 @@ code changes at callsites or in build systems are indicated with ⚠&#xFE0F;.
- added `toml::format_flags::allow_octal_integers`
- added `toml::format_flags::allow_real_tabs_in_strings`
- added `toml::format_flags::allow_unicode_strings`
- added `toml::format_flags::indent_array_elements`
- added `toml::format_flags::indent_sub_tables`
- added `toml::format_flags::indent_array_elements` (#120) (@W4RH4WK)
- added `toml::format_flags::indent_sub_tables` (#120) (@W4RH4WK)
- added `toml::format_flags::quote_infinities_and_nans`
- added `toml::key` - provides a facility to access the source_regions of parsed keys (#82) (@vaartis)
- added `toml::is_key<>` and toml::is_key_or_convertible<>` metafunctions
- added `toml::node_view::operator==`
- added `toml::table::at()` (same semantics as `std::map::at()`)
- added `toml::table::emplace_hint()` (same semantics as `std::map::emplace_hint()`)
- added `toml::table::lower_bound()` (same semantics as `std::map::lower_bound()`)
- added `toml::table::prune()`
- added `toml::value` copy+move constructor overloads with flags override
- added `toml::yaml_formatter`
- added `TOML_ENABLE_FORMATTERS` option
- added clang's enum annotation attributes to all enums
- added formatter indentation flags (#120) (@W4RH4WK)
- added magic `toml::value_flags` constant `toml::preserve_source_value_flags`
- added support for Unicode 14.0
- added value flags to array + table insert methods (#44) (@levicki)

#### Changes:
Expand All @@ -79,14 +82,14 @@ code changes at callsites or in build systems are indicated with ⚠&#xFE0F;.
-&#xFE0F; renamed `TOML_PARSER` option to `TOML_ENABLE_PARSER` (`TOML_PARSER` will continue to work but is deprecated)
-&#xFE0F; renamed `TOML_UNRELEASED_FEATURES` to `TOML_ENABLE_UNRELEASED_FEATURES` (`TOML_UNRELEASED_FEATURES` will continue to work but is deprecated)
-&#xFE0F; renamed `TOML_WINDOWS_COMPAT` to `TOML_ENABLE_WINDOWS_COMPAT` (`TOML_WINDOWS_COMPAT` will continue to work but is deprecated)
- `toml::node::ref()` now supports explicit ref categories and cv-qualifiers
- applied clang-format to all the things 🎉&#xFE0F;
-&#xFE0F; `toml::node::ref()` now supports explicit ref categories and cv-qualifiers
-&#xFE0F; applied clang-format to all the things 🎉&#xFE0F;
- exposed `TOML_NAMESPACE_START` and `TOML_NAMESPACE_END` macros to help with ADL specialization scenarios
- improved performance of parser
- made date/time constructors accept any integral types
- moved all implementation headers to `/impl`
- renamed all implementation headers to `.h` and 'source' headers to `.inl`
- updated conformance tests
- exposed `TOML_NAMESPACE_START` and `TOML_NAMESPACE_END` macros to help with ADL specialization scenarios

#### Removals:
-&#xFE0F; removed `toml::format_flags::allow_value_format_flags`
Expand Down
2 changes: 2 additions & 0 deletions cpp.hint
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@
#define TOML_RETURNS_BY_THROWING
#define TOML_TRIVIAL_ABI
#define TOML_UNLIKELY(...) (__VA_ARGS__)
#define TOML_LIKELY_CASE
#define TOML_UNLIKELY_CASE
2 changes: 1 addition & 1 deletion examples/error_printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ namespace
R"(val = 01 )"sv,

"########## floats"sv,
R"(val = 9999999999999999999999999999999999999999999999999999999999999995.0)"sv,
R"(val = 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0)"sv,
};

inline constexpr auto divider =
Expand Down
2 changes: 1 addition & 1 deletion external/toml-test
82 changes: 82 additions & 0 deletions include/toml++/impl/at_path.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//# This file is a part of toml++ and is subject to the the terms of the MIT license.
//# Copyright (c) Mark Gillard <mark.gillard@outlook.com.au>
//# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
// SPDX-License-Identifier: MIT
#pragma once

#include "forward_declarations.h"

TOML_NAMESPACE_START
{
/// \brief Returns a view of the node matching a fully-qualified "TOML path".
///
/// \detail \cpp
/// auto config = R"(
///
/// [foo]
/// bar = [ 0, 1, 2, [ 3 ], { kek = 4 } ]
///
/// )"_toml;
///
/// std::cout << toml::at_path(config, "foo.bar[2]") << "\n";
/// std::cout << toml::at_path(config, "foo.bar[3][0]") << "\n";
/// std::cout << toml::at_path(config, "foo.bar[4].kek") << "\n";
/// \ecpp
///
/// \out
/// 2
/// 3
/// 4
/// \eout
///
///
/// \warning Keys in paths are interpreted literally, so whitespace (or lack thereof) matters:
/// \cpp
/// toml::at_path(config, "foo.bar") // same as config["foo"]["bar"]
/// toml::at_path(config, "foo. bar") // same as config["foo"][" bar"]
/// toml::at_path(config, "foo..bar") // same as config["foo"][""]["bar"]
/// toml::at_path(config, ".foo.bar") // same as config[""]["foo"]["bar"]
/// \ecpp
/// <br>
/// Additionally, TOML allows '.' (period) characters to appear in keys if they are quoted strings.
/// This function makes no allowance for this this, instead treating all period characters as sub-table delimiters.
/// If you have periods in your table keys, first consider:
/// 1. Not doing that
/// 2. Using node_view::operator[] instead.
///
/// \param root The root node from which the path will be traversed.
/// \param path The "TOML path" to traverse.
TOML_NODISCARD
TOML_API
node_view<node> at_path(node & root, std::string_view path) noexcept;

/// \brief Returns a const view of the node matching a fully-qualified "TOML path".
///
/// \see #toml::at_path(node&, std::string_view)
TOML_NODISCARD
TOML_API
node_view<const node> at_path(const node& root, std::string_view path) noexcept;

#if TOML_ENABLE_WINDOWS_COMPAT

/// \brief Returns a view of the node matching a fully-qualified "TOML path".
///
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \see #toml::at_path(node&, std::string_view)
TOML_NODISCARD
TOML_API
node_view<node> at_path(node & root, std::wstring_view path);

/// \brief Returns a const view of the node matching a fully-qualified "TOML path".
///
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \see #toml::at_path(node&, std::string_view)
TOML_NODISCARD
TOML_API
node_view<const node> at_path(const node& root, std::wstring_view path);

#endif
}
TOML_NAMESPACE_END;
Loading

0 comments on commit 3f4a540

Please # to comment.