Go to the documentation of this file.
4 #ifndef LEXY_CALLBACK_STRING_HPP_INCLUDED
5 #define LEXY_CALLBACK_STRING_HPP_INCLUDED
18 template <
typename String>
21 template <
typename String,
typename Encoding,
typename CaseFoldingDSL =
void>
26 static_assert(lexy::_detail::is_compatible_char_type<Encoding, _char_type>,
27 "invalid character type/encoding combination");
31 if constexpr (std::is_void_v<CaseFoldingDSL>)
35 else if constexpr (CaseFoldingDSL::template is_inplace<Encoding>)
38 auto original_reader = lexy::_range_reader<Encoding>(str.begin(), str.end());
39 auto reader =
typename CaseFoldingDSL::template
case_folding<decltype(original_reader)>{
41 for (
auto ptr = str.data();
true; ++ptr)
43 auto cur = reader.peek();
60 str.reserve(original.size());
62 auto original_reader = lexy::_range_reader<Encoding>(original.begin(), original.end());
63 auto reader =
typename CaseFoldingDSL::template
case_folding<decltype(original_reader)>{
67 auto cur = reader.peek();
78 template <
typename NewCaseFoldingDSL>
93 template <
typename Iterator>
98 template <
typename Str = String,
typename Iterator>
99 constexpr
auto operator()(
const typename Str::allocator_type& allocator, Iterator
begin,
100 Iterator
end)
const -> decltype(String(
begin,
end, allocator))
105 template <
typename Reader>
108 static_assert(lexy::char_type_compatible_with_reader<Reader, _char_type>,
109 "cannot convert lexeme to this string type");
112 if constexpr (std::is_convertible_v<iterator, const _char_type*>)
117 template <
typename Str = String,
typename Reader>
118 constexpr String
operator()(
const typename Str::allocator_type& allocator,
121 static_assert(lexy::char_type_compatible_with_reader<Reader, _char_type>,
122 "cannot convert lexeme to this string type");
125 if constexpr (std::is_convertible_v<iterator, const _char_type*>)
134 auto size = _detail::encode_code_point<Encoding>(cp.
value(),
buffer, 4);
137 template <
typename Str = String>
141 auto size = _detail::encode_code_point<Encoding>(cp.
value(),
buffer, 4);
151 template <
typename CharT,
typename = decltype(
LEXY_DECLVAL(String).push_back(CharT()))>
162 template <
typename Str = String,
typename Iterator>
169 template <
typename Reader>
172 static_assert(lexy::char_type_compatible_with_reader<Reader, _char_type>,
173 "cannot convert lexeme to this string type");
180 auto size = _detail::encode_code_point<Encoding>(cp.
value(),
buffer, 4);
192 return _sink{String()};
194 template <
typename S = String>
195 constexpr
auto sink(
const typename S::allocator_type& allocator)
const
197 return _sink{String(allocator)};
205 template <
typename String,
typename Encoding = deduce_encoding<_
string_
char_type<String>>>
209 #endif // LEXY_CALLBACK_STRING_HPP_INCLUDED
constexpr auto size(const C &c) -> decltype(c.size())
LEXY_DECAY_DECLTYPE(LEXY_DECLVAL(String)[0]) _string_char_type
constexpr auto operator()(const typename Str::allocator_type &allocator, Iterator begin, Iterator end) const -> decltype(String(begin, end, allocator))
constexpr String operator()(const typename Str::allocator_type &allocator, lexeme< Reader > lex) const
string_view::value_type char_type
constexpr String operator()(code_point cp) const
typename Reader::iterator iterator
constexpr iterator begin() const noexcept
constexpr void operator()(code_point cp)
constexpr String operator()(const typename Str::allocator_type &allocator, code_point cp) const
constexpr auto operator()(Iterator begin, Iterator end) const -> decltype(String(begin, end))
constexpr void operator()(String &&str)
constexpr auto end(const C &c) -> decltype(c.end())
constexpr auto value() const noexcept
_string_char_type< String > _char_type
constexpr String operator()(lexeme< Reader > lex) const
constexpr auto case_folding(NewCaseFoldingDSL) const
constexpr const char_type * data() const noexcept
constexpr std::size_t size() const noexcept
#define LEXY_DECAY_DECLTYPE(...)
constexpr String && operator()(String &&str) const
constexpr auto operator()(Iterator begin, Iterator end) -> decltype(void(LEXY_DECLVAL(Str).append(begin, end)))
constexpr iterator end() const noexcept
constexpr auto begin(const C &c) -> decltype(c.begin())
constexpr String operator()(nullopt &&) const
constexpr auto sink() const
constexpr String && finish() &&
constexpr void operator()(lexeme< Reader > lex)
#define LEXY_DECLVAL(...)
constexpr void operator()(CharT c)
constexpr auto eof
Matches EOF.
static constexpr String && _case_folding(String &&str)
constexpr auto sink(const typename S::allocator_type &allocator) const