C/C++ Datatypes API

Defines

MSG_HEAD_SEP
COMMBUFFSIZ

Size of COMM buffer.

FMT_LEN
HEAD_FLAG_VALID

Bit flags.

Set if the header is valid.

HEAD_FLAG_MULTIPART

Set if the header is for a multipart message.

HEAD_TYPE_IN_DATA

Set if the type is stored with the data during serialization.

HEAD_AS_ARRAY

Set if messages will be serialized arrays.

call_python(x, format, ...)

Macro wrapping call to PyObject_CallFunction.

free_generic
init_json_object
init_json_array
init_schema
free_json_object
free_json_array
free_schema
copy_json_object
copy_json_array
copy_schema
display_json_object
display_json_array
display_schema

Typedefs

typedef struct dtype_t dtype_t

C-friendly definition of MetaschemaType.

typedef struct generic_t generic_t

C-friendly defintion of YggGeneric.

typedef generic_t json_array_t

C-friendly definition of vector object.

typedef generic_t json_object_t

C-friendly definition of map object.

typedef generic_t schema_t

C-friendly definition of schema object.

typedef python_t python_class_t

C-friendly defintion of Python class object.

typedef python_t python_function_t

C-friendly defintion of Python function object.

typedef generic_t python_instance_t

C-friendly defintion of Python instance object.

typedef char *unicode_t

Aliases to allow differentiation in parsing model definition.

typedef char *string_t
typedef char *bytes_t
typedef struct comm_head_t comm_head_t

Header information passed by comms for multipart messages.

Functions

void delete_dtype_class_c(void *x)

C wrapper for the C++ delete_dtype_class function.

Parameters

x – void* Pointer to MetaschemaType subclass that should be deleted.

void *type_from_doc_c(const void *type_doc, const bool use_generic)

C wrapper for the C++ type_from_doc function.

Parameters
  • type_doc – void* Pointer to const rapidjson::Value type doc.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

Returns

void* Pointer to MetaschemaType class.

void *type_from_pyobj_c(PyObject *pyobj, const bool use_generic)

C wrapper for the C++ type_from_pyobj function.

Parameters
  • pyobj – void* Pointer to const rapidjson::Value type doc.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

Returns

void* Pointer to MetaschemaType class.

int is_dtype_format_array(dtype_t *type_struct)

Determine if a datatype was created from a format.

Parameters

type_struct[in] dtype_t* Datatype structure.

Returns

int 1 if the datatype was created from a format, 0 if it was not, -1 if there is an error.

generic_t init_generic()

Initialize an empty generic object.

Returns

generic_t New generic object structure.

generic_t init_generic_array()

Initialize an empty array of mixed types with generic wrappers.

Returns

generic_t New generic object structure containing an empty array.

generic_t init_generic_map()

Initialize an empty map (JSON object) of mixed types with generic wrappers.

Returns

generic_t New generic object structure contaiing an empty map (JSON object).

int is_generic_flag(char x)

Determine if the provided character matches the required generic prefix char.

Parameters

x[in] char Character to check.

Returns

int 1 if the character is the correct prefix, 0 otherwise.

int is_generic_init(generic_t x)

Determine if a generic structure is initialized.

Parameters

x[in] generic_t Generic structure to test.

Returns

int 1 if the structure is initialized, 0 otherwise.

generic_t create_generic(dtype_t *type_class, void *data, size_t nbytes)

Create a generic object from the provided information.

Parameters
  • type_class[in] dtype_t* Type structure/class.

  • data[in] void* Pointer to data.

  • nbytes[in] size_t Size of data.

Returns

generic_t Pointer to new generic object structure.

int destroy_generic(generic_t *x)

Destroy a generic object.

Parameters

x[in] generic_t* Pointer to generic object structure to destory.

Returns

int -1 if unsuccessful, 0 otherwise.

generic_t copy_generic(generic_t src)

Copy data from one generic object to the other.

Parameters

src[in] generic_t Generic structure that data should be copied from.

Returns

generic_t Copied structure.

void display_generic(generic_t x)

Display information about the generic type.

Parameters

x[in] generic_t* Wrapper for generic object.

generic_t get_generic_va(size_t nargs, va_list_t ap)

Return the recovered generic structure if one is present in the variable argument list.

Parameters
  • nargs[in] size_t Number of argument present in ap.

  • ap[in] va_list_t Variable argument list.

Returns

generic_t Generic structure if one is present.

generic_t *get_generic_va_ptr(size_t nargs, va_list_t ap)

Return the recovered generic structure if one is present in the variable argument list.

Parameters
  • nargs[in] size_t Number of argument present in ap.

  • ap[in] va_list_t Variable argument list.

Returns

generic_t* Generic structure if one is present, NULL otherwise.

generic_t pop_generic_va(size_t *nargs, va_list_t *ap)

Return the recovered generic structure if one is present in the variable argument list by removing it.

Parameters
  • nargs[in] size_t* Pointer to number of arguments present in ap that will be decremented by 1.

  • ap[in] va_list_t* Pointer to variable argument list.

Returns

generic_t Generic structure if one is present.

generic_t *pop_generic_va_ptr(size_t *nargs, va_list_t *ap)

Return the recovered generic structure if one is present in the variable argument list by removing it.

Parameters
  • nargs[in] size_t* Pointer to number of arguments present in ap that will be decremented by 1.

  • ap[in] va_list_t* Pointer to variable argument list.

Returns

generic_t* Generic structure if one is present, NULL otherwise.

int add_generic_array(generic_t arr, generic_t x)

Add an element to the end of an array of generic elements.

Parameters
Returns

int Flag that is 1 if there is an error and 0 otherwise.

int set_generic_array(generic_t arr, size_t i, generic_t x)

Set an element in the array at a given index to a new value.

Parameters
  • arr[in] generic_t Array to add element to.

  • i[in] size_t Index where element should be added.

  • x[in] generic_t Element to add.

Returns

int Flag that is 1 if there is an error and 0 otherwise.

int get_generic_array(generic_t arr, size_t i, generic_t *x)

Get an element from an array.

Parameters
  • arr[in] generic_t Array to get element from.

  • i[in] size_t Index of element to get.

  • x[out] generic_t* Pointer to address where element should be stored.

Returns

int Flag that is 1 if there is an error and 0 otherwise.

int set_generic_object(generic_t arr, const char *k, generic_t x)

Set an element in the object at for a given key to a new value.

Parameters
  • arr[in] generic_t Object to add element to.

  • k[in] const char* Key where element should be added.

  • x[in] generic_t Element to add.

Returns

int Flag that is 1 if there is an error and 0 otherwise.

int get_generic_object(generic_t arr, const char *k, generic_t *x)

Get an element from an object.

Parameters
  • arr[in] generic_t Object to get element from.

  • k[in] const char* Key of element to return.

  • x[out] generic_t* Pointer to address where element should be stored.

Returns

int Flag that is 1 if there is an error and 0 otherwise.

size_t generic_array_get_size(generic_t x)

Get the number of elements in an array object.

Parameters

x[in] generic_t Generic object that is presumed to contain an array.

Returns

size_t Number of elements in array.

void *generic_array_get_item(generic_t x, const size_t index, const char *type)

Get an item from an array for types that don’t require additional parameters.

Parameters
  • x[in] generic_t Generic object that is presumed to contain an array.

  • index[in] size_t Index for value that should be returned.

  • type[in] const char* Type of value expected.

Returns

void* Pointer to data for array item.

int generic_array_get_item_nbytes(generic_t x, const size_t index)

Get the size of an item from an array in bytes.

Parameters
  • x[in] Generic object that is presumed to contain an array.

  • index[in] Index for value that the size should be returned for.

Returns

Size of the item in bytes.

bool generic_array_get_bool(generic_t x, const size_t index)
int generic_array_get_integer(generic_t x, const size_t index)
void *generic_array_get_null(generic_t x, const size_t index)
double generic_array_get_number(generic_t x, const size_t index)
char *generic_array_get_string(generic_t x, const size_t index)
generic_t generic_array_get_object(generic_t x, const size_t index)
generic_t generic_array_get_array(generic_t x, const size_t index)
char *generic_array_get_direct(generic_t x, const size_t index)
ply_t generic_array_get_ply(generic_t x, const size_t index)
obj_t generic_array_get_obj(generic_t x, const size_t index)
python_t generic_array_get_python_class(generic_t x, const size_t index)
python_t generic_array_get_python_function(generic_t x, const size_t index)
schema_t generic_array_get_schema(generic_t x, const size_t index)
generic_t generic_array_get_any(generic_t x, const size_t index)
void *generic_array_get_scalar(generic_t x, const size_t index, const char *subtype, const size_t precision)

Get a scalar value from an array.

Parameters
  • x[in] generic_t Generic object that is presumed to contain an array.

  • index[in] size_t Index for value that should be returned.

  • subtype[in] const char* Subtype of scalar expected.

  • precision[in] const int Precision of scalar that is expected.

Returns

void* Pointer to scalar data.

int8_t generic_array_get_int8(generic_t x, const size_t index)
int16_t generic_array_get_int16(generic_t x, const size_t index)
int32_t generic_array_get_int32(generic_t x, const size_t index)
int64_t generic_array_get_int64(generic_t x, const size_t index)
uint8_t generic_array_get_uint8(generic_t x, const size_t index)
uint16_t generic_array_get_uint16(generic_t x, const size_t index)
uint32_t generic_array_get_uint32(generic_t x, const size_t index)
uint64_t generic_array_get_uint64(generic_t x, const size_t index)
float generic_array_get_float(generic_t x, const size_t index)
double generic_array_get_double(generic_t x, const size_t index)
long double generic_array_get_long_double(generic_t x, const size_t index)
complex_float_t generic_array_get_complex_float(generic_t x, const size_t index)
complex_double_t generic_array_get_complex_double(generic_t x, const size_t index)
complex_long_double_t generic_array_get_complex_long_double(generic_t x, const size_t index)
char *generic_array_get_bytes(generic_t x, const size_t index)
char *generic_array_get_unicode(generic_t x, const size_t index)
size_t generic_array_get_1darray(generic_t x, const size_t index, const char *subtype, const size_t precision, void **data)

Get a 1d array value from an array.

Parameters
  • x[in] generic_t Generic object that is presumed to contain an array.

  • index[in] size_t Index for value that should be returned.

  • subtype[in] const char* Subtype of array expected.

  • precision[in] const size_t Precision of array that is expected.

  • data[out] void** Pointer to pointer that should be reallocated to store the data.

Returns

size_t Number of elements in the data.

size_t generic_array_get_1darray_int8(generic_t x, const size_t index, int8_t **data)
size_t generic_array_get_1darray_int16(generic_t x, const size_t index, int16_t **data)
size_t generic_array_get_1darray_int32(generic_t x, const size_t index, int32_t **data)
size_t generic_array_get_1darray_int64(generic_t x, const size_t index, int64_t **data)
size_t generic_array_get_1darray_uint8(generic_t x, const size_t index, uint8_t **data)
size_t generic_array_get_1darray_uint16(generic_t x, const size_t index, uint16_t **data)
size_t generic_array_get_1darray_uint32(generic_t x, const size_t index, uint32_t **data)
size_t generic_array_get_1darray_uint64(generic_t x, const size_t index, uint64_t **data)
size_t generic_array_get_1darray_float(generic_t x, const size_t index, float **data)
size_t generic_array_get_1darray_double(generic_t x, const size_t index, double **data)
size_t generic_array_get_1darray_long_double(generic_t x, const size_t index, long double **data)
size_t generic_array_get_1darray_complex_float(generic_t x, const size_t index, complex_float_t **data)
size_t generic_array_get_1darray_complex_double(generic_t x, const size_t index, complex_double_t **data)
size_t generic_array_get_1darray_complex_long_double(generic_t x, const size_t index, complex_long_double_t **data)
size_t generic_array_get_1darray_bytes(generic_t x, const size_t index, char **data)
size_t generic_array_get_1darray_unicode(generic_t x, const size_t index, char **data)
size_t generic_array_get_ndarray(generic_t x, const size_t index, const char *subtype, const size_t precision, void **data, size_t **shape)

Get a nd array value from an array.

Parameters
  • x[in] generic_t Generic object that is presumed to contain an array.

  • index[in] size_t Index for value that should be returned.

  • subtype[in] const char* Subtype of array expected.

  • precision[in] const size_t Precision of array that is expected.

  • data[out] void** Pointer to array that should be reallocated to store the data.

  • shape[out] size_t** Pointer to array that should be reallocated to store the array shape in each dimension.

Returns

size_t Number of dimensions in the array.

