Tny
A simple data serializer in C
/home/nop/Eclipse-CDT/workspace/Tny/src/tny/tny.h
Go to the documentation of this file.
00001 
00048 #ifndef TNY_H_
00049 #define TNY_H_
00050 
00051 #include <stddef.h>
00052 #include <stdint.h>
00053 
00054 typedef enum {
00055     ORDER_LITTLE_ENDIAN = 0x03020100ul,
00056     ORDER_BIG_ENDIAN = 0x00010203ul
00057 } TnyEndianness;
00058 
00059 union tnyHostOrder {
00060         unsigned char bytes[4];
00061         uint32_t value;
00062 };
00063 
00064 extern union tnyHostOrder tnyHostOrder;
00065 
00066 #define HOST_ORDER (tnyHostOrder.value)
00067 
00072 typedef enum {
00073         TNY_NULL,               
00074         TNY_ARRAY,              
00075         TNY_DICT,               
00076         TNY_OBJ,                
00077         TNY_BIN,                
00078         TNY_CHAR,               
00079         TNY_INT32,              
00080         TNY_INT64,              
00081         TNY_DOUBLE              
00082 } TnyType;
00083 
00087 typedef struct _Tny {
00088         struct _Tny *prev;                      
00089         struct _Tny *next;                      
00090         struct _Tny *root;                      
00091         TnyType type;                           
00093         size_t docSize;                         
00095         size_t *docSizePtr;                     
00096         uint32_t size;                          
00098         char *key;                                      
00099         union {
00100                 struct _Tny *tny;
00101                 void *ptr;
00102                 uint64_t num;
00103                 double flt;
00104                 char chr;
00105         } value;                                        
00106 } Tny;
00107 
00126 Tny* Tny_add(Tny *prev, TnyType type, char *key, void *value, uint64_t size);
00127 
00137 Tny* Tny_copy(size_t *docSizePtr, const Tny *src);
00138 
00146 void Tny_remove(Tny *tny);
00147 
00159 Tny* Tny_at(const Tny* tny, size_t index);
00160 
00172 Tny* Tny_get(const Tny* tny, const char *key);
00173 
00187 size_t Tny_dumps(const Tny *tny, void **data);
00188 
00198 Tny* Tny_loads(void *data, size_t length);
00199 
00209 int Tny_hasNext(const Tny *tny);
00210 
00218 Tny* Tny_next(const Tny *tny);
00219 
00225 void Tny_free(Tny *tny);
00226 
00227 #endif /* TNY_H_ */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator