Adaptive Framework
0.9.0
|
Files | |
file | afw_object.h |
Header for interface afw_object helpers. | |
Data Structures | |
struct | afw_object_properties_callback_entry_s |
Struct for afw_object_properties_callback_entry_t. More... | |
Macros | |
#define | AFW_OBJECT_Q_CORE_ID_PREFIX AFW_Q__Adaptive |
Quoted prefix for all core adaptive object types. | |
#define | AFW_OBJECT_S_CORE_ID_PREFIX afw_s__Adaptive |
String prefix for all core adaptive object types. | |
#define | AFW_OBJECT_Q_OBJECT_TYPE_ID_OBJECT AFW_Q__AdaptiveObject_ |
Quoted object type id for untyped adaptive object. | |
#define | AFW_OBJECT_S_OBJECT_TYPE_ID_OBJECT afw_s__AdaptiveObject_ |
String object type id for untyped adaptive object. | |
#define | AFW_OBJECT_Q_OBJECT_TYPE_ID_OBJECT_TYPE AFW_Q__AdaptiveObjectType_ |
Quoted object type id for Object Type object. | |
#define | AFW_OBJECT_S_OBJECT_TYPE_ID_OBJECT_TYPE afw_s__AdaptiveObjectType_ |
String object type id for Object Type object. | |
#define | AFW_OBJECT_Q_OBJECT_TYPE_ID_VALUE_META AFW_Q__AdaptiveValueMeta_ |
Quoted object type id for Value Meta object. | |
#define | AFW_OBJECT_S_OBJECT_TYPE_ID_VALUE_META afw_s__AdaptiveValueMeta_ |
String object type id for Property Type object. | |
#define | AFW_OBJECT_Q_OBJECT_TYPE_ID_DATA_TYPE AFW_Q__AdaptiveDataType_ |
Quoted object type id for Data Type object. | |
#define | AFW_OBJECT_S_OBJECT_TYPE_ID_DATA_TYPE afw_s__AdaptiveDataType_ |
String object type id for Data Type object. | |
#define | AFW_OBJECT_Q_OBJECT_TYPE_ID_JOURNAL_ENTRY AFW_Q__AdaptiveJournalEntry_ |
Quoted object type id for Journal Entry object. | |
#define | AFW_OBJECT_S_OBJECT_TYPE_ID_JOURNAL_ENTRY afw_s__AdaptiveJournalEntry_ |
String object type id for Journal Entry object. | |
#define | AFW_OBJECT_Q_OBJECT_TYPE_ID_PROVISIONING_PEER AFW_Q__AdaptiveProvisioningPeer_ |
Quoted object type id for Provisioning Peer object. | |
#define | AFW_OBJECT_S_OBJECT_TYPE_ID_PROVISIONING_PEER afw_s__AdaptiveProvisioningPeer_ |
String object type id for Provisioning Peer object. | |
#define | AFW_OBJECT_Q_OBJECT_TYPE_ID_RESPONSE AFW_Q__AdaptiveResponse_ |
Quoted object type id for Response. | |
#define | AFW_OBJECT_S_OBJECT_TYPE_ID_RESPONSE afw_s__AdaptiveResponse_ |
String object type id for Response. | |
#define | AFW_OBJECT_Q_PN_META AFW_Q__meta_ |
Quoted pseudo meta property name. | |
#define | AFW_OBJECT_S_PN_META afw_s__meta_ |
String pseudo meta property name. | |
#define | AFW_OBJECT_Q_PN_OBJECT_ID AFW_Q_objectId |
Quoted pseudo meta property name for objectId. | |
#define | AFW_OBJECT_S_PN_OBJECT_ID afw_s_objectId |
String pseudo meta property name for objectId. | |
#define | AFW_OBJECT_Q_PN_PATH AFW_Q_path |
Quoted pseudo meta property name for path. | |
#define | AFW_OBJECT_S_PN_PATH afw_s_path |
String pseudo meta property name for path. | |
#define | AFW_OBJECT_Q_PN_ADAPTOR_ID AFW_Q_adaptorId |
Quoted pseudo meta property name for adaptorId. | |
#define | AFW_OBJECT_S_PN_ADAPTOR_ID afw_s_adaptorId |
String pseudo meta property name for adaptorId. | |
#define | AFW_OBJECT_Q_PN_OBJECT_TYPE AFW_Q_objectType |
Quoted pseudo meta property name for objectType. | |
#define | AFW_OBJECT_S_PN_OBJECT_TYPE afw_s_objectType |
String pseudo meta property name for objectType. | |
#define | AFW_OBJECT_Q_PN_PARENT_PATHS AFW_Q_parentPaths |
Quoted pseudo meta property name for parentPaths. | |
#define | AFW_OBJECT_S_PN_PARENT_PATHS afw_s_parentPaths |
String pseudo meta property name for parentPaths. | |
#define | AFW_OBJECT_Q_PN_PROPERTY_TYPES AFW_Q_propertyTypes |
Quoted pseudo meta property name for property types. | |
#define | AFW_OBJECT_S_PN_PROPERTY_TYPES afw_s_propertyTypes |
String pseudo meta property name for property types. | |
#define | AFW_OBJECT_Q_PN_META_OBJECTTYPE AFW_OBJECT_Q_PN_META "." AFW_OBJECT_Q_PN_OBJECT_TYPE |
Quoted meta.objectType. | |
#define | AFW_OBJECT_S_PN_META_OBJECTTYPE afw_s_a_meta_objectType |
String meta.objectType. | |
#define | AFW_OBJECT_ID_IS_OBJECT_TYPE(OBJECT_TYPE_ID) afw_utf8_equal((OBJECT_TYPE_ID), &afw_s__AdaptiveObjectType_) |
The object type id for object type objects is AdaptiveObjectType. | |
#define | AFW_OBJECT_IS_CORE_OBJECT_TYPE_ID(OBJECT_TYPE_ID, OBJECT_ID) |
Core object type objects have an object id starting with _Adaptive. More... | |
#define | AFW_OBJECT_IS_CORE_TYPE_ID(ID) afw_utf8_starts_with((ID), &afw_s__Adaptive) |
Core type ids starting with _Adaptive. | |
#define | afw_object_is_immutable(instance, xctx) (afw_object_get_setter(instance, xctx) == NULL) |
Determine if object is immutable. More... | |
#define | AFW_OBJECT_IMPL_ERROR_OBJECT_NOT_ENTITY AFW_THROW_ERROR_Z(general, "Object is not an entity", xctx) |
#define | AFW_OBJECT_ASSERT_ENTITY(instance, xctx) |
Asserts that an object is an entity. More... | |
#define | AFW_OBJECT_ERROR_OBJECT_IMMUTABLE AFW_THROW_ERROR_Z(read_only, "Object immutable", xctx) |
#define | AFW_OBJECT_ASSERT_MUTABLE(instance, xctx) |
Asserts that an object is mutable. More... | |
#define | AFW_OBJECT_ERROR_PROPERTY_IMMUTABLE(property_name) |
#define | AFW_OBJECT_GET_ENTITY(entity, object) |
Macro to get entity for object. More... | |
#define | AFW_OBJECT_MEMORY_OPTION_default 0 |
Default object behaviour. More... | |
#define | AFW_OBJECT_MEMORY_OPTION_unmanaged (1 << 0) |
Object should be unmanaged. More... | |
#define | AFW_OBJECT_MEMORY_OPTION_cede_p (1 << 1) |
Object cedes control of the specified pool. More... | |
#define | AFW_OBJECT_MEMORY_OPTION_clone_on_set (1 << 2) |
Clone values on set. More... | |
#define | AFW_OBJECT_MEMORY_OPTION_cede_p_and_clone_on_set |
Object cedes control of the specified pool and clone on set. More... | |
#define | AFW_OBJECT_MEMORY_OPTION_IS(options_mask, option) ((((options_mask) & (AFW_OBJECT_MEMORY_OPTION_ ## option))) != 0) |
Test memory object option mask option. | |
#define | afw_object_create_and_cede_p(p, xctx) |
Create an empty entity object in memory in specified pool and cede control of the pool to the object. More... | |
#define | afw_object_create_managed(p, xctx) |
Create an empty entity object in its own pool. More... | |
#define | afw_object_create_clone_on_set(p, xctx) |
Create an empty entity object in its own pool and clone values on set. More... | |
#define | afw_object_create(p, xctx) |
Create an empty unmanaged object in memory. More... | |
#define | AFW_OBJECT_CREATE_ENTITY_OR_EMBEDDED(result, embedding_object, property_name, always_create_unmanaged, cede_p, entity_p, xctx) |
Helper macro to create a new entity or embedded object. More... | |
#define | afw_object_create_clone_to_managed_object(object, p, xctx) |
Clone an object to a managed object. More... | |
Typedefs | |
typedef 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. More... | |
typedef 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. More... | |
Functions | |
afw_size_t | afw_object_property_count (const afw_object_t *object, afw_xctx_t *xctx) |
Count the number of properties in an object. More... | |
void | afw_object_set_immutable (const afw_object_t *instance, afw_xctx_t *xctx) |
Set an object to immutable if it is not already. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
void | afw_object_parse_entity_path_from_path (afw_utf8_t *entity_path, const afw_utf8_t *path) |
Parse entity path from path. More... | |
const afw_object_t * | afw_object_get_entity (const afw_object_t *object, afw_xctx_t *xctx) |
Get entity for object. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
Provide afw_object interface common support and memory implementation.
#define AFW_OBJECT_ASSERT_ENTITY | ( | instance, | |
xctx | |||
) |
Asserts that an object is an entity.
instance | of object to check. |
xctx | of caller. |
Definition at line 172 of file afw_object.h.
#define AFW_OBJECT_ASSERT_MUTABLE | ( | instance, | |
xctx | |||
) |
Asserts that an object is mutable.
instance | of object to check. |
xctx | of caller. |
Definition at line 189 of file afw_object.h.
#define afw_object_create | ( | p, | |
xctx | |||
) |
Create an empty unmanaged object in memory.
p | to use for the object. |
xctx | of caller. |
Reference counting is not done for an unmanaged object, so the lifetime of the object will be controlled by the lifetime of the p specified.
Definition at line 948 of file afw_object.h.
#define afw_object_create_and_cede_p | ( | p, | |
xctx | |||
) |
Create an empty entity object in memory in specified pool and cede control of the pool to the object.
p | that will be used and controlled by object. |
xctx | of caller. |
The pool specified is use to hold the object and it's properties. The pool will be released when the object is released.
Only a single entity object should cede control of any individual pool or errors will occur.
This function is useful when a pool's resources are needed before an object is created, but those resource need to have the same lifetime as the object.
Example:
const afw_pool_t * new_p; const afw_object_t * object;
new_p = afw_pool_calloc(xctx->p, xctx);
... allocate memory and register cleanup using new_p ...
object = afw_object_create_and_cede_p(new_p, xctx);
... set properties and use object ...
afw_object_release(object, xctx);
Definition at line 898 of file afw_object.h.
#define afw_object_create_clone_on_set | ( | p, | |
xctx | |||
) |
Create an empty entity object in its own pool and clone values on set.
p | to use for the object. |
xctx | of caller. |
Note: This might go away during memory manage rewrite (#51) since normal managed objects will have an enhanced version of this.
This is like afw_object_create_managed() except that the value of a set_property() is cloned into the object's pool.
This function creates a subpool of the pool specified to hold the object and it's properties. A call to afw_object_release() for this object will release this subpool.
Definition at line 934 of file afw_object.h.
#define afw_object_create_clone_to_managed_object | ( | object, | |
p, | |||
xctx | |||
) |
Clone an object to a managed object.
object | to clone. |
p | used for cloned object. |
xctx | of caller. |
This will use afw_object_create_managed() to create the cloned object.
Definition at line 1063 of file afw_object.h.
#define AFW_OBJECT_CREATE_ENTITY_OR_EMBEDDED | ( | result, | |
embedding_object, | |||
property_name, | |||
always_create_unmanaged, | |||
cede_p, | |||
entity_p, | |||
xctx | |||
) |
Helper macro to create a new entity or embedded object.
result | will be set to new object instance. |
embedding_object | for new embedded object or NULL for entity. |
property_name | for embedded object or NULL for entity. |
always_create_unmanaged | object (ignore embedding and cede) |
cede_p | if true, the entity object will cede control of entity_p. |
entity_p | to use for entity object. Ignored for embedded object. |
xctx | of caller. |
This macro will call afw_object_create_managed, afw_object_create_and_cede_p() or afw_object_create_embedded() depending on whether embedding_object is NULL and cede_p is true.
Param cede_p should only be used to cede control of a pool to a single entity object.
This macro is useful for situations such as a recursive object parse function that uses an embedding_object and embedding_property_name variable that will be NULL on the first call and have the embedder on subsequent calls.
Definition at line 1015 of file afw_object.h.
#define afw_object_create_managed | ( | p, | |
xctx | |||
) |
Create an empty entity object in its own pool.
p | to use for the object. |
xctx | of caller. |
This function creates a subpool of the pool specified to hold the object and it's properties. A call to afw_object_release() for this object will release this subpool.
Definition at line 913 of file afw_object.h.
#define AFW_OBJECT_ERROR_PROPERTY_IMMUTABLE | ( | property_name | ) |
Definition at line 197 of file afw_object.h.
#define AFW_OBJECT_GET_ENTITY | ( | entity, | |
object | |||
) |
Macro to get entity for object.
entity | is place to set entity. |
object | to find entity for. |
Definition at line 406 of file afw_object.h.
#define AFW_OBJECT_IS_CORE_OBJECT_TYPE_ID | ( | OBJECT_TYPE_ID, | |
OBJECT_ID | |||
) |
Core object type objects have an object id starting with _Adaptive.
Definition at line 131 of file afw_object.h.
#define afw_object_is_immutable | ( | instance, | |
xctx | |||
) | (afw_object_get_setter(instance, xctx) == NULL) |
Determine if object is immutable.
instance | of object. |
xctx | of caller. |
Definition at line 158 of file afw_object.h.
#define AFW_OBJECT_MEMORY_OPTION_cede_p (1 << 1) |
Object cedes control of the specified pool.
The p passed to create will cede control to the object and be considered the object's pool. The lifetime of the object's pool will be controlled by calls to the object's add_reference() and release() methods.
Definition at line 743 of file afw_object.h.
#define AFW_OBJECT_MEMORY_OPTION_cede_p_and_clone_on_set |
Object cedes control of the specified pool and clone on set.
The p passed to create will cede control to the object and be considered the object's pool. The lifetime of the object's pool will be controlled by calls to the object's add_reference() and release() methods.
Definition at line 763 of file afw_object.h.
#define AFW_OBJECT_MEMORY_OPTION_clone_on_set (1 << 2) |
Clone values on set.
Calls to the objects setter functions will clone the input value to the pool of the object. This is useful if the lifetime of the object is longer than the lifetime of the input values.
Definition at line 753 of file afw_object.h.
#define AFW_OBJECT_MEMORY_OPTION_default 0 |
Default object behaviour.
A subpool will be created of the p passed to create and be considered the object's pool. The lifetime of the object's pool will be controlled by calls to the object's add_reference() and release() methods.
Definition at line 720 of file afw_object.h.
#define AFW_OBJECT_MEMORY_OPTION_unmanaged (1 << 0) |
Object should be unmanaged.
Calls to methods release() and add_reference() will not do reference counting and the associated pool and will not call release() for the pool.
Normally, managed entity objects and embedded object reside in a pool who's lifetime is controlled by the reference count of the object. Specifying this option disables this normal behaviour.
Definition at line 733 of file afw_object.h.
typedef 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.
data | to passed to afw_object_create_properties_callback(). |
property_name | to get. |
xctx | of caller. |
Definition at line 810 of file afw_object.h.
typedef 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.
data | to passed to afw_object_create_properties_callback(). |
property_name | to set. |
value | to set. |
xctx | of caller. |
Definition at line 824 of file afw_object.h.
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.
object_list | is a NULL terminated list of object pointers. |
p | to use for the delta object. |
xctx | of caller. |
IMPORTANT: This implementation of object only supports one use of the "get_next" functions per instance at a time since the iterator memory is part of the instance's self.
The object_list parameter is stored and used each time an object method is called so it must remain allocated.
This object_list can be modified by the caller after calling afw_object_aggregate_external_create() except in the case of reusing an iterator to call afw_object_get_next_property() and afw_object_get_next_property_meta().
Each request to access the object will process the individual objects in order. For instance, afw_object_get_property() will go through the list of objects until it finds the property requested. Also, afw_object_get_next_property() and afw_object_get_next_property_meta() will make sure that they only returns the first instance of a property name.
The setter of the first object instance or NULL is returned by afw_object_get_setter().
After afw_object_aggregate_external_create(), each object in the object_list can still be accessed individually.
Definition at line 34 of file afw_object_aggregate_external.c.
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.
object | to clone. |
p | used for cloned object. |
xctx | of caller. |
Definition at line 138 of file afw_memory.c.
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.
mutable | true makes composite mutable. |
p | is pool for result. |
xctx | of caller. |
... | is one or more objects terminated by a NULL. |
Definition at line 42 of file afw_object_composite.c.
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.
path | for object. |
pairs | key_value pairs of afw_utf8_z_t with NULL at end. |
p | for object. |
xctx | of caller. |
Definition at line 36 of file afw_object_const_key_value.c.
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.
embedding_object | of the new object. |
property_name | of embedded object within embedding object. |
xctx | of caller. |
The embedded object and its properties will use the embedding object's pool, options, and reference counting. The property_name property of the embedding object will be set to the new embedding object.
Definition at line 60 of file afw_object_memory.c.
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.
primary | object. Properties take precedence. |
secondary | object. Properties that are in primary will be ignored. |
p | to use for the object. |
xctx | of caller. |
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.
data | to pass as first parameter to callbacks. |
count | is number of callbacks. |
callbacks | array. |
p | is pool for result. |
xctx | of caller. |
Definition at line 43 of file afw_object_properties_callback.c.
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.
options | as defined by AFW_OBJECT_MEMORY_OPTION_* defines. |
p | to use based on options. |
xctx | of caller. |
Definition at line 32 of file afw_object_memory.c.
const afw_object_t* afw_object_get_entity | ( | const afw_object_t * | object, |
afw_xctx_t * | xctx | ||
) |
Get entity for object.
object | to find entity for. |
xctx | of caller. |
Definition at line 443 of file afw_object.h.
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.
instance | of object. |
property_name | of property. |
source_location | to associate with compiled value or NULL (path used). |
compile_type | (set afw_compile_type_t) |
p | to use for returned value. |
xctx | of caller. |
A slash ('/') followed by the property name will be appended to the source location when calling compile.
Definition at line 252 of file afw_object.c.
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.
instance | of object. |
property_name | of property. |
source_location | to associate with compiled value or NULL (path used). |
compile_type | (set afw_compile_type_t) |
p | to use for returned value. |
xctx | of caller. |
A slash ('/') followed by the property name will be appended to the source location when calling compile.
Definition at line 215 of file afw_object.c.
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.
instance | of object. |
property_name | of property to get. Can be dotted to access embedded object properties. |
xctx | of caller. |
This function also supports several read-only pseudo property names.
Property name | Value |
---|---|
meta.objectId | The result of calling afw_object_meta_get_object_id(). |
meta.objectType | The result of calling afw_object_meta_get_object_type_id(). |
meta.parentPaths | The result of calling afw_object_meta_get_parent_paths(). |
meta.path | The result of calling afw_object_meta_get_path(). |
Definition at line 274 of file afw_object.c.
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.
embedding_object | of the new object. |
property_name | of embedded object within embedding object. |
xctx | of caller. |
The embedded object and its properties will use the embedding object's pool, options, and reference counting. The property_name property of the embedding object will be set to the new embedding object.
Definition at line 103 of file afw_object_memory.c.
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.
p | to use for associative array. |
xctx | of caller. |
Definition at line 37 of file afw_object_memory_associative_array.c.
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.
instance | of object to merge into. |
from | this object. |
replace | properties in instance. |
xctx | of caller. |
Embedded objects will be merged as well.
Definition at line 576 of file afw_object.c.
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.
instance | of object. |
property_name | of property. See afw_object_get_property(). |
p | to use for returned value. |
xctx | of caller. |
The value can be a list, bag, or scalar.
Definition at line 387 of file afw_object.c.
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.
instance | of object. |
property_name | of property. |
p | to use for returned value. |
xctx | of caller. |
Definition at line 369 of file afw_object.c.
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.
instance | of object. |
property_name | Name of property to get. |
xctx | of caller. |
This accepts a boolean value of a case insensitive string value of "true", "t", "false", "f", "0", or "1".
Definition at line 436 of file afw_object.c.
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.
instance | of object. |
property_name | of property. See afw_object_get_property(). |
source_location | to associate with compiled string or NULL. |
shared | struct for shared compile resources or NULL. |
p | to use for returned value. |
xctx | of caller. |
The property value must be an evaluated value. If the value is data type hybrid or string, it is compiled as a hybrid; otherwise, it's just returned.
Definition at line 402 of file afw_object.c.
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.
instance | of object. |
property_name | Name of property to get. |
found | true if property exists. |
xctx | of caller. |
This is like afw_object_old_get_property_as_integer() except the value will be converted to integer if needed instead of throwing a type safe error.
Definition at line 495 of file afw_object.c.
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.
instance | of object. |
property_name | Name of property to get. |
p | pool to use for returned string. |
xctx | of caller. |
Definition at line 531 of file afw_object.c.
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.
instance | of object. |
property_name | Name of property to get. |
p | pool to use for returned string. |
xctx | of caller. |
Use with caution since strings can contain x'00' characters.
Definition at line 555 of file afw_object.c.
void afw_object_parse_entity_path_from_path | ( | afw_utf8_t * | entity_path, |
const afw_utf8_t * | path | ||
) |
Parse entity path from path.
entity_path | is pointer to preallocated afw_utf8_t to put results. |
path | is path to parse. |
Definition at line 418 of file afw_object.h.
afw_size_t afw_object_property_count | ( | const afw_object_t * | object, |
afw_xctx_t * | xctx | ||
) |
Count the number of properties in an object.
object | instance. |
xctx | of caller. |
Definition at line 624 of file afw_object.c.
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.
instance | of object. |
property_name | of property to remove. |
xctx | of caller. |
Remove a property owned by an object. The object ancestors are not changed. If the property does not exist, this method will do nothing. If it is important to know if property exists that is being removed, use method has_property() first.
Definition at line 35 of file afw_object.c.
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.
object | Object pointer to return if not NULL. |
path | Path of object. |
xctx | of caller |
Return object passed. If the object passed is NULL and the path passed is not NULL, use path to attempt to locate and return object from the current xctx's object registry.
Definition at line 464 of file afw_object.h.
void afw_object_set_immutable | ( | const afw_object_t * | instance, |
afw_xctx_t * | xctx | ||
) |
Set an object to immutable if it is not already.
instance | of object. |
xctx | of caller. |
Definition at line 19 of file afw_object.c.
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.
instance | of object. |
property_name | of property to set. |
value | to set or NULL to remove property. |
xctx | of caller. |
Set the value of a property owned by an object. The property will be added, if necessary. The object ancestors are not changed. If it is important to know if property exists that is being set, use method has_property() first.
The value and name must be available for the life of the object. Use the object's pool to allocate memory for the name and value, if necessary.
If value is NULL, the property is removed. If the property does not exist, no error is thrown.
An exception is thrown if the object is immutable.
Definition at line 46 of file afw_object.c.
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.
instance | of object. |
property_name | of property to set. |
year | including century. Negative is BC. No 0. |
month | (1-12). |
day | of month (1-31). Month limited to days in month.. |
tz_hours_offset | Hours (-14 - +14). If +14 or -14, minutes must be 0. |
tz_minutes_offset | Minutes (0 - 59 or -1). -1 indicates no time zone, in which case, hours must be 0. |
xctx | of caller. |
Definition at line 66 of file afw_object.c.
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.
instance | of object. |
property_name | of property to set. |
year | including century. Negative is BC. No 0. |
month | (1-12). |
day | of month (1-31). Month limited to days in month.. |
hour | (0-24). If hour is 24 then other values must be 0. |
minute | (0-59). |
second | (0-60+). 60 or more is allowed for leap seconds. |
microsecond | (0-999999). |
tz_hours_offset | Hours (-14 - +14). If +14 or -14, minutes must be 0. |
tz_minutes_offset | Minutes (0 - 59 or -1). -1 indicates no time zone, in which case, hours must be 0. |
xctx | of caller. |
Definition at line 91 of file afw_object.c.
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.
instance | of object. |
property_name | of property to set. |
is_positive | true if duration is positive or false if negative. |
days | (must be between 0 and AFW_INT32_MAX). |
hours | (must be between 0 and AFW_INT32_MAX). |
minutes | (must be between 0 and AFW_INT32_MAX). |
seconds | (must be between 0 and AFW_INT32_MAX). |
microseconds | (must be between 0 and AFW_INT32_MAX). |
xctx | of caller. |
Definition at line 121 of file afw_object.c.
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.
instance | of object. |
property_name | of property to set. |
string_z | zero terminate string. |
xctx | of caller. |
Definition at line 194 of file afw_object.c.
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.
instance | of object. |
property_name | of property to set. |
hour | (0-24). If hour is 24 then other values must be 0. |
minute | (0-59). |
second | (0-60+). 60 or more is allowed for leap seconds. |
microsecond | (0-999999). |
tz_hours_offset | Hours (-14 - +14). If +14 or -14, minutes must be 0. |
tz_minutes_offset | Minutes (0 - 59 or -1). -1 indicates no time zone, in which case, hours must be 0. |
xctx | of caller. |
Definition at line 146 of file afw_object.c.
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.
instance | of object. |
property_name | of property to set. |
is_positive | true if duration is positive or false if negative. |
years | (must be between 0 and AFW_INT32_MAX). |
months | (must be between 0 and AFW_INT32_MAX). |
xctx | of caller. |
Definition at line 172 of file afw_object.c.