C/C++ Datatypes API

Defines

MSG_HEAD_SEP
COMMBUFFSIZ
FMT_LEN

Typedefs

typedef struct MetaschemaType MetaschemaType

C-friendly definition of MetaschemaType.

typedef struct comm_head_t comm_head_t

Header information passed by comms for multipart messages.

Functions

const char *get_type_name(MetaschemaType *type_class)

Get the name of the type from the class.

Return
const char* Type name.
Parameters
  • type_class: MetaschemaType* Type structure/class.

const char *get_type_subtype(MetaschemaType *type_class)

Get the subtype of the type.

Return
const char* The subtype of the class, “” if there is an error.
Parameters
  • type_class: MetaschemaType* Type structure/class.

const size_t get_type_precision(MetaschemaType *type_class)

Get the precision of the type.

Return
const size_t The precision of the class, 0 if there is an error.
Parameters
  • type_class: MetaschemaType* Type structure/class.

MetaschemaType *get_direct_type()

Construct a Direct type object.

Return
MetaschemaType* Type structure/class.

MetaschemaType *get_scalar_type(const char *subtype, const size_t precision, const char *units)

Construct a Scalar type object.

Return
MetaschemaType* Type structure/class.
Parameters
  • subtype: char* Name of the scalar subtype (e.g. int, uint, float, bytes).
  • precision: size_t Precision of the scalar in bits.
  • units: char* Units for scalar. (e.g. “cm”, “g”, “” for unitless)

MetaschemaType *get_1darray_type(const char *subtype, const size_t precision, const size_t length, const char *units)

Construct a 1D array type object.

Return
MetaschemaType* Type structure/class.
Parameters
  • subtype: char* Name of the array subtype (e.g. int, uint, float, bytes).
  • precision: size_t Precision of the array in bits.
  • length: size_t Number of elements in the array.
  • units: char* Units for array elements. (e.g. “cm”, “g”, “” for unitless)

MetaschemaType *get_ndarray_type(const char *subtype, const size_t precision, const size_t ndim, const size_t *shape, const char *units)

Construct a ND array type object.

Return
MetaschemaType* Type structure/class.
Parameters
  • subtype: char* Name of the array subtype (e.g. int, uint, float, bytes).
  • precision: size_t Precision of the array in bits.
  • ndim: size_t Number of dimensions in the array (and therefore also the number of elements in shape).
  • shape: size_t* Pointer to array where each element is the size of the array in that dimension.
  • units: char* Units for array elements. (e.g. “cm”, “g”, “” for unitless)

MetaschemaType *get_json_array_type(const size_t nitems, MetaschemaType **items)

Construct a JSON array type object.

Return
MetaschemaType* Type structure/class.
Parameters
  • nitems: size_t Number of types in items.
  • items: MetaschemaType** Pointer to array of types describing the array elements.

MetaschemaType *get_json_object_type(const size_t nitems, const char **keys, MetaschemaType **values)

Construct a JSON object type object.

Return
MetaschemaType* Type structure/class.
Parameters
  • nitems: size_t Number of keys/types in keys and values.
  • keys: char** Pointer to array of keys for each type.
  • values: MetaschemaType** Pointer to array of types describing the values for each key.

MetaschemaType *get_ply_type()

Construct a Ply type object.

Return
MetaschemaType* Type structure/class.

MetaschemaType *get_obj_type()

Construct a Obj type object.

Return
MetaschemaType* Type structure/class.

MetaschemaType *get_ascii_table_type(const char *format_str, const int as_array)

Construct an AsciiTable type object.

Return
MetaschemaType* Type structure/class.

MetaschemaType *get_format_type(const char *format_str, const int as_array)

Construct a type object based on the provided format string.

Return
MetaschemaType* Type structure/class.
Parameters
  • format_str: 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: int If 1, the types will be arrays. Otherwise they will be scalars.

MetaschemaType *type_from_void(const char *type_name, const void *type)

Construct a type object based on the type name and a pointer cast to void*.

Return
MetaschemaType* Type structure/class.
Parameters
  • type_name: char* Name of the type represented.
  • type: void* Pointer to location where type information is stored.

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

