Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

sobj.c File Reference


Detailed Description

Simple object main implementation file.

This file implements most of the simple object interface.

#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sobject/iso8601.h>
#include "sobject_p.h"

Include dependency graph for sobj.c:

Include dependency graph

Functions

void sobj_init (struct sobj *)
 Initialize an instance of a simple object.
void sobj_deinit (struct sobj *)
 De-initialize an instance of a simple object.
void sobj_del (void *)
 Destructor callback function for simple object instances.
sobj_binarynew_sobj_binary (void)
 Create a new instance of a plain binary object.
void delete_sobj_binary (struct sobj_binary *)
 Delete an instance of a plain binary object.
sobj_arraynew_sobj_array (void)
 Create a new instance of a plain array object.
void delete_sobj_array (struct sobj_array *)
 Delete an instance of a plain array object.
sobj_vrefnew_sobj_vref (void)
 Create a new instance of a plain vref object.
void delete_sobj_vref (struct sobj_vref *)
 Delete an instance of a plain vref object.
sobj_exprnew_sobj_expr (void)
 Create a new instance of a plain expression object.
void delete_sobj_expr (struct sobj_expr *)
 Delete an instance of a plain expression object.
void * sobj_malloc (size_t size)
 Heap allocation function.
void * sobj_realloc (void *mem, size_t size)
 Heap re-allocation function.
void sobj_free (void *mem)
 Heap free function.
char * sobj_strdup (const char *string)
 Duplicate a null-terminated string.
void * sobj_retain (void *object)
 Increase the referece count of an object (retain the object).
void sobj_release (void *object)
 Decrease the referece count of an object and delete ob zero (release the object).
void sobj_unretain (void *object)
 Decrease the referece count of an object without deletion on zero (unretain the object).
void sobj_drop (void *object)
 Delete an object if the referece counter is zero.
sobj_refcount_t sobj_refcount (void *object)
 Get the current referece counted of the specified object.
void * sobj_xretain (void *object)
 Increase the referece count of an object (retain the object).
void sobj_xrelease (void *object)
 Decrease the referece count of an object and delete ob zero (release the object).
void sobj_xunretain (void *object)
 Decrease the referece count of an object without deletion on zero (unretain the object).
void sobj_xdrop (void *object)
 Delete an object if the referece counter is zero.
sobjsobj_alloc (void)
 Allocate a new instance of a simple object.
sobjsobj_array_lookup (struct sobj_array *sobj_array, struct sobj *key, int *index_ref, struct sobj_env *env)
 Internal function for performing lookup operations on plain array objects.
void sobj_static_init (void)
 Static initialization function for the simple object library.
sobjsobj_NIL (const char *cn)
 Factory for simple objects of type nil.
sobjsobj_BOOL (bool value, const char *cn)
 Factory for simple objects of type bool.
sobjsobj_INT_i (int value, const char *cn)
 Factory for simple objects of type int.
sobjsobj_INT_l (long value, const char *cn)
 Factory for simple objects of type int.
sobjsobj_INT_ll (long long value, const char *cn)
 Factory for simple objects of type int.
sobjsobj_INT_i8 (int8_t value, const char *cn)
 Factory for simple objects of type int.
sobjsobj_INT_i16 (int16_t value, const char *cn)
 Factory for simple objects of type int.
sobjsobj_INT_i32 (int32_t value, const char *cn)
 Factory for simple objects of type int.
sobjsobj_INT_i64 (int64_t value, const char *cn)
 Factory for simple objects of type int.
sobjsobj_INT_imax (intmax_t value, const char *cn)
 Factory for simple objects of type int.
sobjsobj_INT_u (unsigned value, const char *cn)
 Factory for simple objects of type int.
sobjsobj_INT_ul (unsigned long value, const char *cn)
 Factory for simple objects of type int.
sobjsobj_INT_ull (unsigned long long value, const char *cn)
 Factory for simple objects of type int.
sobjsobj_INT_u8 (uint8_t value, const char *cn)
 Factory for simple objects of type int.
sobjsobj_INT_u16 (uint16_t value, const char *cn)
 Factory for simple objects of type int.
sobjsobj_INT_u32 (uint32_t value, const char *cn)
 Factory for simple objects of type int.
sobjsobj_INT_u64 (uint64_t value, const char *cn)
 Factory for simple objects of type int.
sobjsobj_INT_umax (uintmax_t value, const char *cn)
 Factory for simple objects of type int.
sobjsobj_INT_time_t (const void *value)
 Factory for simple objects of type int.
sobjsobj_INT_timeval (const void *value)
 Factory for simple objects of type int.
sobjsobj_INT_timespec (const void *value)
 Factory for simple objects of type int.
sobjsobj_INT_iso8601_time (const void *value)
 Factory for simple objects of type int.
sobjsobj_INT_time_now (void)
 Factory for simple objects of type int.
sobjsobj_FLOAT (double value, const char *cn)
 Factory for simple objects of type float.
