libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
GblStringView Struct Reference

#include <gimbal_string_view.h>

Inheritance diagram for GblStringView:
gbl::StringView

Data Fields

const char * pData
 
size_t nullTerminated: 1
 
size_t length: 63
 

Related Symbols

(Note that these are not member symbols.)

Construction

Methods for constructing a new view

GblStringView GblStringView_fromEmpty (void)
 
GblStringView GblStringView_fromString (const char *pString, size_t length)
 
GblStringView GblStringView_fromQuark (GblQuark quark)
 
Comparisons

Methods providing string view comparison operators

int GblStringView_compare (GblStringView self, const char *pString, size_t len)
 
int GblStringView_compareIgnoreCase (GblStringView self, const char *pString, size_t len)
 
GblBool GblStringView_equals (GblStringView self, const char *pString, size_t len)
 
GblBool GblStringView_equalsIgnoreCase (GblStringView self, const char *pString, size_t len)
 
Reading

Methods for retrieving characters and substrings

char GblStringView_at (GblStringView self, size_t index)
 
char GblStringView_first (GblStringView self)
 
char GblStringView_last (GblStringView self)
 
GBL_RESULT GblStringView_copy (GblStringView self, void *pDst, size_t offset, size_t bytes)
 
Trimming

Methods for creating substrings

GblStringView GblStringView_removePrefix (GblStringView self, size_t length)
 
GblStringView GblStringView_removeSuffix (GblStringView self, size_t length)
 
GblStringView GblStringView_chomp (GblStringView self)
 
GblStringView GblStringView_substr (GblStringView self, size_t offset, size_t length)
 
Searching

Methods for finding, counting, and matching

GblBool GblStringView_contains (GblStringView self, const char *pString, size_t len)
 
GblBool GblStringView_containsIgnoreCase (GblStringView self, const char *pString, size_t len)
 
size_t GblStringView_count (GblStringView self, const char *pString, size_t len)
 
size_t GblStringView_countIgnoreCase (GblStringView self, const char *pString, size_t len)
 
size_t GblStringView_find (GblStringView self, const char *pStr, size_t len, size_t offset)
 
size_t GblStringView_findIgnoreCase (GblStringView self, const char *pStr, size_t len, size_t offset)
 
size_t GblStringView_rfind (GblStringView self, const char *pStr, size_t len, size_t offset)
 
size_t GblStringView_rfindIgnoreCase (GblStringView self, const char *pStr, size_t len, size_t offset)
 
GblBool GblStringView_startsWith (GblStringView self, const char *pString, size_t len)
 
GblBool GblStringView_startsWithIgnoreCase (GblStringView self, const char *pString, size_t len)
 
GblBool GblStringView_endsWith (GblStringView self, const char *pString, size_t len)
 
GblBool GblStringView_endsWithIgnoreCase (GblStringView self, const char *pString, size_t len)
 
size_t GblStringView_findFirstOf (GblStringView self, const char *pChars, size_t len, size_t offset)
 
size_t GblStringView_findLastOf (GblStringView self, const char *pChars, size_t len, size_t offset)
 
size_t GblStringView_findFirstNotOf (GblStringView self, const char *pChars, size_t len, size_t offset)
 
size_t GblStringView_findLastNotOf (GblStringView self, const char *pChars, size_t len, size_t offset)
 
Utilities

Methods providing miscellaneous functionality

GblBool GblStringView_empty (GblStringView self)
 
GblBool GblStringView_blank (GblStringView self)
 
GblHash GblStringView_hash (GblStringView self)
 
GblQuark GblStringView_quark (GblStringView self)
 
GblQuark GblStringView_tryQuark (GblStringView self)
 
const char * GblStringView_intern (GblStringView self)
 
char * GblStringView_strdup (GblStringView self)
 
int GblStringView_scanf (GblStringView self, const char *pFmt,...)
 
int GblStringView_scanfVa (GblStringView self, const char *pFmt, va_list *pVarArgs)
 
Converting

Methods providing conversion operators from string views

char * GblStringView_toCString (GblStringView self, char *pDest, size_t destSize)
 
GblBool GblStringView_toNil (GblStringView self)
 
GblBool GblStringView_toBool (GblStringView self, GblBool *pSuccess)
 
char GblStringView_toChar (GblStringView self, GblBool *pSuccess)
 
uint8_t GblStringView_toUint8 (GblStringView self, GblBool *pSuccess)
 
uint16_t GblStringView_toUint16 (GblStringView self, GblBool *pSuccess)
 
int16_t GblStringView_toInt16 (GblStringView self, GblBool *pSuccess)
 
