.. _program_listing_file_wyrd_properties.h: Program Listing for File properties.h ===================================== |exhale_lsh| :ref:`Return to documentation for file ` (``wyrd/properties.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /* * This file is part of wyrd. * * Author(s): Jens Finkhaeuser * * Copyright (c) 2023 Interpeer gUG (haftungsbeschränkt) * * SPDX-License-Identifier: GPL-3.0-only * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef WYRD_PROPERTIES_H #define WYRD_PROPERTIES_H #include #include #ifdef __cplusplus extern "C" { #endif // __cplusplus /***************************************************************************** * Low-level API */ typedef enum { WYRD_PT_UNKNOWN = 0x00, WYRD_PT_BLOB = 0x01, WYRD_PT_UTF8_STRING = 0x02, WYRD_PT_UINT8 = 0x0a, WYRD_PT_SINT8 = 0x0b, WYRD_PT_UINT16 = 0x0c, WYRD_PT_SINT16 = 0x0d, WYRD_PT_UINT32 = 0x0e, WYRD_PT_SINT32 = 0x0f, WYRD_PT_UINT64 = 0x10, WYRD_PT_SINT64 = 0x11, WYRD_PT_BOOL = 0x20, WYRD_PT_FLOAT = 0x30, WYRD_PT_DOUBLE = 0x31, // A sequential list type; items can be duplicated WYRD_PT_CONT_LIST = 0x40, // A set type; items are unique // WYRD_PT_CONT_SET = 0x41, // (string) key to value mappings; items can be unique or duplicated WYRD_PT_CONT_MAP = 0x42, // WYRD_PT_CONT_MULTI_MAP = 0x42, // TODO add more property types } wyrd_property_type; typedef enum { WYRD_MS_NAIVE_OVERRIDE = 0, // TODO add more merge strategies } wyrd_merge_strategy; WYRD_API wyrd_error_t wyrd_set_property_typed(struct wyrd_handle * handle, char const * path, wyrd_property_type type, wyrd_merge_strategy strategy, void const * value, size_t value_size, int override_type); WYRD_API wyrd_error_t wyrd_get_property(struct wyrd_handle * handle, char const * path, void * value, size_t * value_size); WYRD_API wyrd_error_t wyrd_get_property_type(struct wyrd_handle * handle, char const * path, wyrd_property_type * type); WYRD_API wyrd_error_t wyrd_check_property_type(struct wyrd_handle * handle, char const * path, wyrd_property_type type); WYRD_API wyrd_error_t wyrd_get_merge_strategy(struct wyrd_handle * handle, char const * path, wyrd_merge_strategy * strategy); WYRD_API wyrd_error_t wyrd_check_merge_strategy(struct wyrd_handle * handle, char const * path, wyrd_merge_strategy strategy); typedef void (* wyrd_property_callback)(struct wyrd_handle * handle, char const * path, wyrd_property_type type, void const * value, size_t value_size, void * baton); WYRD_API wyrd_error_t wyrd_add_property_callback(struct wyrd_handle * handle, char const * path, wyrd_property_callback callback, void * baton); #define wyrd_set_property_callback wyrd_add_property_callback WYRD_API wyrd_error_t wyrd_remove_property_callback(struct wyrd_handle * handle, char const * path, wyrd_property_callback callback, void * baton); WYRD_API wyrd_error_t wyrd_clear_property_callback(struct wyrd_handle * handle, char const * path, wyrd_property_callback callback, void * baton); WYRD_API wyrd_error_t wyrd_set_property_blob(struct wyrd_handle * handle, char const * path, wyrd_merge_strategy strategy, void const * value, size_t value_size, int override_type); WYRD_API wyrd_error_t wyrd_get_property_blob(struct wyrd_handle * handle, char const * path, void * value, size_t * value_size); WYRD_API wyrd_error_t wyrd_set_property_utf8string(struct wyrd_handle * handle, char const * path, wyrd_merge_strategy strategy, char const * value, size_t value_size, int override_type); WYRD_API wyrd_error_t wyrd_get_property_utf8string(struct wyrd_handle * handle, char const * path, char * value, size_t * value_size); WYRD_API wyrd_error_t wyrd_set_property_uint8(struct wyrd_handle * handle, char const * path, wyrd_merge_strategy strategy, uint8_t value, int override_type); WYRD_API wyrd_error_t wyrd_get_property_uint8(struct wyrd_handle * handle, char const * path, uint8_t * value); WYRD_API wyrd_error_t wyrd_set_property_sint8(struct wyrd_handle * handle, char const * path, wyrd_merge_strategy strategy, int8_t value, int override_type); WYRD_API wyrd_error_t wyrd_get_property_sint8(struct wyrd_handle * handle, char const * path, int8_t * value); WYRD_API wyrd_error_t wyrd_set_property_uint16(struct wyrd_handle * handle, char const * path, wyrd_merge_strategy strategy, uint16_t value, int override_type); WYRD_API wyrd_error_t wyrd_get_property_uint16(struct wyrd_handle * handle, char const * path, uint16_t * value); WYRD_API wyrd_error_t wyrd_set_property_sint16(struct wyrd_handle * handle, char const * path, wyrd_merge_strategy strategy, int16_t value, int override_type); WYRD_API wyrd_error_t wyrd_get_property_sint16(struct wyrd_handle * handle, char const * path, int16_t * value); WYRD_API wyrd_error_t wyrd_set_property_uint32(struct wyrd_handle * handle, char const * path, wyrd_merge_strategy strategy, uint32_t value, int override_type); WYRD_API wyrd_error_t wyrd_get_property_uint32(struct wyrd_handle * handle, char const * path, uint32_t * value); WYRD_API wyrd_error_t wyrd_set_property_sint32(struct wyrd_handle * handle, char const * path, wyrd_merge_strategy strategy, int32_t value, int override_type); WYRD_API wyrd_error_t wyrd_get_property_sint32(struct wyrd_handle * handle, char const * path, int32_t * value); WYRD_API wyrd_error_t wyrd_set_property_sint64(struct wyrd_handle * handle, char const * path, wyrd_merge_strategy strategy, int64_t value, int override_type); WYRD_API wyrd_error_t wyrd_get_property_sint64(struct wyrd_handle * handle, char const * path, int64_t * value); WYRD_API wyrd_error_t wyrd_set_property_uint64(struct wyrd_handle * handle, char const * path, wyrd_merge_strategy strategy, uint64_t value, int override_type); WYRD_API wyrd_error_t wyrd_get_property_uint64(struct wyrd_handle * handle, char const * path, uint64_t * value); WYRD_API wyrd_error_t wyrd_set_property_float(struct wyrd_handle * handle, char const * path, wyrd_merge_strategy strategy, float value, int override_type); WYRD_API wyrd_error_t wyrd_get_property_float(struct wyrd_handle * handle, char const * path, float * value); WYRD_API wyrd_error_t wyrd_set_property_double(struct wyrd_handle * handle, char const * path, wyrd_merge_strategy strategy, double value, int override_type); WYRD_API wyrd_error_t wyrd_get_property_double(struct wyrd_handle * handle, char const * path, double * value); #if 0 struct wyrd_property_iter; WYRD_API wyrd_error_t wyrd_property_iter_create(struct wyrd_handle * handle, struct wyrd_property_iter ** iter, int depth_first); WYRD_API wyrd_error_t wyrd_property_iter_free(struct wyrd_property_iter ** iter); WYRD_API wyrd_error_t wyrd_property_iter_next(struct wyrd_property_iter * iter); WYRD_API wyrd_error_t wyrd_property_iter_valid(struct wyrd_property_iter const * iter); WYRD_API char const * wyrd_property_iter_path(struct wyrd_property_iter const * iter, size_t * path_size); #endif #ifdef __cplusplus } // extern "C" #endif // __cplusplus #endif // guard