Initialize a header struct.

Return
comm_head_t Structure with provided information, char arrays correctly initialized to empty strings if NULLs provided.
Parameters
  • size: size_t Size of message to be sent.
  • address: char* Address that should be used for remainder of message following this header if it is a multipart message.
  • id: char* Message ID.

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

Split header and body of message.

Return
: int 0 if split is successful, -1 if there was an error.
Parameters
  • buf: const char* Message that should be split.
  • buf_siz: size_t Size of buf.
  • head: const char** pointer to buffer where the extracted header should be stored.
  • headsiz: size_t reference to memory where size of extracted header should be stored.

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

Format header to a string.

Return
: int Size of header written.
Parameters
  • head: comm_head_t Header to be formatted.
  • buf: char * Buffer where header should be written.
  • buf_siz: size_t Size of buf.

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

Extract header information from a string.

Return
: comm_head_t Header information structure.
Parameters
  • buf: const char* Message that header should be extracted from.
  • buf_siz: size_t Size of buf.

void *get_ascii_table_from_void(const char *name, const void *info)

Get the ascii table data structure from void.

Return
: void* Cast pointer to ascii table.
Parameters
  • name: char* Name of the type.
  • info: void* Pointer to type class.

const char *get_type_name_from_void(const char *name, const void *info)

Get the type name from pointer cast as void*.

Return
: const char * Name of type class.
Parameters
  • name: char* Name of the type.
  • info: void* Pointer to type class.

MetaschemaType *copy_from_void(const char *name, const void *info)

Get a copy of the type from pointer cast as void*.

Return
: MetaschemaType* Type class.
Parameters
  • name: char* Name of the type.
  • info: void* Pointer to type class.

int update_precision_from_void(const char *name, void *info, const size_t new_precision)

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

Return
: int 0 if free was successfull, -1 if there was an error.
Parameters
  • name: char* Name of the type.
  • info: void* Pointer to type class.
  • new_precision: size_t New precision.

int free_type_from_void(const char *name, void *info)

Wrapper for freeing MetaschemaType class from pointer cast as void*.

Return
: int 0 if free was successfull, -1 if there was an error.
Parameters
  • name: char* Name of the type.
  • info: void* Pointer to type class.

