libcmutils 0.6.5
Multi-platform C99 utility library
Loading...
Searching...
No Matches

Multifunctional string type. More...

Data Fields

ssize_t(* AddString )(CMUTIL_String *string, const char *tobeadded)
 Add a c-style string to this string object.
 
ssize_t(* AddNString )(CMUTIL_String *string, const char *tobeadded, size_t size)
 Add n bytes string to this string object.
 
ssize_t(* AddChar )(CMUTIL_String *string, char tobeadded)
 Add a character to this string object.
 
ssize_t(* AddPrint )(CMUTIL_String *string, const char *fmt,...)
 Add a formatted string to this string object.
 
ssize_t(* AddVPrint )(CMUTIL_String *string, const char *fmt, va_list args)
 Add a formatted string to this string object.
 
ssize_t(* AddAnother )(CMUTIL_String *string, const CMUTIL_String *tobeadded)
 Add another string object to this string object.
 
ssize_t(* InsertString )(CMUTIL_String *string, const char *tobeadded, uint32_t at)
 Insert a c-style string to this string object.
 
ssize_t(* InsertNString )(CMUTIL_String *string, const char *tobeadded, uint32_t at, size_t size)
 Insert n bytes string to this string object.
 
ssize_t(* InsertPrint )(CMUTIL_String *string, uint32_t idx, const char *fmt,...)
 
ssize_t(* InsertVPrint )(CMUTIL_String *string, uint32_t idx, const char *fmt, va_list args)
 
ssize_t(* InsertAnother )(CMUTIL_String *string, uint32_t idx, CMUTIL_String *tobeadded)
 Insert another string object to this string object.
 
void(* CutTailOff )(CMUTIL_String *string, size_t length)
 Cut off the given number of characters from the tail of this string.
 
CMUTIL_String *(* Substring )(const CMUTIL_String *string, uint32_t offset, size_t length)
 Get substring from this string object.
 
CMUTIL_String *(* ToLower )(const CMUTIL_String *string)
 Creates a lower-case version of this string.
 
void(* SelfToLower )(CMUTIL_String *string)
 Converts this string to lower case.
 
CMUTIL_String *(* ToUpper )(const CMUTIL_String *string)
 Creates an upper-case version of this string.
 
void(* SelfToUpper )(CMUTIL_String *string)
 Converts this string to the upper case.
 
CMUTIL_String *(* Replace )(const CMUTIL_String *string, const char *needle, const char *alter)
 Replace all occurrences of the given substring with another string.
 
size_t(* GetSize )(const CMUTIL_String *string)
 Get the size of this string object.
 
const char *(* GetCString )(const CMUTIL_String *string)
 Get c-style null terminated string from this string object.
 
int(* GetChar )(const CMUTIL_String *string, uint32_t idx)
 Function pointer to retrieve a character from a specified position in a string.
 
void(* Clear )(CMUTIL_String *string)
 Clear the content of this string object.
 
CMUTIL_String *(* Clone )(const CMUTIL_String *string)
 Clone this string object.
 
void(* Destroy )(CMUTIL_String *string)
 Destroy this string object.
 
void(* SelfTrim )(CMUTIL_String *string)
 Trim spaces from both ends of this string object.
 

Detailed Description

Multifunctional string type.

Field Documentation

◆ AddString

ssize_t(* CMUTIL_String::AddString) (CMUTIL_String *string, const char *tobeadded)

Add a c-style string to this string object.

Append the given string to the end of this string object.

Appending an empty string is not an error, it just does nothing.

Parameters
stringThis string object.
tobeaddedC-style null terminated string to be appended.
Returns
New size of this string object, which is the unchanged current size when tobeadded is an empty string. -1 if tobeadded is NULL.

◆ AddNString

ssize_t(* CMUTIL_String::AddNString) (CMUTIL_String *string, const char *tobeadded, size_t size)

Add n bytes string to this string object.

Append the given string to the end of this string object. Given string is not needed to be null terminated.

Appending zero bytes is not an error, it just does nothing.

Parameters
stringThis string object.
tobeaddedC style string to be appended.
sizeNumber of bytes to be appended from the given string.
Returns
New size of this string object, which is the unchanged current size when size is zero. -1 if tobeadded is NULL.

◆ AddChar

ssize_t(* CMUTIL_String::AddChar) (CMUTIL_String *string, char tobeadded)

Add a character to this string object.

Append the given character to the end of this string object.

Parameters
stringThis string object.
tobeaddedCharacter to be appended.
Returns
New size of this string object.

◆ AddPrint

ssize_t(* CMUTIL_String::AddPrint) (CMUTIL_String *string, const char *fmt,...)

Add a formatted string to this string object.

Append a ormatted string to the end of this string object.

Parameters
stringThis string object.
fmtFormat string like a printf function.
...Arguments for format string.
Returns
New size of this string object.

◆ AddVPrint

ssize_t(* CMUTIL_String::AddVPrint) (CMUTIL_String *string, const char *fmt, va_list args)

Add a formatted string to this string object.

Append a formatted string to the end of this string object.

Parameters
stringThis string object.
fmtFormat string like a vprintf function.
argsArguments list for format string.
Returns
New size of this string object.

◆ AddAnother

ssize_t(* CMUTIL_String::AddAnother) (CMUTIL_String *string, const CMUTIL_String *tobeadded)

Add another string object to this string object.

Append the given string object to the end of this string object.

Appending an empty string object is not an error, it just does nothing.

Parameters
stringThis string object.
tobeaddedAnother string object to be appended.
Returns
New size of this string object, which is the unchanged current size when tobeadded is an empty string object. -1 if tobeadded is NULL.

◆ InsertString

ssize_t(* CMUTIL_String::InsertString) (CMUTIL_String *string, const char *tobeadded, uint32_t at)

Insert a c-style string to this string object.

Insert the given string to this string object at the index.

Inserting an empty string is not an error, it just does nothing, but the index is still validated.

Parameters
stringThis string object.
tobeaddedC style null terminated string to be inserted.
atIndex where the given string will be inserted.
Returns
New size of this string object, which is the unchanged current size when tobeadded is an empty string. -1 if tobeadded is NULL or at is greater than the current size of this string object.

◆ InsertNString

ssize_t(* CMUTIL_String::InsertNString) (CMUTIL_String *string, const char *tobeadded, uint32_t at, size_t size)

Insert n bytes string to this string object.

Insert a substring of the given string to this string object at the given index. Given string is not needed to be null terminated.

Inserting zero bytes is not an error, it just does nothing, but the index is still validated.

Parameters
stringThis string object.
tobeaddedC style string to be inserted.
atIndex where the given string will be inserted.
sizeNumber of bytes to be inserted from the given string.
Returns
New size of this string object, which is the unchanged current size when size is zero. -1 if tobeadded is NULL or at is greater than the current size of this string object.

◆ InsertPrint

ssize_t(* CMUTIL_String::InsertPrint) (CMUTIL_String *string, uint32_t idx, const char *fmt,...)

Insert a formatted string to this string object.

Insert a formatted string to this string object at the index.

Parameters
stringThis string object.
idxIndex where a formatted string will be inserted.
fmtFormat string like a printf function.
...Arguments for format string.
Returns
New size of this string object.

◆ InsertVPrint

ssize_t(* CMUTIL_String::InsertVPrint) (CMUTIL_String *string, uint32_t idx, const char *fmt, va_list args)

Insert a formatted string to this string object.

Insert a formatted string to this string object at the index.

Parameters
stringThis string object.
idxIndex where a formatted string will be inserted.
fmtFormat string like a vprintf function.
argsArguments list for format string.
Returns
New size of this string object.

◆ InsertAnother

ssize_t(* CMUTIL_String::InsertAnother) (CMUTIL_String *string, uint32_t idx, CMUTIL_String *tobeadded)