size_t generic_array_get_ndarray_int8(generic_t x, const size_t index, int8_t **data, size_t **shape)
size_t generic_array_get_ndarray_int16(generic_t x, const size_t index, int16_t **data, size_t **shape)
size_t generic_array_get_ndarray_int32(generic_t x, const size_t index, int32_t **data, size_t **shape)
size_t generic_array_get_ndarray_int64(generic_t x, const size_t index, int64_t **data, size_t **shape)
size_t generic_array_get_ndarray_uint8(generic_t x, const size_t index, uint8_t **data, size_t **shape)
size_t generic_array_get_ndarray_uint16(generic_t x, const size_t index, uint16_t **data, size_t **shape)
size_t generic_array_get_ndarray_uint32(generic_t x, const size_t index, uint32_t **data, size_t **shape)
size_t generic_array_get_ndarray_uint64(generic_t x, const size_t index, uint64_t **data, size_t **shape)
size_t generic_array_get_ndarray_float(generic_t x, const size_t index, float **data, size_t **shape)
size_t generic_array_get_ndarray_double(generic_t x, const size_t index, double **data, size_t **shape)
size_t generic_array_get_ndarray_long_double(generic_t x, const size_t index, long double **data, size_t **shape)
size_t generic_array_get_ndarray_complex_float(generic_t x, const size_t index, complex_float_t **data, size_t **shape)
size_t generic_array_get_ndarray_complex_double(generic_t x, const size_t index, complex_double_t **data, size_t **shape)
size_t generic_array_get_ndarray_complex_long_double(generic_t x, const size_t index, complex_long_double_t **data, size_t **shape)
size_t generic_array_get_ndarray_bytes(generic_t x, const size_t index, char **data, size_t **shape)
size_t generic_array_get_ndarray_unicode(generic_t x, const size_t index, char **data, size_t **shape)
size_t generic_map_get_size(generic_t x)

Get the number of elements in an map object.

Parameters

x[in] generic_t Generic object that is presumed to contain a map.

Returns

size_t Number of elements in map.

int generic_map_has_key(generic_t x, char *key)

Determine if a map object has a certain key.

Parameters
  • x[in] generic_t Generic object that is presumed to contain a map.

  • key[in] char* Key to check for.

Returns

int 1 if the key is present, 0 otherwise.

size_t generic_map_get_keys(generic_t x, char ***keys)

Get the keys in a map object.

Parameters
  • x[in] generic_t Generic object that is presumed to contain a map.

  • keys[out] char*** Pointer to memory where array of keys should be stored.

Returns

size_t Number of keys in map.

void *generic_map_get_item(generic_t x, const char *key, const char *type)

Get an item from a map for types that don’t require additional parameters.

Parameters
  • x[in] generic_t Generic object that is presumed to contain a map.

  • key[in] const char* Key string for value that should be returned.

  • type[in] const char* Type of value expected.

Returns

void* Pointer to data for map item.

int generic_map_get_item_nbytes(generic_t x, const char *key)
bool generic_map_get_bool(generic_t x, const char *key)
int generic_map_get_integer(generic_t x, const char *key)
void *generic_map_get_null(generic_t x, const char *key)
double generic_map_get_number(generic_t x, const char *key)
char *generic_map_get_string(generic_t x, const char *key)
generic_t generic_map_get_object(generic_t x, const char *key)
generic_t generic_map_get_array(generic_t x, const char *key)
char *generic_map_get_direct(generic_t x, const char *key)
ply_t generic_map_get_ply(generic_t x, const char *key)
obj_t generic_map_get_obj(generic_t x, const char *key)
python_t generic_map_get_python_class(generic_t x, const char *key)
python_t generic_map_get_python_function(generic_t x, const char *key)
schema_t generic_map_get_schema(generic_t x, const char *key)
generic_t generic_map_get_any(generic_t x, const char *key)
void *generic_map_get_scalar(generic_t x, const char *key, const char *subtype, const size_t precision)

Get a scalar value from a map.

Parameters
  • x[in] generic_t Generic object that is presumed to contain a map.

  • key[in] const char* Key string for value that should be returned.

  • subtype[in] const char* Subtype of scalar expected.

  • precision[in] const int Precision of scalar that is expected.

Returns

void* Pointer to scalar data.

int8_t generic_map_get_int8(generic_t x, const char *key)
int16_t generic_map_get_int16(generic_t x, const char *key)
int32_t generic_map_get_int32(generic_t x, const char *key)
int64_t generic_map_get_int64(generic_t x, const char *key)
uint8_t generic_map_get_uint8(generic_t x, const char *key)
uint16_t generic_map_get_uint16(generic_t x, const char *key)
uint32_t generic_map_get_uint32(generic_t x, const char *key)
uint64_t generic_map_get_uint64(generic_t x, const char *key)
float generic_map_get_float(generic_t x, const char *key)
double generic_map_get_double(generic_t x, const char *key)
long double generic_map_get_long_double(generic_t x, const char *key)
complex_float_t generic_map_get_complex_float(generic_t x, const char *key)
complex_double_t generic_map_get_complex_double(generic_t x, const char *key)
complex_long_double_t generic_map_get_complex_long_double(generic_t x, const char *key)
char *generic_map_get_bytes(generic_t x, const char *key)
char *generic_map_get_unicode(generic_t x, const char *key)
size_t generic_map_get_1darray(generic_t x, const char *key, const char *subtype, const size_t precision, void **data)

Get a 1d array value from a map.

Parameters
  • x[in] generic_t Generic object that is presumed to contain a map.

  • key[in] const char* Key string for value that should be returned.

  • subtype[in] const char* Subtype of array expected.

  • precision[in] const size_t Precision of array that is expected.

  • data[out] void** Pointer to pointer that should be reallocated to store the data.

Returns

size_t Number of elements in the data.

size_t generic_map_get_1darray_int8(generic_t x, const char *key, int8_t **data)
size_t generic_map_get_1darray_int16(generic_t x, const char *key, int16_t **data)
size_t generic_map_get_1darray_int32(generic_t x, const char *key, int32_t **data)
size_t generic_map_get_1darray_int64(generic_t x, const char *key, int64_t **data)
size_t generic_map_get_1darray_uint8(generic_t x, const char *key, uint8_t **data)
size_t generic_map_get_1darray_uint16(generic_t x, const char *key, uint16_t **data)
size_t generic_map_get_1darray_uint32(generic_t x, const char *key, uint32_t **data)
size_t generic_map_get_1darray_uint64(generic_t x, const char *key, uint64_t **data)
size_t generic_map_get_1darray_float(generic_t x, const char *key, float **data)
size_t generic_map_get_1darray_double(generic_t x, const char *key, double **data)
size_t generic_map_get_1darray_long_double(generic_t x, const char *key, long double **data)
size_t generic_map_get_1darray_complex_float(generic_t x, const char *key, complex_float_t **data)
size_t generic_map_get_1darray_complex_double(generic_t x, const char *key, complex_double_t **data)
size_t generic_map_get_1darray_complex_long_double(generic_t x, const char *key, complex_long_double_t **data)
size_t generic_map_get_1darray_bytes(generic_t x, const char *key, char **data)
size_t generic_map_get_1darray_unicode(generic_t x, const char *key, char **data)
size_t generic_map_get_ndarray(generic_t x, const char *key, const char *subtype, const size_t precision, void **data, size_t **shape)

Get a nd array value from a map.

Parameters
  • x[in] generic_t Generic object that is presumed to contain a map.

  • key[in] const char* Key string for value that should be returned.

  • subtype[in] const char* Subtype of array expected.

  • precision[in] const size_t Precision of array that is expected.

  • data[out] void** Pointer to array that should be reallocated to store the data.

  • shape[out] size_t** Pointer to array that should be reallocated to store the array shape in each dimension.

Returns

size_t Number of dimensions in the array.

size_t generic_map_get_ndarray_int8(generic_t x, const char *key, int8_t **data, size_t **shape)
size_t generic_map_get_ndarray_int16(generic_t x, const char *key, int16_t **data, size_t **shape)
size_t generic_map_get_ndarray_int32(generic_t x, const char *key, int32_t **data, size_t **shape)
size_t generic_map_get_ndarray_int64(generic_t x, const char *key, int64_t **data, size_t **shape)
size_t generic_map_get_ndarray_uint8(generic_t x, const char *key, uint8_t **data, size_t **shape)
size_t generic_map_get_ndarray_uint16(generic_t x, const char *key, uint16_t **data, size_t **shape)
size_t generic_map_get_ndarray_uint32(generic_t x, const char *key, uint32_t **data, size_t **shape)
size_t generic_map_get_ndarray_uint64(generic_t x, const char *key, uint64_t **data, size_t **shape)
size_t generic_map_get_ndarray_float(generic_t x, const char *key, float **data, size_t **shape)
size_t generic_map_get_ndarray_double(generic_t x, const char *key, double **data, size_t **shape)
size_t generic_map_get_ndarray_long_double(generic_t x, const char *key, long double **data, size_t **shape)
size_t generic_map_get_ndarray_complex_float(generic_t x, const char *key, complex_float_t **data, size_t **shape)
size_t generic_map_get_ndarray_complex_double(generic_t x, const char *key, complex_double_t **data, size_t **shape)
size_t generic_map_get_ndarray_complex_long_double(generic_t x, const char *key, complex_long_double_t **data, size_t **shape)
size_t generic_map_get_ndarray_bytes(generic_t x, const char *key, char **data, size_t **shape)
size_t generic_map_get_ndarray_unicode(generic_t x, const char *key, char **data, size_t **shape)
int generic_array_set_item(generic_t x, const size_t index, const char *type, void *value)

Set an item in an array for types that don’t require additional parameters.

Parameters
  • x[in] generic_t Generic object that is presumed to contain an array.

  • index[in] size_t Index for value that should be set.

  • type[in] const char* Type of value being set.

  • value[in] void* Pointer to data that item should be set to.

Returns

int -1 if there is an error, 0 otherwise.

int generic_array_set_bool(generic_t x, const size_t index, bool value)
int generic_array_set_integer(generic_t x, const size_t index, int value)
int generic_array_set_null(generic_t x, const size_t index, void *value)
int generic_array_set_number(generic_t x, const size_t index, double value)
int generic_array_set_string(generic_t x, const size_t index, char *value)
int generic_array_set_object(generic_t x, const size_t index, generic_t value)
int generic_array_set_map(generic_t x, const size_t index, generic_t value)
int generic_array_set_array(generic_t x, const size_t index, generic_t value)
int generic_array_set_direct(generic_t x, const size_t index, char *value)
int generic_array_set_ply(generic_t x, const size_t index, ply_t value)
int generic_array_set_obj(generic_t x, const size_t index, obj_t value)
int generic_array_set_python_class(generic_t x, const size_t index, python_t value)
int generic_array_set_python_function(generic_t x, const size_t index, python_t value)
int generic_array_set_schema(generic_t x, const size_t index, schema_t value)
int generic_array_set_any(generic_t x, const size_t index, generic_t value)
int generic_array_set_scalar(generic_t x, const size_t index, void *value, const char *subtype, const size_t precision, const char *units)

Set a scalar value in an array.

Parameters
  • x[in] generic_t Generic object that is presumed to contain an array.

  • index[in] size_t Index for value that should be set.

  • value[in] void* Pointer to scalar data.

  • subtype[in] const char* Subtype of scalar in value.

  • precision[in] const int Precision of scalar in value.

  • units[in] const char* Units of value.

Returns

int -1 if there is an error, 0 otherwise.

int generic_array_set_int8(generic_t x, const size_t index, int8_t value, const char *units)
int generic_array_set_int16(generic_t x, const size_t index, int16_t value, const char *units)
int generic_array_set_int32(generic_t x, const size_t index, int32_t value, const char *units)
int generic_array_set_int64(generic_t x, const size_t index, int64_t value, const char *units)
int generic_array_set_uint8(generic_t x, const size_t index, uint8_t value, const char *units)
int generic_array_set_uint16(generic_t x, const size_t index, uint16_t value, const char *units)
int generic_array_set_uint32(generic_t x, const size_t index, uint32_t value, const char *units)
int generic_array_set_uint64(generic_t x, const size_t index, uint64_t value, const char *units)
int generic_array_set_float(generic_t x, const size_t index, float value, const char *units)
int generic_array_set_double(generic_t x, const size_t index, double value, const char *units)
int generic_array_set_long_double(generic_t x, const size_t index, long double value, const char *units)
int generic_array_set_complex_float(generic_t x, const size_t index, complex_float_t value, const char *units)
int generic_array_set_complex_double(generic_t x, const size_t index, complex_double_t value, const char *units)
int generic_array_set_complex_long_double(generic_t x, const size_t index, complex_long_double_t value, const char *units)
int generic_array_set_bytes(generic_t x, const size_t index, char *value, const char *units)
int generic_array_set_unicode(generic_t x, const size_t index, char *value, const char *units)
int generic_array_set_1darray(generic_t x, const size_t index, void *value, const char *subtype, const size_t precision, const size_t length, const char *units)

Set a 1d array value in an array.

Parameters
  • x[in] generic_t Generic object that is presumed to contain an array.

  • index[in] size_t Index for value that should be set.

  • value[in] void* Pointer to array data.

  • subtype[in] const char* Subtype of array expected.

  • precision[in] const size_t Precision of array that is expected.

  • length[in] const size_t Number of elements in value.

  • units[in] const char* Units of value.

