GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
Functions
gp_vec_str.h File Reference

A dynamic C strings. More...

#include <string.h>
#include <core/gp_compiler.h>
#include <utils/gp_utf.h>
#include <utils/gp_vec.h>

Go to the source code of this file.

Functions

static char * gp_vec_str_new (void)
 Allocated new string vector.
 
static size_t gp_vec_strlen (char *self)
 Returns string vector len.
 
static size_t gp_vec_strsize (char *self)
 Returns string vector size.
 
static char * gp_vec_strdup (const char *src)
 Copies a string into newly allocated string vector.
 
static char * gp_vec_strins (char *self, size_t off, const char *src)
 Inserts a string into a string vector at a given offset.
 
static char * gp_vec_str_append (char *self, const char *str)
 Appends a string to a string vector.
 
static char * gp_vec_chins (char *self, size_t off, char ch)
 Inserts a string into a string vector at a given offset.
 
static char * gp_vec_ins_utf8 (char *self, size_t off, uint32_t unicode)
 Inserts an unicode character into an UTF-8 string.
 
static char * gp_vec_strdel (char *self, size_t off, size_t len)
 Deletes len characters from a string vector at a given offset.
 
static char * gp_vec_strclr (char *self)
 Clears the string.
 
char * gp_vec_printf (char *self, const char *fmt,...)
 Printf into a string vector.
 
char * gp_vec_vprintf (char *self, const char *fmt, va_list va)
 Printf va_list into a string vector.
 

Detailed Description

A dynamic C strings.

Definition in file gp_vec_str.h.

Function Documentation

◆ gp_vec_chins()

static char * gp_vec_chins ( char *  self,
size_t  off,
char  ch 
)
inlinestatic

Inserts a string into a string vector at a given offset.

Parameters
selfA string vector.
offAn offset in the string vector.
srcA string to copy.
Returns
A string vector or a NULL in a case of allocation failure.

Definition at line 125 of file gp_vec_str.h.

References gp_vec_ins().

◆ gp_vec_ins_utf8()

static char * gp_vec_ins_utf8 ( char *  self,
size_t  off,
uint32_t  unicode 
)
inlinestatic

Inserts an unicode character into an UTF-8 string.

Parameters
selfA string vector.
offAn offset in the string. @unicode An unicode character.
Returns
A string vector or a NULL in a case of allocation failure.

Definition at line 146 of file gp_vec_str.h.

References gp_to_utf8(), gp_utf8_bytes(), and gp_vec_ins().

◆ gp_vec_printf()

char * gp_vec_printf ( char *  self,
const char *  fmt,
  ... 
)

Printf into a string vector.

Parameters
selfA string vector.
fmtPrintf format string.
...Printf parameters.
Returns
A new vector size or -1 on allocation failure.

◆ gp_vec_str_append()

static char * gp_vec_str_append ( char *  self,
const char *  str 
)
inlinestatic

Appends a string to a string vector.

Parameters
selfA string vector.
strA string to append.
Returns
A string vector or a NULL in case of an allocation failure.

Definition at line 104 of file gp_vec_str.h.

References gp_vec_len(), and gp_vec_strins().

◆ gp_vec_str_new()

static char * gp_vec_str_new ( void  )
inlinestatic

Allocated new string vector.

Returns
Returns newly allocated empty string vector or a NULL in a case of a failure.

Definition at line 27 of file gp_vec_str.h.

References gp_vec_new().

◆ gp_vec_strclr()

static char * gp_vec_strclr ( char *  self)
inlinestatic

Clears the string.

Parameters
selfA string vector.
Returns
An empty string vector.

Definition at line 181 of file gp_vec_str.h.

References gp_vec_resize().

◆ gp_vec_strdel()

static char * gp_vec_strdel ( char *  self,
size_t  off,
size_t  len 
)
inlinestatic

Deletes len characters from a string vector at a given offset.

Parameters
selfA string vector.
offAn offset in the string vector.
lenNumber of characters to delete.
Returns
Returns NULL if off + len is outside of the vector and the input vector is untouched. Othervise modified string vector is returned.

Definition at line 169 of file gp_vec_str.h.

References gp_vec_del().

◆ gp_vec_strdup()

static char * gp_vec_strdup ( const char *  src)
inlinestatic

Copies a string into newly allocated string vector.

Parameters
srcA strint to duplicate.
Returns
A string vector or a NULL in a case of allocation failure.

Definition at line 63 of file gp_vec_str.h.

References gp_vec_new().

◆ gp_vec_strins()

static char * gp_vec_strins ( char *  self,
size_t  off,
const char *  src 
)
inlinestatic

Inserts a string into a string vector at a given offset.

Parameters
selfA string vector.
offAn offset in the string vector.
srcA string to copy.
Returns
A string vector or a NULL in a case of allocation failure.

Definition at line 84 of file gp_vec_str.h.

References gp_vec_ins().

Referenced by gp_vec_str_append().

◆ gp_vec_strlen()

static size_t gp_vec_strlen ( char *  self)
inlinestatic

Returns string vector len.

Parameters
selfA string vector.
Returns
Returns string vector length.

Definition at line 39 of file gp_vec_str.h.

References gp_vec_len().

◆ gp_vec_strsize()

static size_t gp_vec_strsize ( char *  self)
inlinestatic

Returns string vector size.

Parameters
selfA string vector.
Returns
Returns string vector size i.e. length + 1.

Definition at line 51 of file gp_vec_str.h.

References gp_vec_len().

◆ gp_vec_vprintf()

char * gp_vec_vprintf ( char *  self,
const char *  fmt,
va_list  va 
)

Printf va_list into a string vector.

Parameters
selfA string vector.
fmtPrintf format string.
vaA va list.
Returns
A new vector size or -1 on allocation failure.