uint32_t GblStringView_toUint32 (GblStringView self, GblBool *pSuccess)
 
int32_t GblStringView_toInt32 (GblStringView self, GblBool *pSuccess)
 
uint64_t GblStringView_toUint64 (GblStringView self, GblBool *pSuccess)
 
int64_t GblStringView_toInt64 (GblStringView self, GblBool *pSuccess)
 
float GblStringView_toFloat (GblStringView self, GblBool *pSuccess)
 
double GblStringView_toDouble (GblStringView self, GblBool *pSuccess)
 
void * GblStringView_toPointer (GblStringView self, GblBool *pSuccess)
 

Detailed Description

Immutable substring type.

Represents an externally owned slice or "view" into a region of a string, storing its start address and length. NULL termination is not required, so a string view cannot be assumed to be a well-formed standalone C string.

Definition at line 57 of file gimbal_string_view.h.

Friends And Related Symbol Documentation

◆ GblStringView_fromEmpty()

GblStringView GblStringView_fromEmpty ( void  )
related

Constructs an empty GblStringView (same as zero initializing one)

◆ GblStringView_fromString()

GblStringView GblStringView_fromString ( const char *  pString,
size_t  length 
)
related

Constructs a GblStringView from a(n optionally sized) character array.

◆ GblStringView_fromQuark()

GblStringView GblStringView_fromQuark ( GblQuark  quark)
related

Constructs a GblStringView from an existing GblQuark, or creating an empty view if it's invalid.

◆ GblStringView_compare()

int GblStringView_compare ( GblStringView  self,
const char *  pString,
size_t  len 
)
related

Lexicographically compares the given view to pString, returning a positive or negative for inequality or 0 if equal.

◆ GblStringView_compareIgnoreCase()

int GblStringView_compareIgnoreCase ( GblStringView  self,
const char *  pString,
size_t  len 
)
related

Lexicographically compares the given view to pString, ignoring case, returning a positive or negative for inequality or 0 if equal.

◆ GblStringView_equals()

GblBool GblStringView_equals ( GblStringView  self,
const char *  pString,
size_t  len 
)
related

Returns GBL_TRUE if the given string view equals pString or returns GBL_FALSE otherwise.

◆ GblStringView_equalsIgnoreCase()

GblBool GblStringView_equalsIgnoreCase ( GblStringView  self,
const char *  pString,
size_t  len 
)
related

Returns GBL_TRUE if the given string view equals pString (ignoring casing on both operands) or returns GBL_FALSE otherwise.

◆ GblStringView_at()

char GblStringView_at ( GblStringView  self,
size_t  index 
)
related

Returns the character within the given view at index, raising an error if it is out-of-range.

◆ GblStringView_first()

char GblStringView_first ( GblStringView  self)
related

Returns the first character within the given view, raising an error if the view is empty.

◆ GblStringView_last()

char GblStringView_last ( GblStringView  self)
related

Returns the last character within the given view, raising an error if the view is empty.

◆ GblStringView_copy()

GBL_RESULT GblStringView_copy ( GblStringView  self,
void *  pDst,
size_t  offset,
size_t  bytes 
)
related

Copies an arbitrary substring within teh view into the external buffer, pDst of size bytes starting at offset.

◆ GblStringView_removePrefix()

GblStringView GblStringView_removePrefix ( GblStringView  self,
size_t  length 
)
related

! Returns a new GblStringView which has had the first length characters chopped off, raising an error upon failure

◆ GblStringView_removeSuffix()

GblStringView GblStringView_removeSuffix ( GblStringView  self,
size_t  length 
)
related

Returns a new GblStringView which has the last length characters chopped off, raising an error upon failure.

◆ GblStringView_chomp()

GblStringView GblStringView_chomp ( GblStringView  self)
related

Returns a new GblStringView which has any terminating newline characters (linux + windows) chopped off.

◆ GblStringView_substr()

GblStringView GblStringView_substr ( GblStringView  self,
size_t  offset,
size_t  length 
)
related

Retruns a new GblStringView as a subview of the given GblStringView, starting at offset of size length.

◆ GblStringView_contains()

GblBool GblStringView_contains ( GblStringView  self,
const char *  pString,
size_t  len 
)
related

Returns GBL_TRUE if the given GblStringView contains the substring, pString, otherwise returning GBL_FALSE if not found.

◆ GblStringView_containsIgnoreCase()

GblBool GblStringView_containsIgnoreCase ( GblStringView  self,
const char *  pString,
size_t  len 
)
related

Returns GBL_TRUE if the given GblStringView contains the substring, pString, (ignoring case) otherwise returning GBL_FALSE if not found.