Returns

int -1 if there is an error, 0 otherwise.

int generic_array_set_1darray_int8(generic_t x, const size_t index, int8_t *value, const size_t length, const char *units)
int generic_array_set_1darray_int16(generic_t x, const size_t index, int16_t *value, const size_t length, const char *units)
int generic_array_set_1darray_int32(generic_t x, const size_t index, int32_t *value, const size_t length, const char *units)
int generic_array_set_1darray_int64(generic_t x, const size_t index, int64_t *value, const size_t length, const char *units)
int generic_array_set_1darray_uint8(generic_t x, const size_t index, uint8_t *value, const size_t length, const char *units)
int generic_array_set_1darray_uint16(generic_t x, const size_t index, uint16_t *value, const size_t length, const char *units)
int generic_array_set_1darray_uint32(generic_t x, const size_t index, uint32_t *value, const size_t length, const char *units)
int generic_array_set_1darray_uint64(generic_t x, const size_t index, uint64_t *value, const size_t length, const char *units)
int generic_array_set_1darray_float(generic_t x, const size_t index, float *value, const size_t length, const char *units)
int generic_array_set_1darray_double(generic_t x, const size_t index, double *value, const size_t length, const char *units)
int generic_array_set_1darray_long_double(generic_t x, const size_t index, long double *value, const size_t length, const char *units)
int generic_array_set_1darray_complex_float(generic_t x, const size_t index, complex_float_t *value, const size_t length, const char *units)
int generic_array_set_1darray_complex_double(generic_t x, const size_t index, complex_double_t *value, const size_t length, const char *units)
int generic_array_set_1darray_complex_long_double(generic_t x, const size_t index, complex_long_double_t *value, const size_t length, const char *units)
int generic_array_set_1darray_bytes(generic_t x, const size_t index, char **value, const size_t length, const char *units)
int generic_array_set_1darray_unicode(generic_t x, const size_t index, char **value, const size_t length, const char *units)
int generic_array_set_ndarray(generic_t x, const size_t index, void *data, const char *subtype, const size_t precision, const size_t ndim, const size_t *shape, const char *units)

Set a nd array value from an array.

Parameters
  • x[in] generic_t Generic object that is presumed to contain an array.

  • index[in] size_t Index for value that should be set.

  • data[in] void* Pointer to array data.

  • subtype[in] const char* Subtype of array in value.

  • precision[in] const size_t Precision of array that is in value.

  • ndim[in] size_t Number of dimensions in the array.

  • shape[in] size_t* Pointer to array containing the size of the array in each dimension.

  • units[in] const char* Units that should be added to the array.

Returns

int -1 if there is an error, 0 otherwise.

int generic_array_set_ndarray_int8(generic_t x, const size_t index, int8_t *data, const size_t ndim, const size_t *shape, const char *units)
int generic_array_set_ndarray_int16(generic_t x, const size_t index, int16_t *data, const size_t ndim, const size_t *shape, const char *units)
int generic_array_set_ndarray_int32(generic_t x, const size_t index, int32_t *data, const size_t ndim, const size_t *shape, const char *units)
int generic_array_set_ndarray_int64(generic_t x, const size_t index, int64_t *data, const size_t ndim, const size_t *shape, const char *units)
int generic_array_set_ndarray_uint8(generic_t x, const size_t index, uint8_t *data, const size_t ndim, const size_t *shape, const char *units)
int generic_array_set_ndarray_uint16(generic_t x, const size_t index, uint16_t *data, const size_t ndim, const size_t *shape, const char *units)
int generic_array_set_ndarray_uint32(generic_t x, const size_t index, uint32_t *data, const size_t ndim, const size_t *shape, const char *units)
int generic_array_set_ndarray_uint64(generic_t x, const size_t index, uint64_t *data, const size_t ndim, const size_t *shape, const char *units)
int generic_array_set_ndarray_float(generic_t x, const size_t index, float *data, const size_t ndim, const size_t *shape, const char *units)
int generic_array_set_ndarray_double(generic_t x, const size_t index, double *data, const size_t ndim, const size_t *shape, const char *units)
int generic_array_set_ndarray_long_double(generic_t x, const size_t index, long double *data, const size_t ndim, const size_t *shape, const char *units)
int generic_array_set_ndarray_complex_float(generic_t x, const size_t index, complex_float_t *data, const size_t ndim, const size_t *shape, const char *units)
int generic_array_set_ndarray_complex_double(generic_t x, const size_t index, complex_double_t *data, const size_t ndim, const size_t *shape, const char *units)
int generic_array_set_ndarray_complex_long_double(generic_t x, const size_t index, complex_long_double_t *data, const size_t ndim, const size_t *shape, const char *units)
int generic_array_set_ndarray_bytes(generic_t x, const size_t index, char **data, const size_t ndim, const size_t *shape, const char *units)
int generic_array_set_ndarray_unicode(generic_t x, const size_t index, char **data, const size_t ndim, const size_t *shape, const char *units)
int generic_map_set_item(generic_t x, const char *key, const char *type, void *value)

Set an item from a map for types that don’t require additional parameters.

Parameters
  • x[in] generic_t Generic object that is presumed to contain a map.

  • key[in] const char* Key string for value that should be set.

  • type[in] const char* Type of value being set.

  • value[in] void* Pointer to data that item should be set to.

Returns

int -1 if there is an error, 0 otherwise.

int generic_map_set_bool(generic_t x, const char *key, bool value)
int generic_map_set_integer(generic_t x, const char *key, int value)
int generic_map_set_null(generic_t x, const char *key, void *value)
int generic_map_set_number(generic_t x, const char *key, double value)
int generic_map_set_string(generic_t x, const char *key, char *value)
int generic_map_set_object(generic_t x, const char *key, generic_t value)
int generic_map_set_map(generic_t x, const char *key, generic_t value)
int generic_map_set_array(generic_t x, const char *key, generic_t value)
int generic_map_set_direct(generic_t x, const char *key, char *value)
int generic_map_set_ply(generic_t x, const char *key, ply_t value)
int generic_map_set_obj(generic_t x, const char *key, obj_t value)
int generic_map_set_python_class(generic_t x, const char *key, python_t value)
int generic_map_set_python_function(generic_t x, const char *key, python_t value)
int generic_map_set_schema(generic_t x, const char *key, schema_t value)
int generic_map_set_any(generic_t x, const char *key, generic_t value)
int generic_map_set_scalar(generic_t x, const char *key, void *value, const char *subtype, const size_t precision, const char *units)

Set a scalar value in a map.

Parameters
  • x[in] generic_t Generic object that is presumed to contain a map.

  • key[in] const char* Key string for value that should be set.

  • value[in] void* Pointer to scalar data.

  • subtype[in] const char* Subtype of scalar in value.

  • precision[in] const int Precision of scalar in value.

  • units[in] const char* Units of value.

Returns

int -1 if there is an error, 0 otherwise.

int generic_map_set_int8(generic_t x, const char *key, int8_t value, const char *units)
int generic_map_set_int16(generic_t x, const char *key, int16_t value, const char *units)
int generic_map_set_int32(generic_t x, const char *key, int32_t value, const char *units)
int generic_map_set_int64(generic_t x, const char *key, int64_t value, const char *units)
int generic_map_set_uint8(generic_t x, const char *key, uint8_t value, const char *units)
int generic_map_set_uint16(generic_t x, const char *key, uint16_t value, const char *units)
int generic_map_set_uint32(generic_t x, const char *key, uint32_t value, const char *units)
int generic_map_set_uint64(generic_t x, const char *key, uint64_t value, const char *units)
int generic_map_set_float(generic_t x, const char *key, float value, const char *units)
int generic_map_set_double(generic_t x, const char *key, double value, const char *units)
int generic_map_set_long_double(generic_t x, const char *key, long double value, const char *units)
int generic_map_set_complex_float(generic_t x, const char *key, complex_float_t value, const char *units)
int generic_map_set_complex_double(generic_t x, const char *key, complex_double_t value, const char *units)
int generic_map_set_complex_long_double(generic_t x, const char *key, complex_long_double_t value, const char *units)
int generic_map_set_bytes(generic_t x, const char *key, char *value, const char *units)
int generic_map_set_unicode(generic_t x, const char *key, char *value, const char *units)
int generic_map_set_1darray(generic_t x, const char *key, void *value, const char *subtype, const size_t precision, const size_t length, const char *units)

Set a 1d array value in a map.

Parameters
  • x[in] generic_t Generic object that is presumed to contain a map.

  • key[in] const char* Key string for value that should be set.

  • value[in] void* Pointer to array data.

  • subtype[in] const char* Subtype of array expected.

  • precision[in] const size_t Precision of array that is expected.

  • length[in] const size_t Number of elements in value.

  • units[in] const char* Units of value.

Returns

int -1 if there is an error, 0 otherwise.

int generic_map_set_1darray_int8(generic_t x, const char *key, int8_t *value, const size_t length, const char *units)
int generic_map_set_1darray_int16(generic_t x, const char *key, int16_t *value, const size_t length, const char *units)
int generic_map_set_1darray_int32(generic_t x, const char *key, int32_t *value, const size_t length, const char *units)
int generic_map_set_1darray_int64(generic_t x, const char *key, int64_t *value, const size_t length, const char *units)
int generic_map_set_1darray_uint8(generic_t x, const char *key, uint8_t *value, const size_t length, const char *units)
int generic_map_set_1darray_uint16(generic_t x, const char *key, uint16_t *value, const size_t length, const char *units)
int generic_map_set_1darray_uint32(generic_t x, const char *key, uint32_t *value, const size_t length, const char *units)
int generic_map_set_1darray_uint64(generic_t x, const char *key, uint64_t *value, const size_t length, const char *units)
int generic_map_set_1darray_float(generic_t x, const char *key, float *value, const size_t length, const char *units)
int generic_map_set_1darray_double(generic_t x, const char *key, double *value, const size_t length, const char *units)
int generic_map_set_1darray_long_double(generic_t x, const char *key, long double *value, const size_t length, const char *units)
int generic_map_set_1darray_complex_float(generic_t x, const char *key, complex_float_t *value, const size_t length, const char *units)
int generic_map_set_1darray_complex_double(generic_t x, const char *key, complex_double_t *value, const size_t length, const char *units)
int generic_map_set_1darray_complex_long_double(generic_t x, const char *key, complex_long_double_t *value, const size_t length, const char *units)
int generic_map_set_1darray_bytes(generic_t x, const char *key, char **value, const size_t length, const char *units)
int generic_map_set_1darray_unicode(generic_t x, const char *key, char **value, const size_t length, const char *units)
int generic_map_set_ndarray(generic_t x, const char *key, void *data, const char *subtype, const size_t precision, const size_t ndim, const size_t *shape, const char *units)

Set a nd array value in a map.

Parameters
  • x[in] generic_t Generic object that is presumed to contain a map.

  • key[in] const char* Key string for value that should be set.

  • data[in] void* Pointer to array data.

  • subtype[in] const char* Subtype of array in value.

  • precision[in] const size_t Precision of array that is in value.

  • ndim[in] size_t Number of dimensions in the array.

  • shape[in] size_t* Pointer to array containing the size of the array in each dimension.

  • units[in] const char* Units that should be added to the array.

Returns

int -1 if there is an error, 0 otherwise.

int generic_map_set_ndarray_int8(generic_t x, const char *key, int8_t *data, const size_t ndim, const size_t *shape, const char *units)
int generic_map_set_ndarray_int16(generic_t x, const char *key, int16_t *data, const size_t ndim, const size_t *shape, const char *units)
int generic_map_set_ndarray_int32(generic_t x, const char *key, int32_t *data, const size_t ndim, const size_t *shape, const char *units)
int generic_map_set_ndarray_int64(generic_t x, const char *key, int64_t *data, const size_t ndim, const size_t *shape, const char *units)
int generic_map_set_ndarray_uint8(generic_t x, const char *key, uint8_t *data, const size_t ndim, const size_t *shape, const char *units)
int generic_map_set_ndarray_uint16(generic_t x, const char *key, uint16_t *data, const size_t ndim, const size_t *shape, const char *units)
int generic_map_set_ndarray_uint32(generic_t x, const char *key, uint32_t *data, const size_t ndim, const size_t *shape, const char *units)
int generic_map_set_ndarray_uint64(generic_t x, const char *key, uint64_t *data, const size_t ndim, const size_t *shape, const char *units)
int generic_map_set_ndarray_float(generic_t x, const char *key, float *data, const size_t ndim, const size_t *shape, const char *units)
int generic_map_set_ndarray_double(generic_t x, const char *key, double *data, const size_t ndim, const size_t *shape, const char *units)
int generic_map_set_ndarray_long_double(generic_t x, const char *key, long double *data, const size_t ndim, const size_t *shape, const char *units)
int generic_map_set_ndarray_complex_float(generic_t x, const char *key, complex_float_t *data, const size_t ndim, const size_t *shape, const char *units)
int generic_map_set_ndarray_complex_double(generic_t x, const char *key, complex_double_t *data, const size_t ndim, const size_t *shape, const char *units)
int generic_map_set_ndarray_complex_long_double(generic_t x, const char *key, complex_long_double_t *data, const size_t ndim, const size_t *shape, const char *units)
int generic_map_set_ndarray_bytes(generic_t x, const char *key, char **data, const size_t ndim, const size_t *shape, const char *units)
int generic_map_set_ndarray_unicode(generic_t x, const char *key, char **data, const size_t ndim, const size_t *shape, const char *units)
void destroy_python(python_t *x)

