00001 
00002 #ifndef  __JBXL_LLSD_TOOL_H_
00003 #define  __JBXL_LLSD_TOOL_H_
00004 
00005 
00016 #include "xtools.h"
00017 #include "txml.h"
00018 
00019 
00020 #define  LLSD_MAKER_UNDEF       '!'
00021 #define  LLSD_MAKER_TRUE        '1'
00022 #define  LLSD_MAKER_FALSE       '0'
00023 #define  LLSD_MAKER_INT         'i'     // 4Byte, need ntohl()
00024 #define  LLSD_MAKER_REAL        'r'     // 8Byte, need ntohull()
00025 #define  LLSD_MAKER_UUID        'u'     // 16Byte
00026 #define  LLSD_MAKER_BIN         'b'     // + ntohl(binary.length) + binary
00027 #define  LLSD_MAKER_STR         's'     // + ntohl(string.length) + string
00028 #define  LLSD_MAKER_URI         'l'     // + ntohl(uri.length) + uri
00029 #define  LLSD_MAKER_KEY         'k'     // + ntohl(key.length) + string 
00030 #define  LLSD_MAKER_DATE        'd'     // + ntohull(seconds_since_epoch)
00031 #define  LLSD_MAKER_ARRAY       '['     // '[' + ntohl(element.number) + (child0, child1, ...) + ']' 
00032 #define  LLSD_MAKER_ARRAY_END   ']'     // 
00033 #define  LLSD_MAKER_MAP         '{'     // '{' + htonl(element.number) + ((key0, value0), (key1, value1), ...)+ '}' 
00034 #define  LLSD_MAKER_MAP_END     '}'     // 
00035 
00036 
00038 Buffer  llsd_bin_get_str (uByte** ptr);
00039 int     llsd_bin_get_int (uByte** ptr);
00040 double  llsd_bin_get_real(uByte** ptr);
00041 Buffer  llsd_bin_get_uuid(uByte** ptr);
00042 Buffer  llsd_bin_get_bin (uByte** ptr);
00043 unsigned long long int llsd_bin_get_date(uByte** ptr);  
00044 
00045 #define llsd_bin_get_key(p)     llsd_bin_get_str((p))   
00046 #define llsd_bin_get_uri(p)     llsd_bin_get_str((p))   
00047 #define llsd_bin_get_map(p)     llsd_bin_get_int((p))   
00048 #define llsd_bin_get_array(p)   llsd_bin_get_int((p))   
00049 
00050 int     llsd_bin_get_length(uByte* ptr, int sz);
00051 tXML*   llsd_bin_parse(uByte* ptr, int sz);
00052 tXML*   llsd_bin_main_parse(tXML* xml, uByte* ptr, int sz);
00053 
00054 
00055 int     llsd_xml_contain_key(tXML* xml, const char* key);
00056 int     llsd_xml_get_content_int (tXML* xml, const char* key, const char* item);
00057 double  llsd_xml_get_content_real(tXML* xml, const char* key, const char* item);
00058 Buffer  llsd_xml_get_content_str (tXML* xml, const char* key, const char* item);
00059 Buffer  llsd_xml_get_content_bin (tXML* xml, const char* key, const char* item);
00060 
00061 
00062 #endif      // __JBXL_LLSD_TOOL_H_
00063