|
#include <stddef.h>
#include <stdio.h>
Go to the source code of this file.
Namespaces | |
namespace | stlsoft |
Classes | |
struct | cstring_t |
The cstring structure. More... | |
Defines | |
#define | CSTRING_VER 0x030602ff |
The current composite version number of cstring. | |
#define | CSTRING_VER_MAJOR 3 |
The major version number of cstring. | |
#define | CSTRING_VER_MINOR 6 |
The minor version number of cstring. | |
#define | CSTRING_VER_REVISION 2 |
The revision version number of cstring. | |
#define | CSTRING_EXTERN_C extern "C" |
#define | cstring_t_DEFAULT { 0, NULL, 0, 0 } |
Default initialised value for a cstring_t instance. | |
#define | CSTRING_FROM_END(x) (-1 - (int)(x)) |
Defines a reverse offset for use with the insert and replace functions. | |
#define | CSTRING_F_TYPE_MASK (0x003f) |
#define | CSTRING_F_MEMORY_IS_INTERNAL_HEAP (0x0000) |
#define | CSTRING_F_MEMORY_IS_BORROWED (0x0001) |
#define | CSTRING_F_MEMORY_IS_FIXED (0x0002) |
#define | CSTRING_F_MEMORY_IS_READONLY (0x0004) |
#define | CSTRING_F_MEMORY_IS_CONST CSTRING_F_MEMORY_IS_READONLY |
#define | CSTRING_F_MEMORY_IS_OFFSET (0x0040) |
#define | CSTRING_F_MEMORY_CAN_GROW_TO_HEAP (0x0080) |
#define | CSTRING_F_ARENA_MASK (0xff00) |
#define | CSTRING_F_USE_REALLOC (0x0000) |
#define | CSTRING_F_USE_WINDOWS_GLOBAL_MEMORY (0x0100) |
#define | CSTRING_F_USE_WINDOWS_PROCESSHEAP_MEMORY (0x0200) |
#define | CSTRING_F_USE_WINDOWS_COM_TASK_MEMORY (0x0400) |
#define | CSTRING_F_USE_CUSTOMARENAFUNCTIONS (0x2000) |
#define | CSTRING_F_CUSTOMARENA_CC_CDECL (0x0000) |
#define | CSTRING_F_CUSTOMARENA_CC_STDCALL (0x0040) |
#define | CSTRING_F_USE_WIN32_GLOBAL_MEMORY CSTRING_F_USE_WINDOWS_GLOBAL_MEMORY |
#define | CSTRING_F_USE_WIN32_PROCESSHEAP_MEMORY CSTRING_F_USE_WINDOWS_PROCESSHEAP_MEMORY |
#define | CSTRING_F_USE_WIN32_COM_TASK_MEMORY CSTRING_F_USE_WINDOWS_COM_TASK_MEMORY |
Typedefs | |
typedef int | cstring_flags_t |
Flags type. | |
Enumerations | |
enum | CSTRING_RC { CSTRING_RC_SUCCESS = 0, CSTRING_RC_OUTOFMEMORY, CSTRING_RC_FIXED, CSTRING_RC_BORROWED, CSTRING_RC_READONLY, CSTRING_RC_INVALIDARENA, CSTRING_RC_CUSTOMARENANOTSUPPORTED, CSTRING_RC_EXCEEDFIXEDCAPACITY, CSTRING_RC_EXCEEDBORROWEDCAPACITY, CSTRING_RC_CANNOTYIELDFROMSO, CSTRING_RC_ARENAOVERLOADED, CSTRING_RC_INVALIDSTREAM, CSTRING_RC_EOF, CSTRING_RC_INVALIDSECTION, CSTRING_RC_IOERROR, CSTRING_RC_SYSTEMSPECIFICFAILURE } |
The return code type of the cstring API. More... | |
Functions | |
CSTRING_EXTERN_C char const * | cstring_getStatusCodeString (CSTRING_RC rc) |
Returns a non-NULL nul-terminated character string describing the given error code. | |
CSTRING_EXTERN_C size_t | cstring_getStatusCodeStringLength (CSTRING_RC rc) |
Returns the length of the string returned by cstring_getStatusCodeString() for the given error code. | |
CSTRING_EXTERN_C char const * | cstring_error (CSTRING_RC rc) |
[DEPRECATED] This function is deprecated, and may be removed in a future version: instead use cstring_getStatusCodeString(). | |
CSTRING_EXTERN_C CSTRING_RC | cstring_init (struct cstring_t *pcs) |
Initialises a cstring instance to a default form. | |
CSTRING_EXTERN_C CSTRING_RC | cstring_create (struct cstring_t *pcs, char const *s) |
Creates a cstring instance from a C-style string. | |
CSTRING_EXTERN_C CSTRING_RC | cstring_createLen (struct cstring_t *pcs, char const *s, size_t cch) |
Creates a cstring instance from a fixed number of characters. | |
CSTRING_EXTERN_C CSTRING_RC | cstring_createN (struct cstring_t *pcs, char ch, size_t n) |
Creates a cstring instance consisting of a number of repetitions of a character. | |
CSTRING_EXTERN_C CSTRING_RC | cstring_createEx (struct cstring_t *pcs, char const *s, cstring_flags_t flags, void *arena, size_t capacity) |
Creates a cstring instance with special characteristics from a C-style string. | |
CSTRING_EXTERN_C CSTRING_RC | cstring_createLenEx (struct cstring_t *pcs, char const *s, size_t cch, cstring_flags_t flags, void *arena, size_t capacity) |
Creates a cstring instance with special characteristics from a fixed number of characters. | |
CSTRING_EXTERN_C CSTRING_RC | cstring_destroy (struct cstring_t *pcs) |
Releases resources and resets the attributes of the cstring instance. | |
CSTRING_EXTERN_C CSTRING_RC | cstring_yield2 (struct cstring_t *pcs, char **pPayload, void **pRaw) |
Removes the allocated buffer from the cstring instance into a caller supplied pointer. | |
CSTRING_EXTERN_C CSTRING_RC | cstring_setCapacity (struct cstring_t *pcs, size_t capacity) |
Sets the capacity of the cstring instance. | |
CSTRING_EXTERN_C CSTRING_RC | cstring_assign (struct cstring_t *pcs, char const *s) |
Assigns a C-style string to the cstring instance. | |
CSTRING_EXTERN_C CSTRING_RC | cstring_assignLen (struct cstring_t *pcs, char const *s, size_t cch) |
Assigns a fixed number of characters to the cstring instance. | |
CSTRING_EXTERN_C CSTRING_RC | cstring_copy (struct cstring_t *pcs, struct cstring_t const *pcsSrc) |
Copies the contents of one cstring instance to another. | |
CSTRING_EXTERN_C CSTRING_RC | cstring_append (struct cstring_t *pcs, char const *s) |
Appends a C-style string to the cstring instance. | |
CSTRING_EXTERN_C CSTRING_RC | cstring_appendLen (struct cstring_t *pcs, char const *s, size_t cch) |
Appends a fixed number of characters to the cstring instance. | |
CSTRING_EXTERN_C CSTRING_RC | cstring_truncate (struct cstring_t *pcs, size_t len) |
Truncates the cstring instance. | |
CSTRING_EXTERN_C CSTRING_RC | cstring_swap (struct cstring_t *pcs1, struct cstring_t *pcs2) |
Swaps the contents of the two cstring instances. | |
CSTRING_EXTERN_C CSTRING_RC | cstring_readline (FILE *stm, struct cstring_t *pcs, size_t *numRead) |
Reads in a line of text from the given text stream. | |
CSTRING_EXTERN_C CSTRING_RC | cstring_writeline (FILE *stm, struct cstring_t const *pcs, size_t *numWritten) |
Writes a line of text to the given text stream. | |
CSTRING_EXTERN_C CSTRING_RC | cstring_insert (struct cstring_t *pcs, int index, char const *s) |
Inserts the given string at the given index. | |
CSTRING_EXTERN_C CSTRING_RC | cstring_insertLen (struct cstring_t *pcs, int index, char const *s, size_t cch) |
Inserts the given string at the given index. | |
CSTRING_EXTERN_C CSTRING_RC | cstring_replace (struct cstring_t *pcs, int index, size_t len, char const *s) |
Replaces a specified section of the string with another. | |
CSTRING_EXTERN_C CSTRING_RC | cstring_replaceLen (struct cstring_t *pcs, int index, size_t len, char const *s, size_t cch) |
Replaces a specified section of the string with another. | |
CSTRING_EXTERN_C CSTRING_RC | cstring_replaceAll (struct cstring_t *pcs, char const *f, char const *t, size_t *numReplaced) |
Replaces all instances of one substring with another. | |
char const * | c_str_data_a (struct cstring_t const *pcs) |
char const * | c_str_data (struct cstring_t const *pcs) |
size_t | c_str_len_a (struct cstring_t const *pcs) |
size_t | c_str_len (struct cstring_t const *pcs) |
char const * | c_str_ptr_a (struct cstring_t const *pcs) |
char const * | c_str_ptr (struct cstring_t const *pcs) |
char const * | c_str_data_a (struct cstring_t const &cs) |
char const * | c_str_data (struct cstring_t const &cs) |
size_t | c_str_len_a (struct cstring_t const &cs) |
size_t | c_str_len (struct cstring_t const &cs) |
char const * | c_str_ptr_a (struct cstring_t const &cs) |
char const * | c_str_ptr (struct cstring_t const &cs) |
char const * | c_str_data_a (CSTRING_RC rc) |
char const * | c_str_data (CSTRING_RC rc) |
size_t | c_str_len_a (CSTRING_RC rc) |
size_t | c_str_len (CSTRING_RC rc) |
char const * | c_str_ptr_a (CSTRING_RC rc) |
char const * | c_str_ptr (CSTRING_RC rc) |
#define CSTRING_EXTERN_C extern "C" |
#define CSTRING_F_USE_WIN32_COM_TASK_MEMORY CSTRING_F_USE_WINDOWS_COM_TASK_MEMORY |
#define CSTRING_F_USE_WIN32_GLOBAL_MEMORY CSTRING_F_USE_WINDOWS_GLOBAL_MEMORY |
#define CSTRING_F_USE_WIN32_PROCESSHEAP_MEMORY CSTRING_F_USE_WINDOWS_PROCESSHEAP_MEMORY |
#define CSTRING_FROM_END | ( | x | ) | (-1 - (int)(x)) |
Defines a reverse offset for use with the insert and replace functions.
#define CSTRING_VER 0x030602ff |
The current composite version number of cstring.
#define CSTRING_VER_MAJOR 3 |
The major version number of cstring.
#define CSTRING_VER_MINOR 6 |
The minor version number of cstring.
#define CSTRING_VER_REVISION 2 |
The revision version number of cstring.
char const* c_str_data | ( | CSTRING_RC | rc | ) | [inline] |
char const* c_str_data | ( | struct cstring_t const & | cs | ) | [inline] |
char const* c_str_data | ( | struct cstring_t const * | pcs | ) | [inline] |
char const* c_str_data_a | ( | CSTRING_RC | rc | ) | [inline] |
char const* c_str_data_a | ( | struct cstring_t const & | cs | ) | [inline] |
char const* c_str_data_a | ( | struct cstring_t const * | pcs | ) | [inline] |
size_t c_str_len | ( | CSTRING_RC | rc | ) | [inline] |
size_t c_str_len | ( | struct cstring_t const & | cs | ) | [inline] |
size_t c_str_len | ( | struct cstring_t const * | pcs | ) | [inline] |
size_t c_str_len_a | ( | CSTRING_RC | rc | ) | [inline] |
size_t c_str_len_a | ( | struct cstring_t const & | cs | ) | [inline] |
size_t c_str_len_a | ( | struct cstring_t const * | pcs | ) | [inline] |
char const* c_str_ptr | ( | CSTRING_RC | rc | ) | [inline] |
char const* c_str_ptr | ( | struct cstring_t const & | cs | ) | [inline] |
char const* c_str_ptr | ( | struct cstring_t const * | pcs | ) | [inline] |
char const* c_str_ptr_a | ( | CSTRING_RC | rc | ) | [inline] |
char const* c_str_ptr_a | ( | struct cstring_t const & | cs | ) | [inline] |
char const* c_str_ptr_a | ( | struct cstring_t const * | pcs | ) | [inline] |
CSTRING_EXTERN_C char const* cstring_error | ( | CSTRING_RC | rc | ) |
[DEPRECATED] This function is deprecated, and may be removed in a future version: instead use cstring_getStatusCodeString().
CSTRING_EXTERN_C size_t cstring_getStatusCodeStringLength | ( | CSTRING_RC | rc | ) |
Returns the length of the string returned by cstring_getStatusCodeString() for the given error code.
rc | The error code. Must be one of the CSTRING_RC enumeration |
CSTRING_EXTERN_C CSTRING_RC cstring_insert | ( | struct cstring_t * | pcs, | |
int | index, | |||
char const * | s | |||
) |
Inserts the given string at the given index.
(NULL != s)
CSTRING_EXTERN_C CSTRING_RC cstring_insertLen | ( | struct cstring_t * | pcs, | |
int | index, | |||
char const * | s, | |||
size_t | cch | |||
) |
Inserts the given string at the given index.
(NULL != s || 0 == cch)
CSTRING_EXTERN_C CSTRING_RC cstring_readline | ( | FILE * | stm, | |
struct cstring_t * | pcs, | |||
size_t * | numRead | |||
) |
Reads in a line of text from the given text stream.
stm | The stream from which the line will be read | |
pcs | The initialised string instance into which the line will be stored. | |
numRead | An optional pointer to a variable to receive the number of characters appended to the string. May be NULL |
CSTRING_RC_INVALIDSTREAM | The stream was not valid (as tested by ferror() ) | |
CSTRING_RC_SUCCESS | A line terminated by a carriage return was read in | |
CSTRING_RC_EOF | A line terminted by the end-of-file was read in | |
-other- | any other value returned by cstring_appendLen() |
CSTRING_EXTERN_C CSTRING_RC cstring_replace | ( | struct cstring_t * | pcs, | |
int | index, | |||
size_t | len, | |||
char const * | s | |||
) |
Replaces a specified section of the string with another.
pcs | The cstring instance whose contents will be modified | |
index | The position of the replaced section. May be negative, in which case it represents the position from the end of the string | |
len | The length of the replaced section | |
s | The replacing string |
(NULL != s)
CSTRING_EXTERN_C CSTRING_RC cstring_replaceAll | ( | struct cstring_t * | pcs, | |
char const * | f, | |||
char const * | t, | |||
size_t * | numReplaced | |||
) |
Replaces all instances of one substring with another.
pcs | The cstring instance whose contents will be modified | |
f | The string to search for. If NULL or the empty string, the function returns immediately | |
t | The string to replace with. If NULL or the empty string, all occurences of f will be removed | |
numReplaced | An optional pointer to a variable to receive the number of replacements performed. May be NULL if caller does not require |
CSTRING_EXTERN_C CSTRING_RC cstring_replaceLen | ( | struct cstring_t * | pcs, | |
int | index, | |||
size_t | len, | |||
char const * | s, | |||
size_t | cch | |||
) |
Replaces a specified section of the string with another.
pcs | The cstring instance whose contents will be modified | |
index | The position of the replaced section. May be negative, in which case it represents the position from the end of the string | |
len | The length of the replaced section | |
s | The replacing string | |
cch | The replacing string length |
(NULL != s || 0 == cch)
CSTRING_EXTERN_C CSTRING_RC cstring_writeline | ( | FILE * | stm, | |
struct cstring_t const * | pcs, | |||
size_t * | numWritten | |||
) |
Writes a line of text to the given text stream.
stm | The stream to which the line will be written | |
pcs | The initialised string instance containing the line to be written. | |
numWritten | An optional pointer to a variable to receive the number of characters appended to the string. May be NULL |
CSTRING_RC_INVALIDSTREAM | The stream was not valid (as tested by ferror() ) | |
CSTRING_RC_SUCCESS | A line terminated by a carriage return was read in | |
CSTRING_RC_IOERROR | Could not write to the stream |
|
cstring Library documentation (c) Matthew Wilson and Synesis Software Pty Ltd, 1994-2009 |