2
3
4
5
6
7
8
9
10
11
12
13
15#ifndef GIMBAL_QUARK_HPP
16#define GIMBAL_QUARK_HPP
26
27
28
29
30
31
32
39 Quark(
void) =
default;
44 Quark(
const char* pString, std::size_t length=0):
45 Quark(GblQuark_tryString(pString, length)) {}
47 Quark(
const std::string& stdStr):
48 Quark(stdStr.c_str()) {}
50 Quark(std::string_view strv):
51 Quark(strv.data(), strv.length()) {}
53 bool isValid(
void)
const {
57 const char* toString(
void)
const {
61 std::size_t length(
void)
const {
71 char operator[](std::size_t index)
const {
73 throw std::out_of_range(
"Out-of-range GblQuark access!");
75 return toString()[index];
85 Quark& operator=(
const char* pString) {
86 value_ = GblQuark_tryString(pString);
90 Quark& operator=(
const std::string& stdStr) {
91 return *
this = stdStr.c_str();
94 Quark& operator=(std::string_view strv) {
95 value_ = GblQuark_tryString(strv.data(), strv.length());
101 static Quark fromString(
const char* pString, std::size_t length=0) {
102 return GblQuark_fromString(pString, length);
105 static Quark fromString(
const std::string& stdStr) {
106 return fromString(stdStr.c_str());
109 static Quark fromString(std::string_view strv) {
110 return fromString(strv.data(), strv.length());
113 static Quark fromStatic(
const char* pString) {
117 static const char* internString(
const char* pString, std::size_t length=0) {
118 return GblQuark_internString(pString, length);
121 static const char* internStatic(
const char* pString) {
125 friend std::ostream& operator<<(std::ostream &os,
Quark quark) {
126 os << quark.toString();
131inline Quark operator
""_qrk(
const char* pString, std::size_t size)
noexcept {
OO C++ wrapper object around GblQuark.
const char * GblQuark_internStatic(const char *pString)
Creates a GblQuark from the given STATIC string (if necessary, saving on allocating),...
#define GBL_QUARK_INVALID
Value of an invalid or NULL GblQuark.
GblQuark GblQuark_fromStatic(const char *pSstring)
Returns the GblQuark associated with the given STATIC string, which can save an allocation when initi...
const char * GblQuark_toString(GblQuark quark)
Returns the NULL-terminated interned C string associated with a given GblQuark.
uintptr_t GblQuark
Uniquely identifiable interned string type.