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
- ArrayRef
constexpr gf::StringRef::StringRef |
( |
| ) |
|
|
inline |
Default constructor.
Data is nullptr
and size is 0.
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 |
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 |
gf::StringRef::StringRef |
( |
const std::string & |
str | ) |
|
|
inline |
Constructor from a std::string
- Parameters
-
constexpr const char* gf::StringRef::getData |
( |
| ) |
const |
|
inline |
Get a pointer to the string.
- Returns
- A pointer to the beginning of the string
constexpr std::size_t gf::StringRef::getSize |
( |
| ) |
const |
|
inline |
Get the size of the string.
- Returns
- The size of the string