GATE
Loading...
Searching...
No Matches
values.h File Reference

GATE based type encapsulation support. More...

#include "gate/gate_core_api.h"
#include "gate/gatetypes.h"
#include "gate/strings.h"
#include "gate/objects.h"
#include "gate/times.h"
#include "gate/guids.h"
#include "gate/arrays.h"
#include "gate/maps.h"
#include "gate/structs.h"
#include "gate/blobs.h"
#include "gate/typeids.h"
#include <stddef.h>

Data Structures

struct  gate_value_class
 Variable value carrier object. More...
 

Typedefs

typedef struct gate_value_class gate_value_t
 Variable value carrier object.
 

Functions

GATE_CORE_API gate_value_tgate_value_create (gate_type_id_t value_type, void const *src, gate_value_t *dst)
 Initializes a value type with a copy of given source data type.
 
GATE_CORE_API gate_value_tgate_value_clone (gate_value_t const *src, gate_value_t *dst)
 Initializes a new value by copying/cloning the contents of another value object.
 
GATE_CORE_API void gate_value_release (gate_value_t *dst)
 Releases all allocated data of the contained value type.
 
GATE_CORE_API gate_result_t gate_value_get (gate_value_t const *src, void *ptrdst, gate_size_t dstlen)
 Creates a copy of a contained value in a destination storage area.
 
GATE_CORE_API void const * gate_value_get_ptr (gate_value_t const *src)
 Returns a pointer to the content of a value object.
 
GATE_CORE_API gate_type_id_t gate_value_type (gate_value_t const *src)
 Returns the value type ID of content in a value object.
 

Detailed Description

GATE based type encapsulation support.

Typedef Documentation

◆ gate_value_t

Variable value carrier object.

Stores each possible gate type and a related type ID. The different values are stored on a union, no heap allocation is required

Function Documentation

◆ gate_value_create()

GATE_CORE_API gate_value_t * gate_value_create ( gate_type_id_t value_type,
void const * src,
gate_value_t * dst )

Initializes a value type with a copy of given source data type.

Parameters
[in]value_typeType-ID specifying the data type of the value to be constructed
[in]srcPointer to native data type to be copied into new value specified by value_type
[out]dstInitialized with value object containing a copy of src
Returns
dst in case of success, otherwise NULL

◆ gate_value_clone()

GATE_CORE_API gate_value_t * gate_value_clone ( gate_value_t const * src,
gate_value_t * dst )

Initializes a new value by copying/cloning the contents of another value object.

Primitive types are copied, reference types are duplicated and their reference counter is increased

Parameters
[in]srcPointer source value thats content is copied/cloned
[out]dstInitialized with value object containing a cloned content of src
Returns
dst in case of success, otherwise NULL

◆ gate_value_release()

GATE_CORE_API void gate_value_release ( gate_value_t * dst)

Releases all allocated data of the contained value type.

Reference types' reference counter is decreased, heap allocated objects are freed by their destruction function

Parameters
[in]dstPointer to value object to be released

◆ gate_value_get()

GATE_CORE_API gate_result_t gate_value_get ( gate_value_t const * src,
void * ptrdst,
gate_size_t dstlen )

Creates a copy of a contained value in a destination storage area.

Parameters
[in]srcValue object thats content is accessed
[out]ptrdstPointer to target storage that is initialized with a copy of the value content
[in]dstlenCapacity of storage in ptrdst in bytes
Returns
GATE_RESULT_* result code

◆ gate_value_get_ptr()

GATE_CORE_API void const * gate_value_get_ptr ( gate_value_t const * src)

Returns a pointer to the content of a value object.

Parameters
[in]srcPointer to value object thats content is accessed
Returns
Pointer to content in value object

◆ gate_value_type()

GATE_CORE_API gate_type_id_t gate_value_type ( gate_value_t const * src)

Returns the value type ID of content in a value object.

Parameters
[in]srcPointer to value object thats content is accessed
Returns
Value type ID of content