tlx
|
StringView is a reference to a part of a string, consisting of only a char pointer and a length. More...
#include <string_view.hpp>
Public Types | |
using | iterator = const char * |
Public Member Functions | |
StringView ()=default | |
Default constructor for a StringView. Doesn't initialize anything. More... | |
StringView (const char *data, size_t size) noexcept | |
Creates a new StringView, given a const char* and the size. More... | |
StringView (const std::string::const_iterator &data, size_t size) noexcept | |
Creates a new StringView, given a const iterator to a std::string and the size. More... | |
StringView (const std::string::const_iterator &begin, const std::string::const_iterator &end) noexcept | |
Creates a new reference StringView, given two const iterators to a std::string. More... | |
StringView (const std::string &str) noexcept | |
Construct a StringView to the whole std::string. More... | |
const char * | data () const noexcept |
Returns a pointer to the start of the data. More... | |
iterator | begin () const noexcept |
Returns a pointer to the beginning of the data. More... | |
iterator | end () const noexcept |
Returns a pointer beyond the end of the data. More... | |
size_t | size () const noexcept |
Returns the size of this StringView. More... | |
bool | operator== (const StringView &other) const noexcept |
Equality operator to compare a StringView with another StringView. More... | |
bool | operator!= (const StringView &other) const noexcept |
Inequality operator to compare a StringView with another StringView. More... | |
bool | operator< (const StringView &other) const noexcept |
Less operator to compare a StringView with another StringView lexicographically. More... | |
bool | operator== (const std::string &other) const noexcept |
Equality operator to compare a StringView with a std::string. More... | |
bool | operator!= (const std::string &other) const noexcept |
Inequality operator to compare a StringView with a std::string. More... | |
bool | operator< (const std::string &other) const noexcept |
Less operator to compare a StringView with a std::string lexicographically. More... | |
std::string | to_string () const |
Returns the data of this StringView as a std::string. More... | |
Private Attributes | |
const char * | data_ |
pointer to character data More... | |
size_t | size_ |
size of data More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const StringView &sv) |
make StringView ostreamable More... | |
StringView is a reference to a part of a string, consisting of only a char pointer and a length.
It does not have ownership of the substring and is used mainly for temporary objects.
Definition at line 42 of file string_view.hpp.
using iterator = const char* |
Definition at line 45 of file string_view.hpp.
|
default |
Default constructor for a StringView. Doesn't initialize anything.
|
inlinenoexcept |
Creates a new StringView, given a const char* and the size.
data | pointer to start of data |
size | size of data in bytes. |
Definition at line 57 of file string_view.hpp.
|
inlinenoexcept |
Creates a new StringView, given a const iterator to a std::string and the size.
data | iterator to start of data |
size | size of data in character. |
Definition at line 68 of file string_view.hpp.
|
inlinenoexcept |
Creates a new reference StringView, given two const iterators to a std::string.
begin | iterator to start of data |
end | iterator to the end of data. |
Definition at line 79 of file string_view.hpp.
|
inlineexplicitnoexcept |
Construct a StringView to the whole std::string.
Definition at line 84 of file string_view.hpp.
|
inlinenoexcept |
Returns a pointer to the beginning of the data.
Definition at line 93 of file string_view.hpp.
|
inlinenoexcept |
Returns a pointer to the start of the data.
Definition at line 88 of file string_view.hpp.
|
inlinenoexcept |
Returns a pointer beyond the end of the data.
Definition at line 98 of file string_view.hpp.
|
inlinenoexcept |
Inequality operator to compare a StringView with a std::string.
Definition at line 132 of file string_view.hpp.
|
inlinenoexcept |
Inequality operator to compare a StringView with another StringView.
Definition at line 114 of file string_view.hpp.
|
inlinenoexcept |
Less operator to compare a StringView with a std::string lexicographically.
Definition at line 138 of file string_view.hpp.
|
inlinenoexcept |
Less operator to compare a StringView with another StringView lexicographically.
Definition at line 120 of file string_view.hpp.
|
inlinenoexcept |
Equality operator to compare a StringView with a std::string.
Definition at line 126 of file string_view.hpp.
|
inlinenoexcept |
Equality operator to compare a StringView with another StringView.
Definition at line 108 of file string_view.hpp.
|
inlinenoexcept |
Returns the size of this StringView.
Definition at line 103 of file string_view.hpp.
|
inline |
Returns the data of this StringView as a std::string.
Definition at line 149 of file string_view.hpp.
|
friend |
make StringView ostreamable
Definition at line 144 of file string_view.hpp.
|
private |
pointer to character data
Definition at line 157 of file string_view.hpp.
|
private |
size of data
Definition at line 159 of file string_view.hpp.