Destroy a structure containing a Python object.

topic/timesync

Parameters

x[in] python_t* Pointer to Python object structure that should be freed.

python_t copy_python(python_t x)

Copy a Python object structure (NOTE: this dosn’t copy the underlying Python object but does increment the reference count).

Parameters

x[in] python_t Structure containing Python object to copy.

Returns

python_t Copy of x.

void display_python(python_t x)

Display a Python object structure.

Parameters

x[in] python_t Structure containing Python object to display.

void destroy_python_function(python_function_t *x)

Destroy a structure containing a Python function object.

Parameters

x[in] python_function_t* Pointer to Python function structure that should be freed.

int skip_va_elements(const dtype_t *dtype, size_t *nargs, va_list_t *ap)

Skip datatype arguments.

Parameters
  • dtype[in] dtype_t* Type structure to skip arguments for.

  • nargs[inout] Pointer to number of arguments in ap.

  • ap[inout] va_list_t Variable argument list.

Returns

int 0 if there are no errors, 1 otherwise.

int is_empty_dtype(const dtype_t *dtype)

Determine if a datatype is empty.

Parameters

dtype[in] dtype_t* Type structure to test.

Returns

int 1 if dtype is empty, 0 otherwise.

const char *dtype_name(const dtype_t *type_class)

Get the name of the type from the class.

Parameters

type_class[in] dtype_t* Type structure/class.

Returns

const char* Type name.

const char *dtype_subtype(const dtype_t *type_class)

Get the subtype of the type.

Parameters

type_class[in] dtype_t* Type structure/class.

Returns

const char* The subtype of the class, “” if there is an error.

const size_t dtype_precision(const dtype_t *type_class)

Get the precision of the type.

Parameters

type_class[in] dtype_t* Type structure/class.

Returns

const size_t The precision of the class, 0 if there is an error.

dtype_t *complete_dtype(dtype_t *dtype, const bool use_generic)

Initialize a datatype structure including setting the type string.

Parameters
  • dtype[in] dtype_t* Type structure/class.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

Returns

dtype_t* Initialized type structure/class.

dtype_t *create_dtype_empty(const bool use_generic)

Construct and empty type object.

Parameters

use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

Returns

dtype_t* Type structure/class.

dtype_t *create_dtype_doc(void *type_doc, const bool use_generic)

Create a datatype based on a JSON document.

Parameters
  • type_doc – void* Pointer to const rapidjson::Value type doc.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

Returns

dtype_t* Type structure/class.

dtype_t *create_dtype_python(PyObject *pyobj, const bool use_generic)

Create a datatype based on a Python dictionary.

Parameters
  • pyobj[in] PyObject* Python dictionary.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

Returns

dtype_t* Type structure/class.

dtype_t *create_dtype_direct(const bool use_generic)

Construct a Direct type object.

Parameters

use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

Returns

dtype_t* Type structure/class.

dtype_t *create_dtype_default(const char *type, const bool use_generic)

Construct a type object for one of the default JSON types.

Parameters
  • type[in] char* Name of the type.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

Returns

dtype_t* Type structure/class.

dtype_t *create_dtype_scalar(const char *subtype, const size_t precision, const char *units, const bool use_generic)

Construct a Scalar type object.

Parameters
  • subtype[in] char* Name of the scalar subtype (e.g. int, uint, float, bytes).

  • precision[in] size_t Precision of the scalar in bits.

  • units[in] char* Units for scalar. (e.g. “cm”, “g”, “” for unitless)

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

Returns

dtype_t* Type structure/class.

dtype_t *create_dtype_1darray(const char *subtype, const size_t precision, const size_t length, const char *units, const bool use_generic)

Construct a 1D array type object.

Parameters
  • subtype[in] char* Name of the array subtype (e.g. int, uint, float, bytes).

  • precision[in] size_t Precision of the array in bits.

  • length[in] size_t Number of elements in the array.

  • units[in] char* Units for array elements. (e.g. “cm”, “g”, “” for unitless)

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

Returns

dtype_t* Type structure/class.

dtype_t *create_dtype_ndarray(const char *subtype, const size_t precision, const size_t ndim, const size_t *shape, const char *units, const bool use_generic)

Construct a ND array type object.

Parameters
  • subtype[in] char* Name of the array subtype (e.g. int, uint, float, bytes).

  • precision[in] size_t Precision of the array in bits.

  • ndim[in] size_t Number of dimensions in the array (and therefore also the number of elements in shape).

  • shape[in] size_t* Pointer to array where each element is the size of the array in that dimension.

  • units[in] char* Units for array elements. (e.g. “cm”, “g”, “” for unitless)

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

Returns

dtype_t* Type structure/class.

dtype_t *create_dtype_ndarray_arr(const char *subtype, const size_t precision, const size_t ndim, const int64_t shape[], const char *units, const bool use_generic)

Construct a ND array type object.

Parameters
  • subtype[in] char* Name of the array subtype (e.g. int, uint, float, bytes).

  • precision[in] size_t Precision of the array in bits.

  • ndim[in] size_t Number of dimensions in the array (and therefore also the number of elements in shape).

  • shape[][in] size_t Array where each element is the size of the array in that dimension.

  • units[in] char* Units for array elements. (e.g. “cm”, “g”, “” for unitless)

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

Returns

dtype_t* Type structure/class.

dtype_t *create_dtype_json_array(const size_t nitems, dtype_t **items, const bool use_generic)

Construct a JSON array type object.

Parameters
  • nitems[in] size_t Number of types in items.

  • items[in] dtype_t** Pointer to array of types describing the array elements.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

Returns

dtype_t* Type structure/class.

dtype_t *create_dtype_json_object(const size_t nitems, char **keys, dtype_t **values, const bool use_generic)

Construct a JSON object type object.

Parameters
  • nitems[in] size_t Number of keys/types in keys and values.

  • keys[in] char** Pointer to array of keys for each type.

  • values[in] dtype_t** Pointer to array of types describing the values for each key.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

Returns

dtype_t* Type structure/class.

dtype_t *create_dtype_ply(const bool use_generic)

Construct a Ply type object.

Parameters

use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

Returns

dtype_t* Type structure/class.

dtype_t *create_dtype_obj(const bool use_generic)

Construct a Obj type object.

Parameters

use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

Returns

dtype_t* Type structure/class.

dtype_t *create_dtype_ascii_table(const char *format_str, const int as_array, const bool use_generic)

Construct an AsciiTable type object.

Parameters
  • format_str[in] const char* C-style format string that will be used to determine the type of elements in arrays that will be serialized/deserialized using the resulting type.

  • as_array[in] int If 1, the types will be arrays. Otherwise they will be scalars.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

Returns

dtype_t* Type structure/class.

dtype_t *create_dtype_format(const char *format_str, const int as_array, const bool use_generic)

Construct a type object based on the provided format string.

Parameters
  • format_str[in] const char* C-style format string that will be used to determine the type of elements in arrays that will be serialized/deserialized using the resulting type.

  • as_array[in] int If 1, the types will be arrays. Otherwise they will be scalars.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

Returns

dtype_t* Type structure/class.

dtype_t *create_dtype_pyobj(const char *type, const bool use_generic)

Construct a type object for Python objects.

Parameters
  • type[in] char* Type string.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

Returns

dtype_t* Type structure/class.

dtype_t *create_dtype_pyinst(const char *class_name, const dtype_t *args_dtype, const dtype_t *kwargs_dtype, const bool use_generic)

Construct a type object for Python object instances.

Parameters
  • class_name[in] char* Python class name.

  • args_dtype[in] dtype_t* Datatype describing the arguments creating the instance.

  • kwargs_dtype[in] dtype_t* Datatype describing the keyword arguments creating the instance.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

Returns

dtype_t* Type structure/class.

dtype_t *create_dtype_schema(const bool use_generic)

Construct a type object for a schema.

Parameters

use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

Returns

dtype_t* Type structure/class.

dtype_t *create_dtype_any(const bool use_generic)

Construct a type object for receiving any type.

Parameters

use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

Returns

dtype_t* Type structure/class.

int destroy_dtype(dtype_t **dtype)

Wrapper for freeing MetaschemaType class wrapper struct.

Parameters

dtype[in] dtype_t** Wrapper struct for C++ Metaschema type class.

Returns

: int 0 if free was successfull, -1 if there was an error.

static inline comm_head_t init_header(const size_t size, const char *address, const char *id)

Initialize a header struct.

Parameters
  • size[in] size_t Size of message to be sent.

  • address[in] char* Address that should be used for remainder of message following this header if it is a multipart message.

  • id[in] char* Message ID.

Returns

comm_head_t Structure with provided information, char arrays correctly initialized to empty strings if NULLs provided.

static inline int destroy_header(comm_head_t *x)

Destroy a header object.

Parameters

x[in] comm_head_t* Pointer to the header that should be destroyed.

Returns

int 0 if successful, -1 otherwise.

static inline int split_head_body(const char *buf, const size_t buf_siz, char **head, size_t *headsiz)

Split header and body of message.

Parameters
  • buf[in] const char* Message that should be split.

  • buf_siz[in] size_t Size of buf.

  • head[out] const char** pointer to buffer where the extracted header should be stored.

  • headsiz[out] size_t reference to memory where size of extracted header should be stored.

Returns

: int 0 if split is successful, -1 if there was an error.

int format_comm_header(comm_head_t *head, char **buf, size_t buf_siz, const size_t max_header_size, const int no_type)

Format header to a string.

Parameters
  • head[in] comm_head_t* Pointer to header to be formatted.

  • buf[out] char ** Pointer to buffer where header should be written.

  • buf_siz[in] size_t Size of buf.

  • max_header_size[in] size_t Maximum size that header can occupy before the type should be moved to the data portion of the message.

  • no_type[in] int If 1, type information will not be added to the header. If 0, it will be.

Returns

: int Size of header written.

int parse_type_in_data(char **buf, const size_t buf_siz, comm_head_t *head)

Extract type from data and updated header.

Parameters
  • buf[in] char** Pointer to data containing type.

  • buf_siz[in] size_t Size of buf.

  • head[inout] comm_head_t* Pointer to header structure that should be updated.

Returns

: int -1 if there is an error, size of adjusted data that dosn’t include type otherwise.

comm_head_t parse_comm_header(const char *buf, const size_t buf_siz)

Extract header information from a string.

Parameters
  • buf[in] const char* Message that header should be extracted from.

  • buf_siz[in] size_t Size of buf.

Returns

: comm_head_t Header information structure.

void *dtype_ascii_table(const dtype_t *dtype)

Get the ascii table data structure.

Parameters

dtype[in] dtype_t* Wrapper struct for C++ Metaschema type class.

Returns

: void* Cast pointer to ascii table.

dtype_t *copy_dtype(const dtype_t *dtype)

Get a copy of a type structure.

Parameters

dtype[in] dtype_t* Wrapper struct for C++ Metaschema type class.

Returns

: dtype_t* Type class.

int update_dtype(dtype_t *dtype1, dtype_t *dtype2)

Wrapper for updating a type object with information from another.

Parameters
  • dtype1[in] dtype_t* Wrapper struct for C++ Metaschema type class that should be updated.

  • dtype2[in] dtype_t* Wrapper struct for C++ Metaschema type class that should be updated from.

Returns

: int 0 if successfull, -1 if there was an error.

int update_dtype_from_generic_ap(dtype_t *dtype1, size_t nargs, va_list_t ap)

Wrapper for updatining a type object with information from the provided variable arguments if a generic structure is present.

Parameters
  • dtype1[in] dtype_t* Wrapper struct for C++ Metaschema type class that should be updated.

  • nargs[in] size_t Number of arguments in ap.

  • ap[in] va_list_t Variable argument list.

Returns

: int 0 if successfull, -1 if there was an error.

int update_precision_dtype(const dtype_t *dtype, const size_t new_precision)

Wrapper for updating the precision of a bytes or unicode scalar type.

Parameters
  • dtype[in] dtype_t* Wrapper struct for C++ Metaschema type class.

  • new_precision[in] size_t New precision.

Returns

: int 0 if free was successfull, -1 if there was an error.

int deserialize_dtype(const dtype_t *dtype, const char *buf, const size_t buf_siz, const int allow_realloc, size_t *nargs, va_list_t ap)

Wrapper for deserializing from a data type.

