Allows to exchange strings with external code.
More...
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::StringView. However, as nkMemory depends on nkLog, this class has been introduced to help nkLog in this matter. A StringView is offered with many conversion functions, meaning you should never worry about it in the general use-case.
◆ StringView() [1/6]
nkLog::StringView::StringView |
( |
| ) |
|
|
delete |
◆ StringView() [2/6]
nkLog::StringView::StringView |
( |
const char * |
data | ) |
|
|
noexcept |
Simple pointer constructor. Will use strlen internally to derive its size.
- Parameters
-
data | The string pointer to create a view over. |
◆ StringView() [3/6]
nkLog::StringView::StringView |
( |
const char * |
data, |
|
|
unsigned long long |
size |
|
) |
| |
|
noexcept |
Pointer and size constructor. This method allows to provide the size and allows to avoid the call to strlen, if known upfront.
- Parameters
-
data | The string pointer to create a view over. |
size | The size of the string passed. |
◆ StringView() [4/6]
nkLog::StringView::StringView |
( |
const String & |
str | ) |
|
|
noexcept |
View over String constructor.
- Parameters
-
str | The string to create the view from. |
◆ StringView() [5/6]
nkLog::StringView::StringView |
( |
const std::string & |
str | ) |
|
|
noexcept |
Inlined standard string constructor. This function is inlined and thus will be fed by the client application, correctly addressing the templated class.
- Parameters
-
str | The string to create a view from. |
◆ StringView() [6/6]
nkLog::StringView::StringView |
( |
std::string_view |
str | ) |
|
|
noexcept |
Inlined standard string_view constructor. This function is inlined and thus will be fed by the client application, correctly addressing the templated class.
- Parameters
-
str | The view to create a view from. |
◆ getData()
const char* nkLog::StringView::getData |
( |
| ) |
const |
- Returns
- The string data pointer.
◆ getSize()
unsigned long long nkLog::StringView::getSize |
( |
| ) |
const |
- Returns
- The size of the string view.
◆ operator[]()
char nkLog::StringView::operator[] |
( |
unsigned long long |
index | ) |
const |
Const access operator.
- Parameters
-
index | The index of the char to access. |
◆ operator std::string()
nkLog::StringView::operator std::string |
( |
| ) |
const |
Inlined automatic conversion operator. Used to be able to create std::string from any client code.
◆ operator std::string_view()
nkLog::StringView::operator std::string_view |
( |
| ) |
const |
Inlined automatic conversion operator. Used to be able to create std::string_view from any client code.
The documentation for this class was generated from the following file: