00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00061 #ifndef KVP_FRAME_H
00062 #define KVP_FRAME_H
00063
00064 #include "gnc-date.h"
00065 #include "gnc-numeric.h"
00066 #include "guid.h"
00067
00068 #define QOF_MOD_KVP "qof.kvp"
00069
00071 typedef struct _KvpFrame KvpFrame;
00072
00075 typedef struct _KvpValue KvpValue;
00076
00088 typedef enum
00089 {
00090 KVP_TYPE_GINT64 = 1,
00091 KVP_TYPE_DOUBLE,
00092 KVP_TYPE_NUMERIC,
00093 KVP_TYPE_STRING,
00094 KVP_TYPE_GUID,
00095 KVP_TYPE_TIMESPEC,
00096 KVP_TYPE_BINARY,
00097 KVP_TYPE_GLIST,
00098 KVP_TYPE_FRAME
00099 , KVP_TYPE_GDATE
00100 } KvpValueType;
00101
00106 #define kvp_frame KvpFrame
00107
00108 #define kvp_value KvpValue
00109
00110 #define kvp_value_t KvpValueType
00111
00117 KvpFrame * kvp_frame_new(void);
00118
00124 void kvp_frame_delete(KvpFrame * frame);
00125
00128 KvpFrame * kvp_frame_copy(const KvpFrame * frame);
00129
00131 gboolean kvp_frame_is_empty(const KvpFrame * frame);
00132
00144 void kvp_frame_set_gint64(KvpFrame * frame, const gchar * path, gint64 ival);
00150 void kvp_frame_set_double(KvpFrame * frame, const gchar * path, double dval);
00151
00156 #define kvp_frame_set_gnc_numeric kvp_frame_set_numeric
00157
00162 void kvp_frame_set_numeric(KvpFrame * frame, const gchar * path, gnc_numeric nval);
00168 void kvp_frame_set_timespec(KvpFrame * frame, const gchar * path, Timespec ts);
00174 void kvp_frame_set_gdate(KvpFrame * frame, const gchar * path, GDate date);
00175
00180 #define kvp_frame_set_str kvp_frame_set_string
00181
00194 void kvp_frame_set_string(KvpFrame * frame, const gchar * path, const gchar* str);
00195 void kvp_frame_set_guid(KvpFrame * frame, const gchar * path, const GncGUID *guid);
00196
00197 void kvp_frame_set_frame(KvpFrame *frame, const gchar *path, KvpFrame *chld);
00198 void kvp_frame_set_frame_nc(KvpFrame *frame, const gchar *path, KvpFrame *chld);
00199
00210 KvpFrame * kvp_frame_set_value(KvpFrame * frame,
00211 const gchar * path, const KvpValue * value);
00225 KvpFrame * kvp_frame_set_value_nc(KvpFrame * frame,
00226 const gchar * path, KvpValue * value);
00227
00236 KvpValue * kvp_frame_replace_value_nc (KvpFrame * frame, const gchar * slot,
00237 KvpValue * new_value);
00254 void kvp_frame_add_frame_nc(KvpFrame *frame, const gchar *path, KvpFrame *chld);
00255
00256
00288 gint64 kvp_frame_get_gint64(const KvpFrame *frame, const gchar *path);
00289 double kvp_frame_get_double(const KvpFrame *frame, const gchar *path);
00290 gnc_numeric kvp_frame_get_numeric(const KvpFrame *frame, const gchar *path);
00291 const gchar * kvp_frame_get_string(const KvpFrame *frame, const gchar *path);
00292 GncGUID * kvp_frame_get_guid(const KvpFrame *frame, const gchar *path);
00293 void * kvp_frame_get_binary(const KvpFrame *frame, const gchar *path,
00294 guint64 * size_return);
00295 Timespec kvp_frame_get_timespec(const KvpFrame *frame, const gchar *path);
00296 KvpValue * kvp_frame_get_value(const KvpFrame *frame, const gchar *path);
00297
00316
00317 KvpFrame * kvp_frame_get_frame(const KvpFrame *frame, const gchar *path);
00318
00332 KvpFrame * kvp_frame_get_frame_path (KvpFrame *frame, const gchar *, ...);
00333
00338 KvpFrame * kvp_frame_get_frame_gslist (KvpFrame *frame,
00339 const GSList *key_path);
00340
00352 KvpFrame * kvp_frame_get_frame_slash (KvpFrame *frame,
00353 const gchar *path);
00354
00377
00378
00379
00380
00387 void kvp_frame_set_slot(KvpFrame * frame,
00388 const gchar * key, const KvpValue * value);
00397 void kvp_frame_set_slot_nc(KvpFrame * frame,
00398 const gchar * key, KvpValue * value);
00399
00405 void kvp_frame_set_slot_path (KvpFrame *frame,
00406 const KvpValue *value,
00407 const gchar *first_key, ...);
00408
00414 void kvp_frame_set_slot_path_gslist (KvpFrame *frame,
00415 const KvpValue *value,
00416 GSList *key_path);
00417
00434 KvpValue * kvp_frame_get_slot(const KvpFrame * frame, const gchar * key);
00435
00439 KvpValue * kvp_frame_get_slot_path (KvpFrame *frame,
00440 const gchar *first_key, ...);
00441
00445 KvpValue * kvp_frame_get_slot_path_gslist (KvpFrame *frame,
00446 const GSList *key_path);
00447
00451 gint kvp_frame_compare(const KvpFrame *fa, const KvpFrame *fb);
00452
00453 gint double_compare(double v1, double v2);
00464 gint kvp_glist_compare(const GList * list1, const GList * list2);
00465
00471 GList * kvp_glist_copy(const GList * list);
00472
00478 void kvp_glist_delete(GList * list);
00492 KvpValue * kvp_value_new_gint64(gint64 value);
00493 KvpValue * kvp_value_new_double(double value);
00494
00499 #define kvp_value_new_gnc_numeric kvp_value_new_numeric
00500 KvpValue * kvp_value_new_numeric(gnc_numeric value);
00501 KvpValue * kvp_value_new_string(const gchar * value);
00502 KvpValue * kvp_value_new_guid(const GncGUID * guid);
00503 KvpValue * kvp_value_new_timespec(Timespec timespec);
00504 KvpValue * kvp_value_new_binary(const void * data, guint64 datasize);
00505 KvpValue * kvp_value_new_frame(const KvpFrame * value);
00506 KvpValue * kvp_value_new_gdate(GDate date);
00507
00510 KvpValue * kvp_value_new_glist(const GList * value);
00511
00514 KvpValue * kvp_value_new_binary_nc(void * data, guint64 datasize);
00515
00522 KvpValue * kvp_value_new_glist_nc(GList *lst);
00523
00526 KvpValue * kvp_value_new_frame_nc(KvpFrame * value);
00527
00529 void kvp_value_delete(KvpValue * value);
00530
00532 KvpValue * kvp_value_copy(const KvpValue * value);
00533
00535 KvpFrame * kvp_value_replace_frame_nc(KvpValue *value, KvpFrame * newframe);
00536
00538 GList * kvp_value_replace_glist_nc(KvpValue *value, GList *newlist);
00539
00549 KvpValueType kvp_value_get_type(const KvpValue * value);
00550
00551
00562 gint64 kvp_value_get_gint64(const KvpValue * value);
00563 double kvp_value_get_double(const KvpValue * value);
00564 gnc_numeric kvp_value_get_numeric(const KvpValue * value);
00565
00568 char * kvp_value_get_string(const KvpValue * value);
00569
00572 GncGUID * kvp_value_get_guid(const KvpValue * value);
00573
00576 void * kvp_value_get_binary(const KvpValue * value,
00577 guint64 * size_return);
00578
00582 GList * kvp_value_get_glist(const KvpValue * value);
00583
00586
00587 KvpFrame * kvp_value_get_frame(const KvpValue * value);
00588 Timespec kvp_value_get_timespec(const KvpValue * value);
00589
00591 GDate kvp_value_get_gdate(const KvpValue * value);
00592
00596 gint kvp_value_compare(const KvpValue *va, const KvpValue *vb);
00597
00605 gchar* kvp_value_to_string(const KvpValue *val);
00606
00610 gboolean kvp_value_binary_append(KvpValue *v, void *data, guint64 size);
00611
00619 void kvp_frame_for_each_slot(KvpFrame *f,
00620 void (*proc)(const gchar *key,
00621 KvpValue *value,
00622 gpointer data),
00623 gpointer data);
00624
00628 gchar* kvp_frame_to_string(const KvpFrame *frame);
00629 gchar* binary_to_string(const void *data, guint32 size);
00630 GHashTable* kvp_frame_get_hash(const KvpFrame *frame);
00631
00633 #endif