1#ifndef GIMBAL_STRING_REF_HPP
2#define GIMBAL_STRING_REF_HPP
17 StringRef()
noexcept =
default;
19 StringRef(
const char* pStr, std::size_t len=0)
noexcept:
20 pRef_(GblStringRef_create(pStr, len)) { }
43 ~StringRef()
noexcept {
47 StringRef& operator=(
const char* pCStr)
noexcept {
49 GblStringRef_create(pCStr);
66 operator
const char*()
const noexcept {
70 char operator[](std::size_t index)
const {
72 throw std::out_of_range {
73 "Attempt to index StringRef out-of-range!"
79 StringView view(std::size_t offset=0, std::size_t len=0)
const {
81 len = length() - offset;
83 if(offset + len > length())
84 throw std::out_of_range {
85 "Attempt to create out-of-range StringView from StringRef"
89 return GblStringView {
90 .
pData = pRef_ + offset,
96 std::size_t refCount()
const noexcept {
100 std::size_t length()
const noexcept {
104 bool valid()
const noexcept {
108 bool empty()
const noexcept {
112 bool blank()
const noexcept {
size_t GblStringRef_length(const GblStringRef *pSelf)
Returns the cached length of the given GblStringRef.
GblBool GblStringRef_blank(const GblStringRef *pSelf)
Returns whether the given GblStringRef is blank, containing only NULL or spacing characters.
GblBool GblStringRef_valid(const GblStringRef *pSelf)
Returns whether the given GblStringRef is valid (not NULL)
GblBool GblStringRef_empty(const GblStringRef *pSelf)
Returns whether the given GblStringRef is empty, with nothing but a NULL terminator.
GblRefCount GblStringRef_refCount(const GblStringRef *pSelf)
Returns the number of active references remaining to the given GblStringRef.
GblRefCount GblStringRef_unref(const GblStringRef *pRef)
Releases a reference to pRef, freeing the allocation if it was the last, returning the new refCount.
GblStringRef * GblStringRef_ref(const GblStringRef *pRef)
Returns a new reference to pRef, incrementing its internal reference count rather than actually copyi...
const char GblStringRef
Reference-counted, const char*-compatible string type.
size_t nullTerminated
Reserved bit for maintaining whether the string is NULL terminated or not.
const char * pData
Start address of the string being viewed.
size_t length
Length (bytes) of the substring being viewed.
OO C++ binding object around GblStringView.