◆ GblStringView_count()

size_t GblStringView_count ( GblStringView  self,
const char *  pString,
size_t  len 
)
related

Returns the number of times the substring, pString, appears within the given GblStringView.

◆ GblStringView_countIgnoreCase()

size_t GblStringView_countIgnoreCase ( GblStringView  self,
const char *  pString,
size_t  len 
)
related

Returns the number of times the substring, pString, appears within the given GblStringView, ignoring casing.

◆ GblStringView_find()

size_t GblStringView_find ( GblStringView  self,
const char *  pStr,
size_t  len,
size_t  offset 
)
related

Returns the starting index of the first occurrence of pStr appearing as a substring within the given GblStringView after offset.

◆ GblStringView_findIgnoreCase()

size_t GblStringView_findIgnoreCase ( GblStringView  self,
const char *  pStr,
size_t  len,
size_t  offset 
)
related

Returns the starting index of the first occurrence of pStr appearing as a substring within the given GblStringView after offset (ignoring casing)

◆ GblStringView_rfind()

size_t GblStringView_rfind ( GblStringView  self,
const char *  pStr,
size_t  len,
size_t  offset 
)
related

Returns the starting index of the last occurrence of pStr appearing as a substring within the given GblStringView before offset.

◆ GblStringView_rfindIgnoreCase()

size_t GblStringView_rfindIgnoreCase ( GblStringView  self,
const char *  pStr,
size_t  len,
size_t  offset 
)
related

Returns the starting index of the last occurrence of pStr appearing as a substring within the given GblStringView before offset (ignoring case)

◆ GblStringView_startsWith()

GblBool GblStringView_startsWith ( GblStringView  self,
const char *  pString,
size_t  len 
)
related

Returns GBL_TRUE if the given GblStringView starts with the substring given by pString, otherwise returning GBL_FALSE.

◆ GblStringView_startsWithIgnoreCase()

GblBool GblStringView_startsWithIgnoreCase ( GblStringView  self,
const char *  pString,
size_t  len 
)
related

Returns GBL_TRUE if the given GblStringView starts with the substring given by pString (ignoring casing), otherwise returning GBL_FALSE.

◆ GblStringView_endsWith()

GblBool GblStringView_endsWith ( GblStringView  self,
const char *  pString,
size_t  len 
)
related

Returns GBL_TRUE if the given GblStringView ends with the substring given by pString, otherwise returning GBL_FALSE.

◆ GblStringView_endsWithIgnoreCase()

GblBool GblStringView_endsWithIgnoreCase ( GblStringView  self,
const char *  pString,
size_t  len 
)
related

Returns GBL_TRUE if the given GblStringView ends with the substring given by pString (ignoring casing), otherwise returning GBL_FALSE.

◆ GblStringView_findFirstOf()

size_t GblStringView_findFirstOf ( GblStringView  self,
const char *  pChars,
size_t  len,
size_t  offset 
)
related

Returns the index of the first occurrence of one of the characters provided within pChars, starting at offset.

◆ GblStringView_findLastOf()

size_t GblStringView_findLastOf ( GblStringView  self,
const char *  pChars,
size_t  len,
size_t  offset 
)
related

Returns the index of the last occurrence of one of the characters provided within pChars, ending at offset.

◆ GblStringView_findFirstNotOf()

size_t GblStringView_findFirstNotOf ( GblStringView  self,
const char *  pChars,
size_t  len,
size_t  offset 
)
related

Returns the index of the first occurrence of a character NOT provided within pChars, starting at offset.

◆ GblStringView_findLastNotOf()

size_t GblStringView_findLastNotOf ( GblStringView  self,
const char *  pChars,
size_t  len,
size_t  offset 
)
related

Returns the index of the last occurrence of a character NOT provided within pChars, ending at offset.

◆ GblStringView_empty()

GblBool GblStringView_empty ( GblStringView  self)
related

Returns GBL_TRUE if the given GblStringView is empty, otherwise returning GBL_FALSE.

◆ GblStringView_blank()

GblBool GblStringView_blank ( GblStringView  self)
related

Returns GBL_TRUE if the given GblStringView contains only whitespace characters (spaces, tabs, newlines)

◆ GblStringView_hash()

GblHash GblStringView_hash ( GblStringView  self)
related

Returns the GblHash for the given GblStringView, using the default libGimbal hashing algorithm.

◆ GblStringView_quark()

GblQuark GblStringView_quark ( GblStringView  self)
related

Creates and returns a GblQuark interned string representation from the given GblStringView.

◆ GblStringView_tryQuark()

GblQuark GblStringView_tryQuark ( GblStringView  self)
related

