Allows to exchange strings with external code. More...
Public Member Functions | |
String () noexcept | |
String (char c) noexcept | |
String (const char *data) noexcept | |
String (unsigned long long size) noexcept | |
String (const char *data, unsigned long long size) noexcept | |
String (const String &other) noexcept | |
String (String &&other) noexcept | |
~String () | |
char * | getData () const |
unsigned long long | getSize () const |
char | operator[] (unsigned long long index) const |
char & | operator[] (unsigned long long index) |
String & | operator= (const StringView &other) |
String & | operator= (String &&other) |
String | operator+ (char c) const |
String | operator+ (const StringView &other) const |
void | operator+= (char c) |
void | operator+= (const StringView &other) |
String (const std::string &str) noexcept | |
String (const std::string_view &str) noexcept | |
operator std::string () const | |
operator std::string_view () const | |
Allows to exchange strings with external code.
The aim of this class is not to replace any std::string or std::string_view within a code base. It is intended to avoid passing the std templates, or relying on simple pointers when providing string information to logging capabilities. Note that all other components use nkMemory::String. However, as nkMemory depends on nkLog, this class has been introduced to help nkLog in this matter. A String is offered with many conversion functions, meaning you should never worry about it in the general use-case.
|
noexcept |
Default constructor. Defaults to an empty string (nullptr, of size 0).
|
noexcept |
Char constructor. Creates a single char string.
c | The char to wrap. |
|
noexcept |
Simple pointer constructor. Will use strlen internally to derive its size.
data | The string pointer to create a copy of. |
|
noexcept |
Size constructor. An empty string will allocate needed memory to fit the size requested, without filling it with any data.
size | The size that should be allocated. |
|
noexcept |
Pointer and size constructor. This method allows to provide the size and allows to avoid the call to strlen, if known upfront.
data | The string pointer to create a copy of. |
size | The size of the string passed. |
|
noexcept |
Copy constructor.
other | The string to copy. |
|
noexcept |
Move constructor.
other | The string to move. |
nkLog::String::~String | ( | ) |
Destructor.
|
noexcept |
Inlined standard string constructor. This function is inlined and thus will be fed by the client application, correctly addressing the templated class.
str | The string to create a view from. |
|
noexcept |
Inlined standard string_view constructor. This function is inlined and thus will be fed by the client application, correctly addressing the templated class.
str | The view to create a view from. |
char* nkLog::String::getData | ( | ) | const |
unsigned long long nkLog::String::getSize | ( | ) | const |
char nkLog::String::operator[] | ( | unsigned long long | index | ) | const |
Const access operator.
index | The index of the char to access. |
char& nkLog::String::operator[] | ( | unsigned long long | index | ) |
Access operator.
index | The index of the char to access. |
String& nkLog::String::operator= | ( | const StringView & | other | ) |
String nkLog::String::operator+ | ( | char | c | ) | const |
Concatenation operator.
c | The char to concatenate. |
String nkLog::String::operator+ | ( | const StringView & | other | ) | const |
Concatenation operator.
other | The string to concatenate. |
void nkLog::String::operator+= | ( | char | c | ) |
Self concatenation operator.
c | The char to concatenate. |
void nkLog::String::operator+= | ( | const StringView & | other | ) |
Self concatenation operator.
other | The string to concatenate. |
nkLog::String::operator std::string | ( | ) | const |
Inlined automatic conversion operator. Used to be able to create std::string from any client code.
nkLog::String::operator std::string_view | ( | ) | const |
Inlined automatic conversion operator. Used to be able to create std::string_view from any client code.