diff --git a/external/PEGTL b/external/PEGTL index 464d866d..788f223e 160000 --- a/external/PEGTL +++ b/external/PEGTL @@ -1 +1 @@ -Subproject commit 464d866d8bbf4c8ddc5b67422d09b60ad3b918fc +Subproject commit 788f223ee7c8377f78966c87d60b91188e3df33a diff --git a/include/tao/json/cbor/consume_file.hpp b/include/tao/json/cbor/consume_file.hpp index 9d19e30c..a8c0bb1d 100644 --- a/include/tao/json/cbor/consume_file.hpp +++ b/include/tao/json/cbor/consume_file.hpp @@ -4,9 +4,9 @@ #ifndef TAO_JSON_CBOR_CONSUME_FILE_HPP #define TAO_JSON_CBOR_CONSUME_FILE_HPP -#include +#include -#include "../internal/filesystem.hpp" +#include #include "../consume.hpp" #include "../forward.hpp" @@ -16,14 +16,14 @@ namespace tao::json::cbor { template< typename T, template< typename... > class Traits = traits > - [[nodiscard]] T consume_file( const json::internal::filesystem::path& path ) + [[nodiscard]] T consume_file( const std::filesystem::path& path ) { cbor::basic_parts_parser< utf8_mode::check, 8, pegtl::file_input< pegtl::tracking_mode::lazy > > pp( path ); return json::consume< T, Traits >( pp ); } template< template< typename... > class Traits = traits, typename T > - void consume_file( const json::internal::filesystem::path& path, T& t ) + void consume_file( const std::filesystem::path& path, T& t ) { cbor::basic_parts_parser< utf8_mode::check, 8, pegtl::file_input< pegtl::tracking_mode::lazy > > pp( path ); json::consume< Traits >( pp, t ); diff --git a/include/tao/json/cbor/events/from_file.hpp b/include/tao/json/cbor/events/from_file.hpp index cb18a86c..967f2a6d 100644 --- a/include/tao/json/cbor/events/from_file.hpp +++ b/include/tao/json/cbor/events/from_file.hpp @@ -4,11 +4,11 @@ #ifndef TAO_JSON_CBOR_EVENTS_FROM_FILE_HPP #define TAO_JSON_CBOR_EVENTS_FROM_FILE_HPP +#include + #include #include -#include "../../internal/filesystem.hpp" - #include "../internal/grammar.hpp" namespace tao::json::cbor::events @@ -16,7 +16,7 @@ namespace tao::json::cbor::events // Events producer to parse a file containing a CBOR string representation. template< typename Consumer > - void from_file( Consumer& consumer, const json::internal::filesystem::path& path ) + void from_file( Consumer& consumer, const std::filesystem::path& path ) { pegtl::file_input< pegtl::tracking_mode::lazy > in( path ); pegtl::parse< internal::grammar >( in, consumer ); diff --git a/include/tao/json/cbor/from_file.hpp b/include/tao/json/cbor/from_file.hpp index e5b5fca4..2e24c4f4 100644 --- a/include/tao/json/cbor/from_file.hpp +++ b/include/tao/json/cbor/from_file.hpp @@ -4,18 +4,18 @@ #ifndef TAO_JSON_CBOR_FROM_FILE_HPP #define TAO_JSON_CBOR_FROM_FILE_HPP +#include #include #include "../events/to_value.hpp" #include "../events/transformer.hpp" -#include "../internal/filesystem.hpp" #include "events/from_file.hpp" namespace tao::json::cbor { template< template< typename... > class Traits, template< typename... > class... Transformers > - [[nodiscard]] basic_value< Traits > basic_from_file( const json::internal::filesystem::path& path ) + [[nodiscard]] basic_value< Traits > basic_from_file( const std::filesystem::path& path ) { json::events::transformer< json::events::to_basic_value< Traits >, Transformers... > consumer; events::from_file( consumer, path ); @@ -23,7 +23,7 @@ namespace tao::json::cbor } template< template< typename... > class... Transformers > - [[nodiscard]] value from_file( const json::internal::filesystem::path& path ) + [[nodiscard]] value from_file( const std::filesystem::path& path ) { return basic_from_file< traits, Transformers... >( path ); } diff --git a/include/tao/json/cbor/parts_parser.hpp b/include/tao/json/cbor/parts_parser.hpp index 63ffb184..b097b7d9 100644 --- a/include/tao/json/cbor/parts_parser.hpp +++ b/include/tao/json/cbor/parts_parser.hpp @@ -375,7 +375,7 @@ namespace tao::json::cbor [[nodiscard]] auto mark() { - return m_input.template mark< pegtl::rewind_mode::required >(); + return m_input.template auto_rewind< pegtl::rewind_mode::required >(); } template< typename T > diff --git a/include/tao/json/consume_file.hpp b/include/tao/json/consume_file.hpp index 32b375de..80f56545 100644 --- a/include/tao/json/consume_file.hpp +++ b/include/tao/json/consume_file.hpp @@ -4,9 +4,9 @@ #ifndef TAO_JSON_CONSUME_FILE_HPP #define TAO_JSON_CONSUME_FILE_HPP -#include +#include -#include "internal/filesystem.hpp" +#include #include "consume.hpp" #include "forward.hpp" @@ -15,14 +15,14 @@ namespace tao::json { template< typename T, template< typename... > class Traits = traits > - [[nodiscard]] T consume_file( const internal::filesystem::path& path ) + [[nodiscard]] T consume_file( const std::filesystem::path& path ) { basic_parts_parser< pegtl::file_input< pegtl::tracking_mode::lazy > > pp( path ); return consume< T, Traits >( pp ); } template< template< typename... > class Traits = traits, typename T > - void consume_file( const internal::filesystem::path& path, T& t ) + void consume_file( const std::filesystem::path& path, T& t ) { basic_parts_parser< pegtl::file_input< pegtl::tracking_mode::lazy > > pp( path ); consume< Traits >( pp, t ); diff --git a/include/tao/json/contrib/position.hpp b/include/tao/json/contrib/position.hpp index 94b80f40..b461470c 100644 --- a/include/tao/json/contrib/position.hpp +++ b/include/tao/json/contrib/position.hpp @@ -4,6 +4,7 @@ #ifndef TAO_JSON_CONTRIB_POSITION_HPP #define TAO_JSON_CONTRIB_POSITION_HPP +#include #include #include #include @@ -11,7 +12,6 @@ #include "../events/to_value.hpp" #include "../events/transformer.hpp" -#include "../internal/filesystem.hpp" #include "../from_file.hpp" #include "../message_extension.hpp" @@ -147,7 +147,7 @@ namespace tao::json }; template< template< typename... > class Traits, template< typename... > class... Transformers > - [[nodiscard]] auto basic_from_file_with_position( const internal::filesystem::path& path ) + [[nodiscard]] auto basic_from_file_with_position( const std::filesystem::path& path ) { events::transformer< events::to_basic_value< Traits >, Transformers... > consumer; pegtl::file_input< pegtl::tracking_mode::eager > in( path ); @@ -156,7 +156,7 @@ namespace tao::json } template< template< typename... > class... Transformers > - [[nodiscard]] auto from_file_with_position( const internal::filesystem::path& path ) + [[nodiscard]] auto from_file_with_position( const std::filesystem::path& path ) { return basic_from_file_with_position< make_position_traits< traits >::template type, Transformers... >( path ); } diff --git a/include/tao/json/events/from_file.hpp b/include/tao/json/events/from_file.hpp index 1df9861a..d3df2f96 100644 --- a/include/tao/json/events/from_file.hpp +++ b/include/tao/json/events/from_file.hpp @@ -4,9 +4,10 @@ #ifndef TAO_JSON_EVENTS_FROM_FILE_HPP #define TAO_JSON_EVENTS_FROM_FILE_HPP +#include + #include "../internal/action.hpp" #include "../internal/errors.hpp" -#include "../internal/filesystem.hpp" #include "../internal/grammar.hpp" #include @@ -17,7 +18,7 @@ namespace tao::json::events // Events producer to parse a file containing a JSON string representation. template< typename Consumer > - void from_file( Consumer& consumer, const internal::filesystem::path& path ) + void from_file( Consumer& consumer, const std::filesystem::path& path ) { pegtl::file_input< pegtl::tracking_mode::lazy > in( path ); pegtl::parse< internal::grammar, internal::action, internal::errors >( in, consumer ); diff --git a/include/tao/json/from_file.hpp b/include/tao/json/from_file.hpp index 5a9c3836..2e49bf02 100644 --- a/include/tao/json/from_file.hpp +++ b/include/tao/json/from_file.hpp @@ -4,17 +4,17 @@ #ifndef TAO_JSON_FROM_FILE_HPP #define TAO_JSON_FROM_FILE_HPP +#include #include #include "events/from_file.hpp" #include "events/to_value.hpp" #include "events/transformer.hpp" -#include "internal/filesystem.hpp" namespace tao::json { template< template< typename... > class Traits, template< typename... > class... Transformers > - [[nodiscard]] basic_value< Traits > basic_from_file( const internal::filesystem::path& path ) + [[nodiscard]] basic_value< Traits > basic_from_file( const std::filesystem::path& path ) { events::transformer< events::to_basic_value< Traits >, Transformers... > consumer; events::from_file( consumer, path ); @@ -22,7 +22,7 @@ namespace tao::json } template< template< typename... > class... Transformers > - [[nodiscard]] value from_file( const internal::filesystem::path& path ) + [[nodiscard]] value from_file( const std::filesystem::path& path ) { return basic_from_file< traits, Transformers... >( path ); } diff --git a/include/tao/json/internal/filesystem.hpp b/include/tao/json/internal/filesystem.hpp deleted file mode 100644 index a29f827b..00000000 --- a/include/tao/json/internal/filesystem.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/json/ - -#ifndef TAO_JSON_INTERNAL_FILESYSTEM_HPP -#define TAO_JSON_INTERNAL_FILESYSTEM_HPP - -#include - -namespace tao::json::internal -{ - namespace filesystem = pegtl::internal::filesystem; - -} // namespace tao::json::internal - -#endif diff --git a/include/tao/json/internal/grammar.hpp b/include/tao/json/internal/grammar.hpp index 5d775a6f..7276538a 100644 --- a/include/tao/json/internal/grammar.hpp +++ b/include/tao/json/internal/grammar.hpp @@ -166,7 +166,7 @@ namespace tao::json::internal [[nodiscard]] static bool match_number( Input& in, States&&... st ) { if( in.peek_char() == '0' ) { - if( !match_zero< NEG, A, rewind_mode::dontcare, Action, Control >( in, st... ) ) { + if( !match_zero< NEG, A, rewind_mode::optional, Action, Control >( in, st... ) ) { throw pegtl::parse_error( "incomplete number", in ); } return true; @@ -192,7 +192,7 @@ namespace tao::json::internal case '-': in.bump_in_this_line(); - if( in.empty() || !match_number< true, A, rewind_mode::dontcare, Action, Control >( in, st... ) ) { + if( in.empty() || !match_number< true, A, rewind_mode::optional, Action, Control >( in, st... ) ) { throw pegtl::parse_error( "incomplete number", in ); } return true; diff --git a/include/tao/json/jaxn/consume_file.hpp b/include/tao/json/jaxn/consume_file.hpp index 71bbfd4b..e4b2f0c5 100644 --- a/include/tao/json/jaxn/consume_file.hpp +++ b/include/tao/json/jaxn/consume_file.hpp @@ -4,9 +4,9 @@ #ifndef TAO_JSON_JAXN_CONSUME_FILE_HPP #define TAO_JSON_JAXN_CONSUME_FILE_HPP -#include +#include -#include "../internal/filesystem.hpp" +#include #include "../consume.hpp" #include "../forward.hpp" @@ -16,14 +16,14 @@ namespace tao::json::jaxn { template< typename T, template< typename... > class Traits = traits > - [[nodiscard]] T consume_file( const json::internal::filesystem::path& path ) + [[nodiscard]] T consume_file( const std::filesystem::path& path ) { jaxn::basic_parts_parser< pegtl::file_input< pegtl::tracking_mode::lazy > > pp( path ); return json::consume< T, Traits >( pp ); } template< template< typename... > class Traits = traits, typename T > - void consume_file( const json::internal::filesystem::path& path, T& t ) + void consume_file( const std::filesystem::path& path, T& t ) { jaxn::basic_parts_parser< pegtl::file_input< pegtl::tracking_mode::lazy > > pp( path ); json::consume< Traits >( pp, t ); diff --git a/include/tao/json/jaxn/events/from_file.hpp b/include/tao/json/jaxn/events/from_file.hpp index 3fc6f7d4..500e33b2 100644 --- a/include/tao/json/jaxn/events/from_file.hpp +++ b/include/tao/json/jaxn/events/from_file.hpp @@ -4,6 +4,8 @@ #ifndef TAO_JSON_JAXN_EVENTS_FROM_FILE_HPP #define TAO_JSON_JAXN_EVENTS_FROM_FILE_HPP +#include + #include #include @@ -11,14 +13,12 @@ #include "../internal/errors.hpp" #include "../internal/grammar.hpp" -#include "../../internal/filesystem.hpp" - namespace tao::json::jaxn::events { // Events producer to parse a file containing a JAXN string representation. template< typename Consumer > - void from_file( Consumer& consumer, const json::internal::filesystem::path& path ) + void from_file( Consumer& consumer, const std::filesystem::path& path ) { pegtl::file_input< pegtl::tracking_mode::lazy > in( path ); pegtl::parse< internal::grammar, internal::action, internal::errors >( in, consumer ); diff --git a/include/tao/json/jaxn/from_file.hpp b/include/tao/json/jaxn/from_file.hpp index ec8aa65e..2aa28eb8 100644 --- a/include/tao/json/jaxn/from_file.hpp +++ b/include/tao/json/jaxn/from_file.hpp @@ -4,18 +4,18 @@ #ifndef TAO_JSON_JAXN_FROM_FILE_HPP #define TAO_JSON_JAXN_FROM_FILE_HPP +#include #include #include "../events/to_value.hpp" #include "../events/transformer.hpp" -#include "../internal/filesystem.hpp" #include "events/from_file.hpp" namespace tao::json::jaxn { template< template< typename... > class Traits, template< typename... > class... Transformers > - [[nodiscard]] basic_value< Traits > basic_from_file( const json::internal::filesystem::path& path ) + [[nodiscard]] basic_value< Traits > basic_from_file( const std::filesystem::path& path ) { json::events::transformer< json::events::to_basic_value< Traits >, Transformers... > consumer; events::from_file( consumer, path ); @@ -23,7 +23,7 @@ namespace tao::json::jaxn } template< template< typename... > class... Transformers > - [[nodiscard]] value from_file( const json::internal::filesystem::path& path ) + [[nodiscard]] value from_file( const std::filesystem::path& path ) { return basic_from_file< traits, Transformers... >( path ); } diff --git a/include/tao/json/jaxn/internal/grammar.hpp b/include/tao/json/jaxn/internal/grammar.hpp index 47063dff..7f47be00 100644 --- a/include/tao/json/jaxn/internal/grammar.hpp +++ b/include/tao/json/jaxn/internal/grammar.hpp @@ -242,7 +242,7 @@ namespace tao::json::jaxn::internal typename... States > [[nodiscard]] static bool match_must( Input& in, States&&... st ) { - return Control< must< Rule > >::template match< A, rewind_mode::dontcare, Action, Control >( in, st... ); + return Control< must< Rule > >::template match< A, rewind_mode::optional, Action, Control >( in, st... ); } template< bool NEG, @@ -299,7 +299,7 @@ namespace tao::json::jaxn::internal return Control< must< kw_infinity< NEG > > >::template match< A, M, Action, Control >( in, st... ); case '0': - if( !match_zero< NEG, A, rewind_mode::dontcare, Action, Control >( in, st... ) ) { + if( !match_zero< NEG, A, rewind_mode::optional, Action, Control >( in, st... ) ) { throw pegtl::parse_error( "incomplete number", in ); } return true; @@ -333,14 +333,14 @@ namespace tao::json::jaxn::internal case '+': in.bump_in_this_line(); - if( in.empty() || !match_number< false, A, rewind_mode::dontcare, Action, Control >( in, st... ) ) { + if( in.empty() || !match_number< false, A, rewind_mode::optional, Action, Control >( in, st... ) ) { throw pegtl::parse_error( "incomplete number", in ); } return true; case '-': in.bump_in_this_line(); - if( in.empty() || !match_number< true, A, rewind_mode::dontcare, Action, Control >( in, st... ) ) { + if( in.empty() || !match_number< true, A, rewind_mode::optional, Action, Control >( in, st... ) ) { throw pegtl::parse_error( "incomplete number", in ); } return true; diff --git a/include/tao/json/jaxn/parts_parser.hpp b/include/tao/json/jaxn/parts_parser.hpp index 19349cb3..2295c14b 100644 --- a/include/tao/json/jaxn/parts_parser.hpp +++ b/include/tao/json/jaxn/parts_parser.hpp @@ -33,14 +33,14 @@ namespace tao::json::jaxn switch( in.peek_char() ) { case '+': in.bump_in_this_line(); - if( in.empty() || !sor_value::match_number< false, A, rewind_mode::dontcare, Action, Control >( in, st... ) ) { + if( in.empty() || !sor_value::match_number< false, A, rewind_mode::optional, Action, Control >( in, st... ) ) { throw pegtl::parse_error( "incomplete number", in ); } return true; case '-': in.bump_in_this_line(); - if( in.empty() || !sor_value::match_number< true, A, rewind_mode::dontcare, Action, Control >( in, st... ) ) { + if( in.empty() || !sor_value::match_number< true, A, rewind_mode::optional, Action, Control >( in, st... ) ) { throw pegtl::parse_error( "incomplete number", in ); } return true; @@ -239,9 +239,9 @@ namespace tao::json::jaxn pegtl::parse< pegtl::disable< pegtl::must< jaxn::internal::rules::sor_value, json::internal::rules::wss > > >( m_input ); } - [[nodiscard]] auto mark() // noexcept( noexcept( m_input.template mark< pegtl::rewind_mode::required >() ) ) + [[nodiscard]] auto mark() // noexcept( noexcept( m_input.template auto_rewind< pegtl::rewind_mode::required >() ) ) { - return m_input.template mark< pegtl::rewind_mode::required >(); + return m_input.template auto_rewind< pegtl::rewind_mode::required >(); } template< typename T > diff --git a/include/tao/json/msgpack/consume_file.hpp b/include/tao/json/msgpack/consume_file.hpp index a8c9fd62..39f0c67e 100644 --- a/include/tao/json/msgpack/consume_file.hpp +++ b/include/tao/json/msgpack/consume_file.hpp @@ -4,9 +4,9 @@ #ifndef TAO_JSON_MSGPACK_CONSUME_FILE_HPP #define TAO_JSON_MSGPACK_CONSUME_FILE_HPP -#include +#include -#include "../internal/filesystem.hpp" +#include #include "../consume.hpp" #include "../forward.hpp" @@ -16,14 +16,14 @@ namespace tao::json::msgpack { template< typename T, template< typename... > class Traits = traits > - [[nodiscard]] T consume_file( const json::internal::filesystem::path& path ) + [[nodiscard]] T consume_file( const std::filesystem::path& path ) { msgpack::basic_parts_parser< utf8_mode::check, pegtl::file_input< pegtl::tracking_mode::lazy > > pp( path ); return json::consume< T, Traits >( pp ); } template< template< typename... > class Traits = traits, typename T > - void consume_file( const json::internal::filesystem::path& path, T& t ) + void consume_file( const std::filesystem::path& path, T& t ) { msgpack::basic_parts_parser< utf8_mode::check, pegtl::file_input< pegtl::tracking_mode::lazy > > pp( path ); json::consume< Traits >( pp, t ); diff --git a/include/tao/json/msgpack/events/from_file.hpp b/include/tao/json/msgpack/events/from_file.hpp index 2451bf5d..ce953da2 100644 --- a/include/tao/json/msgpack/events/from_file.hpp +++ b/include/tao/json/msgpack/events/from_file.hpp @@ -4,11 +4,11 @@ #ifndef TAO_JSON_MSGPACK_EVENTS_FROM_FILE_HPP #define TAO_JSON_MSGPACK_EVENTS_FROM_FILE_HPP +#include + #include #include -#include "../../internal/filesystem.hpp" - #include "../internal/grammar.hpp" namespace tao::json::msgpack::events @@ -16,7 +16,7 @@ namespace tao::json::msgpack::events // Events producer to parse a file containing a MSGPACK string representation. template< typename Consumer > - void from_file( Consumer& consumer, const json::internal::filesystem::path& path ) + void from_file( Consumer& consumer, const std::filesystem::path& path ) { pegtl::file_input< pegtl::tracking_mode::lazy > in( path ); pegtl::parse< internal::grammar >( in, consumer ); diff --git a/include/tao/json/msgpack/from_file.hpp b/include/tao/json/msgpack/from_file.hpp index 4f03185d..ea34d49a 100644 --- a/include/tao/json/msgpack/from_file.hpp +++ b/include/tao/json/msgpack/from_file.hpp @@ -4,18 +4,18 @@ #ifndef TAO_JSON_MSGPACK_FROM_FILE_HPP #define TAO_JSON_MSGPACK_FROM_FILE_HPP +#include #include #include "../events/to_value.hpp" #include "../events/transformer.hpp" -#include "../internal/filesystem.hpp" #include "events/from_file.hpp" namespace tao::json::msgpack { template< template< typename... > class Traits, template< typename... > class... Transformers > - [[nodiscard]] basic_value< Traits > basic_from_file( const json::internal::filesystem::path& path ) + [[nodiscard]] basic_value< Traits > basic_from_file( const std::filesystem::path& path ) { json::events::transformer< json::events::to_basic_value< Traits >, Transformers... > consumer; events::from_file( consumer, path ); @@ -23,7 +23,7 @@ namespace tao::json::msgpack } template< template< typename... > class... Transformers > - [[nodiscard]] value from_file( const json::internal::filesystem::path& path ) + [[nodiscard]] value from_file( const std::filesystem::path& path ) { return basic_from_file< traits, Transformers... >( path ); } diff --git a/include/tao/json/msgpack/parts_parser.hpp b/include/tao/json/msgpack/parts_parser.hpp index 7e7154e5..af4f6d90 100644 --- a/include/tao/json/msgpack/parts_parser.hpp +++ b/include/tao/json/msgpack/parts_parser.hpp @@ -295,7 +295,7 @@ namespace tao::json::msgpack [[nodiscard]] auto mark() { - return m_input.template mark< pegtl::rewind_mode::required >(); + return m_input.template auto_rewind< pegtl::rewind_mode::required >(); } template< typename T > diff --git a/include/tao/json/parts_parser.hpp b/include/tao/json/parts_parser.hpp index a34e7cb5..270b434f 100644 --- a/include/tao/json/parts_parser.hpp +++ b/include/tao/json/parts_parser.hpp @@ -76,7 +76,7 @@ namespace tao::json switch( in.peek_char() ) { case '-': in.bump_in_this_line(); - if( in.empty() || !sor_value::match_number< true, A, rewind_mode::dontcare, Action, Control >( in, st... ) ) { + if( in.empty() || !sor_value::match_number< true, A, rewind_mode::optional, Action, Control >( in, st... ) ) { throw pegtl::parse_error( "incomplete number", in ); } return true; @@ -320,7 +320,7 @@ namespace tao::json [[nodiscard]] auto mark() { - return m_input.template mark< pegtl::rewind_mode::required >(); + return m_input.template auto_rewind< pegtl::rewind_mode::required >(); } template< typename T > diff --git a/include/tao/json/ubjson/consume_file.hpp b/include/tao/json/ubjson/consume_file.hpp index 866e045d..1c78f2c8 100644 --- a/include/tao/json/ubjson/consume_file.hpp +++ b/include/tao/json/ubjson/consume_file.hpp @@ -4,9 +4,9 @@ #ifndef TAO_JSON_UBJSON_CONSUME_FILE_HPP #define TAO_JSON_UBJSON_CONSUME_FILE_HPP -#include +#include -#include "../internal/filesystem.hpp" +#include #include "../consume.hpp" #include "../forward.hpp" @@ -16,14 +16,14 @@ namespace tao::json::ubjson { template< typename T, template< typename... > class Traits = traits > - [[nodiscard]] T consume_file( const json::internal::filesystem::path& path ) + [[nodiscard]] T consume_file( const std::filesystem::path& path ) { ubjson::basic_parts_parser< 1 << 24, utf8_mode::check, pegtl::file_input< pegtl::tracking_mode::lazy > > pp( path ); return json::consume< T, Traits >( pp ); } template< template< typename... > class Traits = traits, typename T > - void consume_file( const json::internal::filesystem::path& path, T& t ) + void consume_file( const std::filesystem::path& path, T& t ) { ubjson::basic_parts_parser< 1 << 24, utf8_mode::check, pegtl::file_input< pegtl::tracking_mode::lazy > > pp( path ); json::consume< Traits >( pp, t ); diff --git a/include/tao/json/ubjson/events/from_file.hpp b/include/tao/json/ubjson/events/from_file.hpp index e5345e87..3e57fcd4 100644 --- a/include/tao/json/ubjson/events/from_file.hpp +++ b/include/tao/json/ubjson/events/from_file.hpp @@ -4,11 +4,11 @@ #ifndef TAO_JSON_UBJSON_EVENTS_FROM_FILE_HPP #define TAO_JSON_UBJSON_EVENTS_FROM_FILE_HPP +#include + #include #include -#include "../../internal/filesystem.hpp" - #include "../internal/grammar.hpp" namespace tao::json::ubjson::events @@ -16,7 +16,7 @@ namespace tao::json::ubjson::events // Events producer to parse a file containing a UBJSON string representation. template< typename Consumer > - void from_file( Consumer& consumer, const json::internal::filesystem::path& path ) + void from_file( Consumer& consumer, const std::filesystem::path& path ) { pegtl::file_input< pegtl::tracking_mode::lazy > in( path ); pegtl::parse< internal::grammar >( in, consumer ); diff --git a/include/tao/json/ubjson/from_file.hpp b/include/tao/json/ubjson/from_file.hpp index d5da0b2e..f2855bb1 100644 --- a/include/tao/json/ubjson/from_file.hpp +++ b/include/tao/json/ubjson/from_file.hpp @@ -4,18 +4,18 @@ #ifndef TAO_JSON_UBJSON_FROM_FILE_HPP #define TAO_JSON_UBJSON_FROM_FILE_HPP +#include #include #include "../events/to_value.hpp" #include "../events/transformer.hpp" -#include "../internal/filesystem.hpp" #include "events/from_file.hpp" namespace tao::json::ubjson { template< template< typename... > class Traits, template< typename... > class... Transformers > - [[nodiscard]] basic_value< Traits > basic_from_file( const json::internal::filesystem::path& path ) + [[nodiscard]] basic_value< Traits > basic_from_file( const std::filesystem::path& path ) { json::events::transformer< json::events::to_basic_value< Traits >, Transformers... > consumer; events::from_file( consumer, path ); @@ -23,7 +23,7 @@ namespace tao::json::ubjson } template< template< typename... > class... Transformers > - [[nodiscard]] value from_file( const json::internal::filesystem::path& path ) + [[nodiscard]] value from_file( const std::filesystem::path& path ) { return basic_from_file< traits, Transformers... >( path ); } diff --git a/include/tao/json/ubjson/internal/grammar.hpp b/include/tao/json/ubjson/internal/grammar.hpp index 13051872..111f51b2 100644 --- a/include/tao/json/ubjson/internal/grammar.hpp +++ b/include/tao/json/ubjson/internal/grammar.hpp @@ -67,7 +67,7 @@ namespace tao::json { if( in.peek_char() == '-' ) { in.bump_in_this_line(); - if( in.empty() || !json::internal::rules::sor_value::match_number< true, A, pegtl::rewind_mode::dontcare, Action, Control >( in, consumer ) ) { + if( in.empty() || !json::internal::rules::sor_value::match_number< true, A, pegtl::rewind_mode::optional, Action, Control >( in, consumer ) ) { throw pegtl::parse_error( "incomplete ubjson high-precision number", in ); } return true; diff --git a/include/tao/json/ubjson/parts_parser.hpp b/include/tao/json/ubjson/parts_parser.hpp index bb8fea0e..c158d528 100644 --- a/include/tao/json/ubjson/parts_parser.hpp +++ b/include/tao/json/ubjson/parts_parser.hpp @@ -376,7 +376,7 @@ namespace tao::json::ubjson [[nodiscard]] auto mark() { - return m_input.template mark< pegtl::rewind_mode::required >(); + return m_input.template auto_rewind< pegtl::rewind_mode::required >(); } template< typename T > diff --git a/src/test/json/cbor.cpp b/src/test/json/cbor.cpp index 46eae403..b4284545 100644 --- a/src/test/json/cbor.cpp +++ b/src/test/json/cbor.cpp @@ -6,7 +6,7 @@ #include "make_events.hpp" -#include +#include #include #include @@ -19,7 +19,7 @@ namespace tao::json { cbor::events::to_string t; test::make_events( t ); - const auto r = pegtl::internal::file_reader( "tests/taocpp/make_events.cbor" ).read(); + const auto r = pegtl::internal::read_file_stdio( "tests/taocpp/make_events.cbor" ).read_string(); TEST_ASSERT( r == t.value() ); }