36#ifndef UCX_PROPERTIES_H
37#define UCX_PROPERTIES_H
362#define cxPropertiesInitDefault(prop) \
363 cxPropertiesInit(prop, cx_properties_config_default)
422#define cxPropertiesFill(prop, str) cx_properties_fill(prop, cx_strcast(str))
Advanced buffer implementation.
struct cx_buffer_s CxBuffer
UCX buffer.
Definition buffer.h:196
Common definitions and feature checks.
#define CX_INLINE
Declares a function to be inlined.
Definition common.h:290
#define cx_attr_nonnull
All pointer arguments must be non-NULL.
Definition common.h:141
#define CX_EXPORT
Only used for building Windows DLLs.
Definition common.h:278
#define cx_attr_nodiscard
Warn about discarded return value.
Definition common.h:256
#define cx_attr_access_r(...)
Specifies that the function will only read through the given pointer.
Definition common.h:230
#define cx_attr_cstr_arg(idx)
No support for null_terminated_string_arg in clang or GCC below 14.
Definition common.h:211
Interface for map implementations.
struct cx_map_s CxMap
Type for the UCX map.
Definition map.h:54
CxPropertiesSource cxPropertiesCstrSource(const char *str)
Creates a properties source based on a C string.
void cxPropertiesInit(CxProperties *prop, CxPropertiesConfig config)
Initialize a properties interface.
void cxPropertiesReset(CxProperties *prop)
Destroys and re-initializes the properties interface.
int(* cx_properties_read_init_func)(CxProperties *prop, CxPropertiesSource *src)
A function that may initialize additional memory for the source.
Definition properties.h:272
int(* cx_properties_read_func)(CxProperties *prop, CxPropertiesSource *src, cxstring *target)
A function that reads data from a source.
Definition properties.h:258
struct cx_properties_sink_s CxPropertiesSink
Typedef for a properties sink.
Definition properties.h:197
const CxPropertiesConfig cx_properties_config_default
Default properties configuration.
void cxPropertiesDestroy(CxProperties *prop)
Destroys the properties interface.
struct cx_properties_source_s CxPropertiesSource
Typedef for a properties source.
Definition properties.h:241
CxPropertiesStatus cxPropertiesNext(CxProperties *prop, cxstring *key, cxstring *value)
Retrieves the next key/value-pair.
CxPropertiesSource cxPropertiesCstrnSource(const char *str, size_t len)
Creates a properties source based on C string with the specified length.
int(* cx_properties_sink_func)(CxProperties *prop, CxPropertiesSink *sink, cxstring key, cxstring value)
A function that consumes a k/v-pair in a sink.
Definition properties.h:212
int cxPropertiesFilln(CxProperties *prop, const char *buf, size_t len)
Fills the input buffer with data.
struct cx_properties_config_s CxPropertiesConfig
Typedef for the properties config.
Definition properties.h:92
CxPropertiesSource cxPropertiesFileSource(FILE *file, size_t chunk_size)
Creates a properties source based on an FILE.
CxPropertiesStatus cxPropertiesLoad(CxProperties *prop, CxPropertiesSink sink, CxPropertiesSource source)
Loads properties data from a source and transfers it to a sink.
static int cx_properties_fill(CxProperties *prop, cxstring str)
Internal function, do not use.
Definition properties.h:398
CxPropertiesSink cxPropertiesMapSink(CxMap *map)
Creates a properties sink for an UCX map.
CxPropertiesSource cxPropertiesStringSource(cxstring str)
Creates a properties source based on an UCX string.
void cxPropertiesUseStack(CxProperties *prop, char *buf, size_t capacity)
Specifies stack memory that shall be used as an internal buffer.
void(* cx_properties_read_clean_func)(CxProperties *prop, CxPropertiesSource *src)
A function that cleans memory initialized by the read_init_func.
Definition properties.h:283
struct cx_properties_s CxProperties
Typedef for the properties interface.
Definition properties.h:191
cx_properties_status
Status codes for the properties interface.
Definition properties.h:102
@ CX_PROPERTIES_SINK_FAILED
Sinking a k/v-pair failed.
Definition properties.h:160
@ CX_PROPERTIES_NO_ERROR
Everything is fine.
Definition properties.h:106
@ CX_PROPERTIES_INVALID_EMPTY_KEY
The line contains a delimiter but no key.
Definition properties.h:134
@ CX_PROPERTIES_OK
Not used as a status and never returned by any function.
Definition properties.h:126
@ CX_PROPERTIES_NULL_INPUT
Input buffer is NULL.
Definition properties.h:130
@ CX_PROPERTIES_READ_FAILED
Reading from a properties source failed.
Definition properties.h:154
@ CX_PROPERTIES_INCOMPLETE_DATA
The input ends unexpectedly.
Definition properties.h:117
@ CX_PROPERTIES_READ_INIT_FAILED
Initializing the properties source failed.
Definition properties.h:148
@ CX_PROPERTIES_BUFFER_ALLOC_FAILED
More internal buffer was needed, but could not be allocated.
Definition properties.h:142
@ CX_PROPERTIES_NO_DATA
The input buffer does not contain more data.
Definition properties.h:110
@ CX_PROPERTIES_INVALID_MISSING_DELIMITER
The line contains data but no delimiter.
Definition properties.h:138
enum cx_properties_status CxPropertiesStatus
Typedef for the properties status enum.
Definition properties.h:166
Strings that know their length.
struct cx_string_s cxstring
An immutable string.
Definition string.h:87
Configures the expected characters for the properties parser.
Definition properties.h:54
char continuation
Reserved for future use.
Definition properties.h:86
char delimiter
The key/value delimiter that shall be used.
Definition properties.h:59
char comment3
The third comment character.
Definition properties.h:77
char comment2
The second comment character.
Definition properties.h:71
char comment1
The first comment character.
Definition properties.h:65
Interface for working with properties data.
Definition properties.h:171
CxBuffer input
The text input buffer.
Definition properties.h:180
CxPropertiesConfig config
The configuration.
Definition properties.h:175
CxBuffer buffer
Internal buffer.
Definition properties.h:185
Defines a sink for k/v-pairs.
Definition properties.h:222
cx_properties_sink_func sink_func
A function for consuming k/v-pairs into the sink.
Definition properties.h:234
void * sink
The sink object.
Definition properties.h:226
void * data
Optional custom data.
Definition properties.h:230
Defines a properties source.
Definition properties.h:291
cx_properties_read_init_func read_init_func
Optional function that may prepare the source for reading data.
Definition properties.h:313
void * src
The source object.
Definition properties.h:297
void * data_ptr
Optional additional data pointer.
Definition properties.h:301
size_t data_size
Optional size information.
Definition properties.h:305
cx_properties_read_func read_func
A function that reads data from the source.
Definition properties.h:309
cx_properties_read_clean_func read_clean_func
Optional function that cleans additional memory allocated by the read_init_func.
Definition properties.h:318