26 #include <sol-common-buildopts.h>
283 SOL_ATTR_WARN_UNUSED_RESULT
293 #ifndef SOL_MEMDESC_DESCRIPTION
295 #define SOL_MEMDESC_DESCRIPTION
296 #undef SOL_MEMDESC_DESCRIPTION
307 #ifdef SOL_MEMDESC_DESCRIPTION
308 #define SOL_MEMDESC_SET_DESCRIPTION(...) __VA_ARGS__
310 #define SOL_MEMDESC_SET_DESCRIPTION(...)
313 #ifndef SOL_NO_API_VERSION
335 #ifndef SOL_NO_API_VERSION
336 #define SOL_MEMDESC_OPS_ARRAY_API_VERSION (1)
337 uint16_t api_version;
363 void *(*get_element)(
const struct sol_memdesc *desc,
const void *memory,
size_t idx);
394 #ifndef SOL_NO_API_VERSION
395 #define SOL_MEMDESC_OPS_ENUMERATION_API_VERSION (1)
396 uint16_t api_version;
405 const char *(*to_str)(
const struct sol_memdesc *desc,
const void *memory);
436 #ifndef SOL_NO_API_VERSION
437 #define SOL_MEMDESC_OPS_API_VERSION (1)
438 uint16_t api_version;
479 int (*
copy)(
const struct sol_memdesc *desc,
const void *src_memory,
void *dst_memory);
515 #ifndef SOL_NO_API_VERSION
516 #define SOL_MEMDESC_API_VERSION (1)
517 uint16_t api_version;
631 #ifdef SOL_MEMDESC_DESCRIPTION
641 const char *description;
696 static inline uint16_t
703 #ifndef SOL_NO_API_VERSION
704 if (desc->
api_version != SOL_MEMDESC_API_VERSION_COMPILED)
709 switch (desc->
type) {
711 return sizeof(uint8_t);
713 return sizeof(uint16_t);
715 return sizeof(uint32_t);
717 return sizeof(uint64_t);
719 return sizeof(
unsigned long);
721 return sizeof(size_t);
723 return sizeof(int8_t);
725 return sizeof(int16_t);
727 return sizeof(int32_t);
729 return sizeof(int64_t);
733 return sizeof(ssize_t);
737 return sizeof(double);
739 return sizeof(
char *);
741 return sizeof(
const char *);
743 return sizeof(
void *);
1015 #define SOL_MEMDESC_FOREACH_ARRAY_ELEMENT_IN_RANGE(desc, memory, start_idx, end_idx, itr_idx, element) \
1016 for (itr_idx = start_idx, \
1017 element = (itr_idx < end_idx) ? sol_memdesc_get_array_element((desc), (memory), itr_idx) : NULL; \
1018 itr_idx < end_idx && element; \
1020 element = (itr_idx < end_idx) ? sol_memdesc_get_array_element((desc), (memory), itr_idx) : NULL)
1028 #ifdef SOL_NO_API_VERSION
1029 #define _SOL_MEMDESC_CHECK_API_VERSION(desc) 1
1031 #define _SOL_MEMDESC_CHECK_API_VERSION(desc) ((desc)->api_version == SOL_MEMDESC_API_VERSION_COMPILED)
1041 #define _SOL_MEMDESC_CHECK(desc) \
1042 ((desc) && _SOL_MEMDESC_CHECK_API_VERSION(desc) && (desc)->type != SOL_MEMDESC_TYPE_UNKNOWN)
1051 #define _SOL_MEMDESC_CHECK_STRUCTURE(structure_desc) \
1052 (_SOL_MEMDESC_CHECK(structure_desc) && (structure_desc)->structure_members && _SOL_MEMDESC_CHECK(&((structure_desc)->structure_members->base)))
1066 #define _SOL_MEMDESC_CHECK_STRUCTURE_MEMBER(structure_desc, member_desc) \
1067 (_SOL_MEMDESC_CHECK(&(member_desc)->base) && \
1068 ((member_desc)->offset + sol_memdesc_get_size(&(member_desc)->base) <= sol_memdesc_get_size((structure_desc))))
1077 #define SOL_MEMDESC_FOREACH_STRUCTURE_MEMBER(structure_desc, member_desc) \
1078 for (member_desc = (_SOL_MEMDESC_CHECK_STRUCTURE((structure_desc)) && _SOL_MEMDESC_CHECK_STRUCTURE_MEMBER((structure_desc), (structure_desc)->structure_members)) ? (structure_desc)->structure_members : NULL; \
1079 _SOL_MEMDESC_CHECK_STRUCTURE_MEMBER((structure_desc), member_desc); \
1080 member_desc = _SOL_MEMDESC_CHECK_STRUCTURE_MEMBER((structure_desc), member_desc + 1) ? member_desc + 1 : NULL)
1091 #define SOL_MEMDESC_FOREACH_STRUCTURE_MEMBER_MEMORY(structure_desc, member_desc, structure_memory, member_memory) \
1092 for (member_desc = (_SOL_MEMDESC_CHECK_STRUCTURE((structure_desc)) && _SOL_MEMDESC_CHECK_STRUCTURE_MEMBER((structure_desc), (structure_desc)->structure_members)) ? (structure_desc)->structure_members : NULL, \
1093 member_memory = member_desc ? sol_memdesc_get_structure_member_memory((structure_desc), member_desc, (structure_memory)) : NULL; \
1094 _SOL_MEMDESC_CHECK_STRUCTURE_MEMBER((structure_desc), member_desc) && member_memory; \
1095 member_desc = _SOL_MEMDESC_CHECK_STRUCTURE_MEMBER((structure_desc), member_desc + 1) ? member_desc + 1 : NULL, \
1096 member_memory = member_desc ? sol_memdesc_get_structure_member_memory((structure_desc), member_desc, (structure_memory)) : NULL)
1120 if (!structure_desc || !name.
len)
1148 static inline void *
1152 if (!structure_desc || !member_desc || !structure_memory)
1155 #ifndef SOL_NO_API_VERSION
1156 if (structure_desc->
api_version != SOL_MEMDESC_API_VERSION_COMPILED)
1158 if (member_desc->
base.
api_version != SOL_MEMDESC_API_VERSION_COMPILED)
1168 return ((uint8_t *)structure_memory) + member_desc->
offset;
1211 static inline uint64_t
1217 if (!desc || !memory)
1220 #ifndef SOL_NO_API_VERSION
1221 if (desc->
api_version != SOL_MEMDESC_API_VERSION_COMPILED)
1226 switch (desc->
type) {
1228 return *(
const uint8_t *)memory;
1230 return *(
const uint16_t *)memory;
1232 return *(
const uint32_t *)memory;
1234 return *(
const uint64_t *)memory;
1236 return *(
const unsigned long *)memory;
1238 return *(
const size_t *)memory;
1240 i64 = *(
const int8_t *)memory;
1243 i64 = *(
const int16_t *)memory;
1246 i64 = *(
const int32_t *)memory;
1249 i64 = *(
const int64_t *)memory;
1252 i64 = *(
const long *)memory;
1255 i64 = *(
const ssize_t *)memory;
1258 return *(
const bool *)memory;
1260 i64 = *(
const double *)memory;
1265 if (desc->
size >
sizeof(int64_t)) {
1269 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
1270 else if (desc->
size <
sizeof(int64_t))
1274 memcpy((uint8_t *)&i64 + offset, memory, desc->
size);
1305 static inline int64_t
1311 if (!desc || !memory)
1314 #ifndef SOL_NO_API_VERSION
1315 if (desc->
api_version != SOL_MEMDESC_API_VERSION_COMPILED)
1320 switch (desc->
type) {
1322 return *(
const uint8_t *)memory;
1324 return *(
const uint16_t *)memory;
1326 return *(
const uint32_t *)memory;
1328 u64 = *(
const uint64_t *)memory;
1329 goto check_overflow;
1331 u64 = *(
const unsigned long *)memory;
1332 goto check_overflow;
1334 u64 = *(
const size_t *)memory;
1335 goto check_overflow;
1337 return *(
const int8_t *)memory;
1339 return *(
const int16_t *)memory;
1341 return *(
const int32_t *)memory;
1343 return *(
const int64_t *)memory;
1345 return *(
const long *)memory;
1347 return *(
const ssize_t *)memory;
1349 return *(
const bool *)memory;
1351 return *(
const double *)memory;
1356 if (desc->
size >
sizeof(int64_t)) {
1360 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
1361 else if (desc->
size <
sizeof(int64_t))
1364 memcpy((uint8_t *)&i64 + offset, memory, desc->
size);
1378 if (u64 > INT64_MAX) {
1399 if (!desc || !memory)
1402 #ifndef SOL_NO_API_VERSION
1403 if (desc->
api_version != SOL_MEMDESC_API_VERSION_COMPILED)
1407 switch (desc->
type) {
1409 if (value > UINT8_MAX)
1411 *(uint8_t *)memory = value;
1414 if (value > UINT16_MAX)
1416 *(uint16_t *)memory = value;
1419 if (value > UINT32_MAX)
1421 *(uint32_t *)memory = value;
1424 *(uint64_t *)memory = value;
1427 if (value > ULONG_MAX)
1429 *(
unsigned long *)memory = value;
1432 if (value > SIZE_MAX)
1434 *(
size_t *)memory = value;
1437 if (value > INT8_MAX)
1439 *(int8_t *)memory = value;
1442 if (value > INT16_MAX)
1444 *(int16_t *)memory = value;
1447 if (value > INT32_MAX)
1449 *(int32_t *)memory = value;
1452 if (value > INT64_MAX)
1454 *(int64_t *)memory = value;
1457 if (value > LONG_MAX)
1459 *(
long *)memory = value;
1464 *(ssize_t *)memory = value;
1467 *(
bool *)memory = !!value;
1470 *(
double *)memory = value;
1475 if (desc->
size >
sizeof(int64_t))
1477 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
1478 else if (desc->
size <
sizeof(int64_t))
1482 if (value > (((uint64_t)1 << (desc->
size * 8 - 1)) - 1))
1485 memcpy(memory, (uint8_t *)&value + offset, desc->
size);
1509 static inline int64_t
1512 if (!desc || !memory)
1515 #ifndef SOL_NO_API_VERSION
1516 if (desc->
api_version != SOL_MEMDESC_API_VERSION_COMPILED)
1520 switch (desc->
type) {
1522 if (value < 0 || value > UINT8_MAX)
1524 *(uint8_t *)memory = value;
1527 if (value < 0 || value > UINT16_MAX)
1529 *(uint16_t *)memory = value;
1532 if (value < 0 || value > UINT32_MAX)
1534 *(uint32_t *)memory = value;
1539 *(uint64_t *)memory = value;
1542 if (value < 0 || (uint64_t)value > ULONG_MAX)
1544 *(
unsigned long *)memory = value;
1547 if (value < 0 || (uint64_t)value > SIZE_MAX)
1549 *(
size_t *)memory = value;
1552 if (value < INT8_MIN || value > INT8_MAX)
1554 *(int8_t *)memory = value;
1557 if (value < INT16_MIN || value > INT16_MAX)
1559 *(int16_t *)memory = value;
1562 if (value < INT32_MIN || value > INT32_MAX)
1564 *(int32_t *)memory = value;
1567 *(int64_t *)memory = value;
1570 if (value < LONG_MIN || value > LONG_MAX)
1572 *(
long *)memory = value;
1575 if (value < SSIZE_MIN || value >
SSIZE_MAX)
1577 *(ssize_t *)memory = value;
1580 *(
bool *)memory = !!value;
1583 *(
double *)memory = value;
1588 if (desc->
size >
sizeof(int64_t))
1590 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
1591 else if (desc->
size <
sizeof(int64_t))
1595 if (desc->
size <
sizeof(int64_t)) {
1596 if (value > (((int64_t)1 << (desc->
size * 8 - 1)) - 1))
1598 if (value < -((int64_t)1 << (desc->
size * 8 - 1)))
1602 memcpy(memory, (uint8_t *)&value + offset, desc->
size);
1630 #ifndef SOL_NO_API_VERSION
1631 if (desc->
api_version != SOL_MEMDESC_API_VERSION_COMPILED)
1636 switch (desc->
type) {
1678 #ifndef SOL_NO_API_VERSION
1679 if (desc->
api_version != SOL_MEMDESC_API_VERSION_COMPILED)
1684 switch (desc->
type) {
1716 #ifndef SOL_NO_API_VERSION
1717 #define SOL_MEMDESC_SERIALIZE_OPTIONS_API_VERSION (1)
1718 uint16_t api_version;
1883 #ifdef SOL_MEMDESC_DESCRIPTION
1915 #ifdef SOL_MEMDESC_DESCRIPTION
1919 bool show_description;
int8_t equivalent (one signed byte).
Definition: sol-memdesc.h:110
uint16_t u16
use when SOL_MEMDESC_TYPE_UINT16
Definition: sol-memdesc.h:553
long l
use when SOL_MEMDESC_TYPE_LONG
Definition: sol-memdesc.h:562
int(* serialize_structure_member)(const struct sol_memdesc *structure, const struct sol_memdesc_structure_member *member, const void *memory, struct sol_buffer *buffer, const struct sol_memdesc_serialize_options *opts, struct sol_buffer *prefix, bool is_first)
function used to format a struct member.
Definition: sol-memdesc.h:1810
int sol_memdesc_init_defaults(const struct sol_memdesc *desc, void *memory)
initialize the memory.
int16_t equivalent (two signed bytes).
Definition: sol-memdesc.h:117
static uint16_t sol_memdesc_get_size(const struct sol_memdesc *desc)
get the size in bytes of the memory description.
Definition: sol-memdesc.h:697
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.
Definition: sol-memdesc.h:1510
static bool sol_memdesc_is_unsigned_integer(const struct sol_memdesc *desc)
Helper to check if type is unsigned integer-compatible.
Definition: sol-memdesc.h:1624
const struct sol_str_slice start
Used when starting a new structure.
Definition: sol-memdesc.h:1839
#define SOL_MEMDESC_FOREACH_STRUCTURE_MEMBER(structure_desc, member_desc)
Macro to loop over all structure members.
Definition: sol-memdesc.h:1077
const struct sol_str_slice end
Used when finishing a structure.
Definition: sol-memdesc.h:1843
int sol_memdesc_copy(const struct sol_memdesc *desc, const void *src_memory, void *dst_memory)
copy the memory using the given description.
uint32_t equivalent (four unsigned bytes).
Definition: sol-memdesc.h:82
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.
Definition: sol-memdesc.h:1397
int(* init_defaults)(const struct sol_memdesc *desc, void *memory)
initialize the defaults of memory.
Definition: sol-memdesc.h:450
struct sol_memdesc_ops sol_memdesc_ops
override operations to be used in this memory description.
const struct sol_memdesc_serialize_options SOL_MEMDESC_SERIALIZE_OPTIONS_DEFAULT
the default struct sol_memdesc_serialize_options.
int(* from_str)(const struct sol_memdesc *desc, void *ptr_return, const struct sol_str_slice str)
convert enumeration value from string.
Definition: sol-memdesc.h:419
int(* resize)(const struct sol_memdesc *desc, void *memory, size_t length)
resize array length.
Definition: sol-memdesc.h:381
static void sol_memdesc_free(const struct sol_memdesc *desc, void *memory)
Free the contents and the memory.
Definition: sol-memdesc.h:857
enum sol_memdesc_type type
basic type of the member memory.
Definition: sol-memdesc.h:537
const struct sol_memdesc_structure_member * structure_members
null-terminated array of structure members.
Definition: sol-memdesc.h:596
struct sol_memdesc_structure_member sol_memdesc_structure_member
Description of a structure member.
uint16_t offset
offset in bytes relative to containing structure memory.
Definition: sol-memdesc.h:650
int(* serialize_array_item)(const struct sol_memdesc *desc, size_t idx, const void *memory, struct sol_buffer *buffer, const struct sol_memdesc_serialize_options *opts, struct sol_buffer *prefix)
function used to format an array item.
Definition: sol-memdesc.h:1827
unsigned long ul
use when SOL_MEMDESC_TYPE_ULONG
Definition: sol-memdesc.h:556
static bool sol_memdesc_is_signed_integer(const struct sol_memdesc *desc)
Helper to check if type is signed integer-compatible.
Definition: sol-memdesc.h:1672
int(* serialize_double)(const struct sol_memdesc *desc, double value, struct sol_buffer *buffer)
function used to format a double precision floating point number.
Definition: sol-memdesc.h:1743
const char * s
use when SOL_MEMDESC_TYPE_STRING or SOL_MEMDESC_TYPE_CONST_STRING
Definition: sol-memdesc.h:567
double d
use when SOL_MEMDESC_TYPE_DOUBLE
Definition: sol-memdesc.h:565
Operations specific to SOL_MEMDESC_TYPE_ENUMERATION.
Definition: sol-memdesc.h:393
bool optional
whenever member is mandatory in serialization and parsing.
Definition: sol-memdesc.h:657
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.
Definition: sol-memdesc.h:1212
int sol_memdesc_free_content(const struct sol_memdesc *desc, void *memory)
free the contents (internal memory) of a member.
not to be used.
Definition: sol-memdesc.h:61
int sol_memdesc_compare(const struct sol_memdesc *desc, const void *a_memory, const void *b_memory)
compare two memories using the given description.
struct sol_memdesc_serialize_options::@22 array
options used by serialize_array_item
struct sol_memdesc base
Definition: sol-memdesc.h:623
uint64_t u64
use when SOL_MEMDESC_TYPE_UINT64
Definition: sol-memdesc.h:555
const struct sol_memdesc_ops SOL_MEMDESC_OPS_PTR_VECTOR
operations to handle struct sol_ptr_vector.
const struct sol_memdesc * array_item
Type of array item.
Definition: sol-memdesc.h:588
struct sol_memdesc_serialize_options::@22::@27 index
const char * sol_memdesc_type_to_str(enum sol_memdesc_type type)
Converts a sol_memdesc_type to a string.
int(* free_content)(const struct sol_memdesc *desc, void *memory)
free the contents (internal memory) of a memory.
Definition: sol-memdesc.h:504
int(* serialize_uint64)(const struct sol_memdesc *desc, uint64_t value, struct sol_buffer *buffer)
function used to format an unsigned integer.
Definition: sol-memdesc.h:1735
These are common Soletta macros.
const void * p
use when SOL_MEMDESC_TYPE_PTR, SOL_MEMDESC_TYPE_STRUCTURE or SOL_MEMDESC_TYPE_ARRAY ...
Definition: sol-memdesc.h:568
uint8_t u8
use when SOL_MEMDESC_TYPE_UINT8
Definition: sol-memdesc.h:552
String/int64_t table type.
Definition: sol-str-table.h:228
static int sol_memdesc_append_array_element(const struct sol_memdesc *array_desc, void *memory, const void *ptr_content)
Append the array element.
Definition: sol-memdesc.h:977
int(* compare)(const struct sol_memdesc *desc, const void *a_memory, const void *b_memory)
compare the content of two memories.
Definition: sol-memdesc.h:492
static struct sol_buffer value
Definition: server.c:42
ssize_t ssz
use when SOL_MEMDESC_TYPE_SSIZE
Definition: sol-memdesc.h:563
int8_t i8
use when SOL_MEMDESC_TYPE_INT8
Definition: sol-memdesc.h:558
int32_t i32
use when SOL_MEMDESC_TYPE_INT32
Definition: sol-memdesc.h:560
boolean equivalent.
Definition: sol-memdesc.h:152
uint16_t equivalent (two unsigned bytes).
Definition: sol-memdesc.h:75
size_t equivalent (four or eight unsigned bytes, depends on platform).
Definition: sol-memdesc.h:103
const char * sol_memdesc_enumeration_to_str(const struct sol_memdesc *enumeration, const void *memory)
convert enumeration value to string.
String slice type.
Definition: sol-str-slice.h:84
These are routines that Soletta provides for its buffer implementation.
struct sol_memdesc_serialize_options::@21 structure
options used by serialize_structure_member.
struct sol_memdesc_ops_enumeration sol_memdesc_ops_enumeration
Operations specific to SOL_MEMDESC_TYPE_ENUMERATION.
#define SOL_ATTR_WARN_UNUSED_RESULT
Causes a warning to be emitted if a caller of the function with this attribute does not use its retur...
Definition: sol-macros.h:187
int64_t e
use when SOL_MEMDESC_TYPE_ENUMERATION
Definition: sol-memdesc.h:566
enum sol_memdesc_type sol_memdesc_type_from_str(const char *str)
Converts a Memdesc Type from string to sol_memdesc_type.
null-terminated C-string (char*).
Definition: sol-memdesc.h:169
union sol_memdesc::@18 defcontent
default contents to be used if required == false.
uint64_t equivalent (four unsigned bytes).
Definition: sol-memdesc.h:89
bool detailed
Controls whenever struct sol_memdesc_structure_member::detail is to be printed.
Definition: sol-memdesc.h:1914
int(* serialize_int64)(const struct sol_memdesc *desc, int64_t value, struct sol_buffer *buffer)
function used to format a signed integer.
Definition: sol-memdesc.h:1727
bool b
use when SOL_MEMDESC_TYPE_BOOL
Definition: sol-memdesc.h:564
int16_t i16
use when SOL_MEMDESC_TYPE_INT16
Definition: sol-memdesc.h:559
uint32_t u32
use when SOL_MEMDESC_TYPE_UINT32
Definition: sol-memdesc.h:554
bool detail
whenever member is extended detail.
Definition: sol-memdesc.h:664
ssize_t(* get_length)(const struct sol_memdesc *desc, const void *memory)
calculate array length.
Definition: sol-memdesc.h:352
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.
Definition: sol-memdesc.h:1149
const char * name
memory name, such as the member name in a structure.
Definition: sol-memdesc.h:630
const struct sol_memdesc * pointed_item
Type of a memory pointer.
Definition: sol-memdesc.h:582
int(* copy)(const struct sol_memdesc *desc, const void *src_memory, void *dst_memory)
copy the content from another memory.
Definition: sol-memdesc.h:479
null-terminated C-string (const char*).
Definition: sol-memdesc.h:179
int sol_memdesc_resize_array(const struct sol_memdesc *array_desc, void *memory, size_t length)
Resize the length of an array.
int64_t equivalent (eight signed bytes).
Definition: sol-memdesc.h:131
int64_t i64
use when SOL_MEMDESC_TYPE_INT64
Definition: sol-memdesc.h:561
size_t sz
use when SOL_MEMDESC_TYPE_SIZE
Definition: sol-memdesc.h:557
#define SSIZE_MAX
Maximum value of a ssize variable.
Definition: sol-types.h:102
enumeration
Definition: sol-memdesc.h:201
struct sol_memdesc_ops_array sol_memdesc_ops_array
Operations specific to SOL_MEMDESC_TYPE_ARRAY.
const struct sol_str_slice indent
Used to indent a new container.
Definition: sol-memdesc.h:1847
const struct sol_memdesc_ops * ops
Override operations to use when operating on the memory.
Definition: sol-memdesc.h:611
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.
struct sol_memdesc_serialize_options::@21::@25 value
Description of a structure member.
Definition: sol-memdesc.h:622
an array with internal members.
Definition: sol-memdesc.h:260
const struct sol_memdesc_ops_array * array
Definition: sol-memdesc.h:506
Data type to describe a memory region.
Definition: sol-memdesc.h:514
sol_memdesc_type
Designates the type of the memory description.
Definition: sol-memdesc.h:60
struct sol_memdesc_serialize_options sol_memdesc_serialize_options
Options on how to serialize a memory given its description.
signed long equivalent.
Definition: sol-memdesc.h:138
uint16_t api_version
API version, must match SOL_MEMDESC_API_VERSION at runtime.
Definition: sol-memdesc.h:517
const struct sol_memdesc_ops SOL_MEMDESC_OPS_VECTOR
operations to handle struct sol_vector.
int sol_memdesc_set_content(const struct sol_memdesc *desc, void *memory, const void *ptr_content)
set the content of this memory.
const uint16_t SOL_MEMDESC_API_VERSION_COMPILED
the SOL_MEMDESC_API_VERSION this soletta build used.
const struct sol_memdesc_ops_enumeration * enumeration
Definition: sol-memdesc.h:507
These are routines that Soletta provides for its string slice implementation.
const struct sol_str_table_int64 * enumeration_mapping
null-terminated array of struct sol_str_table.
Definition: sol-memdesc.h:603
bool show_index
Controls whenever the index is to be serialized.
Definition: sol-memdesc.h:1984
int(* serialize_pointer)(const struct sol_memdesc *desc, const void *value, struct sol_buffer *buffer)
function used to format a pointer.
Definition: sol-memdesc.h:1764
struct sol_memdesc sol_memdesc
Data type to describe a memory region.
ssize_t sol_memdesc_get_array_length(const struct sol_memdesc *array_desc, const void *memory)
Get the length of an array.
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.
Options on how to serialize a memory given its description.
Definition: sol-memdesc.h:1715
bool show_key
Controls whenever the key is to be serialized.
Definition: sol-memdesc.h:1906
int32_t equivalent (four signed bytes).
Definition: sol-memdesc.h:124
These are routines that Soletta provides for its string table implementation.
ssize_t equivalent (four or eight signed bytes, depends on platform).
Definition: sol-memdesc.h:145
unsigned long equivalent.
Definition: sol-memdesc.h:96
struct sol_memdesc_serialize_options::@21::@24 key
structure with internal members.
Definition: sol-memdesc.h:231
int(* serialize_bool)(const struct sol_memdesc *desc, bool value, struct sol_buffer *buffer)
function used to format a boolean.
Definition: sol-memdesc.h:1751
double precision floating point equivalent.
Definition: sol-memdesc.h:159
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.
Definition: sol-memdesc.h:1115
int(* set_content)(const struct sol_memdesc *desc, void *memory, const void *ptr_content)
sets the content of a memory.
Definition: sol-memdesc.h:467
struct sol_memdesc_serialize_options::@21::@23 container
generic pointer (void *).
Definition: sol-memdesc.h:218
A sol_buffer is a dynamic array, that can be resized if needed.
Definition: sol-buffer.h:130
int(* serialize_string)(const struct sol_memdesc *desc, const char *value, struct sol_buffer *buffer)
function used to format a string.
Definition: sol-memdesc.h:1775
uint16_t size
size in bytes of the member memory.
Definition: sol-memdesc.h:528
struct sol_str_slice separator
Used if multiple members exist.
Definition: sol-memdesc.h:1902
void * sol_memdesc_get_array_element(const struct sol_memdesc *array_desc, const void *memory, size_t idx)
Get the array element.
Operations specific to SOL_MEMDESC_TYPE_ARRAY.
Definition: sol-memdesc.h:334
uint8_t equivalent (one unsigned byte).
Definition: sol-memdesc.h:68
static bool sol_str_slice_str_eq(const struct sol_str_slice a, const char *b)
Checks if the content of the slice is equal to the string.
Definition: sol-str-slice.h:100
static void * sol_memdesc_new_with_defaults(const struct sol_memdesc *desc)
Allocate the memory required by this description and initialize it.
Definition: sol-memdesc.h:877
int(* serialize_enumeration)(const struct sol_memdesc *desc, const void *memory, struct sol_buffer *buffer)
function used to format an enumeration.
Definition: sol-memdesc.h:1789
override operations to be used in this memory description.
Definition: sol-memdesc.h:435
size_t len
Slice length.
Definition: sol-str-slice.h:85
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.
Definition: sol-memdesc.h:1306