liba 0.1.15
An algorithm library based on C/C++
 
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
Loading...
Searching...
No Matches
basic string library
Collaboration diagram for basic string library:

Data Structures

struct  a_str
 instance structure for basic string More...
 

Macros

#define A_STR_INIT   {A_NULL, 0, 0}
 

Typedefs

typedef struct a_str a_str
 instance structure for basic string
 

Functions

char * a_str_ptr (a_str const *ctx)
 string for a pointer to string structure
 
a_size a_str_len (a_str const *ctx)
 length for a pointer to string structure
 
a_size a_str_mem (a_str const *ctx)
 memory for a pointer to string structure
 
char * a_str_at_ (a_str const *ctx, a_size idx)
 access specified character for a pointer to string structure
 
char * a_str_at (a_str const *ctx, a_size idx)
 access specified character for a pointer to string structure
 
char * a_str_of (a_str const *ctx, a_diff idx)
 access specified character for a pointer to string structure
 
void a_str_setn_ (a_str *ctx, a_size num)
 set length for a pointer to string structure
 
int a_str_setn (a_str *ctx, a_size num)
 set length for a pointer to string structure
 
a_stra_str_new (void)
 allocate a pointer to string structure from memory
 
void a_str_die (a_str *ctx)
 deallocate a pointer to string structure
 
void a_str_ctor (a_str *ctx)
 constructor for string structure
 
void a_str_dtor (a_str *ctx)
 destructor for string structure
 
void a_str_swap (a_str *lhs, a_str *rhs)
 swap the contents of two pointers to string structure
 
char * a_str_exit (a_str *ctx)
 terminate a pointer to string structure
 
int a_str_setm (a_str *ctx, a_size mem)
 allocate memory for a pointer to string structure
 
int a_str_setm_ (a_str *ctx, a_size mem)
 
int a_str_cmp_ (void const *p0, a_size n0, void const *p1, a_size n1)
 compare the memory block 0 with the memory block 1
 
int a_str_cmp (a_str const *lhs, a_str const *rhs)
 compare the string lhs with the string rhs
 
int a_str_cmpn (a_str const *ctx, void const *pdata, a_size nbyte)
 compare the string ctx with the memory block
 
int a_str_cmps (a_str const *ctx, void const *str)
 compare the string ctx with the C string str
 
int a_str_getc (a_str *ctx)
 get a character for a pointer to string structure
 
int a_str_getc_ (a_str *ctx)
 
int a_str_catc (a_str *ctx, int c)
 concatenate a character to a pointer to string structure
 
int a_str_catc_ (a_str *ctx, int c)
 
a_size a_str_getn (a_str *ctx, void *pdata, a_size nbyte)
 get memory block to a pointer to string structure
 
a_size a_str_getn_ (a_str *ctx, void *pdata, a_size nbyte)
 
int a_str_catn (a_str *ctx, void const *pdata, a_size nbyte)
 concatenate memory block to a pointer to string structure
 
int a_str_catn_ (a_str *ctx, void const *pdata, a_size nbyte)
 
int a_str_cats (a_str *ctx, void const *str)
 concatenate C string to a pointer to string structure
 
int a_str_cats_ (a_str *ctx, void const *str)
 
int a_str_catv (a_str *ctx, char const *fmt, va_list va)
 format string append to a pointer to string structure via va_list
 
int a_str_catf (a_str *ctx, char const *fmt,...)
 format string append to a pointer to string structure
 
int a_str_cat (a_str *ctx, a_str const *obj)
 concatenate the string structure obj to the string structure ctx
 
int a_str_cat_ (a_str *ctx, a_str const *obj)
 
void a_str_rtrim (a_str *ctx, char const *s, a_size n)
 trim a string by removing trailing characters. If n is non-zero, the function uses the array s to specify the characters to remove. If n is zero, the function removes all trailing whitespace characters.
 
void a_str_rtrim_ (a_str *ctx, char const *s, a_size n)
 
void a_str_ltrim (a_str *ctx, char const *s, a_size n)
 trim a string by removing leading characters. If n is non-zero, the function uses the array s to specify the characters to remove. If n is zero, the function removes all leading whitespace characters.
 
void a_str_ltrim_ (a_str *ctx, char const *s, a_size n)
 
void a_str_trim (a_str *ctx, char const *s, a_size n)
 trim a string by removing both leading and trailing characters. If n is non-zero, the function uses the array s to specify the characters to remove. If n is zero, the function removes all leading and trailing whitespace characters.
 
void a_str_trim_ (a_str *ctx, char const *s, a_size n)
 
