Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Files | Data Structures | Macros | Typedefs | Functions

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_tafw_object_get_entity (const afw_object_t *object, afw_xctx_t *xctx)
 Get entity for object. More...
 
const afw_object_tafw_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_tafw_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_tafw_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_tafw_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_tafw_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_tafw_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_tafw_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_tafw_object_memory_associative_array_create (const afw_pool_t *p, afw_xctx_t *xctx)
 Create memory object associative array. More...
 
const afw_object_tafw_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_tafw_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_tafw_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_tafw_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_tafw_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_tafw_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_tafw_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_tafw_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_tafw_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...
 

Detailed Description

Provide afw_object interface common support and memory implementation.

Macro Definition Documentation

◆ AFW_OBJECT_ASSERT_ENTITY

#define AFW_OBJECT_ASSERT_ENTITY (   instance,
  xctx 
)
Value:
do { \
if (instance->meta.embedding_object) \
AFW_OBJECT_IMPL_ERROR_OBJECT_NOT_ENTITY; \
} \
while (0)

Asserts that an object is an entity.

Parameters
instanceof object to check.
xctxof caller.

Definition at line 172 of file afw_object.h.

◆ AFW_OBJECT_ASSERT_MUTABLE

#define AFW_OBJECT_ASSERT_MUTABLE (   instance,
  xctx 
)
Value:
do { \
if (afw_object_is_immutable(instance, xctx)) \
AFW_OBJECT_ERROR_OBJECT_IMMUTABLE; \
} \
while (0)
#define afw_object_is_immutable(instance, xctx)
Determine if object is immutable.
Definition: afw_object.h:158

Asserts that an object is mutable.

Parameters
instanceof object to check.
xctxof caller.

Definition at line 189 of file afw_object.h.

◆ afw_object_create

#define afw_object_create (   p,
  xctx 
)
Value:
#define AFW_OBJECT_MEMORY_OPTION_unmanaged
Object should be unmanaged.
Definition: afw_object.h:733
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.

Create an empty unmanaged object in memory.

Parameters
pto use for the object.
xctxof caller.
Returns
instance of new object.

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.

◆ afw_object_create_and_cede_p

#define afw_object_create_and_cede_p (   p,
  xctx 
)
Value:
#define AFW_OBJECT_MEMORY_OPTION_cede_p
Object cedes control of the specified pool.
Definition: afw_object.h:743

Create an empty entity object in memory in specified pool and cede control of the pool to the object.

Parameters
pthat will be used and controlled by object.
xctxof caller.
Returns
instance of new object.

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.

◆ afw_object_create_clone_on_set

#define afw_object_create_clone_on_set (   p,
  xctx 
)
Value:
#define AFW_OBJECT_MEMORY_OPTION_clone_on_set
Clone values on set.
Definition: afw_object.h:753

Create an empty entity object in its own pool and clone values on set.

Parameters
pto use for the object.
xctxof caller.
Returns
instance of new object.

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.

◆ afw_object_create_clone_to_managed_object

#define afw_object_create_clone_to_managed_object (   object,
  p,
  xctx 
)
Value:
object, p, xctx)
afw_data_type_object_create_clone_to_managed_object(const afw_object_t *object, const afw_pool_t *p, afw_xctx_t *xctx)
Clone an object to a managed object.

Clone an object to a managed object.

Parameters
objectto clone.
pused for cloned object.
xctxof caller.
Returns
cloned object.

This will use afw_object_create_managed() to create the cloned object.

Definition at line 1063 of file afw_object.h.

◆ AFW_OBJECT_CREATE_ENTITY_OR_EMBEDDED

#define AFW_OBJECT_CREATE_ENTITY_OR_EMBEDDED (   result,
  embedding_object,
  property_name,
  always_create_unmanaged,
  cede_p,
  entity_p,
  xctx 
)
Value:
if (always_create_unmanaged || \
(property_name && afw_utf8_equal(property_name, &afw_s__meta_))) \
{ \
result = afw_object_create(entity_p, xctx); \
} \
else if (embedding_object) { \
embedding_object, property_name, xctx); \
} \
else { \
(cede_p) \
entity_p, xctx); \
} \
#define afw_object_create(p, xctx)
Create an empty unmanaged object in memory.
Definition: afw_object.h:948
#define AFW_OBJECT_MEMORY_OPTION_default
Default object behaviour.
Definition: afw_object.h:720
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.
afw_boolean_t afw_utf8_equal(const afw_utf8_t *s1, const afw_utf8_t *s2)
Check to see if a string equals another string.