Parameters
  • dtype[in] dtype_t* Wrapper struct for C++ Metaschema type class.

  • buf[in] character pointer to serialized message.

  • buf_siz[in] size_t Size of buf.

  • allow_realloc[in] int If 1, variables being filled are assumed to be pointers to pointers for heap memory. If 0, variables are assumed to be pointers to stack memory. If allow_realloc is set to 1, but stack variables are passed, a segfault can occur.

  • nargs[inout] int Number of arguments remaining in argument list.

  • ap[in] va_list Arguments to be parsed from message. returns: int The number of populated arguments. -1 indicates an error.

int serialize_dtype(const dtype_t *dtype, char **buf, size_t *buf_siz, const int allow_realloc, size_t *nargs, va_list_t ap)

Wrapper for serializing from a data type.

Parameters
  • dtype[in] dtype_t* Wrapper struct for C++ Metaschema type class.

  • buf[in] character pointer to pointer to memory where serialized message should be stored.

  • buf_siz[in] size_t Size of memory allocated to buf.

  • allow_realloc[in] int If 1, buf will be realloced if it is not big enough to hold the serialized emssage. If 0, an error will be returned.

  • nargs[inout] int Number of arguments remaining in argument list.

  • ap[in] va_list Arguments to be formatted. returns: int The length of the serialized message or -1 if there is an error.

void display_dtype(const dtype_t *dtype, const char *indent)

Wrapper for displaying a data type.

Parameters
  • dtype[in] dtype_t* Wrapper struct for C++ Metaschema type class.

  • indent[in] char* Indentation to add to display output.

size_t nargs_exp_dtype(const dtype_t *dtype)

Wrapper for determining how many arguments a data type expects.

Parameters

dtype[in] dtype_t* Wrapper struct for C++ Metaschema type class.

Variables

static char prefix_char = '#'
struct dtype_t
#include <datatypes.h>

C-friendly definition of MetaschemaType.

Public Members

char type[COMMBUFFSIZ]

Type name.

bool use_generic

Flag for empty dtypes to specify generic in/out.

void *obj

MetaschemaType Pointer.

struct generic_t
#include <datatypes.h>

C-friendly defintion of YggGeneric.

Public Members

char prefix

Prefix character for limited verification.

void *obj

Pointer to YggGeneric class.

struct comm_head_t
#include <datatypes.h>

Header information passed by comms for multipart messages.

Public Members

size_t bodysiz

Size of body.

size_t bodybeg

Start of body in header.

int flags

Bit flags encoding the status of the header.

int nargs_populated

Number of arguments populated during deserialization.

size_t size

Size of incoming message.

char address[COMMBUFFSIZ]

Address that message will comm in on.

char id[COMMBUFFSIZ]

Unique ID associated with this message.

char response_address[COMMBUFFSIZ]

Response address.

char request_id[COMMBUFFSIZ]

Request id.

char zmq_reply[COMMBUFFSIZ]

Reply address for ZMQ sockets.

char zmq_reply_worker[COMMBUFFSIZ]

Reply address for worker socket.

char model[COMMBUFFSIZ]

Name of model that sent the header.

int serializer_type

Code indicating the type of serializer.

char format_str[COMMBUFFSIZ]

Format string for serializer.

char field_names[COMMBUFFSIZ]

String containing field names.

char field_units[COMMBUFFSIZ]

String containing field units.

dtype_t *dtype

Type structure.

Typedefs

typedef std::map<std::string, MetaschemaType*> MetaschemaTypeMap
typedef std::vector<MetaschemaType*> MetaschemaTypeVector
class MetaschemaType
#include <MetaschemaType.h>

Base class for metaschema type definitions.

The MetaschemaType provides basic functionality for encoding/decoding datatypes from/to JSON style strings.

Subclassed by AnyMetaschemaType, AsciiTableMetaschemaType, DirectMetaschemaType, JSONArrayMetaschemaType, JSONObjectMetaschemaType, ObjMetaschemaType, PlyMetaschemaType, PyObjMetaschemaType, ScalarMetaschemaType, SchemaMetaschemaType

Public Functions

inline MetaschemaType(const char *type, const bool use_generic = false, const bool always_generic = false)

Constructor for MetaschemaType.

Parameters
  • type[in] const character pointer to the name of the type.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

  • always_generic[in] bool If true, the datatype will always be assumed to expect YggGeneric instances.

inline MetaschemaType(const rapidjson::Value &type_doc, const bool use_generic = false, const bool always_generic = false)

Constructor for MetaschemaType from a JSON type defintion.

Parameters
  • type_doc[in] rapidjson::Value rapidjson object containing the type definition from a JSON encoded header.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

  • always_generic[in] bool If true, the datatype will always be assumed to expect YggGeneric instances.

inline MetaschemaType(PyObject *pyobj, const bool use_generic = false, const bool always_generic = false)

Constructor for MetaschemaType from Python dictionary.

Parameters
  • pyobj[in] PyObject* Python object.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

  • always_generic[in] bool If true, the datatype will always be assumed to expect YggGeneric instances.

inline MetaschemaType(const MetaschemaType &other)

Copy constructor.

Parameters

other[in] MetaschemaType* Instance to copy.

inline virtual ~MetaschemaType()

Destructor for MetaschemaType. Free the type string malloc’d during constructor.

inline virtual bool operator==(const MetaschemaType &Ref) const

Equivalence operator.

Parameters

Ref[in] MetaschemaType instance to compare against.

Returns

bool true if the instance is equivalent, false otherwise.

inline virtual bool operator!=(const MetaschemaType &Ref) const

Inequivalence operator.

Parameters

Ref[in] MetaschemaType instance to compare against.

Returns

bool true if the instances are not equivalent, false otherwise.

inline virtual bool is_empty() const

Determine if the datatype is effectively empty.

Returns

bool true if the datatype is empty, false otherwise.

inline virtual MetaschemaType *copy() const

Create a copy of the type.

Returns

pointer to new MetaschemaType instance with the same data.

inline virtual void display(const char *indent = "") const

Print information about the type to stdout.

Parameters

indent[in] char* Indentation to add to display output.

inline virtual PyObject *as_python_dict() const

Get type information as a Python dictionary.

Returns

PyObject* Python dictionary.

inline virtual void *copy_generic(const YggGeneric *data, void *orig_data = NULL) const

Copy data wrapped in YggGeneric class.

Parameters
  • data[in] YggGeneric* Pointer to generic object.

  • orig_data[in] Pointer to data that should be copied if different that the data that is wrapped.

Returns

void* Pointer to copy of data.

inline virtual void free_generic(YggGeneric *data) const

Free data wrapped in YggGeneric class.

Parameters

data[in] YggGeneric* Pointer to generic object.

inline virtual void display_generic(const YggGeneric *data, const char *indent = "") const

Display data.

Parameters
  • data[in] YggGeneric* Pointer to generic object.

  • indent[in] char* Indentation to add to display output.

inline int check_type() const

Check that the type is correct and get the corresponding code.

Returns

int Type code for the instance’s type.

inline const char *type() const

Get the type string.

Returns

const char pointer to the type string.

inline const int type_code() const

Get the type code.

Returns

int Type code associated with the curent type.

inline const bool use_generic() const

Get the value of class attribute use_generic.

Returns

bool Value of use_generic.

inline virtual void update(const MetaschemaType *new_info)

Update the type object with info from another type object.

Parameters

new_info[in] MetaschemaType* type object.

inline virtual size_t update_from_serialization_args(size_t *nargs, va_list_t &ap)

Update the type object with info from provided variable arguments for serialization.

Parameters
  • nargs[inout] size_t Number of arguments contained in ap. On output the number of unused arguments will be assigned to this address.

  • ap[in] va_list_t Variable argument list.

Returns

size_t Number of arguments in ap consumed.

inline virtual size_t update_from_deserialization_args(size_t *nargs, va_list_t &ap)

Update the type object with info from provided variable arguments for deserialization.

Parameters
  • nargs[inout] size_t Number of arguments contained in ap. On output the number of unused arguments will be assigned to this address.

  • ap[in] va_list_t Variable argument list.

Returns

size_t Number of arguments in ap consumed.

inline virtual void update_from_serialization_args(YggGeneric *x)

Update the type object with info from provided variable arguments for serialization.

Parameters

x[in] YggGeneric* Pointer to generic object containing data to be serialized.

inline virtual void update_from_deserialization_args(YggGeneric *x)

Update the type object with info from provided variable arguments for deserialization.

Parameters

x[inout] YggGeneric* Pointer to generic object where data will be stored.

inline virtual void update_type(const char *new_type)

Update the instance’s type.

Parameters

new_type[in] const char * String for new type.

inline virtual void update_type_element(size_t i, const MetaschemaType *x)

Dummy stand-in to allow access to array/object methods.

Parameters
  • i[in] size_t Index where item type should be added.

  • x[in] MetaschemaType* Type to insert at index i.

inline virtual void update_type_element(const char *k, const MetaschemaType *x)

Dummy stand-in to allow access to array/object methods.

Parameters
  • k[in] const char* Key where item type should be added.

  • x[in] MetaschemaType* Type to insert at key k.

inline virtual void update_use_generic(const bool new_use_generic)

Update the instance’s use_generic flag.

Parameters

new_use_generic[in] const bool New flag value.

inline virtual void set_length(size_t new_length, bool force = false)

Set the type length.

Parameters
  • force[in] bool True if the length should be updated even if it is not compatible with the existing value.

  • new_length[in] size_t New length.

inline virtual const MetaschemaType *get_item_type(const size_t index) const

Get the type associated with an item.

Parameters

index[in] const size_t Index of item to get type for.

Returns

MetaschemaType* Pointer to type class for item.

inline virtual void set_item_type(const size_t index, const MetaschemaType *itemtype)

Set the type associated with an item.

Parameters
  • index[in] const size_t Index of the item to set the type for.

  • itemtype[in] const MetaschemaType* Pointer to item type that should be associated with the provided index.

inline virtual const MetaschemaType *get_property_type(const char *key) const

Get the type associated with a property.

Parameters

key[in] const char* Property key to get type for.

Returns

MetaschemaType* Pointer to type class for property.

inline virtual void set_property_type(const char *key, const MetaschemaType *proptype)

Set the type associated with a property.

Parameters
  • key[in] const char* Property key to set type for.

  • proptype[in] const MetaschemaType* Pointer to property type that should be associated with the provided key.

inline virtual void set_variable_length(bool new_variable_length)

Set the _variable_length private variable.

Parameters

new_variable_length[in] bool New value.

inline virtual void set_in_table(bool new_in_table)

Set the _in_table private variable.

Parameters

new_in_table[in] bool New value.

inline virtual const size_t nelements() const

Get the number of elements in the type.

Returns

size_t Number of elements (1 for scalar).

inline virtual const bool variable_nelements() const

Determine if the number of elements is variable.

Returns

bool true if the number of elements can change, false otherwise.

inline virtual const size_t nbytes() const

Get the item size.

Returns

size_t Size of item in bytes.

inline virtual std::vector<size_t> nbytes_va_core() const

Get the number of bytes occupied by a variable of the type in a variable argument list.

Returns

std::vector<size_t> Number of bytes/variables occupied by the type.

inline std::vector<size_t> nbytes_va() const

Get the number of bytes occupied by a variable of the type in a variable argument list.

Returns

std::vector<size_t> Number of bytes/variables occupied by the type.

inline void skip_va_elements(size_t *nargs, va_list_t *ap) const

Skip arguments that make of this type.

Parameters
  • nargs[inout] Pointer to number of arguments in ap.

  • ap[inout] va_list_t Variable argument list.

inline virtual void skip_va_elements_core(size_t *nargs, va_list_t *ap) const

Skip arguments that make of this type.

Parameters
  • nargs[inout] Pointer to number of arguments in ap.

  • ap[inout] va_list_t Variable argument list.

inline void skip_va_elements_wrap(size_t *nargs, va_list_t *ap) const

Skip arguments that make of this type.

Parameters
  • nargs[inout] Pointer to number of arguments in ap.

  • ap[inout] va_list_t Variable argument list.

inline virtual size_t nargs_exp() const

Get the number of arguments expected to be filled/used by the type.

Returns

size_t Number of arguments.

inline virtual YggGeneric *python2c(PyObject *pyobj) const

Convert a Python representation to a C representation.

Parameters

pyobj[in] PyObject* Pointer to Python object.

Returns

YggGeneric* Pointer to C object.

inline virtual PyObject *c2python(YggGeneric *cobj) const

Convert a C representation to a Python representation.

Parameters

cobj[in] YggGeneric* Pointer to C object.

Returns

PyObject* Pointer to Python object.

inline generic_t pop_generic(size_t *nargs, va_list_t &ap, bool skip_nargs_dec = false) const

Return the recovered generic structure if one is present in the variable argument list by removing it.

Parameters
  • nargs[in] size_t* Pointer to number of arguments present in ap that will be decremented by 1.

  • ap[in] va_list_t Variable argument list.

  • skip_nargs_dec[in] bool If true, nargs will be advaced in order to skip the element defining the number of arguments.

