buffer.hpp
Go to the documentation of this file.
1 // Copyright (C) 2020-2024 Jonathan Müller and lexy contributors
2 // SPDX-License-Identifier: BSL-1.0
3 
4 #ifndef LEXY_INPUT_BUFFER_HPP_INCLUDED
5 #define LEXY_INPUT_BUFFER_HPP_INCLUDED
6 
7 #include <cstring>
9 #include <lexy/_detail/swar.hpp>
10 #include <lexy/error.hpp>
11 #include <lexy/input/base.hpp>
12 #include <lexy/lexeme.hpp>
13 
14 namespace lexy
15 {
16 // The reader used by the buffer if it can use a sentinel.
17 template <typename Encoding>
18 class _br : public _detail::swar_reader_base<_br<Encoding>>
19 {
20 public:
21  using encoding = Encoding;
22  using iterator = const typename Encoding::char_type*;
23 
24  struct marker
25  {
27 
28  constexpr iterator position() const noexcept
29  {
30  return _it;
31  }
32  };
33 
34  explicit _br(iterator begin) noexcept : _cur(begin) {}
35 
36  auto peek() const noexcept
37  {
38  // The last one will be EOF.
39  return *_cur;
40  }
41 
42  void bump() noexcept
43  {
44  ++_cur;
45  }
46 
47  iterator position() const noexcept
48  {
49  return _cur;
50  }
51 
52  marker current() const noexcept
53  {
54  return {_cur};
55  }
56  void reset(marker m) noexcept
57  {
58  _cur = m._it;
59  }
60 
61 private:
63 };
64 
65 // We use aliases for the three encodings that can actually use it.
66 // (i.e. where char_type == int_type).
71 
72 // Create the appropriate buffer reader.
73 template <typename Encoding>
74 constexpr auto _buffer_reader(const typename Encoding::char_type* data)
75 {
76  if constexpr (std::is_same_v<Encoding, lexy::ascii_encoding>)
77  return _bra(data);
78  else if constexpr (std::is_same_v<Encoding, lexy::utf8_encoding>)
79  return _br8(data);
80  else if constexpr (std::is_same_v<Encoding, lexy::utf8_char_encoding>)
81  return _brc(data);
82  else if constexpr (std::is_same_v<Encoding, lexy::utf32_encoding>)
83  return _br32(data);
84  else
85  return _br<Encoding>(data);
86 }
87 } // namespace lexy
88 
89 namespace lexy
90 {
94 template <typename Encoding = default_encoding, typename MemoryResource = void>
95 class buffer
96 {
97  static_assert(lexy::is_char_encoding<Encoding>);
98  static constexpr auto _has_sentinel
99  = std::is_same_v<typename Encoding::char_type, typename Encoding::int_type>;
100 
101 public:
102  using encoding = Encoding;
103  using char_type = typename encoding::char_type;
104  static_assert(std::is_trivially_copyable_v<char_type>);
105 
106  //=== constructors ===//
108  class builder
109  {
110  public:
111  explicit builder(std::size_t size,
112  MemoryResource* resource = _detail::get_memory_resource<MemoryResource>())
113  : _buffer(resource)
114  {
116  _buffer._size = size;
117  }
118 
119  char_type* data() const noexcept
120  {
121  return _buffer._data;
122  }
123  std::size_t size() const noexcept
124  {
125  return _buffer._size;
126  }
127 
128  buffer finish() && noexcept
129  {
130  return LEXY_MOV(_buffer);
131  }
132 
133  private:
135  };
136 
137  static buffer adopt(const char_type* data, std::size_t size,
138  MemoryResource* resource = _detail::get_memory_resource<MemoryResource>())
139  {
140  buffer result(resource);
141  // We can cast away the const-ness, since we require that `data` came from a buffer
142  // origionally, where it wasn't const.
143  result._data = const_cast<char_type*>(data);
144  result._size = size;
145  return result;
146  }
147 
148  constexpr buffer() noexcept : buffer(_detail::get_memory_resource<MemoryResource>()) {}
149 
150  constexpr explicit buffer(MemoryResource* resource) noexcept
151  : _resource(resource), _data(nullptr), _size(0)
152  {}
153 
154  explicit buffer(const char_type* data, std::size_t size,
155  MemoryResource* resource = _detail::get_memory_resource<MemoryResource>())
156  : _resource(resource), _size(size)
157  {
158  _data = allocate(size);
159  if (size > 0)
160  std::memcpy(_data, data, size * sizeof(char_type));
161  }
162  explicit buffer(const char_type* begin, const char_type* end,
163  MemoryResource* resource = _detail::get_memory_resource<MemoryResource>())
164  : buffer(begin, std::size_t(end - begin), resource)
165  {}
166 
167  template <typename CharT, typename = _detail::require_secondary_char_type<encoding, CharT>>
168  explicit buffer(const CharT* data, std::size_t size,
169  MemoryResource* resource = _detail::get_memory_resource<MemoryResource>())
170  : buffer(reinterpret_cast<const char_type*>(data), size, resource)
171  {
172  static_assert(sizeof(CharT) == sizeof(char_type));
173  }
174  template <typename CharT, typename = _detail::require_secondary_char_type<encoding, CharT>>
175  explicit buffer(const CharT* begin, const CharT* end,
176  MemoryResource* resource = _detail::get_memory_resource<MemoryResource>())
177  : buffer(reinterpret_cast<const char_type*>(begin), reinterpret_cast<const char_type*>(end),
178  resource)
179  {
180  static_assert(sizeof(CharT) == sizeof(char_type));
181  }
182 
183  template <typename View, typename = decltype(LEXY_DECLVAL(View).data())>
184  explicit buffer(const View& view,
185  MemoryResource* resource = _detail::get_memory_resource<MemoryResource>())
186  : buffer(view.data(), view.size(), resource)
187  {}
188 
189  buffer(const buffer& other) : buffer(other.data(), other.size(), other._resource.get()) {}
190  buffer(const buffer& other, MemoryResource* resource)
191  : buffer(other.data(), other.size(), resource)
192  {}
193 
194  buffer(buffer&& other) noexcept
195  : _resource(other._resource), _data(other._data), _size(other._size)
196  {
197  other._data = nullptr;
198  other._size = 0;
199  }
200 
201  ~buffer() noexcept
202  {
203  if (!_data)
204  return;
205 
206  if constexpr (_has_sentinel)
207  _resource->deallocate(_data,
209  alignof(char_type));
210  else
211  _resource->deallocate(_data, _size * sizeof(char_type), alignof(char_type));
212  }
213 
214  buffer& operator=(const buffer& other) // NOLINT: we do guard against self-assignment
215  {
216  // Create a temporary buffer that owns the same memory as other but with our resource.
217  // We then move assign it to *this.
218  *this = buffer(other, _resource.get());
219  return *this;
220  }
221 
222  // NOLINTNEXTLINE: Unfortunately, sometimes move is not noexcept.
223  buffer& operator=(buffer&& other) noexcept(std::is_empty_v<MemoryResource>)
224  {
225  if (*_resource == *other._resource)
226  {
227  // We have the same resource; we can just steal other's memory.
228  // We do that by swapping - when other is destroyed it will free our memory.
229  _detail::swap(_data, other._data);
230  _detail::swap(_size, other._size);
231  return *this;
232  }
233  else
234  {
235  LEXY_PRECONDITION(!std::is_empty_v<MemoryResource>);
236 
237  // We create a copy using the right resource and swap the ownership.
238  buffer copy(other, _resource.get());
239  _detail::swap(_data, copy._data);
240  _detail::swap(_size, copy._size);
241  return *this;
242  }
243  }
244 
245  //=== access ===//
246  const char_type* data() const noexcept
247  {
248  return _data;
249  }
250 
251  std::size_t size() const noexcept
252  {
253  return _size;
254  }
255 
256  const char_type* release() && noexcept
257  {
258  auto result = _data;
259  _data = nullptr;
260  _size = 0;
261  return result;
262  }
263 
264  //=== input ===//
265  auto reader() const& noexcept
266  {
267  if constexpr (_has_sentinel)
268  return _buffer_reader<encoding>(_data);
269  else
270  return _range_reader<encoding>(_data, _data + _size);
271  }
272 
273 private:
274  char_type* allocate(std::size_t size) const
275  {
276  if constexpr (_has_sentinel)
277  {
278  auto mem_size = _detail::round_size_for_swar(size + 1);
279  auto memory = static_cast<char_type*>(
280  _resource->allocate(mem_size * sizeof(char_type), alignof(char_type)));
281 
282  for (auto ptr = memory + size; ptr != memory + mem_size; ++ptr)
283  *ptr = encoding::eof();
284 
285  return memory;
286  }
287  else
288  {
289  return static_cast<char_type*>(
290  _resource->allocate(size * sizeof(char_type), alignof(char_type)));
291  }
292  }
293 
296  std::size_t _size;
297 };
298 
299 template <typename CharT>
300 buffer(const CharT*, const CharT*) -> buffer<deduce_encoding<CharT>>;
301 template <typename CharT>
302 buffer(const CharT*, std::size_t) -> buffer<deduce_encoding<CharT>>;
303 template <typename View>
304 buffer(const View&) -> buffer<deduce_encoding<LEXY_DECAY_DECLTYPE(*LEXY_DECLVAL(View).data())>>;
305 
306 template <typename CharT, typename MemoryResource>
307 buffer(const CharT*, const CharT*, MemoryResource*)
308  -> buffer<deduce_encoding<CharT>, MemoryResource>;
309 template <typename CharT, typename MemoryResource>
310 buffer(const CharT*, std::size_t, MemoryResource*)
311  -> buffer<deduce_encoding<CharT>, MemoryResource>;
312 template <typename View, typename MemoryResource>
313 buffer(const View&, MemoryResource*)
314  -> buffer<deduce_encoding<LEXY_DECAY_DECLTYPE(*LEXY_DECLVAL(View).data())>, MemoryResource>;
315 
316 //=== make_buffer ===//
317 template <typename Encoding, encoding_endianness Endian>
319 {
320  template <typename MemoryResource = void>
321  auto operator()(const void* _memory, std::size_t size,
322  MemoryResource* resource = _detail::get_memory_resource<MemoryResource>()) const
323  {
324  constexpr auto native_endianness
325  = LEXY_IS_LITTLE_ENDIAN ? encoding_endianness::little : encoding_endianness::big;
326 
327  using char_type = typename Encoding::char_type;
328  LEXY_PRECONDITION(size % sizeof(char_type) == 0);
329  auto memory = static_cast<const unsigned char*>(_memory);
330 
331  if constexpr (sizeof(char_type) == 1 || Endian == native_endianness)
332  {
333  // No need to deal with endianness at all.
334  // The reinterpret_cast is technically UB, as we didn't create objects in memory,
335  // but until std::start_lifetime_as is added, there is nothing we can do.
336  return buffer<Encoding, MemoryResource>(reinterpret_cast<const char_type*>(memory),
337  size / sizeof(char_type), resource);
338  }
339  else
340  {
341  typename buffer<Encoding, MemoryResource>::builder builder(size / sizeof(char_type),
342  resource);
343 
344  const auto end = memory + size;
345  for (auto dest = builder.data(); memory != end; memory += sizeof(char_type))
346  {
347  constexpr auto is_char16 = std::is_same_v<char_type, char16_t>;
348  constexpr auto is_char32 = std::is_same_v<char_type, char32_t>;
349 
350  // We convert each group of bytes to the appropriate value.
351  if constexpr (is_char16 && Endian == encoding_endianness::little)
352  *dest++ = static_cast<char_type>((memory[0] << 0) | (memory[1] << 8));
353  else if constexpr (is_char32 && Endian == encoding_endianness::little)
354  *dest++ = static_cast<char_type>((memory[0] << 0) | (memory[1] << 8)
355  | (memory[2] << 16) | (memory[3] << 24));
356  else if constexpr (is_char16 && Endian == encoding_endianness::big)
357  *dest++ = static_cast<char_type>((memory[0] << 8) | (memory[1] << 0));
358  else if constexpr (is_char32 && Endian == encoding_endianness::big)
359  *dest++ = static_cast<char_type>((memory[0] << 24) | (memory[1] << 16)
360  | (memory[2] << 8) | (memory[3] << 0));
361  else
362  static_assert(_detail::error<Encoding>, "unhandled encoding/endianness");
363  }
364 
365  return LEXY_MOV(builder).finish();
366  }
367  }
368 };
369 template <>
371 {
372  template <typename MemoryResource = void>
373  auto operator()(const void* _memory, std::size_t size,
374  MemoryResource* resource = _detail::get_memory_resource<MemoryResource>()) const
375  {
376  auto memory = static_cast<const unsigned char*>(_memory);
377 
378  // We just skip over the BOM if there is one, it doesn't matter.
379  if (size >= 3 && memory[0] == 0xEF && memory[1] == 0xBB && memory[2] == 0xBF)
380  {
381  memory += 3;
382  size -= 3;
383  }
384 
386  }
387 };
388 template <>
390 {
391  template <typename MemoryResource = void>
392  auto operator()(const void* _memory, std::size_t size,
393  MemoryResource* resource = _detail::get_memory_resource<MemoryResource>()) const
394  {
395  auto memory = static_cast<const unsigned char*>(_memory);
396 
397  // We just skip over the BOM if there is one, it doesn't matter.
398  if (size >= 3 && memory[0] == 0xEF && memory[1] == 0xBB && memory[2] == 0xBF)
399  {
400  memory += 3;
401  size -= 3;
402  }
403 
405  }
406 };
407 template <>
409 {
410  template <typename MemoryResource = void>
411  auto operator()(const void* _memory, std::size_t size,
412  MemoryResource* resource = _detail::get_memory_resource<MemoryResource>()) const
413  {
414  constexpr auto utf16_big = _make_buffer<utf16_encoding, encoding_endianness::big>{};
415  constexpr auto utf16_little = _make_buffer<utf16_encoding, encoding_endianness::little>{};
416  auto memory = static_cast<const unsigned char*>(_memory);
417 
418  if (size < 2)
419  return utf16_big(memory, size, resource);
420  if (memory[0] == 0xFF && memory[1] == 0xFE)
421  return utf16_little(memory + 2, size - 2, resource);
422  else if (memory[0] == 0xFE && memory[1] == 0xFF)
423  return utf16_big(memory + 2, size - 2, resource);
424  else
425  return utf16_big(memory, size, resource);
426  }
427 };
428 template <>
430 {
431  template <typename MemoryResource = void>
432  auto operator()(const void* _memory, std::size_t size,
433  MemoryResource* resource = _detail::get_memory_resource<MemoryResource>()) const
434  {
435  constexpr auto utf32_big = _make_buffer<utf32_encoding, encoding_endianness::big>{};
436  constexpr auto utf32_little = _make_buffer<utf32_encoding, encoding_endianness::little>{};
437  auto memory = static_cast<const unsigned char*>(_memory);
438 
439  if (size >= 4)
440  {
441  if (memory[0] == 0xFF && memory[1] == 0xFE && memory[2] == 0x00 && memory[3] == 0x00)
442  return utf32_little(memory + 4, size - 4, resource);
443  else if (memory[0] == 0x00 && memory[1] == 0x00 && memory[2] == 0xFE && memory[3])
444  return utf32_big(memory + 4, size - 4, resource);
445  }
446 
447  return utf32_big(memory, size, resource);
448  }
449 };
450 
452 template <typename Encoding, encoding_endianness Endianness>
454 
455 //=== make_buffer_from_input ===//
456 template <typename Input>
457 using _detect_input_data = decltype(LEXY_DECLVAL(Input&).data());
458 
459 template <typename Input, typename MemoryResource = void>
460 constexpr auto make_buffer_from_input(const Input& input,
461  MemoryResource* resource
462  = _detail::get_memory_resource<MemoryResource>())
464 {
465  using type = buffer<typename input_reader<Input>::encoding, MemoryResource>;
466  if constexpr (_detail::is_detected<_detect_input_data, Input>)
467  {
468  return type(input.data(), input.size(), resource);
469  }
470  else
471  {
472  auto reader = input.reader();
473  auto begin = reader.position();
474  while (reader.peek() != input_reader<Input>::encoding::eof())
475  reader.bump();
476  auto end = reader.position();
477 
478  if constexpr (std::is_pointer_v<decltype(begin)>)
479  {
480  return type(begin, end, resource);
481  }
482  else
483  {
485  typename type::builder builder(size, resource);
486  auto dest = builder.data();
487  for (auto cur = begin; cur != end; ++cur)
488  *dest++ = *cur; // NOLINT: clang-analyzer thinks this might access zero memory for
489  // some reason?!
490  return LEXY_MOV(builder).finish();
491  }
492  }
493 }
494 
495 //=== convenience typedefs ===//
496 template <typename Encoding = default_encoding, typename MemoryResource = void>
498 
499 template <typename Tag, typename Encoding = default_encoding, typename MemoryResource = void>
501 
502 template <typename Encoding = default_encoding, typename MemoryResource = void>
504 } // namespace lexy
505 
506 #endif // LEXY_INPUT_BUFFER_HPP_INCLUDED
507 
cx::size
constexpr auto size(const C &c) -> decltype(c.size())
Definition: wildcards.hpp:636
LEXY_MOV
#define LEXY_MOV(...)
Definition: config.hpp:29
lexy::encoding_endianness
encoding_endianness
The endianness used by an encoding.
Definition: encoding.hpp:15
lexy::_make_buffer
Definition: buffer.hpp:318
lexy::encoding_endianness::little
@ little
Little endian.
lexy::_br::current
marker current() const noexcept
Definition: buffer.hpp:52
lexy::buffer::_resource
LEXY_EMPTY_MEMBER _detail::memory_resource_ptr< MemoryResource > _resource
Definition: buffer.hpp:294
lexy::LEXY_INSTANTIATION_NEWTYPE
LEXY_INSTANTIATION_NEWTYPE(_pr, _rr, Encoding, const typename Encoding::char_type *)
lexy::_detail::memory_resource_ptr
std::conditional_t< std::is_void_v< MemoryResource >, _memory_resource_ptr_empty< default_memory_resource >, std::conditional_t< std::is_empty_v< MemoryResource >, _memory_resource_ptr_empty< MemoryResource >, _memory_resource_ptr< MemoryResource > >> memory_resource_ptr
Definition: memory_resource.hpp:140
magic_enum::char_type
string_view::value_type char_type
Definition: magic_enum.hpp:145
lexy::buffer::~buffer
~buffer() noexcept
Definition: buffer.hpp:201
lexy::buffer::builder::_buffer
buffer _buffer
Definition: buffer.hpp:134
lexy::_detect_input_data
decltype(LEXY_DECLVAL(Input &).data()) _detect_input_data
Definition: buffer.hpp:457
lexy::_detail::get_memory_resource
constexpr MemoryResource * get_memory_resource()
Definition: memory_resource.hpp:145
lexy::_br::position
iterator position() const noexcept
Definition: buffer.hpp:47
lexy::make_buffer_from_input
constexpr auto make_buffer_from_input(const Input &input, MemoryResource *resource=_detail::get_memory_resource< MemoryResource >()) -> buffer< typename input_reader< Input >::encoding, MemoryResource >
Definition: buffer.hpp:460
lexy::buffer::allocate
char_type * allocate(std::size_t size) const
Definition: buffer.hpp:274
lexy::_br::bump
void bump() noexcept
Definition: buffer.hpp:42
lexy::buffer::buffer
buffer(const char_type *begin, const char_type *end, MemoryResource *resource=_detail::get_memory_resource< MemoryResource >())
Definition: buffer.hpp:162
lexy::_detail::round_size_for_swar
constexpr std::size_t round_size_for_swar(std::size_t size_in_bytes)
Definition: swar.hpp:235
lexy::_make_buffer< utf16_encoding, encoding_endianness::bom >::operator()
auto operator()(const void *_memory, std::size_t size, MemoryResource *resource=_detail::get_memory_resource< MemoryResource >()) const
Definition: buffer.hpp:411
lexy::error_context
Contains information about the context of an error, production is type-erased.
Definition: error.hpp:233
lexy::buffer::buffer
buffer(buffer &&other) noexcept
Definition: buffer.hpp:194
lexy
Definition: any_ref.hpp:12
LEXY_PRECONDITION
#define LEXY_PRECONDITION(Expr)
Definition: assert.hpp:36
lexy::buffer::buffer
buffer(const char_type *data, std::size_t size, MemoryResource *resource=_detail::get_memory_resource< MemoryResource >())
Definition: buffer.hpp:154
lexy::utf32_encoding
An encoding where the input is assumed to be valid UTF-32.
Definition: encoding.hpp:156
lexy::buffer::_data
char_type * _data
Definition: buffer.hpp:295
cx::end
constexpr auto end(const C &c) -> decltype(c.end())
Definition: wildcards.hpp:686
lexy::_make_buffer< utf32_encoding, encoding_endianness::bom >::operator()
auto operator()(const void *_memory, std::size_t size, MemoryResource *resource=_detail::get_memory_resource< MemoryResource >()) const
Definition: buffer.hpp:432
lexy::error
Generic failure.
Definition: error.hpp:14
lexy::_br::marker
Definition: buffer.hpp:24
lexy::deduce_encoding
typename _deduce_encoding< CharT >::type deduce_encoding
Definition: encoding.hpp:209
lexy::buffer::buffer
buffer(const buffer &other)
Definition: buffer.hpp:189
lexy::_make_buffer::operator()
auto operator()(const void *_memory, std::size_t size, MemoryResource *resource=_detail::get_memory_resource< MemoryResource >()) const
Definition: buffer.hpp:321
lexy::_br::iterator
const typename Encoding::char_type * iterator
Definition: buffer.hpp:22
swar.hpp
lexy::_make_buffer< utf8_encoding, encoding_endianness::bom >::operator()
auto operator()(const void *_memory, std::size_t size, MemoryResource *resource=_detail::get_memory_resource< MemoryResource >()) const
Definition: buffer.hpp:373
lexy::buffer::buffer
buffer(const CharT *data, std::size_t size, MemoryResource *resource=_detail::get_memory_resource< MemoryResource >())
Definition: buffer.hpp:168
lexy::_br::marker::_it
iterator _it
Definition: buffer.hpp:26
lexy::_br::_br
_br(iterator begin) noexcept
Definition: buffer.hpp:34
lexeme.hpp
lexy::buffer
buffer(const CharT *, const CharT *) -> buffer< deduce_encoding< CharT >>
lexy::_detail::swap
constexpr void swap(T &lhs, T &rhs)
Definition: config.hpp:53
lexy::buffer::_size
std::size_t _size
Definition: buffer.hpp:296
lexy::buffer::reader
auto reader() const &noexcept
Definition: buffer.hpp:265
lexy::encoding_endianness::big
@ big
Big endian.
lexy::buffer::buffer
constexpr buffer(MemoryResource *resource) noexcept
Definition: buffer.hpp:150
lexy::_br::_cur
iterator _cur
Definition: buffer.hpp:62
lexy::buffer::operator=
buffer & operator=(const buffer &other)
Definition: buffer.hpp:214
lexyd::bom
constexpr auto bom
The BOM for that particular encoding.
Definition: bom.hpp:43
lexy::buffer::builder::data
char_type * data() const noexcept
Definition: buffer.hpp:119
lexy::buffer::buffer
constexpr buffer() noexcept
Definition: buffer.hpp:148
lexy::buffer::release
const char_type * release() &&noexcept
Definition: buffer.hpp:256
LEXY_DECAY_DECLTYPE
#define LEXY_DECAY_DECLTYPE(...)
Definition: config.hpp:34
lexy::utf8_encoding
An encoding where the input is assumed to be valid UTF-8.
Definition: encoding.hpp:84
lexy::buffer::data
const char_type * data() const noexcept
Definition: buffer.hpp:246
lexy::ascii_encoding
Definition: encoding.hpp:58
lexy::buffer< default_encoding, void >::char_type
typename encoding::char_type char_type
Definition: buffer.hpp:103
lexy::_detail::range_size
constexpr std::size_t range_size(Iterator begin, Sentinel end)
Definition: iterator.hpp:22
lexy::buffer::builder::finish
buffer finish() &&noexcept
Definition: buffer.hpp:128
lexy::default_encoding
An encoding where the input is some 8bit encoding (ASCII, UTF-8, extended ASCII etc....
Definition: encoding.hpp:27
lexy::_br::encoding
Encoding encoding
Definition: buffer.hpp:21
lexy::_br
Definition: buffer.hpp:18
lexy::utf8_char_encoding
An encoding where the input is assumed to be valid UTF-8, but the char type is char.
Definition: encoding.hpp:108
detail::get
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
Definition: json.hpp:5342
lexy::buffer::_has_sentinel
static constexpr auto _has_sentinel
Definition: buffer.hpp:99
cx::begin
constexpr auto begin(const C &c) -> decltype(c.begin())
Definition: wildcards.hpp:661
lexy::utf16_encoding
An encoding where the input is assumed to be valid UTF-16.
Definition: encoding.hpp:132
lexy::buffer::buffer
buffer(const View &view, MemoryResource *resource=_detail::get_memory_resource< MemoryResource >())
Definition: buffer.hpp:184
lexy::_buffer_reader
constexpr auto _buffer_reader(const typename Encoding::char_type *data)
Definition: buffer.hpp:74
lexy::make_buffer_from_raw
constexpr auto make_buffer_from_raw
Creates a buffer with the specified encoding/endianness from raw memory.
Definition: buffer.hpp:453
lexy::buffer::buffer
buffer(const CharT *begin, const CharT *end, MemoryResource *resource=_detail::get_memory_resource< MemoryResource >())
Definition: buffer.hpp:175
lexy::buffer
Definition: buffer.hpp:95
lexy::_br::peek
auto peek() const noexcept
Definition: buffer.hpp:36
std
Definition: std.hpp:31
lexy::lexeme
Definition: lexeme.hpp:16
lexy::_br::marker::position
constexpr iterator position() const noexcept
Definition: buffer.hpp:28
lexy::buffer::size
std::size_t size() const noexcept
Definition: buffer.hpp:251
lexy::buffer::buffer
buffer(const buffer &other, MemoryResource *resource)
Definition: buffer.hpp:190
lexy::buffer::builder::builder
builder(std::size_t size, MemoryResource *resource=_detail::get_memory_resource< MemoryResource >())
Definition: buffer.hpp:111
lexy::buffer::adopt
static buffer adopt(const char_type *data, std::size_t size, MemoryResource *resource=_detail::get_memory_resource< MemoryResource >())
Definition: buffer.hpp:137
lexy::buffer::builder
Allows the creation of an uninitialized buffer that is then filled by the user.
Definition: buffer.hpp:108
lexy::buffer::builder::size
std::size_t size() const noexcept
Definition: buffer.hpp:123
lexy::_detail::swar_reader_base
Definition: swar.hpp:199
base.hpp
lexy::buffer::operator=
buffer & operator=(buffer &&other) noexcept(std::is_empty_v< MemoryResource >)
Definition: buffer.hpp:223
LEXY_EMPTY_MEMBER
#define LEXY_EMPTY_MEMBER
Definition: config.hpp:193
LEXY_DECLVAL
#define LEXY_DECLVAL(...)
Definition: config.hpp:32
lexy::_br::reset
void reset(marker m) noexcept
Definition: buffer.hpp:56
lexyd::eof
constexpr auto eof
Matches EOF.
Definition: eof.hpp:72
lexy::_make_buffer< utf8_char_encoding, encoding_endianness::bom >::operator()
auto operator()(const void *_memory, std::size_t size, MemoryResource *resource=_detail::get_memory_resource< MemoryResource >()) const
Definition: buffer.hpp:392
lexy::input_reader
decltype(LEXY_DECLVAL(Input).reader()) input_reader
Definition: input/base.hpp:106
memory_resource.hpp
error.hpp


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Dec 13 2024 03:19:16