sobjsobj_FLOAT_nan (const char *cn)
 Factory for simple objects of type float with the value NAN (Not A Number).
sobjsobj_FLOAT_inf (const char *cn)
 Factory for simple objects of type float with the value INF (positive infinity).
sobjsobj_FLOAT_neginf (const char *cn)
 Factory for simple objects of type float with the value -INF (negative infinity).
sobjsobj_STRING (const char *string, const char *cn, struct sobj_env *env)
 String factory creating a string object from a text serialization in string context.
sobjsobj_STRING_raw (const char *raw, ptrdiff_t raw_len, const char *cn)
 String factory creating a string object from a raw UNICODE UTF-8 string.
sobjsobj_STRING_ucx (const char *ucx, ptrdiff_t ucx_size, const char *cn)
 String factory creating a string object from an extended UNICODE string.
sobjsobj_BINARY (struct sobj *id, const unsigned char *body, size_t body_length, const char *cn)
 Factory creating simple objects of type binary.
sobjsobj_ARRAY (int key_n, struct sobj **key, int value_n, struct sobj **value, const char *cn)
 Factory for creating simple objects of type array.
sobjsobj_ARRAY1 (struct sobj *key, struct sobj *value, const char *cn)
 Convenience factory function for creating one-element arrays.
sobjsobj_ARRAY2 (struct sobj *key1, struct sobj *value1, struct sobj *key2, struct sobj *value2, const char *cn)
 Convenience factory function for creating two-element arrays.
sobjsobj_ARRAY_str (int key_n, const char **key, int value_n, const char **value, const char *cn)
 Convenience factory function for creating an array of strings.
sobjsobj_VREF (const char *ref, const char *cn)
 Factory function for creating simple objects of type vref.
sobjsobj_VREF_raw (const char *ref, const char *cn)
 Factory function for creating simple objects of type vref.
sobjsobj_VREF_ucx (const char *ref, const char *cn)
 Factory function for creating simple objects of type vref.
sobjsobj_EXPR (enum sobj_expr_type type, struct sobj *op1, struct sobj *op2, struct sobj *op3, const char *cn)
 Factory function for creating simple objects of type expr.
sobjsobj_index (struct sobj *sobj, int index)
 Perform an index operation.
sobjsobj_slice (struct sobj *sobj, int lower_bound, int upper_bound)
 Perform a slice operation.
sobjsobj_select (struct sobj *sobj, struct sobj *key, struct sobj_env *env)
 Perform a selection operation.
sobjsobj_select_with_string (struct sobj *sobj, const char *key_string, struct sobj_env *env)
 Perform a selection operation using a string as the key.
sobjsobj_lookup (struct sobj *sobj, struct sobj *key, struct sobj_env *env)
 Perform a dictionary lookup operation.
sobjsobj_lookup_with_string (struct sobj *sobj, const char *key_string, struct sobj_env *env)
 Perform a dictionary lookup operation using a key string.
sobjsobj_call (struct sobj *sobj, const char *selector, struct sobj *args, struct sobj_env *env)
 Perform a method call on a simple object.
int sobj_index_of (struct sobj *sobj, struct sobj *key, struct sobj_env *env)
 Return the index of the element associated with the specified key.
int sobj_index_of_with_string (struct sobj *sobj, const char *key_string, struct sobj_env *env)
 Return the index of the element associated with the specified key.
sobjsobj_get (struct sobj *sobj, const char *address, bool pure, struct sobj_env *env)
 Get a subobject of the called object.
sobjsobj_get2 (struct sobj *sobj, struct sobj *address, bool pure, struct sobj_env *env)
 Get a subobject of the called object.
sobjsobj_getf (struct sobj *sobj, bool pure, struct sobj_env *env, const char *address_fmt,...)
 Get a subobject of the called object.
sobjsobj_vgetf (struct sobj *sobj, bool pure, struct sobj_env *env, const char *address_fmt, va_list ap)
 Get a subobject of the called object.
char * sobj_substring (struct sobj *sobj, int position, int count, struct sobj_env *env)
 Get a substring from the called object.
size_t sobj_string_length (struct sobj *sobj)
 Return the length of a string (number of UNICODE characters).
enum sobj_type sobj_type (struct sobj *sobj)
 Return the object type.
const char * sobj_typename (enum sobj_type type, bool upper)
 Return a type name string for the specified type.
const char * sobj_classname (struct sobj *sobj)
 Return the object class name.
unsigned long sobj_length (struct sobj *sobj)
 Return the length of the object.
size_t sobj_string_ucx (struct sobj *sobj, char *buffer, ptrdiff_t buffer_size)
 Get the extended UNICODE string from a string object.
sobjsobj_binary_type_id (struct sobj *sobj)
 Get the type id of a simple object of type binary.
const unsigned char * sobj_binary_data (struct sobj *sobj, size_t *length_ref)
 Get the data field of a simple object of type binary.
