Skip to main content

NumberFormatterComponent.ixx File

Component that formats numeric values for UI display. More...

Included Headers

#include <format> #include <string>

Namespaces Index

namespacehelios
namespaceengine

Main engine module aggregating core infrastructure and game systems. More...

namespacemodules

Domain-specific components and systems. More...

namespaceui

User interface components and systems for game entities. More...

namespacelayout

Layout primitives for UI positioning and value formatting. More...

namespacecomponents

Layout-related UI components. More...

Classes Index

classNumberFormatterComponent

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

Description

Component that formats numeric values for UI display.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file NumberFormatterComponent.ixx
3 * @brief Component that formats numeric values for UI display.
4 */
5module;
6
7#include <format>
8#include <string>
9
10export module helios.engine.modules.ui.layout.components.NumberFormatterComponent;
11
12
14
15 /**
16 * @brief Component that formats arithmetic values into a display string.
17 *
18 * Holds a std::vformat-compatible format string that accepts a single
19 * arithmetic argument. Used by binding systems to convert numeric game
20 * state (e.g. scores, health) into text for UiTextComponent.
21 *
22 * @see Score2UiTextUpdateSystem
23 * @see MaxScore2UiTextUpdateSystem
24 */
26
27 /**
28 * @brief The format string used by std::vformat.
29 */
30 std::string format_ = "{:0.f}";
31
32
33
34 public:
35
36 /**
37 * @brief Sets the format string.
38 *
39 * @param format A std::vformat-compatible string (e.g. "{:06.0f}").
40 */
41 void setFormat(std::string format) {
42 format_ = std::move(format);
43 }
44
45 /**
46 * @brief Formats the given arithmetic value into a display string.
47 *
48 * @tparam T An arithmetic type (int, float, double, etc.).
49 *
50 * @param value The value to format.
51 *
52 * @return The formatted string.
53 */
54 template<typename T>
55 requires std::is_arithmetic_v<T>
56 std::string format(T value) const {
57 return std::vformat(format_, std::make_format_args(value));
58 }
59
60 };
61
62
63}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.