Ion C
C library for Ion
Loading...
Searching...
No Matches
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)
#define ION_STRING_ASSIGN(dst, src)
#define ION_STRING_IS_NULL(x)
#define ION_STRING_EQUALS(x, y)
#define ION_STRING_CHAR_AT(str, ii)

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_STRING * ion_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

◆ ION_STRING_ASSIGN

#define ION_STRING_ASSIGN ( dst,
src )
Value:
(dst)->length = (src)->length; (dst)->value = (src)->value

◆ ION_STRING_CHAR_AT

#define ION_STRING_CHAR_AT ( str,
ii )
Value:
((ii) < (str)->length ? (str)->value[ii] : -1)

◆ ION_STRING_EQUALS

#define ION_STRING_EQUALS ( x,
y )
Value:
(((x) == (y)) || (((x)->length == (y)->length) && (memcmp((x)->value, (y)->value, (x)->length) == 0)))

◆ ION_STRING_INIT

#define ION_STRING_INIT ( x)
Value:
(x)->length = 0; (x)->value = NULL

◆ ION_STRING_IS_NULL

#define ION_STRING_IS_NULL ( x)
Value:
((x) == NULL || ((x)->value == NULL))

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.