size_t sobj_binary_copy_data (struct sobj *sobj, unsigned char *buffer, ptrdiff_t buffer_size)
 Get the data field of a simple object of type binary.
int sobj_array_count (struct sobj *sobj)
 Get the number of elements stored in an array object.
void sobj_array_values (struct sobj *sobj, struct sobj **value)
 Get the values stored in an array object.
void sobj_array_keys (struct sobj *sobj, struct sobj **key)
 Get the keys stored in an array object.
sobjsobj_array_key (struct sobj *sobj, int index)
 Get an array key at a specified index.
sobjsobj_array_value (struct sobj *sobj, int index)
 Get an array value at a specified index.
const char * sobj_vref_ref (struct sobj *sobj)
 Get the reference string from a vref object.
enum sobj_expr_type sobj_expr_type (struct sobj *sobj)
 Get the expression type from an expression object.
int sobj_expr_op_count (struct sobj *sobj)
 Get the number of operands from an expression object.
int sobj_expr_op (struct sobj *sobj, struct sobj **op)
 Get the operands from an expression object.
sobjsobj_eval (struct sobj *sobj, struct sobj_env *env)
 Perform an object evaluation.
sobjsobj_resolve (struct sobj *sobj, bool recursive, struct sobj_env *env)
 Resolve variable references.
sobjsobj_copy (struct sobj *sobj)
 Create a (flat) copy of a simple object.
int sobj_compare (struct sobj *sobj, struct sobj *operand, struct sobj_env *env)
 Perform an ordered comparison of the called object with the specified object operand.
const char * sobj_version (const char *version)
 Get the library version number.
void sobj_cleanup (void)
 Final cleanup function.
void sobj_threads (void)
 Indicator function for POSIX threads support.
void sobj_mm_hooks (void)
 Indicator function for memory manager hooks support.

Variables

volatile bool sobj_debug = false
 Flag indicating if the library is being debugged.

Function Documentation

void delete_sobj_array struct sobj_array sobj_array  )  [static]
 

Delete an instance of a plain array object.

Parameters:
sobj_array The plain array object.

void delete_sobj_binary struct sobj_binary sobj_binary  )  [static]
 

Delete an instance of a plain binary object.

Parameters:
sobj_binary The plain binary object.

void delete_sobj_expr struct sobj_expr sobj_expr  )  [static]
 

Delete an instance of a plain expression object.

Parameters:
sobj_expr The plain expression object.

void delete_sobj_vref struct sobj_vref sobj_vref  )  [static]
 

Delete an instance of a plain vref object.

Parameters:
sobj_vref The plain vref object.

struct sobj_array * new_sobj_array void   )  [static]
 

Create a new instance of a plain array object.

The plain array object is typically referenced by a simple object instance of type array.

Returns:
The new instance.

struct sobj_binary * new_sobj_binary void   )  [static]
 

Create a new instance of a plain binary object.

The binary object is typically referenced by a simple object instance of typically binary.

Returns:
The new instance.

struct sobj_expr * new_sobj_expr void   )  [static]
 

Create a new instance of a plain expression object.

Plain expression objects are typically referenced by simple object instances of type expr.

Returns:
The new plain expression object.

struct sobj_vref * new_sobj_vref void   )  [static]
 

Create a new instance of a plain vref object.

Plain vref objects are typically referenced by simple objects of type vref.

Returns:
The new instance.

struct sobj* sobj_alloc void   ) 
 

Allocate a new instance of a simple object.

Returns:
The new instance.

struct sobj* sobj_array_lookup struct sobj_array sobj_array,
struct sobj key,
int *  index_ref,
struct sobj_env env
 

Internal function for performing lookup operations on plain array objects.

Plain array objects may reference a dictionary object to speed-up string key lookups (sobj_dict). If the array object exceeds a predefined size limit and no dictionary object has been created yet, a speed-up dictionary will be created and stored in the array object.

Parameters:
sobj_array The plain array object.
key The key for the lookup operation.
index_ref If index_ref is not a null-pointer and an element is bound to the specified key, the index of the element is stored to *index_ref.
env The environment. This may be a null-pointer.

void sobj_deinit struct sobj sobj  )  [static]
 

De-initialize an instance of a simple object.

Parameters:
sobj The simple object instance.

void sobj_del void *  self  )  [static]
 

Destructor callback function for simple object instances.

Parameters:
self Generic pointer to the simple object instances.

void sobj_init struct sobj sobj  )  [static]
 

Initialize an instance of a simple object.

Parameters:
sobj Pointer to an uninitialized simple object instance.

void sobj_static_init void   )  [static]
 

Static initialization function for the simple object library.

This function is called automatically by the simple object factories if required. The function initializes a number of static copies of common simple objects.


Variable Documentation

volatile bool sobj_debug = false
 

Flag indicating if the library is being debugged.

This flag may be set at runtime using a debugger. It causes the sobj_abort() function to be called in case of a failed assertion.


Generated on Sat Jul 23 16:04:42 2005 for sobject by  doxygen 1.3.9.1