10 #define __AFW_OBJECT_H
30 #define AFW_OBJECT_Q_CORE_ID_PREFIX AFW_Q__Adaptive
33 #define AFW_OBJECT_S_CORE_ID_PREFIX afw_s__Adaptive
36 #define AFW_OBJECT_Q_OBJECT_TYPE_ID_OBJECT AFW_Q__AdaptiveObject_
39 #define AFW_OBJECT_S_OBJECT_TYPE_ID_OBJECT afw_s__AdaptiveObject_
42 #define AFW_OBJECT_Q_OBJECT_TYPE_ID_OBJECT_TYPE AFW_Q__AdaptiveObjectType_
45 #define AFW_OBJECT_S_OBJECT_TYPE_ID_OBJECT_TYPE afw_s__AdaptiveObjectType_
48 #define AFW_OBJECT_Q_OBJECT_TYPE_ID_VALUE_META AFW_Q__AdaptiveValueMeta_
51 #define AFW_OBJECT_S_OBJECT_TYPE_ID_VALUE_META afw_s__AdaptiveValueMeta_
54 #define AFW_OBJECT_Q_OBJECT_TYPE_ID_DATA_TYPE AFW_Q__AdaptiveDataType_
57 #define AFW_OBJECT_S_OBJECT_TYPE_ID_DATA_TYPE afw_s__AdaptiveDataType_
60 #define AFW_OBJECT_Q_OBJECT_TYPE_ID_JOURNAL_ENTRY AFW_Q__AdaptiveJournalEntry_
63 #define AFW_OBJECT_S_OBJECT_TYPE_ID_JOURNAL_ENTRY afw_s__AdaptiveJournalEntry_
66 #define AFW_OBJECT_Q_OBJECT_TYPE_ID_PROVISIONING_PEER AFW_Q__AdaptiveProvisioningPeer_
69 #define AFW_OBJECT_S_OBJECT_TYPE_ID_PROVISIONING_PEER afw_s__AdaptiveProvisioningPeer_
72 #define AFW_OBJECT_Q_OBJECT_TYPE_ID_RESPONSE AFW_Q__AdaptiveResponse_
75 #define AFW_OBJECT_S_OBJECT_TYPE_ID_RESPONSE afw_s__AdaptiveResponse_
78 #define AFW_OBJECT_Q_PN_META AFW_Q__meta_
81 #define AFW_OBJECT_S_PN_META afw_s__meta_
84 #define AFW_OBJECT_Q_PN_OBJECT_ID AFW_Q_objectId
87 #define AFW_OBJECT_S_PN_OBJECT_ID afw_s_objectId
90 #define AFW_OBJECT_Q_PN_PATH AFW_Q_path
93 #define AFW_OBJECT_S_PN_PATH afw_s_path
96 #define AFW_OBJECT_Q_PN_ADAPTOR_ID AFW_Q_adaptorId
99 #define AFW_OBJECT_S_PN_ADAPTOR_ID afw_s_adaptorId
102 #define AFW_OBJECT_Q_PN_OBJECT_TYPE AFW_Q_objectType
105 #define AFW_OBJECT_S_PN_OBJECT_TYPE afw_s_objectType
108 #define AFW_OBJECT_Q_PN_PARENT_PATHS AFW_Q_parentPaths
111 #define AFW_OBJECT_S_PN_PARENT_PATHS afw_s_parentPaths
114 #define AFW_OBJECT_Q_PN_PROPERTY_TYPES AFW_Q_propertyTypes
117 #define AFW_OBJECT_S_PN_PROPERTY_TYPES afw_s_propertyTypes
120 #define AFW_OBJECT_Q_PN_META_OBJECTTYPE \
121 AFW_OBJECT_Q_PN_META "." AFW_OBJECT_Q_PN_OBJECT_TYPE
124 #define AFW_OBJECT_S_PN_META_OBJECTTYPE afw_s_a_meta_objectType
127 #define AFW_OBJECT_ID_IS_OBJECT_TYPE(OBJECT_TYPE_ID) \
128 afw_utf8_equal((OBJECT_TYPE_ID), &afw_s__AdaptiveObjectType_)
131 #define AFW_OBJECT_IS_CORE_OBJECT_TYPE_ID(OBJECT_TYPE_ID, OBJECT_ID) \
132 AFW_OBJECT_ID_IS_OBJECT_TYPE(OBJECT_TYPE_ID) && \
133 afw_utf8_starts_with((OBJECT_ID), &afw_s__Adaptive)
136 #define AFW_OBJECT_IS_CORE_TYPE_ID(ID) \
137 afw_utf8_starts_with((ID), &afw_s__Adaptive)
158 #define afw_object_is_immutable(instance, xctx) \
159 (afw_object_get_setter(instance, xctx) == NULL)
163 #define AFW_OBJECT_IMPL_ERROR_OBJECT_NOT_ENTITY \
164 AFW_THROW_ERROR_Z(general, "Object is not an entity", xctx)
172 #define AFW_OBJECT_ASSERT_ENTITY(instance, xctx) \
174 if (instance->meta.embedding_object) \
175 AFW_OBJECT_IMPL_ERROR_OBJECT_NOT_ENTITY; \
180 #define AFW_OBJECT_ERROR_OBJECT_IMMUTABLE \
181 AFW_THROW_ERROR_Z(read_only, "Object immutable", xctx)
189 #define AFW_OBJECT_ASSERT_MUTABLE(instance, xctx) \
191 if (afw_object_is_immutable(instance, xctx)) \
192 AFW_OBJECT_ERROR_OBJECT_IMMUTABLE; \
197 #define AFW_OBJECT_ERROR_PROPERTY_IMMUTABLE(property_name) \
198 AFW_THROW_ERROR_FZ(read_only, xctx, \
199 "Object property %" AFW_UTF8_FMT " is immutable", \
200 AFW_UTF8_FMT_ARG(property_name))
278 int tz_minutes_offset,
311 int tz_minutes_offset,
363 int tz_minutes_offset,
406 #define AFW_OBJECT_GET_ENTITY(entity,object) \
408 while (entity->meta.embedding_object) \
409 entity = entity->meta.embedding_object
417 AFW_DEFINE_STATIC_INLINE(
void)
423 entity_path->s = path->s;
424 entity_path->len = path->len;
425 for (s = path->s + path->len - 1;
426 s > path->s && *s !=
'/';
430 entity_path->len = s - path->s;
469 if (
object)
return object;
470 if (!path)
return NULL;
720 #define AFW_OBJECT_MEMORY_OPTION_default 0
733 #define AFW_OBJECT_MEMORY_OPTION_unmanaged (1 << 0)
743 #define AFW_OBJECT_MEMORY_OPTION_cede_p (1 << 1)
753 #define AFW_OBJECT_MEMORY_OPTION_clone_on_set (1 << 2)
763 #define AFW_OBJECT_MEMORY_OPTION_cede_p_and_clone_on_set \
764 AFW_OBJECT_MEMORY_OPTION_cede_p + \
765 AFW_OBJECT_MEMORY_OPTION_clone_on_set
769 #define AFW_OBJECT_MEMORY_OPTION_IS(options_mask, option) \
770 ((((options_mask) & (AFW_OBJECT_MEMORY_OPTION_ ## option))) != 0)
810 typedef const afw_value_t *(*afw_object_properties_callback_entry_get_t) (
898 #define afw_object_create_and_cede_p(p, xctx) \
899 afw_object_create_with_options( \
900 AFW_OBJECT_MEMORY_OPTION_cede_p, p, xctx)
913 #define afw_object_create_managed(p, xctx) \
914 afw_object_create_with_options( \
915 AFW_OBJECT_MEMORY_OPTION_default, p, xctx)
934 #define afw_object_create_clone_on_set(p, xctx) \
935 afw_object_create_with_options( \
936 AFW_OBJECT_MEMORY_OPTION_clone_on_set, p, xctx)
948 #define afw_object_create(p, xctx) \
949 afw_object_create_with_options( \
950 AFW_OBJECT_MEMORY_OPTION_unmanaged, p, xctx)
1015 #define AFW_OBJECT_CREATE_ENTITY_OR_EMBEDDED( \
1016 result,embedding_object,property_name,always_create_unmanaged, \
1017 cede_p,entity_p,xctx) \
1018 if (always_create_unmanaged || \
1019 (property_name && afw_utf8_equal(property_name, &afw_s__meta_))) \
1021 result = afw_object_create(entity_p, xctx); \
1023 else if (embedding_object) { \
1024 result = afw_object_create_embedded( \
1025 embedding_object, property_name, xctx); \
1028 result = afw_object_create_with_options( \
1030 ? AFW_OBJECT_MEMORY_OPTION_cede_p \
1031 : AFW_OBJECT_MEMORY_OPTION_default, \
1063 #define afw_object_create_clone_to_managed_object( \
1065 afw_data_type_object_create_clone_to_managed_object( \
#define AFW_BEGIN_DECLARES
#define AFW_DECLARE(type)
Declare a public afw function.
Interfaceafw_interface header.
#define AFW_UTF8_FMT_ARG(A_STRING)
Convenience Macro for use with AFW_UTF8_FMT to specify arg.
#define AFW_UTF8_FMT
Format string specifier used for afw_utf8_t.
afw_utf8_octet_t afw_utf8_z_t
NFC normalized UTF-8 null terminated string.
enum afw_compile_type_e afw_compile_type_t
Compile type enum.
char afw_utf8_octet_t
8 bits of utf-8 codepoint.
apr_size_t afw_size_t
size_t.
apr_int64_t afw_integer_t
typedef for big signed int.
#define AFW_THROW_ERROR_FZ(code, xctx, format_z,...)
Macro used to set error and 0 rv in xctx and throw it.
void afw_object_set_property_as_date_from_parts(const afw_object_t *instance, const afw_utf8_t *property_name, int year, int month, int day, int tz_hours_offset, int tz_minutes_offset, afw_xctx_t *xctx)
Set a date property from parts.
void afw_object_remove_property(const afw_object_t *instance, const afw_utf8_t *property_name, afw_xctx_t *xctx)
Remove a property from object.
const afw_utf8_z_t * afw_object_old_get_property_as_utf8_z(const afw_object_t *instance, const afw_utf8_t *property_name, const afw_pool_t *p, afw_xctx_t *xctx)
Get an object's property value including ancestors as utf8_z in specified pool.
const afw_value_t *(* afw_object_properties_callback_entry_get_t)(void *data, const afw_utf8_t *property_name, afw_xctx_t *xctx)
Typedef for an object property get callback.
#define AFW_OBJECT_GET_ENTITY(entity, object)
Macro to get entity for object.
void afw_object_parse_entity_path_from_path(afw_utf8_t *entity_path, const afw_utf8_t *path)
Parse entity path from path.
void afw_object_set_property_as_dayTimeDuration_from_parts(const afw_object_t *instance, const afw_utf8_t *property_name, afw_boolean_t is_positive, int days, int hours, int minutes, int seconds, int microseconds, afw_xctx_t *xctx)
Set a dayTimeDuration property from parts.
const afw_value_t * afw_object_get_property_extended(const afw_object_t *instance, const afw_utf8_t *property_name, afw_xctx_t *xctx)
Get the value of an object's own property or embedded property.
const afw_object_t * afw_object_insure_embedded_exists(const afw_object_t *embedding_object, const afw_utf8_t *property_name, afw_xctx_t *xctx)
Insure embedded object exists creating if necessary.
const afw_object_t * afw_object_create_clone(const afw_object_t *object, const afw_pool_t *p, afw_xctx_t *xctx)
Clone an object to a specified pool.
const afw_utf8_t * afw_object_old_get_property_as_utf8(const afw_object_t *instance, const afw_utf8_t *property_name, const afw_pool_t *p, afw_xctx_t *xctx)
Get an object's property value as a string in specified pool.
const afw_object_t * afw_object_create_with_options(int options, const afw_pool_t *p, afw_xctx_t *xctx)
Create an empty entity object with options.
afw_integer_t afw_object_old_get_property_as_integer_deprecated(const afw_object_t *instance, const afw_utf8_t *property_name, afw_boolean_t *found, afw_xctx_t *xctx)
Get an object's property value as an integer.
const afw_object_t * afw_object_resolve_instance(const afw_object_t *object, const afw_utf8_t *path, afw_xctx_t *xctx)
Resolve an object's instance pointer.
void afw_object_merge(const afw_object_t *instance, const afw_object_t *from, afw_boolean_t replace, afw_xctx_t *xctx)
Merge properties from one object into another.
const afw_object_associative_array_t * afw_object_memory_associative_array_create(const afw_pool_t *p, afw_xctx_t *xctx)
Create memory object associative array.
const afw_object_t * afw_object_get_entity(const afw_object_t *object, afw_xctx_t *xctx)
Get entity for object.
void afw_object_set_property_as_dateTime_from_parts(const afw_object_t *instance, const afw_utf8_t *property_name, int year, int month, int day, int hour, int minute, int second, int microsecond, int tz_hours_offset, int tz_minutes_offset, afw_xctx_t *xctx)
Set a dateTime property from parts.
const afw_object_t * afw_object_aggregate_external_create(const afw_object_t *const *object_list, const afw_pool_t *p, afw_xctx_t *xctx)
Create an aggregate object with an external object list.
const afw_object_t * afw_object_create_merged(const afw_object_t *primary, const afw_object_t *secondary, const afw_pool_t *p, afw_xctx_t *xctx)
Create a memory object with properties from two other objects.
const afw_utf8_t *const * afw_object_old_get_property_as_array_of_strings(const afw_object_t *instance, const afw_utf8_t *property_name, const afw_pool_t *p, afw_xctx_t *xctx)
Return a NULL terminated list of strings for an object property in a specified pool.
void afw_object_set_property_as_time_from_parts(const afw_object_t *instance, const afw_utf8_t *property_name, int hour, int minute, int second, int microsecond, int tz_hours_offset, int tz_minutes_offset, afw_xctx_t *xctx)
Set a time property from parts.
const afw_object_t * afw_object_create_const_from_key_value_strings_z(const afw_utf8_t *path, const afw_utf8_z_t *const *pairs, const afw_pool_t *p, afw_xctx_t *xctx)
Create a const object from key/value utf-8 null terminated strings.
const afw_value_t *const * afw_object_old_get_property_as_array_of_values(const afw_object_t *instance, const afw_utf8_t *property_name, const afw_pool_t *p, afw_xctx_t *xctx)
Return a NULL terminated list of values for an object property in a specified pool.
void(* afw_object_properties_callback_entry_set_t)(void *data, const afw_utf8_t *property_name, const afw_value_t *value, afw_xctx_t *xctx)
Typedef for an object property set callback.
const afw_value_t * afw_object_get_property_compile_as(const afw_object_t *instance, const afw_utf8_t *property_name, const afw_utf8_t *source_location, afw_compile_type_t compile_type, const afw_pool_t *p, afw_xctx_t *xctx)
Compile a property value using specified compile type.
afw_boolean_t afw_object_old_get_property_as_boolean_deprecated(const afw_object_t *instance, const afw_utf8_t *property_name, afw_xctx_t *xctx)
Get an object's property value as a boolean.
void afw_object_set_property_as_yearMonthDuration_from_parts(const afw_object_t *instance, const afw_utf8_t *property_name, afw_boolean_t is_positive, int years, int months, afw_xctx_t *xctx)
Set a yearMonthDuration property from parts.
void afw_object_set_property_as_string_from_utf8_z(const afw_object_t *instance, const afw_utf8_t *property_name, const afw_utf8_z_t *string_z, afw_xctx_t *xctx)
Set an string property from utf8_z.
const afw_value_t * afw_object_old_get_property_as_compiled_hybrid(const afw_object_t *instance, const afw_utf8_t *property_name, const afw_utf8_t *source_location, const afw_compile_shared_t *shared, const afw_pool_t *p, afw_xctx_t *xctx)
Return a compiled hybrid property value.
void afw_object_set_property(const afw_object_t *instance, const afw_utf8_t *property_name, const afw_value_t *value, afw_xctx_t *xctx)
Set the value of an object's property.
afw_size_t afw_object_property_count(const afw_object_t *object, afw_xctx_t *xctx)
Count the number of properties in an object.
const afw_value_t * afw_object_get_property_compile_and_evaluate_as(const afw_object_t *instance, const afw_utf8_t *property_name, const afw_utf8_t *source_location, afw_compile_type_t compile_type, const afw_pool_t *p, afw_xctx_t *xctx)
Compile and evaluate a property value using specified compile type.
const afw_object_t * afw_object_create_properties_callback(void *data, afw_size_t count, const afw_object_properties_callback_entry_t callbacks[], const afw_pool_t *p, afw_xctx_t *xctx)
Create a mutable composite of unmutable objects.
void afw_object_set_immutable(const afw_object_t *instance, afw_xctx_t *xctx)
Set an object to immutable if it is not already.
const afw_object_t * afw_object_create_composite(afw_boolean_t mutable, const afw_pool_t *p, afw_xctx_t *xctx,...)
Create a composite of immutable objects.
const afw_object_t * afw_object_create_embedded(const afw_object_t *embedding_object, const afw_utf8_t *property_name, afw_xctx_t *xctx)
Create an empty embedded object in a memory object.
Resources that can be shared by multiple compiles.
Interface afw_object_associative_array public struct.
Struct for afw_object_properties_callback_entry_t.
Interface afw_object public struct.
Interface afw_pool public struct.
NFC normalized UTF-8 string.
Interface afw_value public struct.
Interface afw_xctx public struct.