a_size a_utf_len (a_str const *ctx, a_size *stop)
 length for a pointer to string structure using UTF-8
 
int a_utf_catc (a_str *ctx, a_u32 c)
 concatenate a unicode character to a pointer to string structure
 

Detailed Description

Function Documentation

◆ a_str_at()

char * a_str_at ( a_str const * ctx,
a_size idx )

access specified character for a pointer to string structure

Parameters
[in]ctxpoints to an instance of string structure
[in]idxindex of character less than memory
Returns
specified character pointer
Return values
0out of bounds

◆ a_str_at_()

char * a_str_at_ ( a_str const * ctx,
a_size idx )

access specified character for a pointer to string structure

Parameters
[in]ctxpoints to an instance of string structure
[in]idxindex of character less than memory
Note
should check for out of bounds
Returns
specified character pointer

◆ a_str_cat()

int a_str_cat ( a_str * ctx,
a_str const * obj )

concatenate the string structure obj to the string structure ctx

Parameters
[in]ctxpoints to an instance of string structure
[in]objinput source pointing to an instance
Returns
error code value
Return values
0success

◆ a_str_catc()

int a_str_catc ( a_str * ctx,
int c )

concatenate a character to a pointer to string structure

Parameters
[in]ctxpoints to an instance of string structure
[in]ca character to be parsed
Returns
parsed character
Return values
~0failure

◆ a_str_catf()

int a_str_catf ( a_str * ctx,
char const * fmt,
... )

format string append to a pointer to string structure

Parameters
[in]ctxpoints to an instance of string structure
[in]fmtformat of string to be parsed
Returns
number of parsed characters

◆ a_str_catn()

int a_str_catn ( a_str * ctx,
void const * pdata,
a_size nbyte )

concatenate memory block to a pointer to string structure

Parameters
[in]ctxpoints to an instance of string structure
[in]pdatapoints to memory block to put
[in]nbytelength of memory block to put
Returns
error code value
Return values
0success

◆ a_str_cats()

int a_str_cats ( a_str * ctx,
void const * str )

concatenate C string to a pointer to string structure

Parameters
[in]ctxpoints to an instance of string structure
[in]strstring terminated with a null character
Returns
error code value
Return values
0success

◆ a_str_catv()

int a_str_catv ( a_str * ctx,
char const * fmt,
va_list va )

format string append to a pointer to string structure via va_list

Parameters
[in]ctxpoints to an instance of string structure
[in]fmtformat of string to be parsed
[in]vainstance of variable argument
Returns
number of parsed characters

◆ a_str_cmp()

int a_str_cmp ( a_str const * lhs,
a_str const * rhs )

compare the string lhs with the string rhs

Parameters
[in]lhsstring structure to be compared
[in]rhsstring structure to be compared
Returns
relationship between the strings
Return values
<0string lhs < string rhs
>0string lhs > string rhs
0string lhs == string rhs

◆ a_str_cmp_()

int a_str_cmp_ ( void const * p0,
a_size n0,
void const * p1,
a_size n1 )

compare the memory block 0 with the memory block 1

Parameters
[in]p0points to memory block 0 to be compared
[in]n0length of memory block 0 to be compared
[in]p1points to memory block 1 to be compared
[in]n1length of memory block 1 to be compared
Returns
relationship between the memory blocks
Return values
<0memory block 0 < memory block 1
>0memory block 0 > memory block 1
0memory block 0 == memory block 1

◆ a_str_cmpn()

int a_str_cmpn ( a_str const * ctx,
void const * pdata,
a_size nbyte )

compare the string ctx with the memory block

Parameters
[in]ctxpoints to an instance of string structure
[in]pdatapoints to memory block to be compared
[in]nbytelength of memory block to be compared
Returns
relationship between the strings
Return values
<0string ctx < memory block
>0string ctx > memory block
0string ctx == memory block

◆ a_str_cmps()

int a_str_cmps ( a_str const * ctx,
void const * str )

compare the string ctx with the C string str

Parameters
[in]ctxpoints to an instance of string structure
[in]strstring terminated with a null character
Returns
relationship between the strings
Return values
<0string ctx < C string str
>0string ctx > C string str
0string ctx == C string str

◆ a_str_ctor()

void a_str_ctor ( a_str * ctx)

constructor for string structure

Parameters
[in]ctxpoints to an instance of string structure

◆ a_str_die()

void a_str_die ( a_str * ctx)

deallocate a pointer to string structure

Parameters
[in]ctxpoints to an instance of string structure

