Pyrogenesis
trunk
|
A string reference. More...
#include <format.h>
Public Member Functions | |
BasicStringRef (const Char *s, std::size_t size=0) | |
Constructs a string reference object from a C string and a size. More... | |
BasicStringRef (const std::basic_string< Char > &s) | |
Constructs a string reference from an std::string object. More... | |
operator std::basic_string< Char > () const | |
Converts a string reference to an std::string object. More... | |
const Char * | c_str () const |
Returns the pointer to a C string. More... | |
std::size_t | size () const |
Returns the string size. More... | |
Private Attributes | |
const Char * | data_ |
std::size_t | size_ |
Friends | |
bool | operator== (BasicStringRef lhs, BasicStringRef rhs) |
bool | operator!= (BasicStringRef lhs, BasicStringRef rhs) |
A string reference.
It can be constructed from a C string or std::string
.
You can use one of the following typedefs for common character types:
+---------—+----------------------—+ | Type | Definition | +============+=========================+ | StringRef | BasicStringRef<char> | +---------—+----------------------—+ | WStringRef | BasicStringRef<wchar_t> | +---------—+----------------------—+
This class is most useful as a parameter type to allow passing different types of strings to a function, for example::
template<typename... Args> std::string format(StringRef format, const Args & ... args);
format("{}", 42); format(std::string("{}"), 42);
|
inline |
Constructs a string reference object from a C string and a size.
If size is zero, which is the default, the size is computed automatically.
|
inline |
Constructs a string reference from an std::string
object.
|
inline |
Returns the pointer to a C string.
|
inline |
Converts a string reference to an std::string
object.
|
inline |
Returns the string size.
|
friend |
|
friend |
|
private |
|
mutableprivate |