Helper macro to create a new entity or embedded object.

Parameters
resultwill be set to new object instance.
embedding_objectfor new embedded object or NULL for entity.
property_namefor embedded object or NULL for entity.
always_create_unmanagedobject (ignore embedding and cede)
cede_pif true, the entity object will cede control of entity_p.
entity_pto use for entity object. Ignored for embedded object.
xctxof 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.

◆ afw_object_create_managed

#define afw_object_create_managed (   p,
  xctx 
)
Value:

Create an empty entity object in its own pool.

Parameters
pto use for the object.
xctxof caller.
Returns
instance of new object.

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.

◆ AFW_OBJECT_ERROR_PROPERTY_IMMUTABLE

#define AFW_OBJECT_ERROR_PROPERTY_IMMUTABLE (   property_name)
Value:
AFW_THROW_ERROR_FZ(read_only, xctx, \
"Object property %" AFW_UTF8_FMT " is immutable", \
AFW_UTF8_FMT_ARG(property_name))
#define AFW_UTF8_FMT_ARG(A_STRING)
Convenience Macro for use with AFW_UTF8_FMT to specify arg.
Definition: afw_common.h:605
#define AFW_UTF8_FMT
Format string specifier used for afw_utf8_t.
Definition: afw_common.h:588
#define AFW_THROW_ERROR_FZ(code, xctx, format_z,...)
Macro used to set error and 0 rv in xctx and throw it.
Definition: afw_error.h:319

Definition at line 197 of file afw_object.h.

◆ AFW_OBJECT_GET_ENTITY

#define AFW_OBJECT_GET_ENTITY (   entity,
  object 
)
Value:
entity = object; \
while (entity->meta.embedding_object) \
entity = entity->meta.embedding_object

Macro to get entity for object.

Parameters
entityis place to set entity.
objectto find entity for.

Definition at line 406 of file afw_object.h.

◆ AFW_OBJECT_IS_CORE_OBJECT_TYPE_ID

#define AFW_OBJECT_IS_CORE_OBJECT_TYPE_ID (   OBJECT_TYPE_ID,
  OBJECT_ID 
)
Value:
AFW_OBJECT_ID_IS_OBJECT_TYPE(OBJECT_TYPE_ID) && \
afw_utf8_starts_with((OBJECT_ID), &afw_s__Adaptive)
#define AFW_OBJECT_ID_IS_OBJECT_TYPE(OBJECT_TYPE_ID)
The object type id for object type objects is AdaptiveObjectType.
Definition: afw_object.h:127

Core object type objects have an object id starting with _Adaptive.

Definition at line 131 of file afw_object.h.

◆ afw_object_is_immutable

#define afw_object_is_immutable (   instance,
  xctx 
)    (afw_object_get_setter(instance, xctx) == NULL)

Determine if object is immutable.

Parameters
instanceof object.
xctxof caller.
Returns
boolean result.

Definition at line 158 of file afw_object.h.

◆ AFW_OBJECT_MEMORY_OPTION_cede_p

#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.

◆ AFW_OBJECT_MEMORY_OPTION_cede_p_and_clone_on_set

#define AFW_OBJECT_MEMORY_OPTION_cede_p_and_clone_on_set
Value:
AFW_OBJECT_MEMORY_OPTION_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.

◆ AFW_OBJECT_MEMORY_OPTION_clone_on_set

#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.

◆ AFW_OBJECT_MEMORY_OPTION_default

#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.

◆ AFW_OBJECT_MEMORY_OPTION_unmanaged

#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 Documentation

◆ afw_object_properties_callback_entry_get_t

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.

Parameters
datato passed to afw_object_create_properties_callback().
property_nameto get.
xctxof caller.
Returns
property value or NULL if not found.

Definition at line 810 of file afw_object.h.

◆ afw_object_properties_callback_entry_set_t

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.

Parameters
datato passed to afw_object_create_properties_callback().
property_nameto set.
valueto set.
xctxof caller.

Definition at line 824 of file afw_object.h.

Function Documentation

◆ afw_object_aggregate_external_create()

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.

Parameters
object_listis a NULL terminated list of object pointers.
pto use for the delta object.
xctxof caller.
Returns
aggregate object.

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.

◆ afw_object_create_clone()

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.

Parameters
objectto clone.
pused for cloned object.
xctxof caller.
Returns
cloned object.