int deserialize_from_void(const char *name, const void *info, 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 cast as void*.

Parameters
  • name: char* Name of the type.
  • info: void* Pointer to type class.
  • buf: character pointer to serialized message.
  • buf_siz: size_t Size of buf.
  • allow_realloc: 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: int Number of arguments remaining in argument list.
  • ap: va_list Arguments to be parsed from message. returns: int The number of populated arguments. -1 indicates an error.

int serialize_from_void(const char *name, const void *info, char **buf, size_t *buf_siz, const int allow_realloc, size_t *nargs, va_list_t ap)

Wrapper for serializing from a data type cast as void*.

Parameters
  • name: char* Name of the type.
  • info: void* Pointer to type class.
  • buf: character pointer to pointer to memory where serialized message should be stored.
  • buf_siz: size_t Size of memory allocated to buf.
  • allow_realloc: 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: int Number of arguments remaining in argument list.
  • ap: va_list Arguments to be formatted. returns: int The length of the serialized message or -1 if there is an error.

void display_from_void(const char *name, const void *info)

Wrapper for displaying a data type.

Parameters
  • name: char* Name of the type.
  • info: void* Pointer to type class.

size_t nargs_exp_from_void(const char *name, const void *info)

Wrapper for determining how many arguments a data type expects.

Parameters
  • name: char* Name of the type.
  • info: void* Pointer to type class.

struct comm_head_t
#include <datatypes.h>

Header information passed by comms for multipart messages.

Public Members

int multipart

1 if message is multipart, 0 if it is not.

size_t bodysiz

Size of body.

size_t bodybeg

Start of body in header.

int valid

1 if the header is valid, 0 otherwise.

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.

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.

int as_array

1 if messages will be serialized arrays.

char type[COMMBUFFSIZ]

Type name.

void *serializer_info

JSON type.

Enums

enum [anonymous]

Values:

T_BOOLEAN
T_INTEGER
T_NULL
T_NUMBER
T_STRING
T_ARRAY
T_OBJECT
T_DIRECT
T_1DARRAY
T_NDARRAY
T_SCALAR
T_FLOAT
T_UINT
T_INT
T_COMPLEX
T_BYTES
T_UNICODE
T_PLY
T_OBJ
T_ASCII_TABLE

Functions

static void cislog_throw_error(const char *fmt, ...)

Throw an error and long it.

Parameters
  • fmt: char* Format string.
  • ...: Parameters that should be formated using the format string.

std::map<const char *, int, strcomp> get_type_map()

Return the global type map, populating it as necessary.

Return
std::map<const char*, int, strcomp> mapping from type name to code.

Variables

std::map<const char *, int, strcomp> global_type_map

Global type map to be filled.

struct strcomp
#include <MetaschemaType.h>

String comparison structure.

Public Functions

bool operator()(char const *a, char const *b) const

Comparison operator.

Return
bool true if the strings are equivalent, false otherwise.
Parameters
  • a: char const * First string for comparison.
  • b: char const * Second string for comparison.

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 AsciiTableMetaschemaType, DirectMetaschemaType, JSONArrayMetaschemaType, JSONObjectMetaschemaType, ObjMetaschemaType, PlyMetaschemaType, ScalarMetaschemaType

Public Functions

MetaschemaType(const char *type)

Constructor for MetaschemaType.

Parameters
  • type: const character pointer to the name of the type.

MetaschemaType(const rapidjson::Value &type_doc)

Constructor for MetaschemaType from a JSON type defintion.

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

MetaschemaType *copy()

Create a copy of the type.

Return
pointer to new MetaschemaType instance with the same data.

virtual void display()

Print information about the type to stdout.

int check_type()

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

Return
int Type code for the instance’s type.

virtual ~MetaschemaType()

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

const char *type()

Get the type string.

Return
const char pointer to the type string.

const int type_code()

Get the type code.

Return
int Type code associated with the curent type.

virtual void update_type(const char *new_type)

Update the instance’s type.

Parameters
  • new_type: const char * String for new type.

virtual void set_length(size_t new_length)

Set the type length.

Parameters
  • new_length: size_t New length.

virtual size_t get_length()

Get the type’s length.

Return
size_t Type length.

virtual size_t nargs_exp()

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

Return
size_t Number of arguments.

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

Encode the type in a JSON string.

Return
bool true if the encoding was successful, false otherwise.
Parameters
  • writer: rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.

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

Encode the type’s properties in a JSON string.

Return
bool true if the encoding was successful, false otherwise.
Parameters
  • writer: rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.

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

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

Return
bool true if the encoding was successful, false otherwise.
Parameters
  • writer: rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.
  • nargs: size_t * Pointer to the number of arguments contained in ap. On return it will be set to the number of arguments used.
  • ap: va_list_t Variable number of arguments that should be encoded as a JSON string.

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

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

Return
bool true if the encoding was successful, false otherwise.
Parameters
  • writer: rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.
  • nargs: size_t * Pointer to the number of arguments contained in ap. On return it will be set to the number of arguments used.
  • ...: Variable number of arguments that should be encoded as a JSON string.

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)

Copy data from a source buffer to a destination buffer.

Return
int -1 if there is an error, otherwise its the size of the data copied to the destination buffer.
Parameters
  • src_buf: char* Pointer to source buffer.
  • src_buf_siz: size_t Size of src_buf.
  • dst_buf: char** Pointer to memory address of destination buffer.
  • dst_buf_siz: 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: 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: bool (optional) If true, the terminal character will not be added to the end of the copied buffer. Defaults to false.

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.

Return
int Size of the serialized data in buf.
Parameters
  • buf: char ** Buffer where serialized data should be written.
  • buf_siz: size_t* Size of buf. If buf is reallocated, the new size of the buffer will be assigned to this address.
  • allow_realloc: 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: size_t Number of arguments contained in ap. On output the number of arguments used will be assigned to this address.
  • ap: va_list_t Variable number of arguments that will be serialized.

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

Decode variables from a JSON string.

