microfmt
Zero-allocation C++ formatting for constrained environments
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
microfmt::format_parse_context Class Reference

#include <microfmt.hpp>

Public Types

using iterator = microfmt::string_view::const_iterator
 
using const_iterator = microfmt::string_view::const_iterator
 
using value_type = char
 
using size_type = std::size_t
 

Public Member Functions

constexpr format_parse_context (microfmt::string_view spec RELOCO_LIFETIMEBOUND RELOCO_LIFETIME_CAPTURE_BY_THIS) noexcept
 
constexpr microfmt::string_view spec () const noexcept RELOCO_LIFETIMEBOUND
 
constexpr bool empty () const noexcept
 
constexpr size_type size () const noexcept
 
constexpr const_iterator begin () const noexcept RELOCO_LIFETIMEBOUND
 
constexpr const_iterator end () const noexcept RELOCO_LIFETIMEBOUND
 
constexpr const_iterator cbegin () const noexcept RELOCO_LIFETIMEBOUND
 
constexpr const_iterator cend () const noexcept RELOCO_LIFETIMEBOUND
 
constexpr char front () const noexcept
 
constexpr char back () const noexcept
 
RELOCO_CHECKED constexpr char operator[] (size_type idx) const noexcept
 
RELOCO_BEGIN_UNSAFE_CODE constexpr void advance_to (const_iterator it) noexcept
 
RELOCO_END_UNSAFE_CODE constexpr void remove_prefix (size_type n) noexcept
 
constexpr char consume () noexcept
 
constexpr bool starts_with (char ch) const noexcept
 
constexpr bool starts_with (microfmt::string_view prefix) const noexcept
 
constexpr size_type find (char ch, size_type pos=0) const noexcept
 
constexpr microfmt::string_view substr (size_type pos=0, size_type count=microfmt::string_view::npos) const noexcept RELOCO_LIFETIMEBOUND
 
constexpr bool consume_debug_flag () noexcept
 Detects and consumes a leading ? – Rust's {:?} Debug flag, as opposed to {}'s Display – returning true (and removing it from the remaining spec) if present, false otherwise.
 

Member Typedef Documentation

◆ const_iterator

using microfmt::format_parse_context::const_iterator = microfmt::string_view::const_iterator

◆ iterator

using microfmt::format_parse_context::iterator = microfmt::string_view::const_iterator

◆ size_type

◆ value_type

Constructor & Destructor Documentation

◆ format_parse_context()

constexpr microfmt::format_parse_context::format_parse_context ( microfmt::string_view spec RELOCO_LIFETIMEBOUND  RELOCO_LIFETIME_CAPTURE_BY_THIS)
inlineexplicitconstexprnoexcept

Member Function Documentation

◆ advance_to()

RELOCO_BEGIN_UNSAFE_CODE constexpr void microfmt::format_parse_context::advance_to ( const_iterator  it)
inlineconstexprnoexcept

◆ back()

constexpr char microfmt::format_parse_context::back ( ) const
inlineconstexprnoexcept

◆ begin()

constexpr const_iterator microfmt::format_parse_context::begin ( ) const
inlineconstexprnoexcept

◆ cbegin()

constexpr const_iterator microfmt::format_parse_context::cbegin ( ) const
inlineconstexprnoexcept

◆ cend()

constexpr const_iterator microfmt::format_parse_context::cend ( ) const
inlineconstexprnoexcept

◆ consume()

constexpr char microfmt::format_parse_context::consume ( )
inlineconstexprnoexcept

◆ consume_debug_flag()

constexpr bool microfmt::format_parse_context::consume_debug_flag ( )
inlineconstexprnoexcept

Detects and consumes a leading ? – Rust's {:?} Debug flag, as opposed to {}'s Display – returning true (and removing it from the remaining spec) if present, false otherwise.

A shared convention, not a hardcoded type list: any formatter<T> that has a meaningfully different "debug" representation (e.g. microfmt::string_view/char, quoting and escaping their content) calls this from parse() and remembers the result. Types whose Debug and Display forms coincide (integers, floats, bool, ..., matching Rust's own derived Debug for these) need not call it at all – an unconsumed ? is simply never recognized by their own flag/width parsing, which is indistinguishable from Display.

Defining MICROFMT_DISABLE_DEBUG_FLAG removes every call site of this function from microfmt::formatter<char>/formatter<microfmt::string_view>/ formatter<std::string_view>/detail::const_char_like at the preprocessor level (see docs/porting.md), so a literal {:?} in a format string simply behaves like {} for those types too, in exchange for dropping the escaping/quoting code paths from the binary on targets that never need textual {:?} support. reloco::Debug<T>/ microfmt::as_debug() are entirely unaffected either way: they never go through spec/this function at all (see as_debug()'s own doc comment below).

◆ empty()

constexpr bool microfmt::format_parse_context::empty ( ) const
inlineconstexprnoexcept

◆ end()

constexpr const_iterator microfmt::format_parse_context::end ( ) const
inlineconstexprnoexcept

◆ find()

constexpr size_type microfmt::format_parse_context::find ( char  ch,
size_type  pos = 0 
) const
inlineconstexprnoexcept

◆ front()

constexpr char microfmt::format_parse_context::front ( ) const
inlineconstexprnoexcept

◆ operator[]()

RELOCO_CHECKED constexpr char microfmt::format_parse_context::operator[] ( size_type  idx) const
inlineconstexprnoexcept

◆ remove_prefix()

RELOCO_END_UNSAFE_CODE constexpr void microfmt::format_parse_context::remove_prefix ( size_type  n)
inlineconstexprnoexcept

◆ size()

constexpr size_type microfmt::format_parse_context::size ( ) const
inlineconstexprnoexcept

◆ spec()

constexpr microfmt::string_view microfmt::format_parse_context::spec ( ) const
inlineconstexprnoexcept

◆ starts_with() [1/2]

constexpr bool microfmt::format_parse_context::starts_with ( char  ch) const
inlineconstexprnoexcept

◆ starts_with() [2/2]

constexpr bool microfmt::format_parse_context::starts_with ( microfmt::string_view  prefix) const
inlineconstexprnoexcept

◆ substr()

constexpr microfmt::string_view microfmt::format_parse_context::substr ( size_type  pos = 0,
size_type  count = microfmt::string_view::npos 
) const
inlineconstexprnoexcept

The documentation for this class was generated from the following file: