2018-03-03 08:15:19 +01:00
|
|
|
#ifndef __CW_TYPES_H
|
|
|
|
#define __CW_TYPES_H
|
|
|
|
|
2018-03-05 20:39:15 +01:00
|
|
|
#include "mavl.h"
|
2018-03-03 08:15:19 +01:00
|
|
|
|
2018-03-05 20:39:15 +01:00
|
|
|
struct cw_Type{
|
|
|
|
/** A human readable name for this type */
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
/** A pointer to a function to delete elements of this type */
|
|
|
|
void (*del)(mavldata_t *data);
|
|
|
|
|
|
|
|
/** A method to put this object to a buffer */
|
|
|
|
int (*put)(mavldata_t * data, uint8_t*dst);
|
|
|
|
|
|
|
|
/** The get emthod */
|
|
|
|
mavldata_t * (*get)(mavldata_t *data, const uint8_t*src, int len);
|
|
|
|
|
|
|
|
/** A pointer to a function to convert elements of this type to a string.
|
|
|
|
This function is mainly used to store elements to an SQL database
|
|
|
|
or to json strings */
|
|
|
|
int (*to_str)(const mavldata_t * data, char *dst, int max_len);
|
|
|
|
|
|
|
|
/** Cereate an item of this type from a string, which was previously
|
|
|
|
created by the #del function. */
|
2018-03-06 03:08:14 +01:00
|
|
|
mavldata_t * (*from_str)(mavldata_t * data, const char *src);
|
2018-03-05 20:39:15 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
int (*def)(void *, void *);
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
extern const struct cw_Type cw_type_byte;
|
2018-03-03 08:15:19 +01:00
|
|
|
#define CW_TYPE_BYTE (&cw_type_byte)
|
|
|
|
|
2018-03-05 21:42:11 +01:00
|
|
|
extern const struct cw_Type cw_type_word;
|
|
|
|
extern const struct cw_Type cw_type_dword;
|
2018-03-06 18:52:45 +01:00
|
|
|
extern const struct cw_Type cw_type_version;
|
2018-03-03 08:15:19 +01:00
|
|
|
|
2018-03-05 21:42:11 +01:00
|
|
|
void cw_types_mavl_delete(mavldata_t *data);
|
2018-03-05 20:39:15 +01:00
|
|
|
|
2018-03-05 21:42:11 +01:00
|
|
|
#define cw_types_mavl_create()\
|
|
|
|
mavl_create(mavl_cmp_kv, cw_types_mavl_delete)
|
2018-03-05 20:39:15 +01:00
|
|
|
|
2018-03-06 03:08:14 +01:00
|
|
|
#endif /* __CW_TYPES_H */
|