Ion C
C library for Ion
ion_string.h File Reference
#include <string.h>
#include "ion_platform_config.h"
#include "ion_types.h"

Go to the source code of this file.

Data Structures

struct  _ion_string
 

Macros

#define DEFAULT_STRING_LENGTH   8
 
#define ION_STRING_INIT(x)   (x)->length = 0; (x)->value = NULL
 
#define ION_STRING_ASSIGN(dst, src)   (dst)->length = (src)->length; (dst)->value = (src)->value
 
#define ION_STRING_IS_NULL(x)   ((x) == NULL || ((x)->value == NULL))
 
#define ION_STRING_EQUALS(x, y)   (((x) == (y)) || (((x)->length == (y)->length) && (memcmp((x)->value, (y)->value, (x)->length) == 0)))
 
#define ION_STRING_CHAR_AT(str, ii)   ((ii) < (str)->length ? (str)->value[ii] : -1)
 

Functions

ION_API_EXPORT void ion_string_init (ION_STRING *str)
 
ION_API_EXPORT void ion_string_assign (ION_STRING *dst, ION_STRING *src)
 
ION_API_EXPORT ION_STRINGion_string_assign_cstr (ION_STRING *str, char *val, SIZE len)
 
ION_API_EXPORT char * ion_string_strdup (ION_STRING *p_ionstring)
 
ION_API_EXPORT iERR ion_string_copy_to_owner (hOWNER owner, ION_STRING *dst, ION_STRING *src)
 
ION_API_EXPORT int ion_string_get_length (ION_STRING *str)
 
ION_API_EXPORT BYTE ion_string_get_byte (ION_STRING *str, int idx)
 
ION_API_EXPORT BYTE * ion_string_get_bytes (ION_STRING *str)
 
ION_API_EXPORT BOOL ion_string_is_null (ION_STRING *str)
 
ION_API_EXPORT BOOL ion_string_is_equal (ION_STRING *str1, ION_STRING *str2)
 

Macro Definition Documentation

◆ DEFAULT_STRING_LENGTH

#define DEFAULT_STRING_LENGTH   8

default for minimum alloc, 8 is average from IBM study

Function Documentation

◆ ion_string_get_byte()

ION_API_EXPORT BYTE ion_string_get_byte ( ION_STRING str,
int  idx 
)

Returns -1 is idx is out of range or str is null

◆ ion_string_get_bytes()

ION_API_EXPORT BYTE* ion_string_get_bytes ( ION_STRING str)

Gets a pointer to the UTF-8 bytes held by the string. The number of bytes in the string is determined via ion_string_get_length().

Parameters
strmust not be null.
Returns
a pointer to the first UTF-8 byte in the string; may be null. The byte sequence is not null-terminated.

◆ ion_string_get_length()

ION_API_EXPORT int ion_string_get_length ( ION_STRING str)

Gets the number of UTF-8 bytes held by the string.

Parameters
strmust not be null.
Returns
may be zero.