Return
bool true if the data was successfully decoded, false otherwise.
Parameters
  • data: rapidjson::Value Reference to entry in JSON string.
  • allow_realloc: int If 1, the passed variables will be reallocated to contain the deserialized data.
  • nargs: 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: va_list_t Reference to variable argument list containing address where deserialized data should be assigned.

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.

Return
int -1 if there is an error, otherwise the number of arguments remaining in ap.
Parameters
  • buf: char* Buffer containing serialized data.
  • buf_siz: size_t Size of the serialized data.
  • allow_realloc: int If 1, the provided variables will be realloced as necessary to house the deserialized data.
  • nargs: size_t* Number of arguments contained in ap. On return, the number of arguments assigned will be assigned to this address.
  • ap: va_list_t Arguments that should be assigned based on the deserialized data.

Private Members

const char *type_
const int type_code_

Defines

STRBUFF

Typedefs

typedef float _Complex complex_float
typedef double _Complex complex_double
typedef long double _Complex complex_long_double
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

ScalarMetaschemaType(const char *subtype, const size_t precision, const char *units = "")

Constructor for ScalarMetaschemaType.

Parameters
  • subtype: const character pointer to the name of the subtype.
  • precision: size_t Type precision in bits.
  • units: const char * (optional) Type units.

ScalarMetaschemaType(const rapidjson::Value &type_doc)

Constructor for ScalarMetaschemaType from a JSON type defintion.

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

~ScalarMetaschemaType()

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

ScalarMetaschemaType *copy()

Create a copy of the type.

Return
pointer to new ScalarMetaschemaType instance with the same data.

void display()

Print information about the type to stdout.

int check_subtype()

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

Return
int Type code for the instance’s subtype.

const char *subtype()

Get the subtype string.

Return
const char pointer to the subtype string.

const size_t precision()

Get the type precision.

Return
size_t Type precision in bytes.

const char *units()

Get the type units.

Return
const char* Type units string.

virtual const size_t nelements()

Get the number of elements in the type.

Return
size_t Number of elements (1 for scalar).

const size_t nbits()

Get the size of the type in bits.

Return
size_t Type size.

const size_t nbytes()

Get the size of the type in bytes.

Return
size_t Type size.

void update_type(const char *new_type)

Update the instance’s type.

Parameters
  • new_type: const char * String for new type.

void update_subtype(const char *new_subtype)

Update the instance’s subtype.

Parameters
  • new_subtype: const char * String for new subtype.

void update_units(const char *new_units)

Update the instance’s units.

Parameters
  • new_units: const char * String for new units.

void set_precision(const size_t new_precision)

Update the instance’s precision.

Parameters
  • new_precision: size_t New precision.

size_t nargs_exp()

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

Return
size_t Number of arguments.

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

Encode the type’s properties in a JSON string.

Return
bool true if the encoding was successful, false otherwise.
Parameters
  • writer: rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.

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

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

Return
bool true if the encoding was successful, false otherwise.
Parameters
  • writer: rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.
  • nargs: size_t * Pointer to the number of arguments contained in ap. On return it will be set to the number of arguments used.
  • ap: va_list_t Variable number of arguments that should be encoded as a JSON string.

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

Decode variables from a JSON string.

Return
bool true if the data was successfully decoded, false otherwise.
Parameters
  • data: rapidjson::Value Reference to entry in JSON string.
  • allow_realloc: int If 1, the passed variables will be reallocated to contain the deserialized data.
  • nargs: 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: va_list_t Reference to variable argument list containing address where deserialized data should be assigned.

Private Members

const char *subtype_
const int subtype_code_
const size_t precision_
const char *units_
bool _variable_precision
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

OneDArrayMetaschemaType(const char *subtype, const size_t precision, const size_t length, const char *units = "")

Constructor for OneDArrayMetaschemaType.

Parameters
  • subtype: const character pointer to the name of the subtype.
  • precision: size_t Type precision in bits.
  • length: size_t Number of elements in the array.
  • units: const char * (optional) Type units.

OneDArrayMetaschemaType(const rapidjson::Value &type_doc)

Constructor for OneDArrayMetaschemaType from a JSON type defintion.

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