◆ a_str_dtor()

void a_str_dtor ( a_str * ctx)

destructor for string structure

Parameters
[in]ctxpoints to an instance of string structure

◆ a_str_exit()

char * a_str_exit ( a_str * ctx)

terminate a pointer to string structure

Parameters
[in]ctxpoints to an instance of string structure
Note
should use free to release this memory
Returns
string of string structure

◆ a_str_getc()

int a_str_getc ( a_str * ctx)

get a character for a pointer to string structure

Parameters
[in]ctxpoints to an instance of string structure
Returns
a parsed character
Return values
~0failure

◆ a_str_getn()

a_size a_str_getn ( a_str * ctx,
void * pdata,
a_size nbyte )

get memory block to a pointer to string structure

Parameters
[in]ctxpoints to an instance of string structure
[in]pdatapoints to memory block to get
[in]nbytelength of memory block to get
Returns
number of parsed characters

◆ a_str_len()

a_size a_str_len ( a_str const * ctx)

length for a pointer to string structure

Parameters
[in]ctxpoints to an instance of string structure
Returns
size of length

◆ a_str_ltrim()

void a_str_ltrim ( a_str * ctx,
char const * s,
a_size n )

trim a string by removing leading characters. If n is non-zero, the function uses the array s to specify the characters to remove. If n is zero, the function removes all leading whitespace characters.

Parameters
[in]ctxpoints to an instance of string structure.
[in]spoints to the characters to remove.
[in]nnumber of the characters to remove.

◆ a_str_mem()

a_size a_str_mem ( a_str const * ctx)

memory for a pointer to string structure

Parameters
[in]ctxpoints to an instance of string structure
Returns
size of memory

◆ a_str_of()

char * a_str_of ( a_str const * ctx,
a_diff idx )

access specified character for a pointer to string structure

Parameters
[in]ctxpoints to an instance of string structure
[in]idxindex of character -length < idx < length
Returns
specified character pointer
Return values
0out of bounds

◆ a_str_ptr()

char * a_str_ptr ( a_str const * ctx)

string for a pointer to string structure

Parameters
[in]ctxpoints to an instance of string structure
Returns
string

◆ a_str_rtrim()

void a_str_rtrim ( a_str * ctx,
char const * s,
a_size n )

trim a string by removing trailing characters. If n is non-zero, the function uses the array s to specify the characters to remove. If n is zero, the function removes all trailing whitespace characters.

Parameters
[in]ctxpoints to an instance of string structure.
[in]spoints to the characters to remove.
[in]nnumber of the characters to remove.

◆ a_str_setm()

int a_str_setm ( a_str * ctx,
a_size mem )

allocate memory for a pointer to string structure

Parameters
[in]ctxpoints to an instance of string structure
[in]memnew memory capacity of string
Returns
error code value
Return values
0success

◆ a_str_setn()

int a_str_setn ( a_str * ctx,
a_size num )

set length for a pointer to string structure

Parameters
[in]ctxpoints to an instance of string structure
[in]numnew length for a pointer to string structure
Returns
error code value
Return values
0success

◆ a_str_setn_()

void a_str_setn_ ( a_str * ctx,
a_size num )

set length for a pointer to string structure

Parameters
[in]ctxpoints to an instance of string structure
[in]numnew length for a pointer to string structure
Note
length must less than memory

◆ a_str_swap()

void a_str_swap ( a_str * lhs,
a_str * rhs )

swap the contents of two pointers to string structure

Parameters
[in]lhspoints to an instance of string structure
[in]rhspoints to an instance of string structure

◆ a_str_trim()

void a_str_trim ( a_str * ctx,
char const * s,
a_size n )

trim a string by removing both leading and trailing characters. If n is non-zero, the function uses the array s to specify the characters to remove. If n is zero, the function removes all leading and trailing whitespace characters.

Parameters
[in]ctxpoints to an instance of string structure.
[in]spoints to the characters to remove.
[in]nnumber of the characters to remove.

◆ a_utf_catc()

int a_utf_catc ( a_str * ctx,
a_u32 c )

concatenate a unicode character to a pointer to string structure

Parameters
[in]ctxpoints to an instance of string structure
[in]ca unicode character to concatenate
Returns
error code value
Return values
0success

◆ a_utf_len()

a_size a_utf_len ( a_str const * ctx,
a_size * stop )

length for a pointer to string structure using UTF-8

Parameters
[in]ctxpoints to an instance of string structure
[out]stopstore the number of consumed bytes
  • 0 don't return the number of consumed bytes
Returns
number of unicode code points