tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
basic_format_parse_context.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_FORMAT_BASIC_FORMAT_PARSE_CONTEXT_HPP
4#define TETL_FORMAT_BASIC_FORMAT_PARSE_CONTEXT_HPP
5
9
10namespace etl {
11
12template <typename CharT>
14 using char_type = CharT;
17
18 constexpr explicit basic_format_parse_context(basic_string_view<CharT> fmt, size_t numArgs = 0) noexcept
19 : _begin{fmt.begin()}
20 , _end{fmt.end()}
21 , _numArgs{numArgs}
22 {
23 }
24
27
28 [[nodiscard]] constexpr auto begin() const noexcept -> const_iterator { return _begin; }
29
30 [[nodiscard]] constexpr auto end() const noexcept -> const_iterator { return _end; }
31
32 constexpr auto advance_to(const_iterator it) -> void { _begin = it; }
33
34 [[nodiscard]] constexpr auto next_arg_id() -> size_t { return static_cast<size_t>(_nextArgId++); }
35
36 constexpr auto check_arg_id(size_t /*id*/) -> void { _nextArgId = -1; }
37
38private:
39 // next_arg_id_ > 0 means automatic
40 // next_arg_id_ == 0 means unknown
41 // next_arg_id_ < 0 means manual
42
43 iterator _begin;
44 iterator _end;
45 size_t _numArgs;
46 ptrdiff_t _nextArgId{};
47};
48
51
52} // namespace etl
53
54#endif // TETL_FORMAT_BASIC_FORMAT_PARSE_CONTEXT_HPP
Definition adjacent_find.hpp:8
basic_format_parse_context< char > format_parse_context
Definition basic_format_parse_context.hpp:49
basic_format_parse_context< wchar_t > wformat_parse_context
Definition basic_format_parse_context.hpp:50
TETL_BUILTIN_PTRDIFF ptrdiff_t
etl::ptrdiff_t is the signed integer type of the result of subtracting two pointers.
Definition ptrdiff_t.hpp:14
Definition basic_format_parse_context.hpp:13
CharT char_type
Definition basic_format_parse_context.hpp:14
basic_format_parse_context(basic_format_parse_context const &other)=delete
constexpr basic_format_parse_context(basic_string_view< CharT > fmt, size_t numArgs=0) noexcept
Definition basic_format_parse_context.hpp:18
constexpr auto check_arg_id(size_t) -> void
Definition basic_format_parse_context.hpp:36
constexpr auto begin() const noexcept -> const_iterator
Definition basic_format_parse_context.hpp:28
constexpr auto next_arg_id() -> size_t
Definition basic_format_parse_context.hpp:34
auto operator=(basic_format_parse_context const &other) -> basic_format_parse_context &=delete
constexpr auto advance_to(const_iterator it) -> void
Definition basic_format_parse_context.hpp:32
const_iterator iterator
Definition basic_format_parse_context.hpp:16
constexpr auto end() const noexcept -> const_iterator
Definition basic_format_parse_context.hpp:30
typename basic_string_view< CharT >::const_iterator const_iterator
Definition basic_format_parse_context.hpp:15
The class template basic_string_view describes an object that can refer to a constant contiguous sequ...
Definition basic_string_view.hpp:34
constexpr auto begin() const noexcept -> const_iterator
Returns an iterator to the first character of the view.
Definition basic_string_view.hpp:99
Char const * const_iterator
Definition basic_string_view.hpp:41