Magnum::Ui::HexadecimalFormatter class new in Git master

Formatter for hexadecimal integer values.

Public types

enum class Flag: UnsignedByte { ExplicitPlus = 1 << 0, Uppercase = 1 << 1, BasePrefix = 1 << 2, HashPrefix = 1 << 3 }
Flag.
using Flags = Containers::EnumSet<Flag> new in Git master
Flags.

Public static functions

static auto parse(Containers::StringView text, Int& value) -> ParseState
Parse text matching the formatter output.
static auto parse(Containers::StringView text, UnsignedInt& value) -> ParseState
static auto parse(Containers::StringView text, Long& value) -> ParseState
static auto parse(Containers::StringView text, UnsignedLong& value) -> ParseState

Constructors, destructors, conversion operators

HexadecimalFormatter(Flags flags = {}) explicit
Constructor.

Public functions

auto flags() const -> Flags
Flags.
auto setFlags(Flags flags) -> HexadecimalFormatter&
Set flags.
auto addFlags(Flags flags) -> HexadecimalFormatter&
Add flags.
auto clearFlags(Flags flags) -> HexadecimalFormatter&
Clear flags.
auto minWidth() const -> Int
Minimal number width.
auto setMinWidth(Int width) -> HexadecimalFormatter&
Set minimal number width.
void operator()(TextLayer& layer, DataHandle data, Int value) const
Format a value.
void operator()(TextLayer& layer, DataHandle data, UnsignedInt value) const
void operator()(TextLayer& layer, DataHandle data, Long value) const
void operator()(TextLayer& layer, DataHandle data, UnsignedLong value) const
void operator()(TextLayer& layer, LayerDataHandle data, Int value) const
Format a value assuming it comes from given layer.
void operator()(TextLayer& layer, LayerDataHandle data, UnsignedInt value) const
void operator()(TextLayer& layer, LayerDataHandle data, Long value) const
void operator()(TextLayer& layer, LayerDataHandle data, UnsignedLong value) const

Enum documentation

enum class Magnum::Ui::HexadecimalFormatter::Flag: UnsignedByte

Flag.

Enumerators
ExplicitPlus

Prefix positive values with an explicit + sign

Uppercase

Use uppercase heaxadecimal letters and prefix if Flag::BasePrefix is enabled, instead of lowercase.

BasePrefix

Format with a 0x prefix. If Flag::Uppercase is enabled as well, prefixes with 0X instead of 0x. If both Flag::BasePrefix and HashPrefix is enabled, HashPrefix has a precedence.

HashPrefix

Format with a # prefix, such as for color values. If both Flag::BasePrefix and HashPrefix is enabled, HashPrefix has a precedence.

Typedef documentation

typedef Containers::EnumSet<Flag> Magnum::Ui::HexadecimalFormatter::Flags new in Git master

Flags.

Function documentation

static ParseState Magnum::Ui::HexadecimalFormatter::parse(Containers::StringView text, Int& value)

Parse text matching the formatter output.

Parameters
text Text to parse
value Where to put the parsed value
Returns Result of the parsing operation

Expects that text is Containers::StringViewFlag::NullTerminated. Leading and trailing whitespace is trimmed from the text and the value is parsed assuming it's hexadecimal, potentially with a 0x / 0X or # prefix. Both lowercase and uppercase input is supported.

If parsing succeeds, the function returns ParseState::Success and populates value. If the text is empty or all whitespace, ParseState::Failed is returned, same if the text contains a negative value and the resulting type is unsigned. Otherwise, if the value cannot fit into chosen resulting type, value is filled with a corresponding min / max representable value and ParseState::Clamped is returned.

static ParseState Magnum::Ui::HexadecimalFormatter::parse(Containers::StringView text, UnsignedInt& value)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

static ParseState Magnum::Ui::HexadecimalFormatter::parse(Containers::StringView text, Long& value)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

static ParseState Magnum::Ui::HexadecimalFormatter::parse(Containers::StringView text, UnsignedLong& value)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Magnum::Ui::HexadecimalFormatter::HexadecimalFormatter(Flags flags = {}) explicit

Constructor.

Parameters
flags Flags

HexadecimalFormatter& Magnum::Ui::HexadecimalFormatter::setFlags(Flags flags)

Set flags.

Returns Reference to self (for method chaining)

HexadecimalFormatter& Magnum::Ui::HexadecimalFormatter::addFlags(Flags flags)

Add flags.

Returns Reference to self (for method chaining)

Calls setFlags() with the existing flags ORed with flags. Useful for preserving previously set flags.

HexadecimalFormatter& Magnum::Ui::HexadecimalFormatter::clearFlags(Flags flags)

Clear flags.

Returns Reference to self (for method chaining)

Calls setFlags() with the existing flags ANDed with the inverse of flags. Useful for removing a subset of previously set flags.

HexadecimalFormatter& Magnum::Ui::HexadecimalFormatter::setMinWidth(Int width)

Set minimal number width.

If the formatted number has less digits than specified width, it's padded by leading zeros. Sign or prefix isn't counted into the width. Expects that width is at least 0 and at most 255. Default value is 1.

If width is 0, formatting a zero value results in an empty text, regardless of whether Flag::ExplicitPlus, BasePrefix or HashPrefix was specified.

void Magnum::Ui::HexadecimalFormatter::operator()(TextLayer& layer, DataHandle data, Int value) const

Format a value.

Expects that data is valid in layer. Internally formats the value to a stack-allocated string and passes it to TextLayer::setText(), see that function documentation for more information.

void Magnum::Ui::HexadecimalFormatter::operator()(TextLayer& layer, DataHandle data, UnsignedInt value) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void Magnum::Ui::HexadecimalFormatter::operator()(TextLayer& layer, DataHandle data, Long value) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void Magnum::Ui::HexadecimalFormatter::operator()(TextLayer& layer, DataHandle data, UnsignedLong value) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void Magnum::Ui::HexadecimalFormatter::operator()(TextLayer& layer, LayerDataHandle data, Int value) const

Format a value assuming it comes from given layer.

Like operator()(TextLayer&, DataHandle, Int) const but without checking that handle indeed belongs to layer. See its documentation for more information.

void Magnum::Ui::HexadecimalFormatter::operator()(TextLayer& layer, LayerDataHandle data, UnsignedInt value) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void Magnum::Ui::HexadecimalFormatter::operator()(TextLayer& layer, LayerDataHandle data, Long value) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void Magnum::Ui::HexadecimalFormatter::operator()(TextLayer& layer, LayerDataHandle data, UnsignedLong value) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Debug& operator<<(Debug& debug, HexadecimalFormatter::Flag value) new in Git master

Debug output operator.

Debug& operator<<(Debug& debug, HexadecimalFormatter::Flags value) new in Git master

Debug output operator.