OneDArrayMetaschemaType *copy()

Create a copy of the type.

Return
pointer to new OneDArrayMetaschemaType instance with the same data.

void display()

Print information about the type to stdout.

const size_t nelements()

Get the number of elements in the type.

Return
size_t Number of elements.

void set_length(size_t new_length)

Update the instance’s length.

Parameters
  • new_length: size_t New length.

size_t get_length()

Get type length.

Return
size_t Number of elements in the array.

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

Encode the type’s properties in a JSON string.

Return
bool true if the encoding was successful, false otherwise.
Parameters
  • writer: rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.

Private Members

size_t length_
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 = "")

Constructor for NDArrayMetaschemaType.

Parameters
  • subtype: const character pointer to the name of the subtype.
  • precision: size_t Type precision in bits.
  • shape: std::vector<size_t> Shape of type array in each dimension.
  • units: const char * (optional) Type units.

NDArrayMetaschemaType(const rapidjson::Value &type_doc)

Constructor for NDArrayMetaschemaType from a JSON type defintion.

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

NDArrayMetaschemaType *copy()

Create a copy of the type.

Return
pointer to new NDArrayMetaschemaType instance with the same data.

void display()

Print information about the type to stdout.

const size_t ndim()

Get the number of dimensions in the array.

Return
size_t Number of dimensions in type.

std::vector<size_t> shape()

Get the shape of the array type.

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

const size_t nelements()

Get the number of elements in the type.

Return
size_t Number of elements.

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

Encode the type’s properties in a JSON string.

Return
bool true if the encoding was successful, false otherwise.
Parameters
  • writer: rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.

Private Members

std::vector<size_t> shape_
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

JSONArrayMetaschemaType(std::vector<MetaschemaType *> items, const char *format_str = "")

Constructor for JSONArrayMetaschemaType.

Parameters
  • items: std::vector<MetaschemaType*> Type classes for array items.
  • format_str: const char * (optional) Format string describing the item types. Defaults to empty string.

JSONArrayMetaschemaType *copy()

Create a copy of the type.

Return
pointer to new JSONArrayMetaschemaType instance with the same data.

void display()

Print information about the type to stdout.

size_t nitems()

Get number of items in type.

Return
size_t Number of items in type.

std::vector<MetaschemaType *> items()

Get types for items.

Return
std::vector<MetaschemaType*> Array item types.

bool all_arrays()

Determine if the items are all arrays.

Return
bool true if all items are arrays, false otherwise.

size_t nargs_exp()

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

Return
size_t Number of arguments.

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

Encode the type’s properties in a JSON string.

Return
bool true if the encoding was successful, false otherwise.
Parameters
  • writer: rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.

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

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

Return
bool true if the encoding was successful, false otherwise.
Parameters
  • writer: rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.
  • nargs: size_t * Pointer to the number of arguments contained in ap. On return it will be set to the number of arguments used.
  • ap: va_list_t Variable number of arguments that should be encoded as a JSON string.

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

Decode variables from a JSON string.

Return
bool true if the data was successfully decoded, false otherwise.
Parameters
  • data: rapidjson::Value Reference to entry in JSON string.
  • allow_realloc: int If 1, the passed variables will be reallocated to contain the deserialized data.
  • nargs: 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: va_list_t Reference to variable argument list containing address where deserialized data should be assigned.

Private Members

std::vector<MetaschemaType *> items_
char format_str_[1000]
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

JSONObjectMetaschemaType(std::map<const char *, MetaschemaType *, strcomp> properties)

Constructor for JSONObjectMetaschemaType.

Parameters
  • properties: std::map<const char*, MetaschemaType*, strcomp> Map from property names to types.

JSONObjectMetaschemaType *copy()

Create a copy of the type.

Return
pointer to new JSONObjectMetaschemaType instance with the same data.

void display()

Print information about the type to stdout.

std::map<const char *, MetaschemaType *, strcomp> properties()

Get types for properties.

Return
std::map<const char*, MetaschemaType*, strcomp> Map from property names to types.

size_t nargs_exp()

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

Return
size_t Number of arguments.

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

