diff options
Diffstat (limited to 'src/lib/eina/eina_intbuf.h')
-rw-r--r-- | src/lib/eina/eina_intbuf.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/src/lib/eina/eina_intbuf.h b/src/lib/eina/eina_intbuf.h new file mode 100644 index 0000000000..b1b635f115 --- /dev/null +++ b/src/lib/eina/eina_intbuf.h @@ -0,0 +1,85 @@ +#ifndef EINA_INTBUF_H +#define EINA_INTBUF_H + +/** + * @addtogroup Eina_Integer_Buffer_Group Compressed Integer Buffer + * + * @brief The functions provide compressed integer buffers management. + * + * The compressed integer buffer data type is designed to be compress once, + * but being read very often and very fast. The data set that it is designed + * for should be incremental integer (positive and negative direction + * are supported). + */ + +/** + * @addtogroup Eina_Data_Types_Group Data Types + * + * @{ + */ + +/** + * @defgroup Eina_Integer_Buffer_Group Compressed Ieger Buffer + * + * @{ + */ + +/** + * @typedef Eina_Intbuf + * Type for a compressed integer buffer. + */ +typedef struct _Eina_Intbuf Eina_Intbuf; + +struct _Eina_Intbuf +{ + int last_data; + unsigned int length; + + unsigned char *bytes; +}; + +/** + * @brief Create a new compressed integer buffer. + * + * @return Newly allocated compressed integer buffer instance. + */ +static inline Eina_Intbuf *eina_intbuf_new(void); + +/** + * @brief Free a compressed integer buffer. + * + * @param buf The compressed integer buffer to free. + */ +static void eina_intbuf_free(Eina_Intbuf *buf); + +/** + * @brief Push an integer at the end of an compressed integer buffer. + * + * @param buf The compressed integer buffer tofree. + * @param data The integer to push in. + */ +static inline void eina_intbuf_push(Eina_Intbuf *buf, int data); + +/** + * @brief + */ +static inline inline Eina_Bool +eina_intbuf_read(Eina_Intbuf *buf, + unsigned int *buffer_offset, + int *data); + +#define EINA_INTBUF_FOREACH(buf, it, data) \ + for (it = 0, data = eina_intbuf_read(buf, &it, data); \ + eina_intbuf_read(buf, &it, &data); ) + +#include "eina_intbuf.x" + +/** + * @} + */ + +/** + * @} + */ + +#endif |