Gamedev Framework (gf)  0.3.0
A C++11 framework for 2D games
Public Member Functions | List of all members
gf::StringRef Class Reference

A constant reference to a string and its size. More...

#include <gf/StringRef.h>

Public Member Functions

constexpr StringRef ()
 Default constructor. More...
 
constexpr StringRef (const char *str, std::size_t size)
 Constructor from a pointer and a size. More...
 
 StringRef (const char *str)
 Constructor from a null-terminated string. More...
 
 StringRef (const std::string &str)
 Constructor from a std::string More...
 
constexpr const char * getData () const
 Get a pointer to the string. More...
 
constexpr std::size_t getSize () const
 Get the size of the string. More...
 

Detailed Description

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

Constructor & Destructor Documentation

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
strA pointer to a string
sizeThe 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
strA null-terminated string
gf::StringRef::StringRef ( const std::string &  str)
inline

Constructor from a std::string

Parameters
strA C++ string

Member Function Documentation

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