![]() |
ATLAS Offline Software
|
A class that formats an integer as a hexadecimal string embedded within a format string. More...
#include <HexString.h>
Public Member Functions | |
| template<typename T> | |
| constexpr | HexString (T context) |
| Constructs the formatted string by injecting the hex value of the context into the placeholder. | |
| constexpr | operator std::string_view () const noexcept |
| Implicit conversion operator to std::string_view. | |
| constexpr std::size_t | size () const noexcept |
| Returns the total size of the formatted string. | |
| const char * | c_str () const noexcept |
| Returns a pointer to the underlying null-terminated character array. | |
Static Private Member Functions | |
| static constexpr std::size_t | get_placeholder_pos () |
| Finds the position of the "{}" placeholder within the format string. | |
Private Attributes | |
| char | m_text [s_PrefixLen+s_MaxHexDigits+s_PostfixLen+1] {} |
| The internal buffer storing the fully formatted string. | |
| std::size_t | m_actual_size = 0 |
| The actual length of the generated string. | |
Static Private Attributes | |
| static constexpr std::size_t | s_FormatLen = FormatStr.length() |
| The total length of the format string. | |
| static constexpr std::size_t | s_PlaceholderPos = get_placeholder_pos() |
| The index of the "{}" placeholder. | |
| static constexpr std::size_t | s_PrefixLen = s_PlaceholderPos |
| The index of the "{}" placeholder. | |
| static constexpr std::size_t | s_PostfixLen = s_FormatLen - s_PrefixLen - 2 |
| The length of the string postfix (after the placeholder). | |
| static constexpr std::size_t | s_MaxHexDigits = 16 |
| The maximum number of hex digits (supports up to 64-bit integers). | |
Friends | |
| constexpr std::string | operator+ (std::string lhs, const HexString &rhs) |
| constexpr std::string | operator+ (const HexString &lhs, const std::string &rhs) |
| constexpr std::string | operator+ (const char *lhs, const HexString &rhs) |
| constexpr std::string | operator+ (const HexString &lhs, const char *rhs) |
A class that formats an integer as a hexadecimal string embedded within a format string.
| FormatStr | A FixedString containing exactly one "{}" placeholder. |
Definition at line 54 of file HexString.h.
|
inlineexplicitconstexpr |
Constructs the formatted string by injecting the hex value of the context into the placeholder.
The benefit of this is that it uses a fixed character buffer determined at compile time eliminating the need for allocations in runtime.
| T | An integral type (e.g., int, uint32_t, size_t). |
| context | The integer value to be formatted as a hex string. |
Definition at line 95 of file HexString.h.
|
inlinenoexcept |
Returns a pointer to the underlying null-terminated character array.
Definition at line 171 of file HexString.h.
|
inlinestaticconstexprprivate |
Finds the position of the "{}" placeholder within the format string.
Definition at line 63 of file HexString.h.
|
inlineconstexprnoexcept |
Implicit conversion operator to std::string_view.
Definition at line 133 of file HexString.h.
|
inlineconstexprnoexcept |
Returns the total size of the formatted string.
Definition at line 165 of file HexString.h.
|
friend |
Definition at line 153 of file HexString.h.
|
friend |
Definition at line 157 of file HexString.h.
|
friend |
Definition at line 145 of file HexString.h.
|
friend |
Definition at line 140 of file HexString.h.
|
private |
The actual length of the generated string.
Definition at line 84 of file HexString.h.
|
private |
The internal buffer storing the fully formatted string.
Definition at line 82 of file HexString.h.
|
staticconstexprprivate |
The total length of the format string.
Definition at line 57 of file HexString.h.
|
staticconstexprprivate |
The maximum number of hex digits (supports up to 64-bit integers).
Definition at line 79 of file HexString.h.
|
staticconstexprprivate |
The index of the "{}" placeholder.
Definition at line 71 of file HexString.h.
|
staticconstexprprivate |
The length of the string postfix (after the placeholder).
Definition at line 77 of file HexString.h.
|
staticconstexprprivate |
The index of the "{}" placeholder.
Definition at line 75 of file HexString.h.