Definition at line 138 of file afw_memory.c.

◆ afw_object_create_composite()

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.

Parameters
mutabletrue makes composite mutable.
pis pool for result.
xctxof caller.
...is one or more objects terminated by a NULL.
Returns
instance of new object.

Definition at line 42 of file afw_object_composite.c.

◆ afw_object_create_const_from_key_value_strings_z()

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.

Parameters
pathfor object.
pairskey_value pairs of afw_utf8_z_t with NULL at end.
pfor object.
xctxof caller.
Returns
object.

Definition at line 36 of file afw_object_const_key_value.c.

◆ afw_object_create_embedded()

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.

Parameters
embedding_objectof the new object.
property_nameof embedded object within embedding object.
xctxof caller.
Returns
instance of new object.

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.

◆ afw_object_create_merged()

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.

Parameters
primaryobject. Properties take precedence.
secondaryobject. Properties that are in primary will be ignored.
pto use for the object.
xctxof caller.
Returns
Merged object.

◆ afw_object_create_properties_callback()

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.

Parameters
datato pass as first parameter to callbacks.
countis number of callbacks.
callbacksarray.
pis pool for result.
xctxof caller.
Returns
instance of new object.

Definition at line 43 of file afw_object_properties_callback.c.

◆ afw_object_create_with_options()

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.

Parameters
optionsas defined by AFW_OBJECT_MEMORY_OPTION_* defines.
pto use based on options.
xctxof caller.
Returns
instance of new object.

Definition at line 32 of file afw_object_memory.c.

◆ afw_object_get_entity()

const afw_object_t* afw_object_get_entity ( const afw_object_t object,
afw_xctx_t xctx 
)

Get entity for object.

Parameters
objectto find entity for.
xctxof caller.
Returns
entity.

Definition at line 443 of file afw_object.h.

◆ afw_object_get_property_compile_and_evaluate_as()

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.

Parameters
instanceof object.
property_nameof property.
source_locationto associate with compiled value or NULL (path used).
compile_type(set afw_compile_type_t)
pto use for returned value.
xctxof caller.
Returns
result of compiling and evaluating the property value.

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.

◆ afw_object_get_property_compile_as()

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.

Parameters
instanceof object.
property_nameof property.
source_locationto associate with compiled value or NULL (path used).
compile_type(set afw_compile_type_t)
pto use for returned value.
xctxof caller.
Returns
result of compiling the property value.

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.

◆ afw_object_get_property_extended()

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.

Parameters
instanceof object.
property_nameof property to get. Can be dotted to access embedded object properties.
xctxof caller.
Returns
value or NULL if not found;

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().
Todo:
FIXME: Correct? Return NULL if instance or property_name is missing.
Todo:
FIXME: make a list. else if (afw_utf8_equal_utf8_z(&meta_pn, "parentPaths")) { meta_value = afw_object_get_parent_paths(instance, xctx); };
Todo:
FIXME: Property names like "xyz." and "xyz..x get through.

Definition at line 274 of file afw_object.c.

◆ afw_object_insure_embedded_exists()

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.

Parameters
embedding_objectof the new object.
property_nameof embedded object within embedding object.
xctxof caller.
Returns
instance of embedded object.

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.

◆ afw_object_memory_associative_array_create()

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.

Parameters
pto use for associative array.
xctxof caller.
Returns
object associative array instance.

Definition at line 37 of file afw_object_memory_associative_array.c.

◆ afw_object_merge()

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.

Parameters
instanceof object to merge into.
fromthis object.
replaceproperties in instance.
xctxof caller.

Embedded objects will be merged as well.

Definition at line 576 of file afw_object.c.

◆ afw_object_old_get_property_as_array_of_strings()

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.

Parameters
instanceof object.
property_nameof property. See afw_object_get_property().
pto use for returned value.
xctxof caller.
Returns
NULL terminated list of strings or NULL if value is NULL.

The value can be a list, bag, or scalar.

Definition at line 387 of file afw_object.c.

◆ afw_object_old_get_property_as_array_of_values()

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.

Parameters
instanceof object.
property_nameof property.
pto use for returned value.
xctxof caller.
Returns
result of afw_value_as_array_of_values() on the property value.

Definition at line 369 of file afw_object.c.

◆ afw_object_old_get_property_as_boolean_deprecated()

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.

Parameters
instanceof object.
property_nameName of property to get.
xctxof caller.
Returns
value or false if not found.

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.

