Cogs.Core
|
Utility class to ensure that a StringView string is null terminated. More...
#include <StringViewCharPtr.h>
Public Member Functions | |
StringViewCharPtr (const char *data)=delete | |
Construct from constant C-string. Always null terminated. | |
StringViewCharPtr (const Cogs::StringView data) | |
StringViewCharPtr (const std::string &data)=delete | |
Deleted to avoid passing a std::string converted to string_view in constructor above. | |
StringViewCharPtr (const StringViewCharPtr &)=delete | |
StringViewCharPtr & | operator= (const StringViewCharPtr &)=delete |
constexpr | operator const char * () const noexcept |
Gets null terminated C-string. | |
constexpr const char * | c_str () const noexcept |
Gets null terminated C-string. | |
constexpr | operator Cogs::StringView () const noexcept |
Gets null terminated StringView. | |
Private Types | |
using | traits_type = std::char_traits< char > |
Private Attributes | |
Cogs::StringView | view |
std::string | copy |
Utility class to ensure that a StringView string is null terminated.
Can be used to pass Cogs::StringView string to Bridge functions requiring null terminated. Can normally use the passed StringView, but copies to std::string if needed.
Fails: getFieldId(componentId, Cogs::StringView("positionXX", 8).data()); OK: getFieldId(componentId, Cogs::Core::StringViewCharPtr(Cogs::StringView("positionXX", 8).data()));
Definition at line 17 of file StringViewCharPtr.h.
|
private |
Definition at line 18 of file StringViewCharPtr.h.
Cogs::Core::StringViewCharPtr::StringViewCharPtr | ( | const Cogs::StringView | data | ) |
Construct from Cogs::StringView. Copies to local string if substring passed
Definition at line 5 of file StringViewCharPtr.cpp.
|
inlineconstexprnoexcept |
Gets null terminated C-string.
Definition at line 38 of file StringViewCharPtr.h.
|
inlineconstexprnoexcept |
Gets null terminated StringView.
Definition at line 41 of file StringViewCharPtr.h.
|
inlineconstexprnoexcept |
Gets null terminated C-string.
Definition at line 35 of file StringViewCharPtr.h.
|
private |
Definition at line 45 of file StringViewCharPtr.h.
|
private |
Definition at line 44 of file StringViewCharPtr.h.