Returns

generic_t Generic structure if one is present.

inline generic_t *pop_generic_ptr(size_t *nargs, va_list_t &ap, bool skip_nargs_dec = false) const

Return the recovered generic structure if one is present in the variable argument list by removing it.

Parameters
  • nargs[in] size_t* Pointer to number of arguments present in ap that will be decremented by 1.

  • ap[in] va_list_t Variable argument list.

  • skip_nargs_dec[in] bool If true, nargs will not be modified. Defaults to false.

Returns

generic_t* Generic structure if one is present, NULL otherwise.

inline bool encode_type(rapidjson::Writer<rapidjson::StringBuffer> *writer) const

Encode the type in a JSON string.

Parameters

writer[in] rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.

Returns

bool true if the encoding was successful, false otherwise.

inline virtual bool encode_type_prop(rapidjson::Writer<rapidjson::StringBuffer> *writer) const

Encode the type’s properties in a JSON string.

Parameters

writer[in] rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.

Returns

bool true if the encoding was successful, false otherwise.

inline virtual bool encode_data(rapidjson::Writer<rapidjson::StringBuffer> *writer, size_t *nargs, va_list_t &ap) const

Encode arguments describine an instance of this type into a JSON string.

Parameters
  • writer[in] rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.

  • nargs[inout] size_t * Pointer to the number of arguments contained in ap. On return it will be set to the number of arguments used.

  • ap[in] va_list_t Variable number of arguments that should be encoded as a JSON string.

Returns

bool true if the encoding was successful, false otherwise.

inline bool encode_data(rapidjson::Writer<rapidjson::StringBuffer> *writer, size_t *nargs, ...) const

Encode arguments describine an instance of this type into a JSON string.

Parameters
  • writer[in] rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.

  • nargs[inout] size_t * Pointer to the number of arguments contained in ap. On return it will be set to the number of arguments used.

  • ...[in] Variable number of arguments that should be encoded as a JSON string.

Returns

bool true if the encoding was successful, false otherwise.

inline bool encode_data_wrap(rapidjson::Writer<rapidjson::StringBuffer> *writer, size_t *nargs, va_list_t &ap) const

Encode arguments describine an instance of this type into a JSON string first checking if the arguments should be generic.

Parameters
  • writer[in] rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.

  • nargs[inout] size_t * Pointer to the number of arguments contained in ap. On return it will be set to the number of arguments used.

  • ap[in] va_list_t Variable number of arguments that should be encoded as a JSON string.

Returns

bool true if the encoding was successful, false otherwise.

inline bool encode_data_wrap(rapidjson::Writer<rapidjson::StringBuffer> *writer, size_t *nargs, ...) const

Encode arguments describine an instance of this type into a JSON string first checking if the arguments should be generic.

Parameters
  • writer[in] rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.

  • nargs[inout] size_t * Pointer to the number of arguments contained in ap. On return it will be set to the number of arguments used.

  • ...[in] Variable number of arguments that should be encoded as a JSON string.

Returns

bool true if the encoding was successful, false otherwise.

inline virtual bool encode_data(rapidjson::Writer<rapidjson::StringBuffer> *writer, YggGeneric *x) const

Encode arguments describine an instance of this type into a JSON string.

Parameters
  • writer[in] rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.

  • x[in] YggGeneric* Pointer to generic wrapper for data.

Returns

bool true if the encoding was successful, false otherwise.

inline virtual int copy_to_buffer(const char *src_buf, const size_t src_buf_siz, char **dst_buf, size_t &dst_buf_siz, const int allow_realloc, bool skip_terminal = false) const

Copy data from a source buffer to a destination buffer.

Parameters
  • src_buf[in] char* Pointer to source buffer.

  • src_buf_siz[in] size_t Size of src_buf.

  • dst_buf[inout] char** Pointer to memory address of destination buffer.

  • dst_buf_siz[inout] size_t Reference to size of destination buffer. If dst_buf is reallocated, this will be updated with the size of the buffer after reallocation.

  • allow_realloc[in] int If 1, dst_buf can be reallocated if it is not large enough to contain the contents of src_buf. If 0, an error will be thrown if dst_buf is not large enough.

  • skip_terminal[in] bool (optional) If true, the terminal character will not be added to the end of the copied buffer. Defaults to false.

Returns

int -1 if there is an error, otherwise its the size of the data copied to the destination buffer.

inline virtual int serialize(char **buf, size_t *buf_siz, const int allow_realloc, size_t *nargs, va_list_t &ap)

Serialize an instance including it’s type and data.

Parameters
  • buf[out] char ** Buffer where serialized data should be written.

  • buf_siz[inout] size_t* Size of buf. If buf is reallocated, the new size of the buffer will be assigned to this address.

  • allow_realloc[in] int If 1, buf will be reallocated if it is not large enough to contain the serialized data. If 0, an error will be raised if it is not large enough.

  • nargs[inout] size_t Number of arguments contained in ap. On output the number of arguments used will be assigned to this address.

  • ap[in] va_list_t Variable number of arguments that will be serialized.

Returns

int Size of the serialized data in buf.

inline virtual int serialize(char **buf, size_t *buf_siz, const int allow_realloc, YggGeneric *x)

Serialize an instance including it’s type and data.

Parameters
  • buf[out] char ** Buffer where serialized data should be written.

  • buf_siz[inout] size_t* Size of buf. If buf is reallocated, the new size of the buffer will be assigned to this address.

  • allow_realloc[in] int If 1, buf will be reallocated if it is not large enough to contain the serialized data. If 0, an error will be raised if it is not large enough.

  • x[in] Pointer to generic wrapper for object being serialized.

Returns

int Size of the serialized data in buf.

inline virtual bool decode_data(rapidjson::Value &data, const int allow_realloc, size_t *nargs, va_list_t &ap) const

Decode variables from a JSON string.

Parameters
  • data[in] rapidjson::Value Reference to entry in JSON string.

  • allow_realloc[in] int If 1, the passed variables will be reallocated to contain the deserialized data.

  • nargs[inout] size_t Number of arguments contained in ap. On return, the number of arguments assigned from the deserialized data will be assigned to this address.

  • ap[out] va_list_t Reference to variable argument list containing address where deserialized data should be assigned.

Returns

bool true if the data was successfully decoded, false otherwise.

inline bool decode_data(rapidjson::Value &data, const int allow_realloc, size_t *nargs, ...) const

Decode variables from a JSON string.

Parameters
  • data[in] rapidjson::Value Reference to entry in JSON string.

  • allow_realloc[in] int If 1, the passed variables will be reallocated to contain the deserialized data.

  • nargs[inout] size_t Number of arguments contained in ap. On return, the number of arguments assigned from the deserialized data will be assigned to this address.

  • ...[out] Variable number of arguments that contain addresses where deserialized data should be assigned.

Returns

bool true if the data was successfully decoded, false otherwise.

inline bool decode_data_wrap(rapidjson::Value &data, const int allow_realloc, size_t *nargs, va_list_t &ap) const

Decode variables from a JSON string, first checking if the type expects a generic object and extracting it if it does.

Parameters
  • data[in] rapidjson::Value Reference to entry in JSON string.

  • allow_realloc[in] int If 1, the passed variables will be reallocated to contain the deserialized data.

  • nargs[inout] size_t Number of arguments contained in ap. On return, the number of arguments assigned from the deserialized data will be assigned to this address.

  • ap[out] va_list_t Reference to variable argument list containing address where deserialized data should be assigned.

Returns

bool true if the data was successfully decoded, false otherwise.

inline bool decode_data_wrap(rapidjson::Value &data, const int allow_realloc, size_t *nargs, ...) const

Decode variables from a JSON string, first checking if the type expects a generic object and extracting it if it does.

Parameters
  • data[in] rapidjson::Value Reference to entry in JSON string.

  • allow_realloc[in] int If 1, the passed variables will be reallocated to contain the deserialized data.

  • nargs[inout] size_t Number of arguments contained in ap. On return, the number of arguments assigned from the deserialized data will be assigned to this address.

  • ...[out] Variable number of arguments that contain addresses where deserialized data should be assigned.

Returns

bool true if the data was successfully decoded, false otherwise.

inline virtual bool decode_data(rapidjson::Value &data, YggGeneric *x) const

Decode variables from a JSON string.

Parameters
  • data[in] rapidjson::Value Reference to entry in JSON string.

  • x[out] YggGeneric* Pointer to generic object where data should be stored.

Returns

bool true if the data was successfully decoded, false otherwise.

inline virtual int deserialize(const char *buf, const size_t buf_siz, const int allow_realloc, size_t *nargs, va_list_t &ap)

Deserialize variables from a JSON string.

Parameters
  • buf[in] char* Buffer containing serialized data.

  • buf_siz[in] size_t Size of the serialized data.

  • allow_realloc[in] int If 1, the provided variables will be realloced as necessary to house the deserialized data.

  • nargs[inout] size_t* Number of arguments contained in ap. On return, the number of arguments assigned will be assigned to this address.

  • ap[out] va_list_t Arguments that should be assigned based on the deserialized data.

Returns

int -1 if there is an error, otherwise the number of arguments used.

inline virtual int deserialize(const char *buf, const size_t buf_siz, YggGeneric *x)

Deserialize variables from a JSON string.

Parameters
  • buf[in] char* Buffer containing serialized data.

  • buf_siz[in] size_t Size of the serialized data.

  • x[out] YggGeneric* Pointer to generic type wrapper where deserialized data should be stored.

Returns

int -1 if there is an error, 0 otherwise.

class ScalarMetaschemaType : public MetaschemaType
#include <ScalarMetaschemaType.h>

Base class for scalar type definition.

The ScalarMetaschemaType provides basic functionality for encoding/decoding scalar datatypes from/to JSON style strings.

Subclassed by NDArrayMetaschemaType, OneDArrayMetaschemaType

Public Functions

inline ScalarMetaschemaType(const char *subtype, const size_t precision, const char *units = "", const bool use_generic = false)

Constructor for ScalarMetaschemaType.

Parameters
  • subtype[in] const character pointer to the name of the subtype.

  • precision[in] size_t Type precision in bits.

  • units[in] const char * (optional) Type units.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

inline ScalarMetaschemaType(const rapidjson::Value &type_doc, const bool use_generic = false)

Constructor for ScalarMetaschemaType from a JSON type defintion.

Parameters
  • type_doc[in] rapidjson::Value rapidjson object containing the type definition from a JSON encoded header.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

inline ScalarMetaschemaType(PyObject *pyobj, const bool use_generic = false)

Constructor for ScalarMetaschemaType from Python dictionary.

Parameters
  • pyobj[in] PyObject* Python object.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

inline ScalarMetaschemaType(const ScalarMetaschemaType &other)

Copy constructor.

Parameters

other[in] ScalarMetaschemaType* Instance to copy.

inline virtual ~ScalarMetaschemaType()

Destructor for ScalarMetaschemaType. Free the type string malloc’d during constructor.

inline virtual bool operator==(const MetaschemaType &Ref) const override

Equivalence operator.

Parameters

Ref[in] MetaschemaType instance to compare against.

Returns

bool true if the instance is equivalent, false otherwise.

inline virtual bool is_empty() const override

Determine if the datatype is effectively empty.

Returns

bool true if the datatype is empty, false otherwise.

inline virtual ScalarMetaschemaType *copy() const override

Create a copy of the type.

Returns

pointer to new ScalarMetaschemaType instance with the same data.

inline virtual void display(const char *indent = "") const override

Print information about the type to stdout.

Parameters

indent[in] char* Indentation to add to display output.

inline virtual PyObject *as_python_dict() const override

Get type information as a Python dictionary.

Returns

PyObject* Python dictionary.

inline virtual void display_generic(const YggGeneric *data, const char *indent = "") const override

Display data.

Parameters
  • data[in] YggGeneric* Pointer to generic object.

  • indent[in] char* Indentation to add to display output.

inline int check_subtype() const

Check that the subtype is correct and get the corresponding code.

Returns

int Type code for the instance’s subtype.

inline const int subtype_code() const

Get the subtype code.

Returns

const int Subtype code.

inline const char *subtype() const

Get the subtype string.

Returns

const char pointer to the subtype string.

inline const size_t precision() const

Get the type precision.

Returns

size_t Type precision in bytes.

inline const bool in_table() const

Get the in_table flag.

Returns

bool true if in table, false otherwise.

inline const char *units() const

Get the type units.

Returns

const char* Type units string.

inline const size_t nbits() const

Get the size of the type in bits.

Returns

size_t Type size.

inline virtual const size_t nbytes() const override

Get the size of the type in bytes.

Returns

size_t Type size.

inline virtual std::vector<size_t> nbytes_va_core() const override

Get the number of bytes occupied by a variable of the type in a variable argument list.

Returns

std::vector<size_t> Number of bytes/variables occupied by the type.

inline virtual void skip_va_elements_core(size_t *nargs, va_list_t *ap) const override

Skip arguments that make of this type.