◆ afw_object_old_get_property_as_compiled_hybrid()

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.

Parameters
instanceof object.
property_nameof property. See afw_object_get_property().
source_locationto associate with compiled string or NULL.
sharedstruct for shared compile resources or NULL.
pto use for returned value.
xctxof caller.
Returns
the value representation of a compiled hybrid property.

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_object_old_get_property_as_integer_deprecated()

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.

Parameters
instanceof object.
property_nameName of property to get.
foundtrue if property exists.
xctxof caller.
Returns
value or false if not found.

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.

◆ afw_object_old_get_property_as_utf8()

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.

Parameters
instanceof object.
property_nameName of property to get.
ppool to use for returned string.
xctxof caller.
Returns
value or NULL if not found;

Definition at line 531 of file afw_object.c.

◆ afw_object_old_get_property_as_utf8_z()

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.

Parameters
instanceof object.
property_nameName of property to get.
ppool to use for returned string.
xctxof caller.
Returns
value or NULL if not found;

Use with caution since strings can contain x'00' characters.

Definition at line 555 of file afw_object.c.

◆ afw_object_parse_entity_path_from_path()

void afw_object_parse_entity_path_from_path ( afw_utf8_t entity_path,
const afw_utf8_t path 
)

Parse entity path from path.

Parameters
entity_pathis pointer to preallocated afw_utf8_t to put results.
pathis path to parse.

Definition at line 418 of file afw_object.h.

◆ afw_object_property_count()

afw_size_t afw_object_property_count ( const afw_object_t object,
afw_xctx_t xctx 
)

Count the number of properties in an object.

Parameters
objectinstance.
xctxof caller.
Returns
number of properties.

Definition at line 624 of file afw_object.c.

◆ afw_object_remove_property()

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.

Parameters
instanceof object.
property_nameof property to remove.
xctxof 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.

◆ afw_object_resolve_instance()

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.

Parameters
objectObject pointer to return if not NULL.
pathPath of object.
xctxof caller
Returns
Path.

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.

◆ afw_object_set_immutable()

void afw_object_set_immutable ( const afw_object_t instance,
afw_xctx_t xctx 
)

Set an object to immutable if it is not already.

Parameters
instanceof object.
xctxof caller.

Definition at line 19 of file afw_object.c.

◆ afw_object_set_property()

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.

Parameters
instanceof object.
property_nameof property to set.
valueto set or NULL to remove property.
xctxof 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.

◆ afw_object_set_property_as_date_from_parts()

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.

Parameters
instanceof object.
property_nameof property to set.
yearincluding century. Negative is BC. No 0.
month(1-12).
dayof month (1-31). Month limited to days in month..
tz_hours_offsetHours (-14 - +14). If +14 or -14, minutes must be 0.
tz_minutes_offsetMinutes (0 - 59 or -1). -1 indicates no time zone, in which case, hours must be 0.
xctxof caller.

Definition at line 66 of file afw_object.c.

◆ afw_object_set_property_as_dateTime_from_parts()

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.

Parameters
instanceof object.
property_nameof property to set.
yearincluding century. Negative is BC. No 0.
month(1-12).
dayof 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_offsetHours (-14 - +14). If +14 or -14, minutes must be 0.
tz_minutes_offsetMinutes (0 - 59 or -1). -1 indicates no time zone, in which case, hours must be 0.
xctxof caller.

Definition at line 91 of file afw_object.c.

◆ afw_object_set_property_as_dayTimeDuration_from_parts()

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.

Parameters
instanceof object.
property_nameof property to set.
is_positivetrue 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).
xctxof caller.

Definition at line 121 of file afw_object.c.

◆ afw_object_set_property_as_string_from_utf8_z()

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.

Parameters
instanceof object.
property_nameof property to set.
string_zzero terminate string.
xctxof caller.

Definition at line 194 of file afw_object.c.

◆ afw_object_set_property_as_time_from_parts()

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.

Parameters
instanceof object.
property_nameof 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_offsetHours (-14 - +14). If +14 or -14, minutes must be 0.
tz_minutes_offsetMinutes (0 - 59 or -1). -1 indicates no time zone, in which case, hours must be 0.
xctxof caller.

Definition at line 146 of file afw_object.c.

◆ afw_object_set_property_as_yearMonthDuration_from_parts()

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.

Parameters
instanceof object.
property_nameof property to set.
is_positivetrue 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).
xctxof caller.

Definition at line 172 of file afw_object.c.