13 #ifndef TLX_CONTAINER_STRING_VIEW_HEADER 14 #define TLX_CONTAINER_STRING_VIEW_HEADER 70 const std::string::const_iterator&
end) noexcept
78 const char *
data() const noexcept {
93 size_t size() const noexcept {
99 return size_ == other.size_ &&
111 return std::lexicographical_compare(
117 return size_ == other.size() &&
129 return std::lexicographical_compare(
135 return os.write(sv.
data(), sv.
size());
167 return std::lexicographical_compare(
168 a.data(), a.data() + a.size(), b.data(), b.data() + b.size());
188 #endif // !TLX_CONTAINER_STRING_VIEW_HEADER bool operator<(const StringView &other) const noexcept
StringView(const std::string &str) noexcept
Construct a StringView to the whole std::string.
iterator begin() const noexcept
Returns a pointer to the beginning of the data.
StringView()=default
Default constructor for a StringView. Doesn't initialize anything.
static uint32_t hash_djb2(const unsigned char *str)
Simple, fast, but "insecure" string hash method by Dan Bernstein from http://www.cse.yorku.ca/~oz/hash.html.
friend std::ostream & operator<<(std::ostream &os, const StringView &sv)
make StringView ostreamable
iterator end() const noexcept
Returns a pointer beyond the end of the data.
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.
size_t size() const noexcept
Returns the size of this StringView.
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.
bool operator==(const StringView &other) const noexcept
Equality operator to compare a StringView with another StringView.
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
StringView is a reference to a part of a string, consisting of only a char pointer and a length...
bool operator!=(const StringView &other) const noexcept
Inequality operator to compare a StringView with another StringView.
std::string to_string() const
Returns the data of this StringView as a std::string.
const char * data() const noexcept
Returns a pointer to the start of the data.
StringView(const char *data, size_t size) noexcept
Creates a new StringView, given a const char* and the size.
HashCrc32< T > hash
Select a hashing method.
const char * data_
pointer to character data