Parameters
  • nargs[inout] Pointer to number of arguments in ap.

  • ap[inout] va_list_t Variable argument list.

inline virtual void numpy_dims(int *nd, npy_intp **dims) const

Determine the dimensions of the equivalent numpy array.

Parameters
  • nd[inout] int* Address of integer where number of dimensions should be stored.

  • dims[inout] npy_intp** Address of pointer to memory where dimensions should be stored.

inline virtual void update(const MetaschemaType *new_info) override

Update the type object with info from another type object.

Parameters

new_info[in] MetaschemaType* type object.

inline virtual size_t update_from_serialization_args(size_t *nargs, va_list_t &ap) override

Update the type object with info from provided variable arguments for serialization.

Parameters
  • nargs[inout] size_t Number of arguments contained in ap. On output the number of unused arguments will be assigned to this address.

  • ap[in] va_list_t Variable argument list.

Returns

size_t Number of arguments in ap consumed.

inline virtual void update_type(const char *new_type) override

Update the instance’s type.

Parameters

new_type[in] const char * String for new type.

inline void update_subtype(const char *new_subtype, bool force = false)

Update the instance’s subtype.

Parameters
  • new_subtype[in] const char * String for new subtype.

  • force[in] bool True if the subtype should be updated even if it is not compatible with the existing value.

inline bool are_compat_units(const char *x, const char *y) const

Determine if two units are compatible.

Parameters
  • x[in] One set of units.

  • y[in] Second set of units.

Returns

bool true if they are compat, false otherwise

inline void update_units(const char *new_units, bool force = false)

Update the instance’s units.

Parameters
  • new_units[in] const char * String for new units.

  • force[in] bool True if the units should be updated even if it is not compatible with the existing value.

inline void set_precision(const size_t new_precision, bool force = false)

Update the instance’s precision.

Parameters
  • new_precision[in] size_t New precision.

  • force[in] bool True if the precision should be updated even if it is not compatible with the existing value.

inline virtual void set_in_table(bool new_in_table) override

Set the _in_table private variable.

Parameters

new_in_table[in] bool New value.

inline virtual size_t nargs_exp() const override

Get the number of arguments expected to be filled/used by the type.

Returns

size_t Number of arguments.

inline virtual YggGeneric *python2c(PyObject *pyobj) const override

Convert a Python representation to a C representation.

Parameters

pyobj[in] PyObject* Pointer to Python object.

Returns

YggGeneric* Pointer to C object.

inline virtual PyObject *c2python(YggGeneric *cobj) const override

Convert a C representation to a Python representation.

Parameters

cobj[in] YggGeneric* Pointer to C object.

Returns

PyObject* Pointer to Python object.

inline virtual bool encode_type_prop(rapidjson::Writer<rapidjson::StringBuffer> *writer) const override

Encode the type’s properties in a JSON string.

Parameters

writer[in] rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.

Returns

bool true if the encoding was successful, false otherwise.

inline virtual bool encode_data(rapidjson::Writer<rapidjson::StringBuffer> *writer, size_t *nargs, va_list_t &ap) const override

Encode arguments describine an instance of this type into a JSON string.

Parameters
  • writer[in] rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.

  • nargs[inout] size_t * Pointer to the number of arguments contained in ap. On return it will be set to the number of arguments used.

  • ap[in] va_list_t Variable number of arguments that should be encoded as a JSON string.

Returns

bool true if the encoding was successful, false otherwise.

inline virtual bool encode_data(rapidjson::Writer<rapidjson::StringBuffer> *writer, YggGeneric *x) const override

Encode arguments describine an instance of this type into a JSON string.

Parameters
  • writer[in] rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.

  • x[in] YggGeneric* Pointer to generic wrapper for data.

Returns

bool true if the encoding was successful, false otherwise.

inline virtual bool decode_data(rapidjson::Value &data, const int allow_realloc, size_t *nargs, va_list_t &ap) const override

Decode variables from a JSON string.

Parameters
  • data[in] rapidjson::Value Reference to entry in JSON string.

  • allow_realloc[in] int If 1, the passed variables will be reallocated to contain the deserialized data.

  • nargs[inout] size_t Number of arguments contained in ap. On return, the number of arguments assigned from the deserialized data will be assigned to this address.

  • ap[out] va_list_t Reference to variable argument list containing address where deserialized data should be assigned.

Returns

bool true if the data was successfully decoded, false otherwise.

inline virtual bool decode_data(rapidjson::Value &data, YggGeneric *x) const override

Decode variables from a JSON string.

Parameters
  • data[in] rapidjson::Value Reference to entry in JSON string.

  • x[out] YggGeneric* Pointer to generic object where data should be stored.

Returns

bool true if the data was successfully decoded, false otherwise.

inline size_t cast_bytes(unsigned char **bytes, const size_t nbytes) const

Cast raw bytes as the type described by this object.

Parameters
  • bytes[inout] Pointer to memory contain raw bytes to cast. The cast version will be stored here after any necessary changes have been made.

  • nbytes[in] The size of the memory pointed to by bytes. An error will be raised if the bytes cannot be cast because they would exceed this size.

Returns

The size of the re-cast bytes.

Private Members

const char *subtype_
const int subtype_code_
const size_t precision_
const char *units_
bool _variable_precision
size_t cast_precision_
bool _in_table
class NDArrayMetaschemaType : public ScalarMetaschemaType
#include <ScalarMetaschemaType.h>

Base class for ND array type definition.

The NDArrayMetaschemaType provides basic functionality for encoding/decoding ND array datatypes from/to JSON style strings.

Public Functions

NDArrayMetaschemaType(const char *subtype, const size_t precision, const std::vector<size_t> shape, const char *units = "", const bool use_generic = false)

Constructor for NDArrayMetaschemaType.

Parameters
  • subtype[in] const character pointer to the name of the subtype.

  • precision[in] size_t Type precision in bits.

  • shape[in] std::vector<size_t> Shape of type array in each dimension.

  • units[in] const char * (optional) Type units.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

NDArrayMetaschemaType(const rapidjson::Value &type_doc, const bool use_generic = false)

Constructor for NDArrayMetaschemaType from a JSON type defintion.

Parameters
  • type_doc[in] rapidjson::Value rapidjson object containing the type definition from a JSON encoded header.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

NDArrayMetaschemaType(PyObject *pyobj, const bool use_generic = false)

Constructor for NDArrayMetaschemaType from Python dictionary.

Parameters
  • pyobj[in] PyObject* Python object.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

NDArrayMetaschemaType(const NDArrayMetaschemaType &other)

Copy constructor.

Parameters

other[in] NDArrayMetaschemaType* Instance to copy.

virtual ~NDArrayMetaschemaType()
virtual bool operator==(const MetaschemaType &Ref) const override

Equivalence operator.

Parameters

Ref[in] MetaschemaType instance to compare against.

Returns

bool true if the instance is equivalent, false otherwise.

virtual NDArrayMetaschemaType *copy() const override

Create a copy of the type.

Returns

pointer to new NDArrayMetaschemaType instance with the same data.

virtual void display(const char *indent = "") const override

Print information about the type to stdout.

Parameters

indent[in] char* Indentation to add to display output.

virtual PyObject *as_python_dict() const override

Get type information as a Python dictionary.

Returns

PyObject* Python dictionary.

const size_t ndim() const

Get the number of dimensions in the array.

Returns

size_t Number of dimensions in type.

std::vector<size_t> shape() const

Get the shape of the array type.

Returns

std::vector<size_t> Shape of type in each dimension.

virtual const size_t nelements() const override

Get the number of elements in the type.

Returns

size_t Number of elements.

virtual const bool variable_nelements() const override

Determine if the number of elements is variable.

Returns

bool true if the number of elements can change, false otherwise.

virtual void numpy_dims(int *nd, npy_intp **dims) const override

Determine the dimensions of the equivalent numpy array.

Parameters
  • nd[inout] int* Address of integer where number of dimensions should be stored.

  • dims[inout] npy_intp** Address of pointer to memory where dimensions should be stored.

virtual size_t nargs_exp() const override

Get the number of arguments expected to be filled/used by the type.

Returns

size_t Number of arguments.

virtual void update(const MetaschemaType *new_info) override

Update the type object with info from another type object.

Parameters

new_info[in] MetaschemaType* type object.

virtual size_t update_from_serialization_args(size_t *nargs, va_list_t &ap) override

Update the type object with info from provided variable arguments for serialization.

Parameters
  • nargs[inout] size_t Number of arguments contained in ap. On output the number of unused arguments will be assigned to this address.

  • ap[in] va_list_t Variable argument list.

Returns

size_t Number of arguments in ap consumed.

virtual size_t update_from_deserialization_args(size_t *nargs, va_list_t &ap) override

Update the type object with info from provided variable arguments for deserialization.

Parameters
  • nargs[inout] size_t Number of arguments contained in ap. On output the number of unused arguments will be assigned to this address.

  • ap[in] va_list_t Variable argument list.

Returns

size_t Number of arguments in ap consumed.

void set_shape(std::vector<size_t> new_shape, bool force = false)

Update the instance’s shape.

Parameters
  • new_shape[in] std::vector<size_t> Vector of new array sizes in each dimension.

  • force[in] bool True if the shape should be updated even if it is not compatible with the existing value.

virtual bool encode_type_prop(rapidjson::Writer<rapidjson::StringBuffer> *writer) const override

Encode the type’s properties in a JSON string.

Parameters

writer[in] rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.

Returns

bool true if the encoding was successful, false otherwise.

virtual bool decode_data(rapidjson::Value &data, const int allow_realloc, size_t *nargs, va_list_t &ap) const override

Decode variables from a JSON string.

Parameters
  • data[in] rapidjson::Value Reference to entry in JSON string.

  • allow_realloc[in] int If 1, the passed variables will be reallocated to contain the deserialized data.

  • nargs[inout] size_t Number of arguments contained in ap. On return, the number of arguments assigned from the deserialized data will be assigned to this address.

  • ap[out] va_list_t Reference to variable argument list containing address where deserialized data should be assigned.

Returns

bool true if the data was successfully decoded, false otherwise.

Private Members

std::vector<size_t> shape_
bool _variable_shape
class OneDArrayMetaschemaType : public ScalarMetaschemaType
#include <ScalarMetaschemaType.h>

Base class for 1D array type definition.

The OneDArrayMetaschemaType provides basic functionality for encoding/decoding 1D array datatypes from/to JSON style strings.

Public Functions

inline OneDArrayMetaschemaType(const char *subtype, const size_t precision, const size_t length, const char *units = "", const bool use_generic = false)

Constructor for OneDArrayMetaschemaType.

Parameters
  • subtype[in] const character pointer to the name of the subtype.

  • precision[in] size_t Type precision in bits.

  • length[in] size_t Number of elements in the array.

  • units[in] const char * (optional) Type units.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

inline OneDArrayMetaschemaType(const rapidjson::Value &type_doc, const bool use_generic = false)

Constructor for OneDArrayMetaschemaType from a JSON type defintion.

Parameters
  • type_doc[in] rapidjson::Value rapidjson object containing the type definition from a JSON encoded header.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

inline OneDArrayMetaschemaType(PyObject *pyobj, const bool use_generic = false)

Constructor for OneDArrayMetaschemaType from Python dictionary.

Parameters
  • pyobj[in] PyObject* Python object.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

inline OneDArrayMetaschemaType(const OneDArrayMetaschemaType &other)

Copy constructor.

Parameters

other[in] OneDArrayMetaschemaType* Instance to copy.

inline virtual ~OneDArrayMetaschemaType()
inline virtual bool operator==(const MetaschemaType &Ref) const override

Equivalence operator.

Parameters

Ref[in] MetaschemaType instance to compare against.

Returns

bool true if the instance is equivalent, false otherwise.

inline virtual OneDArrayMetaschemaType *copy() const override

Create a copy of the type.

Returns

pointer to new OneDArrayMetaschemaType instance with the same data.

inline virtual void display(const char *indent = "") const override

Print information about the type to stdout.

Parameters

indent[in] char* Indentation to add to display output.

inline virtual PyObject *as_python_dict() const override

Get type information as a Python dictionary.

Returns

PyObject* Python dictionary.

inline virtual const size_t nelements() const override

Get the number of elements in the type.

Returns

size_t Number of elements.

inline virtual const bool variable_nelements() const override

Determine if the number of elements is variable.

Returns

bool true if the number of elements can change, false otherwise.

inline virtual void numpy_dims(int *nd, npy_intp **dims) const override

Determine the dimensions of the equivalent numpy array.

Parameters
  • nd[inout] int* Address of integer where number of dimensions should be stored.

  • dims[inout] npy_intp** Address of pointer to memory where dimensions should be stored.

inline virtual void update(const MetaschemaType *new_info) override

Update the type object with info from another type object.

Parameters

new_info[in] MetaschemaType* type object.

inline virtual size_t update_from_serialization_args(size_t *nargs, va_list_t &ap) override

Update the type object with info from provided variable arguments for serialization.