Attempts to return the GblQuark corresponding to the given GblStringView, retruning GBL_QUARK_INVALID if there isn't one.

◆ GblStringView_intern()

const char * GblStringView_intern ( GblStringView  self)
related

Interns (creates a GblQuark) from the given GblStringView, returning its C string representation.

◆ GblStringView_strdup()

char * GblStringView_strdup ( GblStringView  self)
related

Duplicates the given GblStringView as a heap-allocated NULL-terminated C string and returns it. Don't forget to free it!

◆ GblStringView_scanf()

int GblStringView_scanf ( GblStringView  self,
const char *  pFmt,
  ... 
)
related

Calls libC's sscanf() using the given GblStringView as the source buffer.

◆ GblStringView_scanfVa()

int GblStringView_scanfVa ( GblStringView  self,
const char *  pFmt,
va_list *  pVarArgs 
)
related

Calls libC's vsscanf() using the given GblStringView as the source buffer.

◆ GblStringView_toCString()

char * GblStringView_toCString ( GblStringView  self,
char *  pDest,
size_t  destSize 
)
related

Converts the given GblStringView to a NULL-terminated C string, copying it to the pDest buffer of destSize capacity.

◆ GblStringView_toNil()

GblBool GblStringView_toNil ( GblStringView  self)
related

Converts the given GblStringView to NIL (returns GBL_TRUE if it's empty or matches "nil")

◆ GblStringView_toBool()

GblBool GblStringView_toBool ( GblStringView  self,
GblBool pSuccess 
)
related

Converts the given GblStringView to a boolean value, optionally returning whether the conversion succeeded or not.

◆ GblStringView_toChar()

char GblStringView_toChar ( GblStringView  self,
GblBool pSuccess 
)
related

Converts the given GblStringView to a char value, optionally returning whether the conversion succeeded or not.

◆ GblStringView_toUint8()

uint8_t GblStringView_toUint8 ( GblStringView  self,
GblBool pSuccess 
)
related

Converts the given GblStringView to a uint8_t value, optionally returning whether the conversion succeeded or not.

◆ GblStringView_toUint16()

uint16_t GblStringView_toUint16 ( GblStringView  self,
GblBool pSuccess 
)
related

Converts the given GblStringView to a uint16_t value, optionally returning whether the conversion succeeded or not.

◆ GblStringView_toInt16()

int16_t GblStringView_toInt16 ( GblStringView  self,
GblBool pSuccess 
)
related

Converts the given GblStringView to an int16_t value, optionally returning whether the conversion succeeded or not.

◆ GblStringView_toUint32()

uint32_t GblStringView_toUint32 ( GblStringView  self,
GblBool pSuccess 
)
related

Converts the given GblStringView to a uint32_t value, optionally returning whether the conversion succeeded or not.

◆ GblStringView_toInt32()

int32_t GblStringView_toInt32 ( GblStringView  self,
GblBool pSuccess 
)
related

Converts the given GblStringView to an int32_t value, optionally returning whether the conversion succeeded or not.

◆ GblStringView_toUint64()

uint64_t GblStringView_toUint64 ( GblStringView  self,
GblBool pSuccess 
)
related

Converts the given GblStringView to a uint64_t value, optionally returning whether the conversion succeeded or not.

◆ GblStringView_toInt64()

int64_t GblStringView_toInt64 ( GblStringView  self,
GblBool pSuccess 
)
related

Converts the given GblStringView to an int64_t value, optionally returning whether the conversion succeeded or not.

◆ GblStringView_toFloat()

float GblStringView_toFloat ( GblStringView  self,
GblBool pSuccess 
)
related

Converts the given GblStringView to a float value, optionally returning whether the conversion succeeded or not.

◆ GblStringView_toDouble()

double GblStringView_toDouble ( GblStringView  self,
GblBool pSuccess 
)
related

Converts the given GblStringView to a double value, optionally returning whether the conversion succeeded or not.

◆ GblStringView_toPointer()

void * GblStringView_toPointer ( GblStringView  self,
GblBool pSuccess 
)
related

Converts the given GblStringView to a pointer value, optionally returning whether the conversion succeeded or not.

Field Documentation

◆ pData

const char* GblStringView::pData

Start address of the string being viewed.

Definition at line 58 of file gimbal_string_view.h.

◆ nullTerminated

size_t GblStringView::nullTerminated

Reserved bit for maintaining whether the string is NULL terminated or not.

Definition at line 59 of file gimbal_string_view.h.

◆ length

size_t GblStringView::length

Length (bytes) of the substring being viewed.

Definition at line 61 of file gimbal_string_view.h.


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