Synesis Software

cstring/cstring.h File Reference


Detailed Description

Definition of the cstring API.

#include <stddef.h>

Go to the source code of this file.

Classes

struct  cstring_t
 The cstring structure

Represents a cstring as a string slice - length + pointer - along with the allocated capacity, and flags controlling the allocation arena and other characteristics. More...


Defines

#define CSTRING_VER_MAJOR   3
 The major version number of cstring.
#define CSTRING_VER_MINOR   4
 The minor version number of cstring.
#define CSTRING_VER_REVISION   2
 The revision version number of cstring.
#define CSTRING_VER   0x03040100
 The current composite 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_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_ARENA_MASK   (0xff00)
#define CSTRING_F_USE_REALLOC   (0x0000)
#define CSTRING_F_USE_WIN32_GLOBAL_MEMORY   (0x0100)
#define CSTRING_F_USE_WIN32_PROCESSHEAP_MEMORY   (0x0200)
#define CSTRING_F_USE_WIN32_COM_TASK_MEMORY   (0x0400)
#define CSTRING_F_USE_CUSTOMARENAFUNCTIONS   (0x2000)
#define CSTRING_F_CUSTOMARENA_CC_CDECL   (0x0000)
#define CSTRING_F_CUSTOMARENA_CC_STDCALL   (0x0040)

Typedefs

typedef enum CSTRING_RC CSTRING_RC
typedef size_t cstring_flags_t
 Flags type.
typedef cstring_t cstring_t

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
}
 The return code type of the cstring API. More...

Functions

char const * cstring_error (CSTRING_RC rc)
 Returns a non-NULL nul-terminated character string describing the given error code.
CSTRING_RC cstring_init (struct cstring_t *pcs)
 Initialises a cstring instance to a default form.
CSTRING_RC cstring_create (struct cstring_t *pcs, char const *s)
 Creates a cstring instance from a C-style string.
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_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_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_RC cstring_destroy (struct cstring_t *pcs)
 Releases resources and resets the attributes of the cstring instance.
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_RC cstring_setCapacity (struct cstring_t *pcs, size_t capacity)
 Sets the capacity of the cstring instance.
CSTRING_RC cstring_assign (struct cstring_t *pcs, char const *s)
 Assigns a C-style string to the cstring instance.
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_RC cstring_copy (struct cstring_t *pcs, struct cstring_t const *pcsSrc)
 Copies the contents of one cstring instance to another.
CSTRING_RC cstring_append (struct cstring_t *pcs, char const *s)
 Appends a C-style string to the cstring instance.
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_RC cstring_truncate (struct cstring_t *pcs, size_t len)
 Truncates the cstring instance.
CSTRING_RC cstring_swap (struct cstring_t *pcs1, struct cstring_t *pcs2)
 Swaps the contents of the two cstring instances.


Define Documentation

#define CSTRING_EXTERN_C   extern "C"
 

#define CSTRING_VER   0x03040100
 

The current composite version number of cstring.

#define CSTRING_VER_MAJOR   3
 

The major version number of cstring.

#define CSTRING_VER_MINOR   4
 

The minor version number of cstring.

#define CSTRING_VER_REVISION   2
 

The revision version number of cstring.


Typedef Documentation

typedef enum CSTRING_RC CSTRING_RC
 

typedef struct cstring_t cstring_t
 


cstring Library documentation © Matthew Wilson and Synesis Software Pty Ltd, 1994-2005