Encode the type’s properties in a JSON string.

Return
bool true if the encoding was successful, false otherwise.
Parameters
  • writer: rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.

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

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

Return
bool true if the encoding was successful, false otherwise.
Parameters
  • writer: rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.
  • nargs: size_t * Pointer to the number of arguments contained in ap. On return it will be set to the number of arguments used.
  • ap: va_list_t Variable number of arguments that should be encoded as a JSON string.

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

Decode variables from a JSON string.

Return
bool true if the data was successfully decoded, false otherwise.
Parameters
  • data: rapidjson::Value Reference to entry in JSON string.
  • allow_realloc: int If 1, the passed variables will be reallocated to contain the deserialized data.
  • nargs: 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: va_list_t Reference to variable argument list containing address where deserialized data should be assigned.

Private Members

std::map<const char *, MetaschemaType *, strcomp> properties_
class AsciiTableMetaschemaType : public MetaschemaType
#include <AsciiTableMetaschemaType.h>

Class for ascii table serializaiton/deserialization.

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

Public Functions

AsciiTableMetaschemaType(const char *format_str, const int as_array = 0)

Constructor for AsciiTableMetaschemaType.

Parameters
  • format_str: char * Format string describing table structure.
  • as_array: int (optional) If 1, the instance will act to serialize/deserialize table columns. If 0, the instnace will act to serialize/deserialize table rows. Defaults to 0.

~AsciiTableMetaschemaType()

Destructor for AsciiTableMetaschemaType. Free the table structure created during constructor.

AsciiTableMetaschemaType *copy()

Create a copy of the type.

Return
pointer to new AsciiTableMetaschemaType instance with the same data.

void display()

Print information about the type to stdout.

const char *format_str()

Get format string describing table.

Return
char * Format string.

asciiTable_t *table()

Get table struct.

Return
asciiTable_t* Table struct.

const int as_array()

Get as_array.

Return
bool 1 if elements in table are all arrays, 0 otherwise.

virtual size_t nargs_exp()

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

Return
size_t Number of arguments.

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

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

Return
bool true if the encoding was successful, false otherwise.
Parameters
  • writer: rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.
  • nargs: size_t * Pointer to the number of arguments contained in ap. On return it will be set to the number of arguments used.
  • ap: va_list_t Variable number of arguments that should be encoded as a JSON string.

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.

Return
int Size of the serialized data in buf.
Parameters
  • buf: char ** Buffer where serialized data should be written.
  • buf_siz: size_t* Size of buf. If buf is reallocated, the new size of the buffer will be assigned to this address.
  • allow_realloc: 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: size_t Number of arguments contained in ap. On output the number of arguments used will be assigned to this address.
  • ap: va_list_t Variable number of arguments that will be serialized.

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

Decode variables from a JSON string.

Return
bool true if the data was successfully decoded, false otherwise.
Parameters
  • data: rapidjson::Value Reference to entry in JSON string.
  • allow_realloc: int If 1, the passed variables will be reallocated to contain the deserialized data.
  • nargs: 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: va_list_t Reference to variable argument list containing address where deserialized data should be assigned.

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.

Return
int -1 if there is an error, otherwise the number of arguments remaining in ap.
Parameters
  • buf: char* Buffer containing serialized data.
  • buf_siz: size_t Size of the serialized data.
  • allow_realloc: int If 1, the provided variables will be realloced as necessary to house the deserialized data.
  • nargs: size_t* Number of arguments contained in ap. On return, the number of arguments assigned will be assigned to this address.
  • ap: va_list_t Arguments that should be assigned based on the deserialized data.

Private Members

const int as_array_
asciiTable_t *table_
class PlyMetaschemaType : public MetaschemaType
#include <PlyMetaschemaType.h>

Class for PLY type definition.

The PlyMetaschemaType provides basic functionality for encoding/decoding Ply structures from/to JSON style strings.

Public Functions

PlyMetaschemaType()

Constructor for PlyMetaschemaType.

PlyMetaschemaType(const rapidjson::Value &type_doc)

Constructor for PlyMetaschemaType from a JSON type defintion.

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

PlyMetaschemaType *copy()

