diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/spirit/test/x3/test.hpp | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/spirit/test/x3/test.hpp')
-rw-r--r-- | src/boost/libs/spirit/test/x3/test.hpp | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/src/boost/libs/spirit/test/x3/test.hpp b/src/boost/libs/spirit/test/x3/test.hpp new file mode 100644 index 00000000..af1c22ee --- /dev/null +++ b/src/boost/libs/spirit/test/x3/test.hpp @@ -0,0 +1,125 @@ +/*============================================================================= + Copyright (c) 2001-2013 Joel de Guzman + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_TEST_FEBRUARY_01_2007_0605PM) +#define BOOST_SPIRIT_TEST_FEBRUARY_01_2007_0605PM + +#include <boost/spirit/home/x3/core/parse.hpp> +#include <boost/utility/string_view.hpp> +#include <iostream> + +namespace spirit_test +{ + template <typename Char, typename Parser> + bool test(Char const* in, Parser const& p, bool full_match = true) + { + Char const* last = in; + while (*last) + last++; + return boost::spirit::x3::parse(in, last, p) + && (!full_match || (in == last)); + } + + template <typename Char, typename Parser> + bool test(boost::basic_string_view<Char, std::char_traits<Char>> in, + Parser const& p, bool full_match = true) + { + auto const last = in.end(); + auto pos = in.begin(); + + return boost::spirit::x3::parse(pos, last, p) && (!full_match || (pos == last)); + } + + template <typename Char, typename Parser, typename Skipper> + bool test(Char const* in, Parser const& p + , Skipper const& s, bool full_match = true) + { + Char const* last = in; + while (*last) + last++; + return boost::spirit::x3::phrase_parse(in, last, p, s) + && (!full_match || (in == last)); + } + + template <typename Char, typename Parser> + bool test_failure(Char const* in, Parser const& p) + { + Char const * const start = in; + Char const* last = in; + while (*last) + last++; + + return !boost::spirit::x3::parse(in, last, p) && (in == start); + } + + template <typename Char, typename Parser> + bool test_failure(boost::basic_string_view<Char, std::char_traits<Char>> const in, + Parser const& p) + { + auto pos = in.begin(); + return !boost::spirit::x3::parse(pos, in.end(), p) && (pos == in.begin()); + } + + template <typename Char, typename Parser, typename Attr> + bool test_attr(Char const* in, Parser const& p + , Attr& attr, bool full_match = true) + { + Char const* last = in; + while (*last) + last++; + return boost::spirit::x3::parse(in, last, p, attr) + && (!full_match || (in == last)); + } + + template <typename Char, typename Parser, typename Attr, typename Skipper> + bool test_attr(Char const* in, Parser const& p + , Attr& attr, Skipper const& s, bool full_match = true) + { + Char const* last = in; + while (*last) + last++; + return boost::spirit::x3::phrase_parse(in, last, p, s, attr) + && (!full_match || (in == last)); + } + + template <typename Char, typename Parser> + bool binary_test(Char const* in, std::size_t size, Parser const& p, + bool full_match = true) + { + Char const* last = in + size; + return boost::spirit::x3::parse(in, last, p) + && (!full_match || (in == last)); + } + + template <typename Char, typename Parser, typename Skipper> + bool binary_test(Char const* in, std::size_t size, Parser const& p, + Skipper const& s, bool full_match = true) + { + Char const* last = in + size; + return boost::spirit::x3::phrase_parse(in, last, p, s) + && (!full_match || (in == last)); + } + + template <typename Char, typename Parser, typename Attr> + bool binary_test_attr(Char const* in, std::size_t size, Parser const& p, + Attr& attr, bool full_match = true) + { + Char const* last = in + size; + return boost::spirit::x3::parse(in, last, p, attr) + && (!full_match || (in == last)); + } + + template <typename Char, typename Parser, typename Attr, typename Skipper> + bool binary_test_attr(Char const* in, std::size_t size, Parser const& p, + Attr& attr, Skipper const& s, bool full_match = true) + { + Char const* last = in + size; + return boost::spirit::x3::phrase_parse(in, last, p, s, attr) + && (!full_match || (in == last)); + } +} + +#endif |