libcstl
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules
Data Structures | Macros | Variables

Vector-like memory management of a collection of characters. More...

Data Structures

struct  cstl_STRING
 A string object. More...
 

Macros

#define CSTL_STRING_INITIALIZER(CTYPE)
 Constant initialization of a string object.
 
#define DECLARE_CSTL_STRING(TYPE, NAME)
 (Statically) declare and initialize a vector
 

Variables

static void const size_t sz
 
cstl_STRING_char_t size_t i
 
static int const cstl_STRING_char_t *const str
 
static int const struct cstl_STRING *const s2
 
void size_t pos
 
void size_t size_t cnt
 
void size_t size_t cstl_STRING_char_t ch
 
void size_t const cstl_STRING_char_t size_t n
 
static void size_t const struct cstl_STRINGins
 
static void const cstl_STRING_char_t *const const size_t len
 
void size_t size_t struct cstl_STRINGss
 
ssize_t const cstl_STRING_char_t * ndl
 

Supported string types

typedef struct cstl_string cstl_string_t
 String of narrow characters.
 
typedef struct cstl_wstring cstl_wstring_t
 String of wide characters.
 

Detailed Description

Vector-like memory management of a collection of characters.

Unless otherwise noted, cstl_STRING is a "templatized" parameter and should be replaced with the type of string object in use, e.g. cstl_string, cstl_wstring.

For example, the equivalent of

// templatized prototype
void cstl_STRING_init(struct cstl_STRING *);
A string object.
Definition _string.h:64

is

// narrow string initialization
void cstl_string_init(struct cstl_string *);
// wide string initialization
void cstl_wstring_init(struct cstl_wstring *);

Macro Definition Documentation

◆ CSTL_STRING_INITIALIZER

#define CSTL_STRING_INITIALIZER (   CTYPE)
Value:
{ \
.v = CSTL_VECTOR_INITIALIZER(CTYPE), \
}
#define CSTL_VECTOR_INITIALIZER(TYPE)
Constant initialization of a vector object.
Definition vector.h:54

Constant initialization of a string object.

Unlike the templatized functions, "STRING" is not a placeholder for a "templatized" name. This macro/function is called literally as CSTL_STRING_INITIALIZER() and the CTYPE parameter is the type of character held by the string object, e.g. cstl_string_char_t, cstl_wstring_char_t

Parameters
CTYPEThe type of character that the string will hold

Definition at line 81 of file string.h.

◆ DECLARE_CSTL_STRING

#define DECLARE_CSTL_STRING (   TYPE,
  NAME 
)
Value:
struct cstl_##TYPE NAME = \
CSTL_STRING_INITIALIZER(cstl_##TYPE##_char_t)

(Statically) declare and initialize a vector

Unlike the templatized functions, "STRING" is not a placeholder for a "templatized" name. This macro/function is called literally as DECLARE_CSTL_STRING() and the TYPE parameter is the type of string object being declared without the cstl_ prefix, e.g.

// or
DECLARE_CSTL_STRING(wstring, ws);
#define DECLARE_CSTL_STRING(TYPE, NAME)
(Statically) declare and initialize a vector
Definition string.h:101
Parameters
TYPEThe type of string object being declared
NAMEThe name of the variable being declared

Definition at line 101 of file string.h.

Typedef Documentation

◆ cstl_string_t

typedef struct cstl_string cstl_string_t

String of narrow characters.

Definition at line 63 of file string.h.

◆ cstl_wstring_t

typedef struct cstl_wstring cstl_wstring_t

String of wide characters.

Definition at line 65 of file string.h.

Variable Documentation

◆ ch

ssize_t cstl_STRING_char_t ch
Initial value:
{
CSTL_TOKCAT(cstl_STRING, _insert_ch )( s, CSTL_TOKCAT(cstl_STRING, _size )( s ), cnt, ch )

Definition at line 255 of file _string.h.

◆ cnt

static void const size_t cnt

Definition at line 255 of file _string.h.

◆ i

const cstl_STRING_char_t size_t i

Definition at line 154 of file _string.h.

◆ ins

void size_t const struct cstl_STRING* ins
Initial value:
{
CSTL_TOKCAT(cstl_STRING, _insert_str_n )( s, pos, CSTL_TOKCAT(cstl_STRING, _str )( ins ), CSTL_TOKCAT(cstl_STRING, _size )( ins ) )

Definition at line 301 of file _string.h.

◆ len

void const cstl_STRING_char_t* const const size_t len
Initial value:
{
CSTL_TOKCAT(cstl_STRING, _insert_str_n )( s, CSTL_TOKCAT(cstl_STRING, _size )( s ), str, len )

Definition at line 352 of file _string.h.

◆ n

void size_t size_t n

Definition at line 270 of file _string.h.

◆ ndl

static ssize_t const struct cstl_STRING *const ndl

Definition at line 438 of file _string.h.

◆ pos

static ssize_t const struct cstl_STRING *const const size_t pos
Initial value:
{
return CSTL_TOKCAT(cstl_STRING, _find_str )( hay, CSTL_TOKCAT(cstl_STRING, _str )( ndl ), pos )

Definition at line 255 of file _string.h.

◆ s2

static void struct cstl_STRING *const s2
Initial value:
{
return CSTL_TOKCAT(cstl_STRING, _compare_str )( s1, CSTL_TOKCAT(cstl_STRING, _str )( s2 ) )

Definition at line 227 of file _string.h.

◆ ss

void size_t size_t struct cstl_STRING* ss

Definition at line 409 of file _string.h.

◆ str

static void const cstl_STRING_char_t *const str
Initial value:
{
return STDSTRF(cmp, CSTL_TOKCAT(cstl_STRING, _str )( s ), str)

Definition at line 209 of file _string.h.

◆ sz

void size_t sz
Initial value:
{
cstl_vector_reserve(&s->v, sz + 1)
void cstl_vector_reserve(struct cstl_vector *v, size_t sz)
Request to increase the capacity of the vector.
Definition vector.c:59

Definition at line 121 of file _string.h.