Skip to main content

NumberFormatterComponent Class

Component that formats arithmetic values into a display string. More...

Declaration

class helios::engine::modules::ui::layout::components::NumberFormatterComponent { ... }

Public Member Functions Index

voidsetFormat (std::string format)

Sets the format string. More...

template <typename T>
std::stringformat (T value) const

Formats the given arithmetic value into a display string. More...

Private Member Attributes Index

std::stringformat_ = "{:0.f}"

The format string used by std::vformat. More...

Description

Component that formats arithmetic values into a display string.

Holds a std::vformat-compatible format string that accepts a single arithmetic argument. Used by binding systems to convert numeric game state (e.g. scores, health) into text for UiTextComponent.

See Also

Score2UiTextUpdateSystem

See Also

MaxScore2UiTextUpdateSystem

Definition at line 25 of file NumberFormatterComponent.ixx.

Public Member Functions

format()

template <typename T>
std::string helios::engine::modules::ui::layout::components::NumberFormatterComponent::format (T value)
inline

Formats the given arithmetic value into a display string.

Template Parameters
T

An arithmetic type (int, float, double, etc.).

Parameters
value

The value to format.

Returns

The formatted string.

Definition at line 56 of file NumberFormatterComponent.ixx.

56 std::string format(T value) const {
57 return std::vformat(format_, std::make_format_args(value));
58 }

Referenced by setFormat.

setFormat()

void helios::engine::modules::ui::layout::components::NumberFormatterComponent::setFormat (std::string format)
inline

Sets the format string.

Parameters
format

A std::vformat-compatible string (e.g. "{:06.0f}").

Definition at line 41 of file NumberFormatterComponent.ixx.

41 void setFormat(std::string format) {
42 format_ = std::move(format);
43 }

Reference format.

Private Member Attributes

format_

std::string helios::engine::modules::ui::layout::components::NumberFormatterComponent::format_ = "{:0.f}"

The format string used by std::vformat.

Definition at line 30 of file NumberFormatterComponent.ixx.

30 std::string format_ = "{:0.f}";

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.