Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
sol-memdesc.h File Reference

These are routines that Soletta provides for its memory description (memdesc) implementation. More...

#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <sol-common-buildopts.h>
#include <sol-str-slice.h>
#include <sol-str-table.h>
#include <sol-macros.h>
#include <sol-buffer.h>

Go to the source code of this file.

Data Structures

struct  sol_memdesc
 Data type to describe a memory region. More...
 
struct  sol_memdesc_ops
 override operations to be used in this memory description. More...
 
struct  sol_memdesc_ops_array
 Operations specific to SOL_MEMDESC_TYPE_ARRAY. More...
 
struct  sol_memdesc_ops_enumeration
 Operations specific to SOL_MEMDESC_TYPE_ENUMERATION. More...
 
struct  sol_memdesc_serialize_options
 Options on how to serialize a memory given its description. More...
 
struct  sol_memdesc_structure_member
 Description of a structure member. More...
 

Macros

#define _SOL_MEMDESC_CHECK(desc)   ((desc) && _SOL_MEMDESC_CHECK_API_VERSION(desc) && (desc)->type != SOL_MEMDESC_TYPE_UNKNOWN)
 Helper to check for a valid struct sol_memdesc. More...
 
#define _SOL_MEMDESC_CHECK_API_VERSION(desc)   ((desc)->api_version == SOL_MEMDESC_API_VERSION_COMPILED)
 Helper to check api-version if needed. More...
 
#define _SOL_MEMDESC_CHECK_STRUCTURE(structure_desc)   (_SOL_MEMDESC_CHECK(structure_desc) && (structure_desc)->structure_members && _SOL_MEMDESC_CHECK(&((structure_desc)->structure_members->base)))
 Helper to check for a valid struct sol_memdesc of type SOL_MEMDESC_TYPE_STRUCTURE. More...
 
#define _SOL_MEMDESC_CHECK_STRUCTURE_MEMBER(structure_desc, member_desc)
 Helper to check for a valid struct sol_memdesc of type SOL_MEMDESC_TYPE_STRUCTURE and if member is within structure boundaries. More...
 
#define SOL_MEMDESC_API_VERSION   (1)
 API version to use in struct sol_memdesc::api_version. More...
 
#define SOL_MEMDESC_DESCRIPTION
 This is selected at compile time to allow reducing binary size if this cpp symbol is undefined. More...
 
#define SOL_MEMDESC_FOREACH_ARRAY_ELEMENT_IN_RANGE(desc, memory, start_idx, end_idx, itr_idx, element)
 Macro to loop of array elements in a given range. More...
 
#define SOL_MEMDESC_FOREACH_STRUCTURE_MEMBER(structure_desc, member_desc)
 Macro to loop over all structure members. More...
 
#define SOL_MEMDESC_FOREACH_STRUCTURE_MEMBER_MEMORY(structure_desc, member_desc, structure_memory, member_memory)
 Macro to loop over all structure members and associated memory. More...
 
#define SOL_MEMDESC_OPS_API_VERSION   (1)
 API version to use in struct sol_memdesc_ops::api_version. More...
 
#define SOL_MEMDESC_OPS_ARRAY_API_VERSION   (1)
 API version to use in struct sol_memdesc_ops_array::api_version. More...
 
#define SOL_MEMDESC_OPS_ENUMERATION_API_VERSION   (1)
 API version to use in struct sol_memdesc_ops_enumeration::api_version. More...
 
#define SOL_MEMDESC_SERIALIZE_OPTIONS_API_VERSION   (1)
 API version to use in struct sol_memdesc_serialize_options::api_version. More...
 
#define SOL_MEMDESC_SET_DESCRIPTION(...)
 Helper to set the description member of struct sol_memdesc if that is available (conditional to SOL_MEMDESC_SET_DESCRIPTION). More...
 

Typedefs

typedef struct sol_memdesc sol_memdesc
 Data type to describe a memory region. More...
 
typedef struct sol_memdesc_ops sol_memdesc_ops
 override operations to be used in this memory description. More...
 
typedef struct
sol_memdesc_ops_array 
sol_memdesc_ops_array
 Operations specific to SOL_MEMDESC_TYPE_ARRAY. More...
 
typedef struct
sol_memdesc_ops_enumeration 
sol_memdesc_ops_enumeration
 Operations specific to SOL_MEMDESC_TYPE_ENUMERATION. More...
 
typedef struct
sol_memdesc_serialize_options 
sol_memdesc_serialize_options
 Options on how to serialize a memory given its description. More...
 
typedef struct
sol_memdesc_structure_member 
sol_memdesc_structure_member
 Description of a structure member. More...
 

Enumerations

enum  sol_memdesc_type {
  SOL_MEMDESC_TYPE_UNKNOWN = 0, SOL_MEMDESC_TYPE_UINT8, SOL_MEMDESC_TYPE_UINT16, SOL_MEMDESC_TYPE_UINT32,
  SOL_MEMDESC_TYPE_UINT64, SOL_MEMDESC_TYPE_ULONG, SOL_MEMDESC_TYPE_SIZE, SOL_MEMDESC_TYPE_INT8,
  SOL_MEMDESC_TYPE_INT16, SOL_MEMDESC_TYPE_INT32, SOL_MEMDESC_TYPE_INT64, SOL_MEMDESC_TYPE_LONG,
  SOL_MEMDESC_TYPE_SSIZE, SOL_MEMDESC_TYPE_BOOL, SOL_MEMDESC_TYPE_DOUBLE, SOL_MEMDESC_TYPE_STRING,
  SOL_MEMDESC_TYPE_CONST_STRING, SOL_MEMDESC_TYPE_ENUMERATION, SOL_MEMDESC_TYPE_PTR, SOL_MEMDESC_TYPE_STRUCTURE,
  SOL_MEMDESC_TYPE_ARRAY
}
 Designates the type of the memory description. More...
 