Insert another string object to this string object.

Insert the given string object to this string object at the index.

Inserting an empty string object is not an error, it just does nothing, but the index is still validated.

Parameters
stringThis string object.
idxIndex where another string object will be inserted.
tobeaddedAnother string object to be inserted.
Returns
New size of this string object, which is the unchanged current size when tobeadded is an empty string object. -1 if tobeadded is NULL or idx is greater than the current size of this string object.

◆ CutTailOff

void(* CMUTIL_String::CutTailOff) (CMUTIL_String *string, size_t length)

Cut off the given number of characters from the tail of this string.

If the length is bigger than the size of this string, this string will be cleared.

Parameters
stringThis string object.
lengthNumber of characters to be cut off from the tail.

◆ Substring

CMUTIL_String *(* CMUTIL_String::Substring) (const CMUTIL_String *string, uint32_t offset, size_t length)

Get substring from this string object.

Parameters
stringThis string object.
offsetStarting offset of substring.
lengthLength of substring.
Returns
New string object which is the substring of this string. Must be destroyed after use.

◆ ToLower

CMUTIL_String *(* CMUTIL_String::ToLower) (const CMUTIL_String *string)

Creates a lower-case version of this string.

Parameters
stringThis string object.
Returns
New string object which is the lower case version of this string. Must be destroyed after use.

◆ SelfToLower

void(* CMUTIL_String::SelfToLower) (CMUTIL_String *string)

Converts this string to lower case.

Parameters
stringThis string object.

◆ ToUpper

CMUTIL_String *(* CMUTIL_String::ToUpper) (const CMUTIL_String *string)

Creates an upper-case version of this string.

Parameters
stringThis string object.
Returns
New string object which is the upper case version of this string. Must be destroyed after use.

◆ SelfToUpper

void(* CMUTIL_String::SelfToUpper) (CMUTIL_String *string)

Converts this string to the upper case.

Parameters
stringThis string object.

◆ Replace

CMUTIL_String *(* CMUTIL_String::Replace) (const CMUTIL_String *string, const char *needle, const char *alter)

Replace all occurrences of the given substring with another string.

Parameters
stringThis string object.
needleSubstring to be replaced.
alterReplacement string. An empty string is allowed and removes every occurrence of needle.
Returns
New string object which is the result of replacement. Must be destroyed after use. NULL if needle or alter is NULL, or on internal failure.

◆ GetSize

size_t(* CMUTIL_String::GetSize) (const CMUTIL_String *string)

Get the size of this string object.

Parameters
stringThis string object.
Returns
Size of this string object.

◆ GetCString

const char *(* CMUTIL_String::GetCString) (const CMUTIL_String *string)

Get c-style null terminated string from this string object.

Parameters
stringThis string object.
Returns
C-style null terminated string.

◆ GetChar

int(* CMUTIL_String::GetChar) (const CMUTIL_String *string, uint32_t idx)

Function pointer to retrieve a character from a specified position in a string.

This function pointer allows access to a character within a string structure at the position referenced by the provided index.

Parameters
stringPointer to a CMUTIL_String structure containing the string data.
idxThe position of the desired character within the string.
Returns
The character located at the specified position, or an negative value if the index is out of bounds.

◆ Clear

void(* CMUTIL_String::Clear) (CMUTIL_String *string)

Clear the content of this string object.

Parameters
stringThis string object.

◆ Clone

CMUTIL_String *(* CMUTIL_String::Clone) (const CMUTIL_String *string)

Clone this string object.

Parameters
stringThis string object.
Returns
New string object which is the clone of this string. Must be destroyed after use.

◆ Destroy

void(* CMUTIL_String::Destroy) (CMUTIL_String *string)

Destroy this string object.

Parameters
stringThis string object.

◆ SelfTrim

void(* CMUTIL_String::SelfTrim) (CMUTIL_String *string)

Trim spaces from both ends of this string object.

Parameters
stringThis string object.

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