Go to the documentation of this file.
13 #ifndef TLX_CONTAINER_STRING_VIEW_HEADER
14 #define TLX_CONTAINER_STRING_VIEW_HEADER
70 const std::string::const_iterator&
end) noexcept
74 explicit StringView(
const std::string& str) noexcept
78 const char *
data() const noexcept {
93 size_t size() const noexcept {
99 return size_ == other.size_ &&
111 return std::lexicographical_compare(
116 bool operator == (
const std::string& other)
const noexcept {
117 return size_ == other.size() &&
122 bool operator != (
const std::string& other)
const noexcept {
128 bool operator < (
const std::string& other)
const noexcept {
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());
180 struct hash<
tlx::StringView> {
188 #endif // !TLX_CONTAINER_STRING_VIEW_HEADER
static uint32_t hash_djb2(const unsigned char *str)
Simple, fast, but "insecure" string hash method by Dan Bernstein from http://www.cse....
static bool operator<(const std::string &a, const StringView &b) noexcept
Less operator to compare a std::string with a StringView lexicographically.
StringView is a reference to a part of a string, consisting of only a char pointer and a length.
iterator begin() const noexcept
Returns a pointer to the beginning of the data.
StringView()=default
Default constructor for a StringView. Doesn't initialize anything.
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.
static bool operator==(const std::string &a, const StringView &b) noexcept
Equality operator to compare a std::string with a StringView.
static bool operator!=(const std::string &a, const StringView &b) noexcept
Inequality operator to compare a std::string with a StringView.
bool operator==(const StringView &other) const noexcept
Equality operator to compare a StringView with another StringView.
size_t size() const noexcept
Returns the size of this 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.
bool operator!=(const StringView &other) const noexcept
Inequality operator to compare a StringView with another StringView.
const char * data_
pointer to character data
bool operator<(const StringView &other) const noexcept
Less operator to compare a StringView with another StringView lexicographically.