Thrill
0.1
|
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 32 of file string_view.hpp.
#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... | |
iterator | begin () const noexcept |
Returns a pointer to the beginning of the data. More... | |
const char * | data () const noexcept |
Returns a pointer to the start of the data. More... | |
iterator | end () const noexcept |
Returns a pointer beyond the end of the data. More... | |
bool | operator!= (const StringView &other) const noexcept |
Inequality operator to compare a StringView with another StringView. More... | |
bool | operator!= (const std::string &other) const noexcept |
Inequality operator to compare a StringView with a std::string. More... | |
bool | operator< (const StringView &other) const noexcept |
bool | operator< (const std::string &other) const noexcept |
bool | operator== (const StringView &other) const noexcept |
Equality operator to compare a StringView with another StringView. More... | |
bool | operator== (const std::string &other) const noexcept |
Equality operator to compare a StringView with a std::string. More... | |
size_t | size () const noexcept |
Returns the size of this StringView. 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... | |
using iterator = const char* |
Definition at line 35 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 47 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 58 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 69 of file string_view.hpp.
|
inlineexplicitnoexcept |
Construct a StringView to the whole std::string.
Definition at line 74 of file string_view.hpp.
|
inlinenoexcept |
Returns a pointer to the beginning of the data.
Definition at line 83 of file string_view.hpp.
References StringView::data_.
|
inlinenoexcept |
Returns a pointer to the start of the data.
Definition at line 78 of file string_view.hpp.
References StringView::data_.
Referenced by hash< tlx::StringView >::operator()().
|
inlinenoexcept |
Returns a pointer beyond the end of the data.
Definition at line 88 of file string_view.hpp.
References StringView::data_, and StringView::size_.
|
inlinenoexcept |
Inequality operator to compare a StringView with another StringView.
Definition at line 104 of file string_view.hpp.
References StringView::operator==().
|
inlinenoexcept |
Inequality operator to compare a StringView with a std::string.
Definition at line 122 of file string_view.hpp.
References StringView::operator==().
|
inlinenoexcept |
Less operator to compare a StringView with another StringView lexicographically
Definition at line 110 of file string_view.hpp.
References StringView::data_, and StringView::size_.
|
inlinenoexcept |
Less operator to compare a StringView with a std::string lexicographically
Definition at line 128 of file string_view.hpp.
References StringView::data_, and StringView::size_.
|
inlinenoexcept |
Equality operator to compare a StringView with another StringView.
Definition at line 98 of file string_view.hpp.
References StringView::data_, and StringView::size_.
Referenced by StringView::operator!=().
|
inlinenoexcept |
Equality operator to compare a StringView with a std::string.
Definition at line 116 of file string_view.hpp.
References StringView::data_, and StringView::size_.
|
inlinenoexcept |
Returns the size of this StringView.
Definition at line 93 of file string_view.hpp.
References StringView::size_.
Referenced by examples::word_count::HashWordCountExample(), main(), hash< tlx::StringView >::operator()(), and examples::word_count::WordCount().
|
inline |
Returns the data of this StringView as a std::string.
Definition at line 139 of file string_view.hpp.
References StringView::data_, and StringView::size_.
Referenced by examples::word_count::HashWordCountExample(), main(), WordCount(), and examples::word_count::WordCount().
|
friend |
make StringView ostreamable
Definition at line 134 of file string_view.hpp.
|
private |
pointer to character data
Definition at line 147 of file string_view.hpp.
Referenced by StringView::begin(), StringView::data(), StringView::end(), StringView::operator<(), StringView::operator==(), and StringView::to_string().
|
private |
size of data
Definition at line 149 of file string_view.hpp.
Referenced by StringView::end(), StringView::operator<(), StringView::operator==(), StringView::size(), and StringView::to_string().