GnuCash 2.4.99
kvp_frame.h
Go to the documentation of this file.
00001 /********************************************************************\
00002  * kvp_frame.h -- Implements a key-value frame system               *
00003  * This program is free software; you can redistribute it and/or    *
00004  * modify it under the terms of the GNU General Public License as   *
00005  * published by the Free Software Foundation; either version 2 of   *
00006  * the License, or (at your option) any later version.              *
00007  *                                                                  *
00008  * This program is distributed in the hope that it will be useful,  *
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00011  * GNU General Public License for more details.                     *
00012  *                                                                  *
00013  * You should have received a copy of the GNU General Public License*
00014  * along with this program; if not, contact:                        *
00015  *                                                                  *
00016  * Free Software Foundation           Voice:  +1-617-542-5942       *
00017  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
00018  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
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);
00169 
00174 #define kvp_frame_set_str kvp_frame_set_string
00175 
00188 void kvp_frame_set_string(KvpFrame * frame, const gchar * path, const gchar* str);
00189 void kvp_frame_set_guid(KvpFrame * frame, const gchar * path, const GncGUID *guid);
00190 
00191 void kvp_frame_set_frame(KvpFrame *frame, const gchar *path, KvpFrame *chld);
00192 void kvp_frame_set_frame_nc(KvpFrame *frame, const gchar *path, KvpFrame *chld);
00193 
00204 KvpFrame *   kvp_frame_set_value(KvpFrame * frame,
00205                                  const gchar * path, const KvpValue * value);
00219 KvpFrame *    kvp_frame_set_value_nc(KvpFrame * frame,
00220                                      const gchar * path, KvpValue * value);
00221 
00230 KvpValue * kvp_frame_replace_value_nc (KvpFrame * frame, const gchar * slot,
00231                                        KvpValue * new_value);
00248 void kvp_frame_add_frame_nc(KvpFrame *frame, const gchar *path, KvpFrame *chld);
00249 
00250 
00282 gint64      kvp_frame_get_gint64(const KvpFrame *frame, const gchar *path);
00283 double      kvp_frame_get_double(const KvpFrame *frame, const gchar *path);
00284 gnc_numeric kvp_frame_get_numeric(const KvpFrame *frame, const gchar *path);
00285 const gchar * kvp_frame_get_string(const KvpFrame *frame, const gchar *path);
00286 GncGUID      * kvp_frame_get_guid(const KvpFrame *frame, const gchar *path);
00287 Timespec    kvp_frame_get_timespec(const KvpFrame *frame, const gchar *path);
00288 KvpValue  * kvp_frame_get_value(const KvpFrame *frame, const gchar *path);
00289 
00308 /*@ dependent @*/
00309 KvpFrame  * kvp_frame_get_frame(const KvpFrame *frame, const gchar *path);
00310 
00311 KvpFrame    * kvp_frame_get_frame_slash (KvpFrame *frame,
00312         const gchar *path);
00313 
00336 /* KvpValue * kvp_frame_replace_slot_nc (KvpFrame * frame, const gchar * slot, */
00337 /*                                       KvpValue * new_value); */
00338 
00339 
00346 void          kvp_frame_set_slot(KvpFrame * frame,
00347                                  const gchar * key, const KvpValue * value);
00356 void          kvp_frame_set_slot_nc(KvpFrame * frame,
00357                                     const gchar * key, KvpValue * value);
00358 
00364 void          kvp_frame_set_slot_path (KvpFrame *frame,
00365                                        const KvpValue *value,
00366                                        const gchar *first_key, ...);
00367 
00373 void          kvp_frame_set_slot_path_gslist (KvpFrame *frame,
00374         const KvpValue *value,
00375         GSList *key_path);
00376 
00393 KvpValue   * kvp_frame_get_slot(const KvpFrame * frame, const gchar * key);
00394 
00398 KvpValue   * kvp_frame_get_slot_path (KvpFrame *frame,
00399                                       const gchar *first_key, ...);
00400 
00404 KvpValue   * kvp_frame_get_slot_path_gslist (KvpFrame *frame,
00405         const GSList *key_path);
00406 
00410 gint          kvp_frame_compare(const KvpFrame *fa, const KvpFrame *fb);
00411 
00412 gint          double_compare(double v1, double v2);
00423 gint        kvp_glist_compare(const GList * list1, const GList * list2);
00424 
00430 GList     * kvp_glist_copy(const GList * list);
00431 
00437 void        kvp_glist_delete(GList * list);
00451 KvpValue   * kvp_value_new_gint64(gint64 value);
00452 KvpValue   * kvp_value_new_double(double value);
00453 
00458 #define kvp_value_new_gnc_numeric kvp_value_new_numeric
00459 KvpValue   * kvp_value_new_numeric(gnc_numeric value);
00460 KvpValue   * kvp_value_new_string(const gchar * value);
00461 KvpValue   * kvp_value_new_guid(const GncGUID * guid);
00462 KvpValue   * kvp_value_new_timespec(Timespec timespec);
00463 KvpValue   * kvp_value_new_binary(const void * data, guint64 datasize);
00464 KvpValue   * kvp_value_new_frame(const KvpFrame * value);
00465 KvpValue   * kvp_value_new_gdate(GDate date);
00466 
00469 KvpValue   * kvp_value_new_glist(const GList * value);
00470 
00473 KvpValue   * kvp_value_new_binary_nc(void * data, guint64 datasize);
00474 
00481 KvpValue   * kvp_value_new_glist_nc(GList *lst);
00482 
00485 KvpValue   * kvp_value_new_frame_nc(KvpFrame * value);
00486 
00488 void          kvp_value_delete(KvpValue * value);
00489 
00491 KvpValue   * kvp_value_copy(const KvpValue * value);
00492 
00494 KvpFrame * kvp_value_replace_frame_nc(KvpValue *value, KvpFrame * newframe);
00495 
00497 GList * kvp_value_replace_glist_nc(KvpValue *value, GList *newlist);
00498 
00508 KvpValueType kvp_value_get_type(const KvpValue * value);
00509 
00510 
00521 gint64      kvp_value_get_gint64(const KvpValue * value);
00522 double      kvp_value_get_double(const KvpValue * value);
00523 gnc_numeric kvp_value_get_numeric(const KvpValue * value);
00524 
00527 char        * kvp_value_get_string(const KvpValue * value);
00528 
00531 GncGUID        * kvp_value_get_guid(const KvpValue * value);
00532 
00535 void        * kvp_value_get_binary(const KvpValue * value,
00536                                    guint64 * size_return);
00537 
00541 GList       * kvp_value_get_glist(const KvpValue * value);
00542 
00545 /*@ dependent @*/
00546 KvpFrame   * kvp_value_get_frame(const KvpValue * value);
00547 Timespec    kvp_value_get_timespec(const KvpValue * value);
00548 
00550 GDate    kvp_value_get_gdate(const KvpValue * value);
00551 
00555 gint          kvp_value_compare(const KvpValue *va, const KvpValue *vb);
00556 
00564 gchar* kvp_value_to_string(const KvpValue *val);
00565 
00569 gboolean kvp_value_binary_append(KvpValue *v, void *data, guint64 size);
00570 
00578 void kvp_frame_for_each_slot(KvpFrame *f,
00579                              void (*proc)(const gchar *key,
00580                                      KvpValue *value,
00581                                      gpointer data),
00582                              gpointer data);
00583 
00587 gchar* kvp_frame_to_string(const KvpFrame *frame);
00588 gchar* binary_to_string(const void *data, guint32 size);
00589 GHashTable* kvp_frame_get_hash(const KvpFrame *frame);
00590 
00592 #endif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines