libcstl
|
Go to the source code of this file.
Macros | |
#define | CSTL_STRING_INITIALIZER(CTYPE) |
Constant initialization of a string object. | |
#define | DECLARE_CSTL_STRING(TYPE, NAME) |
(Statically) declare and initialize a vector | |
Typedefs | |
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. | |
This is the public-facing header for string objects. The actual implementation is in _string.[ch], hidden behind a lot of macros that function as a poor man's template. This allows the same code to implement both narrow and wide character string objects.
This file sets the cstl_STRING
, STRCHAR
, and STDSTRPFX
macros, and then includes the actual implementation file to import all of its types, functions, and prototypes.
To add new variants:
cstl_STRING
should be set to the name of the string object, e.g. string, wstringSTRCHAR
should be the type of character housed by the string, e.g. char, wchar_tSTDSTRPFX
should be the prefix of standard library functions associated with the type of string being implemented. For example, the implementation relies on the strlen()
function. For the narrow string, STDSTRPFX
is set to str
to select strlen()
. For the wide string, it would be wcs
to select wcslen()
.Definition in file string.h.