Functions

static int sol_memdesc_append_array_element (const struct sol_memdesc *array_desc, void *memory, const void *ptr_content)
 Append the array element. More...
 
int sol_memdesc_compare (const struct sol_memdesc *desc, const void *a_memory, const void *b_memory)
 compare two memories using the given description. More...
 
int sol_memdesc_copy (const struct sol_memdesc *desc, const void *src_memory, void *dst_memory)
 copy the memory using the given description. More...
 
int sol_memdesc_enumeration_from_str (const struct sol_memdesc *enumeration, void *ptr_return, const struct sol_str_slice str)
 convert enumeration value from string. More...
 
const char * sol_memdesc_enumeration_to_str (const struct sol_memdesc *enumeration, const void *memory)
 convert enumeration value to string. More...
 
static const struct
sol_memdesc_structure_member
sol_memdesc_find_structure_member (const struct sol_memdesc *structure_desc, struct sol_str_slice name)
 Find structure member given its name. More...
 
static void sol_memdesc_free (const struct sol_memdesc *desc, void *memory)
 Free the contents and the memory. More...
 
int sol_memdesc_free_content (const struct sol_memdesc *desc, void *memory)
 free the contents (internal memory) of a member. More...
 
void * sol_memdesc_get_array_element (const struct sol_memdesc *array_desc, const void *memory, size_t idx)
 Get the array element. More...
 
ssize_t sol_memdesc_get_array_length (const struct sol_memdesc *array_desc, const void *memory)
 Get the length of an array. More...
 
static int64_t sol_memdesc_get_as_int64 (const struct sol_memdesc *desc, const void *memory)
 Helper to fetch the memory as the largest supported signed integer. More...
 
static uint64_t sol_memdesc_get_as_uint64 (const struct sol_memdesc *desc, const void *memory)
 Helper to fetch the memory as the largest supported unsigned integer. More...
 
static uint16_t sol_memdesc_get_size (const struct sol_memdesc *desc)
 get the size in bytes of the memory description. More...
 
static void * sol_memdesc_get_structure_member_memory (const struct sol_memdesc *structure_desc, const struct sol_memdesc_structure_member *member_desc, const void *structure_memory)
 get the pointer to the struct member memory description inside the given container. More...
 
int sol_memdesc_init_defaults (const struct sol_memdesc *desc, void *memory)
 initialize the memory. More...
 
static bool sol_memdesc_is_signed_integer (const struct sol_memdesc *desc)
 Helper to check if type is signed integer-compatible. More...
 
static bool sol_memdesc_is_unsigned_integer (const struct sol_memdesc *desc)
 Helper to check if type is unsigned integer-compatible. More...
 
static void * sol_memdesc_new_with_defaults (const struct sol_memdesc *desc)
 Allocate the memory required by this description and initialize it. More...
 
int sol_memdesc_resize_array (const struct sol_memdesc *array_desc, void *memory, size_t length)
 Resize the length of an array. More...
 
int sol_memdesc_serialize (const struct sol_memdesc *desc, const void *memory, struct sol_buffer *buffer, const struct sol_memdesc_serialize_options *opts, struct sol_buffer *prefix)
 Serialize a memory to a buffer using a description. More...
 
static int64_t sol_memdesc_set_as_int64 (const struct sol_memdesc *desc, void *memory, int64_t value)
 Helper to set the memory as the largest supported signed integer. More...
 
static int sol_memdesc_set_as_uint64 (const struct sol_memdesc *desc, void *memory, uint64_t value)
 Helper to set the memory as the largest supported unsigned integer. More...
 
int sol_memdesc_set_content (const struct sol_memdesc *desc, void *memory, const void *ptr_content)
 set the content of this memory. More...
 
enum sol_memdesc_type sol_memdesc_type_from_str (const char *str)
 Converts a Memdesc Type from string to sol_memdesc_type. More...
 
const char * sol_memdesc_type_to_str (enum sol_memdesc_type type)
 Converts a sol_memdesc_type to a string. More...
 

Variables

const uint16_t SOL_MEMDESC_API_VERSION_COMPILED
 the SOL_MEMDESC_API_VERSION this soletta build used. More...
 
const struct sol_memdesc_ops SOL_MEMDESC_OPS_PTR_VECTOR
 operations to handle struct sol_ptr_vector. More...
 
const struct sol_memdesc_ops SOL_MEMDESC_OPS_VECTOR
 operations to handle struct sol_vector. More...
 
const struct
sol_memdesc_serialize_options 
SOL_MEMDESC_SERIALIZE_OPTIONS_DEFAULT
 the default struct sol_memdesc_serialize_options. More...
 

Detailed Description

These are routines that Soletta provides for its memory description (memdesc) implementation.

Macro Definition Documentation

#define SOL_MEMDESC_API_VERSION   (1)

API version to use in struct sol_memdesc::api_version.

#define SOL_MEMDESC_OPS_API_VERSION   (1)

API version to use in struct sol_memdesc_ops::api_version.

#define SOL_MEMDESC_OPS_ARRAY_API_VERSION   (1)

API version to use in struct sol_memdesc_ops_array::api_version.

#define SOL_MEMDESC_OPS_ENUMERATION_API_VERSION   (1)

API version to use in struct sol_memdesc_ops_enumeration::api_version.

#define SOL_MEMDESC_SERIALIZE_OPTIONS_API_VERSION   (1)

API version to use in struct sol_memdesc_serialize_options::api_version.