Create a copy of the type.

Return
pointer to new PlyMetaschemaType instance with the same data.

virtual size_t nargs_exp()

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

Return
size_t Number of arguments.

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

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

Return
bool true if the encoding was successful, false otherwise.
Parameters
  • writer: rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.
  • nargs: size_t * Pointer to the number of arguments contained in ap. On return it will be set to the number of arguments used.
  • ap: va_list_t Variable number of arguments that should be encoded as a JSON string.

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

Decode variables from a JSON string.

Return
bool true if the data was successfully decoded, false otherwise.
Parameters
  • data: rapidjson::Value Reference to entry in JSON string.
  • allow_realloc: int If 1, the passed variables will be reallocated to contain the deserialized data.
  • nargs: 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: va_list_t Reference to variable argument list containing address where deserialized data should be assigned.

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

Class for OBJ type definition.

The ObjMetaschemaType provides basic functionality for encoding/decoding Obj structures from/to JSON style strings.

Public Functions

ObjMetaschemaType()

Constructor for ObjMetaschemaType.

ObjMetaschemaType(const rapidjson::Value &type_doc)

Constructor for ObjMetaschemaType from a JSON type defintion.

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

ObjMetaschemaType *copy()

Create a copy of the type.

Return
pointer to new ObjMetaschemaType instance with the same data.

virtual size_t nargs_exp()

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

Return
size_t Number of arguments.

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

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

Return
bool true if the encoding was successful, false otherwise.
Parameters
  • writer: rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.
  • nargs: size_t * Pointer to the number of arguments contained in ap. On return it will be set to the number of arguments used.
  • ap: va_list_t Variable number of arguments that should be encoded as a JSON string.

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

Decode variables from a JSON string.

Return
bool true if the data was successfully decoded, false otherwise.
Parameters
  • data: rapidjson::Value Reference to entry in JSON string.
  • allow_realloc: int If 1, the passed variables will be reallocated to contain the deserialized data.
  • nargs: 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: va_list_t Reference to variable argument list containing address where deserialized data should be assigned.

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

Class for sending strings directly.

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

Public Functions

DirectMetaschemaType()

Constructor for MetaschemaType.

DirectMetaschemaType(const rapidjson::Value &type_doc)

Constructor for DirectMetaschemaType from a JSON type defintion.

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

DirectMetaschemaType *copy()

Create a copy of the type.

Return
pointer to new DirectMetaschemaType instance with the same data.

size_t nargs_exp()

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

Return
size_t Number of arguments.

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

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

Return
bool true if the encoding was successful, false otherwise.
Parameters
  • writer: rapidjson::Writer<rapidjson::StringBuffer> rapidjson writer.
  • nargs: size_t * Pointer to the number of arguments contained in ap. On return it will be set to the number of arguments used.
  • ap: va_list_t Variable number of arguments that should be encoded as a JSON string.

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.

Return
int Size of the serialized data in buf.
Parameters
  • buf: char ** Buffer where serialized data should be written.
  • buf_siz: size_t* Size of buf. If buf is reallocated, the new size of the buffer will be assigned to this address.
  • allow_realloc: 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: size_t Number of arguments contained in ap. On output the number of arguments used will be assigned to this address.
  • ap: va_list_t Variable number of arguments that will be serialized.

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

Decode variables from a JSON string.

Return
bool true if the data was successfully decoded, false otherwise.
Parameters
  • data: rapidjson::Value Reference to entry in JSON string.
  • allow_realloc: int If 1, the passed variables will be reallocated to contain the deserialized data.
  • nargs: 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: va_list_t Reference to variable argument list containing address where deserialized data should be assigned.

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.

Return
int -1 if there is an error, otherwise the number of arguments remaining in ap.
Parameters
  • buf: char* Buffer containing serialized data.
  • buf_siz: size_t Size of the serialized data.
  • allow_realloc: int If 1, the provided variables will be realloced as necessary to house the deserialized data.
  • nargs: size_t* Number of arguments contained in ap. On return, the number of arguments assigned will be assigned to this address.
  • ap: va_list_t Arguments that should be assigned based on the deserialized data.