28 #ifndef BSL_FMT_OPTIONS_HPP 29 #define BSL_FMT_OPTIONS_HPP 66 fmt_fsm_alternate_form = 2U,
67 fmt_fsm_sign_aware = 3U,
82 fmt_align_default = 0U,
96 fmt_sign_neg_only = 0U,
97 fmt_sign_pos_neg = 1U,
98 fmt_sign_space_for_pos = 3U,
111 fmt_type_default = 0U,
150 bool m_alternate_form{};
179 case details::fmt_fsm::fmt_fsm_align: {
180 this->fmt_options_impl_align(f, idx, len);
181 fsm = details::fmt_fsm::fmt_fsm_sign;
185 case details::fmt_fsm::fmt_fsm_sign: {
186 this->fmt_options_impl_sign(f, idx);
187 fsm = details::fmt_fsm::fmt_fsm_alternate_form;
191 case details::fmt_fsm::fmt_fsm_alternate_form: {
192 this->fmt_options_impl_alternate_form(f, idx);
193 fsm = details::fmt_fsm::fmt_fsm_sign_aware;
197 case details::fmt_fsm::fmt_fsm_sign_aware: {
198 this->fmt_options_impl_sign_aware(f, idx);
199 fsm = details::fmt_fsm::fmt_fsm_width;
203 case details::fmt_fsm::fmt_fsm_width: {
204 this->fmt_options_impl_width(f, idx, len);
205 fsm = details::fmt_fsm::fmt_fsm_type;
209 case details::fmt_fsm::fmt_fsm_type: {
210 this->fmt_options_impl_type(f, idx);
306 [[nodiscard]] constexpr
bool 309 return m_alternate_form;
322 m_alternate_form = val;
333 [[nodiscard]] constexpr
bool 425 fmt_options_impl_align(
432 if ((idx + 1U) < len) {
434 f_align = f[idx + 1U];
444 m_align = fmt_align::fmt_align_left;
451 m_align = fmt_align::fmt_align_right;
458 m_align = fmt_align::fmt_align_center;
468 if (fmt_align::fmt_align_default == m_align) {
471 m_align = fmt_align::fmt_align_left;
477 m_align = fmt_align::fmt_align_right;
483 m_align = fmt_align::fmt_align_center;
505 fmt_options_impl_sign(cstr_type
const f,
bsl::uintmax &idx) noexcept
509 m_sign = fmt_sign::fmt_sign_pos_neg;
515 m_sign = fmt_sign::fmt_sign_neg_only;
521 m_sign = fmt_sign::fmt_sign_space_for_pos;
542 fmt_options_impl_alternate_form(cstr_type
const f,
bsl::uintmax &idx) noexcept
545 m_alternate_form =
true;
560 fmt_options_impl_sign_aware(cstr_type
const f,
bsl::uintmax &idx) noexcept
578 fmt_options_impl_width(
583 for (
bsl::uintmax i{}; (i < max_num_digits) && (idx < len); ++i) {
586 if ((digit >=
'0') && (digit <=
'9')) {
588 m_width += static_cast<bsl::uintmax>(digit);
589 m_width -= static_cast<bsl::uintmax>(
'0');
608 fmt_options_impl_type(cstr_type
const f,
bsl::uintmax &idx) noexcept
613 m_type = fmt_type::fmt_type_b;
618 m_type = fmt_type::fmt_type_c;
623 m_type = fmt_type::fmt_type_d;
628 m_type = fmt_type::fmt_type_s;
634 m_type = fmt_type::fmt_type_x;
constexpr fmt_sign sign() const noexcept
Returns the "sign" field in the {fmt} syntax based on the previously provided format string.
Definition: fmt_options.hpp:280
constexpr bsl::uintmax npos
defines npos
Definition: npos.hpp:37
constexpr void set_align(fmt_align const val) noexcept
Sets the "align" field in the {fmt} syntax, overriding what the previously provided format string pro...
Definition: fmt_options.hpp:266
constexpr void set_fill(char_type const val) noexcept
Sets the "fill" field in the {fmt} syntax, overriding what the previously provided format string prov...
Definition: fmt_options.hpp:239
constexpr bool sign_aware() const noexcept
Returns the "sign aware" field in the {fmt} syntax based on the previously provided format string.
Definition: fmt_options.hpp:334
constexpr void set_sign(fmt_sign const val) noexcept
Sets the "sign" field in the {fmt} syntax, overriding what the previously provided format string prov...
Definition: fmt_options.hpp:293
Used by fmt to determine how to format the output of an fmt command. See the documentation fo bsl::fm...
Definition: fmt_options.hpp:141
::uint32_t uint32
defines an 32bit unsigned integer
Definition: cstdint.hpp:49
constexpr bsl::uintmax width() const noexcept
Returns the "width" field in the {fmt} syntax based on the previously provided format string.
Definition: fmt_options.hpp:361
char const * cstr_type
C-style string type.
Definition: cstr_type.hpp:39
constexpr fmt_options ptrops
defines how to format a ptr like type.
Definition: fmt_options.hpp:650
constexpr fmt_align align() const noexcept
Returns the "align" field in the {fmt} syntax based on the previously provided format string.
Definition: fmt_options.hpp:253
fmt_align
Used to determine what the alignment of the output should be. If the width is not defined,...
Definition: fmt_options.hpp:80
constexpr bool alternate_form() const noexcept
Returns the "alt form" field in the {fmt} syntax based on the previously provided format string.
Definition: fmt_options.hpp:307
fmt_sign
Used to determine how an integral's sign field is handled. This only has an effect on signed types.
Definition: fmt_options.hpp:94
constexpr fmt_options nullops
defines no formatting.
Definition: fmt_options.hpp:648
char char_type
Standard Char Type.
Definition: char_type.hpp:41
constexpr fmt_type type() const noexcept
Returns the "type" field in the {fmt} syntax based on the previously provided format string.
Definition: fmt_options.hpp:388
constexpr fmt_options(cstr_type const f) noexcept
Creates a bsl::fmt_options given a user provided format string. The goal of this class is to pre-proc...
Definition: fmt_options.hpp:170
fmt_type
Used to determine how to output an unsigned integer type (either as hex or dec). All ofther {fmt} typ...
Definition: fmt_options.hpp:109
constexpr char_type fill() const noexcept
Returns the "fill" field in the {fmt} syntax based on the previously provided format string.
Definition: fmt_options.hpp:226
constexpr bsl::uintmax builtin_strlen(cstr_type const str) noexcept
Same as std::strlen with parameter checks. If str is a nullptr, this returns 0.
Definition: cstring.hpp:154
::uintptr_t uintptr
defines a unsigned integer the size of a void *
Definition: cstdint.hpp:92
constexpr void set_alternate_form(bool const val) noexcept
Sets the "alt form" field in the {fmt} syntax, overriding what the previously provided format string ...
Definition: fmt_options.hpp:320
constexpr void set_width(bsl::uintmax const val) noexcept
Sets the "width" field in the {fmt} syntax, overriding what the previously provided format string pro...
Definition: fmt_options.hpp:374
::uintmax_t uintmax
defines a unsigned integer with the maximum possible size
Definition: cstdint.hpp:97
constexpr void set_type(fmt_type const val) noexcept
Sets the "type" field in the {fmt} syntax, overriding what the previously provided format string prov...
Definition: fmt_options.hpp:401
fmt_fsm
Used to define a finite state machine that is used to parse the {fmt} style syntax for formatting....
Definition: fmt_options.hpp:62
constexpr void set_sign_aware(bool const val) noexcept
Sets the "sign aware" field in the {fmt} syntax, overriding what the previously provided format strin...
Definition: fmt_options.hpp:347