Class holding information about a string, with no ownership over the data. More...
Public Member Functions | |
StringView () noexcept | |
StringView (const char *data) noexcept | |
StringView (const char *data, unsigned long long size) noexcept | |
StringView (const nkLog::StringView &logStr) noexcept | |
StringView (const String &other) noexcept | |
StringView (const StringView &other) noexcept | |
StringView (StringView &&other) noexcept | |
const char * | getData () const |
unsigned long long | getSize () const |
bool | empty () const |
char | front () const |
char | back () const |
const char * | begin () const |
char * | begin () |
const char * | end () const |
unsigned char * | end () |
BufferCast< StringView > | split (StringView separator) |
StringView & | operator= (const char *data) noexcept |
StringView & | operator= (const String &other) noexcept |
StringView & | operator= (const StringView &other) noexcept |
StringView & | operator= (StringView &&other) noexcept |
char | operator[] (unsigned long long index) const |
String | operator+ (char c) const |
String | operator+ (const char *data) const |
String | operator+ (const StringView &other) const |
bool | operator== (const char *other) const |
bool | operator== (const StringView &other) const |
bool | operator!= (const char *other) const |
bool | operator!= (const StringView &other) const |
template<typename T = std::string> | |
StringView (const std::string &str) noexcept | |
template<typename T = std::string> | |
StringView (const std::string &str, unsigned long long index, unsigned long long size=0ull) noexcept | |
template<typename T = std::string_view> | |
StringView (const std::string_view &str) noexcept | |
template<typename T = std::string_view> | |
StringView (const std::string_view &str, unsigned long long index, unsigned long long size=0ull) noexcept | |
operator std::string () const | |
operator std::string_view () const | |
operator nkLog::String () const | |
operator nkLog::StringView () const | |
StringView & | operator= (const std::string &data) |
StringView & | operator= (const std::string_view &data) |
Class holding information about a string, with no ownership over the data.
This class will abstract a chain of characters and offer some utility to help manipulating them. The aim of this class is not to replace std::string_view within a codebase, but rather to offer a safe data exchange class from an app to the dlls, and the other way around. This class being fully exported, it doesn't suffer from the caveats a template can have in such situations.
To help in this dialog between app and dlls, the class is thought to be as transparent as possible between const char*, std::string_view and other widespread way of representing strings. Typical usage would just be to use standard structures in your app and benefit from the automatic conversions from one type to another.
Note that a view does not own the memory provided. As such, it is pretty fast as no memory shuffling is necessary. However, care must be taken when using it with temporary memory.
|
noexcept |
Default constructor. Will default to a nullptr data and a size of 0.
|
noexcept |
Const char* constructor. Provided memory location will be pointed by the view. Be sure provided data is null-terminated so that its length can correctly be determined.
data | The pointer to the chain of characters to take over. |
|
noexcept |
Guided const char* constructor. Provided memory location will be pointed and based on the size given. Prefer this constructor over the const char* constructor if you know the size required.
data | The pointer to the chain of characters to point to. |
size | The size of the chain provided, in number of chars. |
|
noexcept |
|
noexcept |
|
noexcept |
Copy constructor.
other | The view to copy. |
|
noexcept |
Move constructor.
other | The view to move over. |
|
noexcept |
Standard string constructor. The string provided will be pointed by the view.
str | The string to point to. |
|
noexcept |
Standards sub-string constructor. The string provided will be pointed by the view, at given index and size.
str | The string to point to. |
index | The index of the char to start the view on. |
size | The size of the view to create. If 0, will default to the whole remainder of the string starting from the index. |
|
noexcept |
Standard string view constructor. The view provided will be used to find the memory to point to.
str | The view to mimick. |
|
noexcept |
Standards sub-string view constructor. The view provided will be used to find the memory to point to.
str | The view to mimick. |
index | The index of the char to start the view on. |
size | The size of the view to create. If 0, will default to the whole remainder of the string starting from the index. |
const char* nkMemory::StringView::getData | ( | ) | const |
unsigned long long nkMemory::StringView::getSize | ( | ) | const |
bool nkMemory::StringView::empty | ( | ) | const |
char nkMemory::StringView::front | ( | ) | const |
char nkMemory::StringView::back | ( | ) | const |
const char* nkMemory::StringView::begin | ( | ) | const |
char* nkMemory::StringView::begin | ( | ) |
const char* nkMemory::StringView::end | ( | ) | const |
unsigned char* nkMemory::StringView::end | ( | ) |
BufferCast<StringView> nkMemory::StringView::split | ( | StringView | separator | ) |
Splits a string into multiple tokens.
separator | The separator pattern to use to split the string. |
|
noexcept |
Const char* assignment operator.
data | The pointer over the memory to point to. |
|
noexcept |
String assignment operator.
other | The string to point to. |
|
noexcept |
Copy assignment operator.
other | The view to copy. |
|
noexcept |
Move assignment operator.
other | The view to move over. |
char nkMemory::StringView::operator[] | ( | unsigned long long | index | ) | const |
Const access operator.
index | The index of the char to access. |
String nkMemory::StringView::operator+ | ( | char | c | ) | const |
Char concatenation operator.
c | The char to concatenate. |
String nkMemory::StringView::operator+ | ( | const char * | data | ) | const |
Char pointer concatenation operator.
data | The pointed data to concatenate with. |
String nkMemory::StringView::operator+ | ( | const StringView & | other | ) | const |
View concatenation operator.
other | The view to concatenate with. |
bool nkMemory::StringView::operator== | ( | const char * | other | ) | const |
Const char* equality operator.
other | The const char* to check equality with. |
bool nkMemory::StringView::operator== | ( | const StringView & | other | ) | const |
View equality operator.
other | The view to check equality with. |
bool nkMemory::StringView::operator!= | ( | const char * | other | ) | const |
Const char* inequality operator.
other | The const char* to check difference with. |
bool nkMemory::StringView::operator!= | ( | const StringView & | other | ) | const |
View inequality operator.
other | The view to check difference with. |
nkMemory::StringView::operator std::string | ( | ) | const |
Conversion operator, to std::string.
nkMemory::StringView::operator std::string_view | ( | ) | const |
Conversion operator, to std::string_view.
nkMemory::StringView::operator nkLog::String | ( | ) | const |
Conversion operator, to nkLog::String.
nkMemory::StringView::operator nkLog::StringView | ( | ) | const |
Conversion operator, to nkLog::StringView.
StringView& nkMemory::StringView::operator= | ( | const std::string & | data | ) |
Templated assignment operator.
data | The string to assign. |
StringView& nkMemory::StringView::operator= | ( | const std::string_view & | data | ) |
Templated assignment operator.
data | The string view to assign. |