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