Helpers to use C++ strings parameters.
More...
This wraps std::string and std::string_view to the SDL's C interfaces.
This should only be declared in function parameters, using it otherwise is to ask for undefined behavior
◆ StringParam() [1/4]
constexpr SDL::StringParam::StringParam |
( |
const char * |
str | ) |
|
|
inlineconstexpr |
This assumes the parameter object lifetime is larger than this object, which is always true on parameters, so it just stores the pointer, no copy is done.
- Parameters
-
str | the string to store. This parameter must outlive this object. |
◆ StringParam() [2/4]
constexpr SDL::StringParam::StringParam |
( |
const std::string & |
str | ) |
|
|
inlineconstexpr |
This assumes the parameter object lifetime is larger than this object, which is always true on parameters, so it just stores the pointer to internal string data, no copy is done.
- Parameters
-
str | the reference to a string. This parameter must outlive this object. |
◆ StringParam() [3/4]
constexpr SDL::StringParam::StringParam |
( |
std::string && |
str | ) |
|
|
inlineconstexpr |
This case we assume the ownership for the string and will properly call destructor automatically.
- Parameters
-
◆ StringParam() [4/4]
SDL::StringParam::StringParam |
( |
std::string_view |
str | ) |
|
|
inline |
String view are very usefull on C++, but they don't have the null terminator expected by most string SDL APIs, so we always copy its content to a stored std::string.
- Parameters
-
str | the string_view to store |
◆ c_str()
constexpr const char * SDL::StringParam::c_str |
( |
| ) |
const |
|
inlineconstexpr |
- Returns
- the C string representation. We guarantee it to be null terminated unless the objects it was constructed from are corrupted.
◆ operator const char *()
constexpr SDL::StringParam::operator const char * |
( |
| ) |
const |
|
inlineconstexpr |
- Returns
- the C string representation. We guarantee it to be null terminated unless the objects it was constructed from are corrupted.
The documentation for this class was generated from the following file: