A constant reference to a string and its size.
More...
#include <gf/StringRef.h>
A constant reference to a string and its size.
This class stores a pointer to a string and its size. It can be built from various inputs: std::string
, C string.
- See also
- gf::ArrayRef, gf::BufferRef
◆ const_iterator
◆ iterator
◆ StringRef() [1/6]
constexpr gf::StringRef::StringRef |
( |
| ) |
|
|
inline |
Default constructor.
Data is nullptr
and size is 0.
◆ StringRef() [2/6]
constexpr gf::StringRef::StringRef |
( |
std::nullptr_t |
| ) |
|
|
inline |
Null constructor.
Data is nullptr
and size is 0.
◆ StringRef() [3/6]
constexpr gf::StringRef::StringRef |
( |
const char * |
str, |
|
|
std::size_t |
size |
|
) |
| |
|
inline |
Constructor from a pointer and a size.
- Parameters
-
str | A pointer to a string |
size | The size of the string |
◆ StringRef() [4/6]
gf::StringRef::StringRef |
( |
const char * |
str | ) |
|
|
inline |
Constructor from a null-terminated string.
The size is computed with std::strlen
.
- Parameters
-
str | A null-terminated string |
◆ StringRef() [5/6]
gf::StringRef::StringRef |
( |
const std::string & |
str | ) |
|
|
inline |
Constructor from a std::string
- Parameters
-
◆ StringRef() [6/6]
constexpr gf::StringRef::StringRef |
( |
const char * |
b, |
|
|
const char * |
e |
|
) |
| |
|
inline |
Constructor from two iterators.
- Parameters
-
b | A pointer to the beginning of a string |
e | A pointer to the end of the same string |
◆ begin()
Get an iterator to the beginning of the string.
- Returns
- A pointer to the first character
- See also
- end()
◆ end()
Get an iterator past the end of the string.
- Returns
- A pointer past the last character
- See also
- begin()
◆ getData()
constexpr const char* gf::StringRef::getData |
( |
| ) |
const |
|
inlinenoexcept |
Get a pointer to the string.
- Returns
- A pointer to the beginning of the string
◆ getISize()
constexpr int gf::StringRef::getISize |
( |
| ) |
const |
|
inlinenoexcept |
Get the size of the string as an int.
- Returns
- The size of the string as an int
◆ getSize()
constexpr std::size_t gf::StringRef::getSize |
( |
| ) |
const |
|
inlinenoexcept |
Get the size of the string.
- Returns
- The size of the string
◆ isEmpty()
constexpr bool gf::StringRef::isEmpty |
( |
| ) |
const |
|
inlinenoexcept |
Check if the string is empty.
An empty string is a string with size 0. So the null string is empty.
- Returns
- True if the string is empty
◆ operator[]()
constexpr char gf::StringRef::operator[] |
( |
std::size_t |
index | ) |
const |
|
inline |
Get a character at a given index.
No verification is done on the index.
- Parameters
-
index | The index of character |
- Returns
- The character at the given index
◆ toString()
std::string gf::StringRef::toString |
( |
| ) |
const |
|
inline |
Get a std::string.
- Returns
- A string with the same data