libGimbal 0.2.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal::String Class Reference
Inheritance diagram for gimbal::String:
Collaboration diagram for gimbal::String:

Public Member Functions

const GblStringBuffer * getString_ (void) const
 
GblStringBuffer * getString_ (void)
 
 String (std::nullptr_t, Size size=sizeof(String))
 
 String (Context *pCtx=nullptr, Size size=sizeof(String))
 
 String (const std::string &stdString, Context *pCtx=nullptr, Size size=sizeof(String))
 
 GBL_PMR_STRING_ONLY_ (String(const std::pmr::string &stdPmrString, Context *pCtx=nullptr, Size size=sizeof(String)):String(std::string_view{stdPmrString.c_str()}, pCtx, size) {}) String(const char *pCStr
 
Context Size Size take (GblStringBuffer *pGblStr)
 
auto take (void)
 
void give (std::pair< char *, Size > data)
 
void clear (void)
 
const String & operator= (std::string_view view)
 
const String & operator= (const String &rhs)
 
const String & operator= (StringView string)
 
const String & operator= (const std::string &stdString)
 
- Public Member Functions inherited from gimbal::StringViewBase< String >
 operator const GblStringBuffer * () const
 
const char & getElement_ (size_t index) const
 
char & getElement_ (size_t index)
 
void setElement_ (size_t index, char value)
 
size_t getElementCount_ (void) const
 
Size getStackBytes (void) const
 
constexpr Size getLength (void) const
 
constexpr Size getCapacity (void) const
 
Context * getContext (void) const
 
constexpr bool isEmpty (void) const
 
constexpr bool isStack (void) const
 
constexpr bool isHeap (void) const
 
const char * getCString (void) const
 
char * getCString (void)
 
std::string toStdString (void) const
 
constexpr std::string_view toStringView (void) const
 

Data Fields

Context * pCtx
 
Context Size size
 
- Data Fields inherited from GblStringBuffer
GblArrayList data
 

Additional Inherited Members

- Public Types inherited from gimbal::StringViewBase< String >
using StringViewType
 
using Derived
 
using Iterable
 
using iterator
 
using const_iterator
 
- Protected Member Functions inherited from gimbal::StringViewBase< String >
decltype(auto) str_ (void) const
 
decltype(auto) str_ (void)
 

Detailed Description

Definition at line 184 of file gimbal_string.hpp.

Constructor & Destructor Documentation

◆ String() [1/3]

gimbal::String::String ( std::nullptr_t ,
Size size = sizeof(String) )
inline

Definition at line 201 of file gimbal_string.hpp.

201 :
202 String(static_cast<Context*>(nullptr), size) {}

◆ String() [2/3]

gimbal::String::String ( Context * pCtx = nullptr,
Size size = sizeof(String) )
inline

Definition at line 204 of file gimbal_string.hpp.

204 :
205 String(std::string_view{}, pCtx, size) {}

◆ String() [3/3]

gimbal::String::String ( const std::string & stdString,
Context * pCtx = nullptr,
Size size = sizeof(String) )
inline

Definition at line 208 of file gimbal_string.hpp.

208 :
209 String(std::string_view{stdString.c_str()}, pCtx, size) {}

Member Function Documentation

◆ getString_() [1/2]

const GblStringBuffer * gimbal::String::getString_ ( void ) const
inline

Definition at line 190 of file gimbal_string.hpp.

190 {
191 return static_cast<const GblStringBuffer*>(this);
192 }

◆ getString_() [2/2]

GblStringBuffer * gimbal::String::getString_ ( void )
inline

Definition at line 194 of file gimbal_string.hpp.

194 {
195 return static_cast<GblStringBuffer*>(this);
196 }

◆ take() [1/2]

Context Size Size gimbal::String::take ( GblStringBuffer * pGblStr)
inline

Definition at line 247 of file gimbal_string.hpp.

247 {
248 char* pCStr = nullptr;
249 Size capacity = 0;
250 Exception::checkThrow(GblStringBuffer_release(pGblStr, &pCStr, &capacity));
251 return { pCStr, capacity };
252 }
GBL_RESULT GblStringBuffer_release(GblStringBuffer *pSelf, char **ppStrPtr, size_t *pCapacity)
Takes ownership of the given GblStringBuffer's internal buffer, also returning its capacity and a res...

◆ take() [2/2]

auto gimbal::String::take ( void )
inline

Definition at line 254 of file gimbal_string.hpp.

254 {
255 return take(this);
256 }

◆ give()

void gimbal::String::give ( std::pair< char *, Size > data)
inline

Definition at line 258 of file gimbal_string.hpp.

258 {
259 Exception::checkThrow(GblStringBuffer_acquire(this, data.first, data.second));
260 }
GBL_RESULT GblStringBuffer_acquire(GblStringBuffer *pSelf, char *pData, size_t capacity)
Transfers ownership of a given C string to the given buffer, assigning its value and updating its cap...
GblArrayList data
Internal storage buffer.

◆ clear()

void gimbal::String::clear ( void )
inline

Definition at line 262 of file gimbal_string.hpp.

262 {
263 Exception::checkThrow(GblStringBuffer_clear(this));
264 }
GBL_RESULT GblStringBuffer_clear(GblStringBuffer *pSelf)
Clears the contents of the given GblStringBuffer, resetting it back to an empty state and returning a...

◆ operator=() [1/4]

const String & gimbal::String::operator= ( std::string_view view)
inline

Definition at line 266 of file gimbal_string.hpp.

266 {
267 Exception::checkThrow(GblStringBuffer_set(this, GBL_STRING_VIEW(view.data(), view.size())));
268 return *this;
269 }
const char * GblStringBuffer_set(GblStringBuffer *pSelf, const char *pStr, size_t len)
Assigns the value of the given GblStringBuffer to pStr, optionally taking its length,...

◆ operator=() [2/4]

const String & gimbal::String::operator= ( const String & rhs)
inline

Definition at line 271 of file gimbal_string.hpp.

271 {
272 return *this = StringView(rhs);
273 }

◆ operator=() [3/4]

const String & gimbal::String::operator= ( StringView string)
inline

Definition at line 275 of file gimbal_string.hpp.

275 {
276 return *this = string.toStringView();
277 }

◆ operator=() [4/4]

const String & gimbal::String::operator= ( const std::string & stdString)
inline

Definition at line 279 of file gimbal_string.hpp.

279 {
280 return *this = stdString.c_str();
281 }

Field Documentation

◆ pCtx

Context* gimbal::String::pCtx

Definition at line 216 of file gimbal_string.hpp.

◆ size

Context Size gimbal::String::size

Definition at line 216 of file gimbal_string.hpp.

216 :
217 String(pCStr? std::string_view{pCStr} : std::string_view{}, pCtx, size) {}
218
219 String(const std::string_view& stringView, Context* pCtx=nullptr, Size size=sizeof(String)) {
220 Exception::checkThrow(GblStringBuffer_construct(this,
221 GBL_STRING_VIEW(stringView.data(), stringView.length()),
222 size,
223 pCtx));
224 }
225
226 // Copy Ctor
227 String(const String& rhs, Context* pCtx=nullptr, Size size=sizeof(String)):
228 String(StringView(rhs), pCtx, size) {}
229
230 String(StringView other, Context* pCtx=nullptr, Size size=sizeof(String)):
231 String(other.toStringView(), pCtx? pCtx : other.getContext(), size) {}
232
233 // Move Ctor
234 String(String&& rhs, Context* pCtx=nullptr, Size size=sizeof(String)):
235 String(static_cast<GblStringBuffer&&>(rhs), pCtx, size) {}
236
237 String(GblStringBuffer&& rhs, Context* pCtx=nullptr, Size size=sizeof(String)):
238 String(pCtx, size)
239 {
240 *this = rhs;
241 }
242
243 ~String(void) {
244 Exception::checkThrow(GblStringBuffer_destruct(this));
245 }
GBL_RESULT GblStringBuffer_destruct(GblStringBuffer *pSelf)
Destructs the given GblStringBuffer structure, releasing any allocated resources and returning a resu...
GBL_RESULT GblStringBuffer_construct(GblStringBuffer *pSelf, const char *pString, size_t length, size_t structSize, GblContext *pCtx)
Constructs the given GblStringBuffer struct with any given initial values (or defaults),...

The documentation for this class was generated from the following file: