FloatFormatter class new in Git master
#include <Magnum/Ui/Formatter.h>
Formatter for floating-point values.
Public types
- enum class Flag: UnsignedByte { ExplicitPlus = 1 << 0, Uppercase = 1 << 1, Decimal = 1 << 2, Exponent = 1 << 3 }
- Flag.
-
using Flags = Containers::
EnumSet<Flag> new in Git master - Flags.
Public static functions
-
static auto parse(Containers::
StringView text, Float& value) -> ParseState - Parse text matching the formatter output.
-
static auto parse(Containers::
StringView text, Double& value) -> ParseState
Constructors, destructors, conversion operators
- FloatFormatter(Flags flags = {}) explicit
- Constructor.
Public functions
- auto flags() const -> Flags
- Flags.
- auto setFlags(Flags flags) -> FloatFormatter&
- Set flags.
- auto addFlags(Flags flags) -> FloatFormatter&
- Add flags.
- auto clearFlags(Flags flags) -> FloatFormatter&
- Clear flags.
- auto precision() const -> Int
- Number precision.
- auto setPrecision(Int precision) -> FloatFormatter&
- Set number precision.
- void operator()(TextLayer& layer, DataHandle data, Float value) const
- Format a value.
- void operator()(TextLayer& layer, DataHandle data, Double value) const
- void operator()(TextLayer& layer, LayerDataHandle data, Float value) const
- Format a value assuming it comes from given layer.
- void operator()(TextLayer& layer, LayerDataHandle data, Double value) const
Enum documentation
enum class Magnum:: Ui:: FloatFormatter:: Flag: UnsignedByte
Flag.
| Enumerators | |
|---|---|
| ExplicitPlus |
Prefix positive values with an explicit + sign |
| Uppercase |
Use uppercase for exponents, infinity and NaN values. Default is lowercase. |
| Decimal |
Force decimal notation. The precision set by setPrecision() then specifies the number of digits after the decimal point. Default is either decimal or exponent notation depending on value an precision. Setting both Flag:: |
| Exponent |
Force decimal exponent notation. The precision set by setPrecision() then specifies the number of digits after the decimal point. Default is either decimal or exponent notation depending on value an precision. Setting both Flag:: |
Typedef documentation
typedef Containers:: EnumSet<Flag> Magnum:: Ui:: FloatFormatter:: Flags new in Git master
Flags.
Function documentation
static ParseState Magnum:: Ui:: FloatFormatter:: parse(Containers:: StringView text,
Float& 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::
If parsing succeeds, the function returns ParseState::value. If the text is empty or all whitespace, ParseState::value is filled with a corresponding positive or negative infinity and ParseState::
static ParseState Magnum:: Ui:: FloatFormatter:: parse(Containers:: StringView text,
Double& 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:: FloatFormatter:: FloatFormatter(Flags flags = {}) explicit
Constructor.
| Parameters | |
|---|---|
| flags | Flags |
FloatFormatter& Magnum:: Ui:: FloatFormatter:: setFlags(Flags flags)
Set flags.
| Returns | Reference to self (for method chaining) |
|---|
FloatFormatter& Magnum:: Ui:: FloatFormatter:: 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.
FloatFormatter& Magnum:: Ui:: FloatFormatter:: 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.
FloatFormatter& Magnum:: Ui:: FloatFormatter:: setPrecision(Int precision)
Set number precision.
Expects that precision is at least 0 and at most 255. Note that the precision choice along with the value itself affects whether the value is printed with or without an exponent, enable Flag::6, which is consistent with how Debug or Utility::
void Magnum:: Ui:: FloatFormatter:: operator()(TextLayer& layer,
DataHandle data,
Float 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::
void Magnum:: Ui:: FloatFormatter:: operator()(TextLayer& layer,
DataHandle data,
Double 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:: FloatFormatter:: operator()(TextLayer& layer,
LayerDataHandle data,
Float value) const
Format a value assuming it comes from given layer.
Like operator()(TextLayer&, DataHandle, Float) const but without checking that handle indeed belongs to layer. See its documentation for more information.
void Magnum:: Ui:: FloatFormatter:: operator()(TextLayer& layer,
LayerDataHandle data,
Double 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,
FloatFormatter:: Flag value) new in Git master
Debug output operator.
Debug& operator<<(Debug& debug,
FloatFormatter:: Flags value) new in Git master
Debug output operator.