Lightweight string-like object.
More...
Lightweight string-like object.
tts::text is a simple string-like object that can be used to represent and manipulate text data in TTS. It provides basic functionalities such as construction from formatted strings, concatenation, and stream output support
#define TTS_MAIN
#include <tts/tts.hpp>
{
tts::text qty(
" with values %d %f", 42, 3.5f);
TTS_EQUAL(full,
"Hello World ! with values 42 3.500000");
};
- See also
- tts::as_text
|
|
| text () |
| | Default constructor.
|
|
template<std::size_t N> |
| | text (char const (&data)[N]) |
| | Construct from fixed-size C-style string.
|
| template<typename... Args> |
| | text (char const *format, Args... args) |
| | Construct from formatted string.
|
|
| text (char const *ptr) |
| | Construct from C-style string.
|
|
| text (text &&other) noexcept |
| | Move constructor.
|
|
| text (text const &other) |
| | Copy constructor.
|
|
| ~text () |
| | Destructor.
|
|
decltype(auto) | begin () |
| | Get an iterator to the beginning of the text.
|
|
decltype(auto) | begin () const |
| | Get a const iterator to the beginning of the text.
|
| char const * | data () const |
|
decltype(auto) | end () |
| | Get an iterator to the end of the text.
|
|
decltype(auto) | end () const |
| | Get a const iterator to the end of the text.
|
|
bool | is_empty () const |
| | Check if the text is empty.
|
|
text | operator+ (text const &other) const |
| | Concatenate and return a new text instance.
|
|
text & | operator+= (char const *other) |
| | Concatenate a C-style string.
|
|
text & | operator+= (text const &other) |
| | Concatenate another text instance.
|
|
text & | operator= (text &&other) noexcept |
| | Move assignment operator.
|
|
text & | operator= (text const &other) |
| | Copy assignment operator.
|
|
size_t | size () const |
| | Get the size of the text.
|
|
void | swap (text &o) noexcept |
| | Swap contents with another text instance.
|
|
|
template<_::stream OS> |
| OS & | operator<< (OS &os, text const &t) |
| | Stream output operator.
|
|
template<std::size_t N> |
| auto | operator<=> (text const &a, char const (&b)[N]) noexcept |
| | Three-way comparison operator with C-style string.
|
|
std::strong_ordering | operator<=> (text const &a, text const &b) noexcept |
| | Three-way comparison operator with other text instance.
|
|
template<std::size_t N> |
| bool | operator== (text const &a, char const (&b)[N]) noexcept |
| | Equality comparison operator with C-style string.
|
|
bool | operator== (text const &a, text const &b) noexcept |
| | Equality comparison operator.
|
◆ text()
template<typename... Args>
| tts::text::text |
( |
char const * | format, |
|
|
Args... | args ) |
|
inlineexplicit |
Construct from formatted string.
tts::text is constructible from a C-style format string and a variable number of arguments.
- Parameters
-
| format | C-style format string |
| args | Arguments to format according to format |
◆ data()
| char const * tts::text::data |
( |
| ) |
const |
|
inlinenodiscard |
Get a pointer to the constant underlying character data Returns an empty string literal if data_ is null to prevent s crashes