lexeme_input.hpp
Go to the documentation of this file.
1 // Copyright (C) 2022 Jonathan Müller and lexy contributors
2 // SPDX-License-Identifier: BSL-1.0
3 
4 #ifndef LEXY_INPUT_LEXEME_INPUT_HPP_INCLUDED
5 #define LEXY_INPUT_LEXEME_INPUT_HPP_INCLUDED
6 
7 #include <lexy/input/base.hpp>
8 #include <lexy/lexeme.hpp>
9 
10 namespace lexy
11 {
12 template <typename ParentInput>
14 {
16  using _input_ptr
17  = std::conditional_t<input_is_view<ParentInput>, ParentInput, const ParentInput*>;
18 
19 public:
20  using encoding = typename _lexeme_type::encoding;
22  using iterator = typename _lexeme_type::iterator;
23 
24  //=== constructor ===//
25  explicit lexeme_input(const ParentInput& input, _lexeme_type lexeme)
26  : _input([&] {
27  if constexpr (input_is_view<ParentInput>)
28  return input;
29  else
30  return &input;
31  }()),
33  {}
34 
35  explicit lexeme_input(const ParentInput& input, iterator begin, iterator end)
37  {}
38 
39  //=== access ===//
40  const ParentInput& parent_input() const
41  {
42  if constexpr (input_is_view<ParentInput>)
43  return _input;
44  else
45  return *_input;
46  }
47 
49  {
50  return _lexeme;
51  }
52 
53  //=== input ===//
54  auto reader() const& noexcept
55  {
56  return _range_reader<encoding>(_lexeme.begin(), _lexeme.end());
57  }
58 
59 private:
62 };
63 } // namespace lexy
64 
65 #endif // LEXY_INPUT_LEXEME_INPUT_HPP_INCLUDED
66 
lexy::lexeme_input
Definition: lexeme_input.hpp:13
lexy::lexeme::char_type
typename encoding::char_type char_type
Definition: lexeme.hpp:20
lexy::lexeme_input::iterator
typename _lexeme_type::iterator iterator
Definition: lexeme_input.hpp:22
lexy::lexeme::iterator
typename Reader::iterator iterator
Definition: lexeme.hpp:21
lexy::lexeme::begin
constexpr iterator begin() const noexcept
Definition: lexeme.hpp:38
lexy::lexeme_input::_input_ptr
std::conditional_t< input_is_view< ParentInput >, ParentInput, const ParentInput * > _input_ptr
Definition: lexeme_input.hpp:17
lexy::lexeme_input::reader
auto reader() const &noexcept
Definition: lexeme_input.hpp:54
lexy::lexeme_input::char_type
typename _lexeme_type::char_type char_type
Definition: lexeme_input.hpp:21
lexy
Definition: any_ref.hpp:12
cx::end
constexpr auto end(const C &c) -> decltype(c.end())
Definition: wildcards.hpp:686
lexy::lexeme_input::lexeme_input
lexeme_input(const ParentInput &input, iterator begin, iterator end)
Definition: lexeme_input.hpp:35
lexeme.hpp
lexy::lexeme::encoding
typename Reader::encoding encoding
Definition: lexeme.hpp:19
lexy::lexeme::end
constexpr iterator end() const noexcept
Definition: lexeme.hpp:42
cx::begin
constexpr auto begin(const C &c) -> decltype(c.begin())
Definition: wildcards.hpp:661
lexy::lexeme_input::encoding
typename _lexeme_type::encoding encoding
Definition: lexeme_input.hpp:20
lexy::lexeme
Definition: lexeme.hpp:16
lexy::lexeme_input::_input
_input_ptr _input
Definition: lexeme_input.hpp:60
base.hpp
lexy::lexeme_input::parent_input
const ParentInput & parent_input() const
Definition: lexeme_input.hpp:40
lexy::lexeme_input::lexeme_input
lexeme_input(const ParentInput &input, _lexeme_type lexeme)
Definition: lexeme_input.hpp:25
lexy::lexeme_input::_lexeme
_lexeme_type _lexeme
Definition: lexeme_input.hpp:61
lexy::lexeme_input::lexeme
_lexeme_type lexeme() const
Definition: lexeme_input.hpp:48


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Jun 28 2024 02:20:07