Parameters
  • nargs[inout] size_t Number of arguments contained in ap. On output the number of unused arguments will be assigned to this address.

  • ap[in] va_list_t Variable argument list.

Returns

size_t Number of arguments in ap consumed.

inline virtual size_t update_from_deserialization_args(size_t *nargs, va_list_t &ap) override

Update the type object with info from provided variable arguments for deserialization.

Parameters
  • nargs[inout] size_t Number of arguments contained in ap. On output the number of unused arguments will be assigned to this address.

  • ap[in] va_list_t Variable argument list.

Returns

size_t Number of arguments in ap consumed.

inline virtual void set_length(size_t new_length, bool force = false) override

Update the instance’s length.

Parameters
  • new_length[in] size_t New length.

  • force[in] bool True if the length should be updated even if it is not compatible with the existing value.

inline virtual void set_variable_length(bool new_variable_length) override

Set the _variable_length private variable.

Parameters

new_variable_length[in] bool New value.

inline size_t length() const

Get type length.

Returns

size_t Number of elements in the array.

inline virtual size_t nargs_exp() const override

Get the number of arguments expected to be filled/used by the type.

Returns

size_t Number of arguments.

inline virtual bool encode_type_prop(rapidjson::Writer<rapidjson::StringBuffer> *writer) const override

Encode the type’s properties in a JSON string.

Parameters

writer[in] rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.

Returns

bool true if the encoding was successful, false otherwise.

inline virtual bool decode_data(rapidjson::Value &data, const int allow_realloc, size_t *nargs, va_list_t &ap) const override

Decode variables from a JSON string.

Parameters
  • data[in] rapidjson::Value Reference to entry in JSON string.

  • allow_realloc[in] int If 1, the passed variables will be reallocated to contain the deserialized data.

  • nargs[inout] size_t Number of arguments contained in ap. On return, the number of arguments assigned from the deserialized data will be assigned to this address.

  • ap[out] va_list_t Reference to variable argument list containing address where deserialized data should be assigned.

Returns

bool true if the data was successfully decoded, false otherwise.

Private Members

size_t length_
bool _variable_length
class JSONArrayMetaschemaType : public MetaschemaType
#include <JSONArrayMetaschemaType.h>

Class for describing JSON arrays.

The JSONArrayMetaschemaType provides basic functionality for encoding/decoding JSON array datatypes from/to JSON style strings.

Public Functions

inline JSONArrayMetaschemaType(const MetaschemaTypeVector items, const char *format_str = "", const bool use_generic = true)

Constructor for JSONArrayMetaschemaType.

Parameters
  • items[in] MetaschemaTypeVector Type classes for array items.

  • format_str[in] const char * (optional) Format string describing the item types. Defaults to empty string.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

inline JSONArrayMetaschemaType(const rapidjson::Value &type_doc, const char *format_str = "", const bool use_generic = true, const char item_key[100] = "items")

Constructor for JSONArrayMetaschemaType from a JSON type defintion.

Parameters
  • type_doc[in] rapidjson::Value rapidjson object containing the type definition from a JSON encoded header.

  • format_str[in] const char * (optional) Format string describing the item types. Defaults to empty string.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

  • item_key[in] const char Key to use for items. Defaults to “items”.

inline JSONArrayMetaschemaType(PyObject *pyobj, const bool use_generic = true, const char item_key[100] = "items")

Constructor for JSONArrayMetaschemaType from Python dictionary.

Parameters
  • pyobj[in] PyObject* Python object.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

  • item_key[in] const char Key to use for items. Defaults to “items”.

inline JSONArrayMetaschemaType(const JSONArrayMetaschemaType &other)

Copy constructor.

Parameters

other[in] JSONArrayMetaschemaType* Instance to copy.

inline virtual ~JSONArrayMetaschemaType()

Destructor for JSONArrayMetaschemaType. Free the type string malloc’d during constructor.

inline void free_items()

Free the items.

inline virtual bool operator==(const MetaschemaType &Ref) const override

Equivalence operator.

Parameters

Ref[in] MetaschemaType instance to compare against.

Returns

bool true if the instance is equivalent, false otherwise.

inline virtual bool is_empty() const override

Determine if the datatype is effectively empty.

Returns

bool true if the datatype is empty, false otherwise.

inline virtual JSONArrayMetaschemaType *copy() const override

Create a copy of the type.

Returns

pointer to new JSONArrayMetaschemaType instance with the same data.

inline virtual void display(const char *indent = "") const override

Print information about the type to stdout.

Parameters

indent[in] char* Indentation to add to display output.

inline virtual PyObject *as_python_dict() const override

Get type information as a Python dictionary.

Returns

PyObject* Python dictionary.

inline virtual void *copy_generic(const YggGeneric *data, void *orig_data = NULL) const override

Copy data wrapped in YggGeneric class.

Parameters
  • data[in] YggGeneric* Pointer to generic object.

  • orig_data[in] Pointer to data that should be copied if different that the data that is wrapped.

Returns

void* Pointer to copy of data.

inline virtual void free_generic(YggGeneric *data) const override

Free data wrapped in YggGeneric class.

Parameters

data[in] YggGeneric* Pointer to generic object.

inline virtual void display_generic(const YggGeneric *data, const char *indent) const override

Display data.

Parameters
  • data[in] YggGeneric* Pointer to generic object.

  • indent[in] char* Indentation to add to display output.

inline size_t nitems() const

Get number of items in type.

Returns

size_t Number of items in type.

inline MetaschemaTypeVector items() const

Get types for items.

Returns

MetaschemaTypeVector Array item types.

inline const char *format_str() const

Get format string.

Returns

char* Format string.

inline bool all_arrays() const

Determine if the items are all arrays.

Returns

bool true if all items are arrays, false otherwise.

inline virtual void update(const MetaschemaType *new_info) override

Update the type object with info from another type object.

Parameters

new_info[in] MetaschemaType* type object.

inline virtual void update_type_element(size_t i, const MetaschemaType *x) override

Update the type at an index.

Parameters
  • i[in] size_t Index where item type should be added.

  • x[in] MetaschemaType* Type to insert at index i.

inline void update_items(const MetaschemaTypeVector new_items, bool force = false)

Update the item types.

Parameters
  • new_items[in] MetaschemaTypeVector Vector of new types describing items.

  • force[in] bool If true, the existing items are overwritten, otherwise they are only updated.

inline virtual void update_use_generic(const bool new_use_generic) override

Update the instance’s use_generic flag.

Parameters

new_use_generic[in] const bool New flag value.

inline virtual const MetaschemaType *get_item_type(const size_t index) const override

Get the type associated with an item.

Parameters

index[in] const size_t Index of item to get type for.

Returns

MetaschemaType* Pointer to type class for item.

inline virtual void set_item_type(const size_t index, const MetaschemaType *itemtype) override

Set the type associated with an item. An error will be raised if the property identified by key is already present and the provided type does not match the existing type.

Parameters
  • index[in] const size_t Index of the item to set the type for.

  • itemtype[in] const MetaschemaType* Pointer to item type that should be associated with the provided index.

inline virtual size_t update_from_serialization_args(size_t *nargs, va_list_t &ap) override

Update the type object with info from provided variable arguments for serialization.

Parameters
  • nargs[inout] size_t Number of arguments contained in ap. On output the number of unused arguments will be assigned to this address.

  • ap[in] va_list_t Variable argument list.

Returns

size_t Number of arguments in ap consumed.

inline virtual size_t update_from_deserialization_args(size_t *nargs, va_list_t &ap) override

Update the type object with info from provided variable arguments for deserialization.

Parameters
  • nargs[inout] size_t Number of arguments contained in ap. On output the number of unused arguments will be assigned to this address.

  • ap[in] va_list_t Variable argument list.

Returns

size_t Number of arguments in ap consumed.

inline virtual const size_t nbytes() const override

Get the item size.

Returns

size_t Size of item in bytes.

inline virtual std::vector<size_t> nbytes_va_core() const override

Get the number of bytes occupied by a variable of the type in a variable argument list.

Returns

std::vector<size_t> Number of bytes/variables occupied by the type.

inline virtual size_t nargs_exp() const override

Get the number of arguments expected to be filled/used by the type.

Returns

size_t Number of arguments.

inline virtual void skip_va_elements_core(size_t *nargs, va_list_t *ap) const override

Skip arguments that make of this type.

Parameters
  • nargs[inout] Pointer to number of arguments in ap.

  • ap[inout] va_list_t Variable argument list.

inline virtual YggGeneric *python2c(PyObject *pyobj) const override

Convert a Python representation to a C representation.

Parameters

pyobj[in] PyObject* Pointer to Python object.

Returns

YggGeneric* Pointer to C object.

inline virtual PyObject *c2python(YggGeneric *cobj) const override

Convert a C representation to a Python representation.

Parameters

cobj[in] YggGeneric* Pointer to C object.

Returns

PyObject* Pointer to Python object.

inline virtual bool encode_type_prop(rapidjson::Writer<rapidjson::StringBuffer> *writer) const override

Encode the type’s properties in a JSON string.

Parameters

writer[in] rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.

Returns

bool true if the encoding was successful, false otherwise.

inline virtual bool encode_data(rapidjson::Writer<rapidjson::StringBuffer> *writer, size_t *nargs, va_list_t &ap) const override

Encode arguments describine an instance of this type into a JSON string.

Parameters
  • writer[in] rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.

  • nargs[inout] size_t * Pointer to the number of arguments contained in ap. On return it will be set to the number of arguments used.

  • ap[in] va_list_t Variable number of arguments that should be encoded as a JSON string.

Returns

bool true if the encoding was successful, false otherwise.

inline virtual bool encode_data(rapidjson::Writer<rapidjson::StringBuffer> *writer, YggGeneric *x) const override

Encode arguments describine an instance of this type into a JSON string.

Parameters
  • writer[in] rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.

  • x[in] YggGeneric* Pointer to generic wrapper for data.

Returns

bool true if the encoding was successful, false otherwise.

inline virtual bool decode_data(rapidjson::Value &data, const int allow_realloc, size_t *nargs, va_list_t &ap) const override

Decode variables from a JSON string.

Parameters
  • data[in] rapidjson::Value Reference to entry in JSON string.

  • allow_realloc[in] int If 1, the passed variables will be reallocated to contain the deserialized data.

  • nargs[inout] size_t Number of arguments contained in ap. On return, the number of arguments assigned from the deserialized data will be assigned to this address.

  • ap[out] va_list_t Reference to variable argument list containing address where deserialized data should be assigned.

Returns

bool true if the data was successfully decoded, false otherwise.

inline virtual bool decode_data(rapidjson::Value &data, YggGeneric *x) const override

Decode variables from a JSON string.

Parameters
  • data[in] rapidjson::Value Reference to entry in JSON string.

  • x[out] YggGeneric* Pointer to generic object where data should be stored.

Returns

bool true if the data was successfully decoded, false otherwise.

Private Members

char item_key_[100]
MetaschemaTypeVector items_
char format_str_[1001]
class JSONObjectMetaschemaType : public MetaschemaType
#include <JSONObjectMetaschemaType.h>

Class for describing JSON objects.

The JSONObjectMetaschemaType provides basic functionality for encoding/decoding JSON object datatypes from/to JSON style strings.

Public Functions

inline JSONObjectMetaschemaType(const MetaschemaTypeMap properties, const bool use_generic = true)

Constructor for JSONObjectMetaschemaType.

Parameters
  • properties[in] MetaschemaTypeMap Map from property names to types.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

inline JSONObjectMetaschemaType(const rapidjson::Value &type_doc, const bool use_generic = true, const char prop_key[100] = "properties")

Constructor for JSONObjectMetaschemaType from a JSON type defintion.

Parameters
  • type_doc[in] rapidjson::Value rapidjson object containing the type definition from a JSON encoded header.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

  • prop_key[in] const char Key to use for properties. Defaults to “properties”.

inline JSONObjectMetaschemaType(PyObject *pyobj, const bool use_generic = true, const char prop_key[100] = "properties")

Constructor for JSONObjectMetaschemaType from Python dictionary.

Parameters
  • pyobj[in] PyObject* Python object.

  • use_generic[in] bool If true, serialized/deserialized objects will be expected to be YggGeneric classes.

  • prop_key[in] const char Key to use for properties. Defaults to “properties”.

inline JSONObjectMetaschemaType(const JSONObjectMetaschemaType &other)

Copy constructor.

Parameters

other[in] JSONObjectMetaschemaType* Instance to copy.

inline virtual ~JSONObjectMetaschemaType()

Destructor for JSONObjectMetaschemaType. Free the type string malloc’d during constructor.

inline void free_properties()

Free properties.

inline virtual bool operator==(const MetaschemaType &Ref) const override

Equivalence operator.

Parameters

Ref[in] MetaschemaType instance to compare against.

Returns

bool true if the instance is equivalent, false otherwise.

inline virtual bool is_empty() const override

Determine if the datatype is effectively empty.

Returns

bool true if the datatype is empty, false otherwise.

inline virtual