Skip to content

Commit

Permalink
Small changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinH committed Feb 28, 2024
1 parent 32bd765 commit 3dacaef
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) 2018-2024 Dr. Colin Hirsch and Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/config/

#ifndef TAO_CONFIG_INTERNAL_EXTENSION_UTILITY_HPP
#define TAO_CONFIG_INTERNAL_EXTENSION_UTILITY_HPP
#ifndef TAO_CONFIG_INTERNAL_EXTENSION_WRAPPER_HPP
#define TAO_CONFIG_INTERNAL_EXTENSION_WRAPPER_HPP

#include <type_traits>
#include <utility>
Expand All @@ -18,12 +18,6 @@

namespace tao::config::internal
{
template< typename R >
[[nodiscard]] json_t convert_result( const pegtl::position& p, R&& r )
{
return result_traits< std::decay_t< R > >::convert( p, std::forward< R >( r ) );
}

// NOTE: We can't just make wrap() variadic the straightforward way because that would look like
// return convert_result( p, f( argument_traits< std::decay_t< As > >( in, st, em ).convert()... ) );
// and with the order of function parameter evaluation not being defined in C++ that doesn't work.
Expand Down
4 changes: 2 additions & 2 deletions include/tao/config/internal/inner_extensions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "extension_maps.hpp"
#include "extension_types.hpp"
#include "extension_utility.hpp"
#include "extension_wrapper.hpp"
#include "forward.hpp"
#include "json.hpp"
#include "json_traits.hpp"
Expand All @@ -20,7 +20,7 @@ namespace tao::config::internal
[[nodiscard]] inline json_t do_inner_extension( pegtl_input_t& in, state& st, const extension_maps& em )
{
if( parse_open( in ) ) {
const std::string name = parse_extension( in );
const std::string name = parse_name( in );
{
const auto i = em.inner.find( name );
if( i != em.inner.end() ) {
Expand Down
4 changes: 2 additions & 2 deletions include/tao/config/internal/member_extensions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "extension_maps.hpp"
#include "extension_types.hpp"
#include "extension_utility.hpp"
#include "extension_wrapper.hpp"
#include "key1_guard.hpp"
#include "parse_utility.hpp"
#include "state.hpp"
Expand All @@ -15,7 +15,7 @@ namespace tao::config::internal
{
[[nodiscard]] inline bool do_member_extension( pegtl_input_t& in, state& st, const extension_maps& em )
{
const std::string name = parse_extension( in );
const std::string name = parse_name( in );
{
const auto i = em.member.find( name );
if( i != em.member.end() ) {
Expand Down
5 changes: 3 additions & 2 deletions include/tao/config/internal/parse_utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
#ifndef TAO_CONFIG_INTERNAL_PARSE_UTILITY_HPP
#define TAO_CONFIG_INTERNAL_PARSE_UTILITY_HPP

#include <optional>
#include <string>
#include <utility>

#include "extension_action.hpp"
#include "extension_grammar.hpp"
#include "forward.hpp"
#include "jaxn_action.hpp"
#include "json.hpp"
#include "json_to_value.hpp"
Expand Down Expand Up @@ -66,7 +67,7 @@ namespace tao::config::internal
return result;
}

[[nodiscard]] inline std::string parse_extension( pegtl_input_t& in )
[[nodiscard]] inline std::string parse_name( pegtl_input_t& in )
{
std::string result;
pegtl::parse< pegtl::must< rules::wss, rules::extension_rule, rules::wss >, extension_action >( in, result );
Expand Down
8 changes: 8 additions & 0 deletions include/tao/config/internal/result_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <string>
#include <string_view>
#include <type_traits>
#include <utility>

#include "forward.hpp"
#include "json.hpp"
Expand Down Expand Up @@ -58,6 +60,12 @@ namespace tao::config::internal
}
};

template< typename R >
[[nodiscard]] json_t convert_result( const pegtl::position& p, R&& r )
{
return result_traits< std::decay_t< R > >::convert( p, std::forward< R >( r ) );
}

} // namespace tao::config::internal

#endif
4 changes: 2 additions & 2 deletions include/tao/config/internal/value_extensions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "concat.hpp"
#include "config_action.hpp"
#include "extension_maps.hpp"
#include "extension_utility.hpp"
#include "extension_wrapper.hpp"
#include "forward.hpp"
#include "parse_utility.hpp"
#include "pegtl.hpp"
Expand All @@ -20,7 +20,7 @@ namespace tao::config::internal
{
[[nodiscard]] inline bool do_value_extension( pegtl_input_t& in, state& st, const extension_maps& em )
{
const std::string name = parse_extension( in );
const std::string name = parse_name( in );
{
const auto i = em.value.find( name );
if( i != em.value.end() ) {
Expand Down

0 comments on commit 3dacaef

Please sign in to comment.