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  * 59 Temple Place - Suite 330        Fax:    +1-617-542-2652       *
00018  * Boston, MA  02111-1307,  USA       gnu@gnu.org                   *
00019  *                                                                  *
00020 \********************************************************************/
00061 #ifndef KVP_FRAME_H
00062 #define KVP_FRAME_H
00063 
00064 #include <glib.h>
00065 
00066 #include "gnc-date.h"
00067 #include "gnc-numeric.h"
00068 #include "guid.h"
00069 
00070 #define QOF_MOD_KVP "qof-kvp"
00071 
00073 typedef struct _KvpFrame KvpFrame;
00074 
00077 typedef struct _KvpValue KvpValue;
00078  
00090 typedef enum {
00091   KVP_TYPE_GINT64=1,   
00092   KVP_TYPE_DOUBLE,     
00093   KVP_TYPE_NUMERIC,    
00094   KVP_TYPE_STRING,     
00095   KVP_TYPE_GUID,       
00096   KVP_TYPE_TIMESPEC,   
00097   KVP_TYPE_BINARY,     
00098   KVP_TYPE_GLIST,      
00099   KVP_TYPE_FRAME       
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(KvpFrame * frame);
00132 
00144 void kvp_frame_set_gint64(KvpFrame * frame, const char * path, gint64 ival);
00150 void kvp_frame_set_double(KvpFrame * frame, const char * 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 char * path, gnc_numeric nval);
00168 void kvp_frame_set_timespec(KvpFrame * frame, const char * path, Timespec ts);
00169 
00174 #define kvp_frame_set_str kvp_frame_set_string
00175 
00188 void kvp_frame_set_string(KvpFrame * frame, const char * path, const char* str);
00189 void kvp_frame_set_guid(KvpFrame * frame, const char * path, const GUID *guid);
00190 
00191 void kvp_frame_set_frame(KvpFrame *frame, const char *path, KvpFrame *chld);
00192 void kvp_frame_set_frame_nc(KvpFrame *frame, const char *path, KvpFrame *chld);
00193 
00204 KvpFrame *   kvp_frame_set_value(KvpFrame * frame, 
00205                                  const char * path, const KvpValue * value);
00219 KvpFrame *    kvp_frame_set_value_nc(KvpFrame * frame, 
00220                                  const char * path, KvpValue * value);
00221 
00230 KvpValue * kvp_frame_replace_value_nc (KvpFrame * frame, const char * slot,
00231                                        KvpValue * new_value);
00248 void     kvp_frame_add_url_encoding (KvpFrame *frame, const char *enc);
00266 void kvp_frame_add_gint64(KvpFrame * frame, const char * path, gint64 ival);
00267 void kvp_frame_add_double(KvpFrame * frame, const char * path, double dval);
00272 #define kvp_frame_add_gnc_numeric kvp_frame_add_numeric
00273 
00274 void kvp_frame_add_numeric(KvpFrame * frame, const char * path, gnc_numeric nval);
00275 void kvp_frame_add_timespec(KvpFrame * frame, const char * path, Timespec ts);
00276 
00281 #define kvp_frame_add_str kvp_frame_add_string
00282 
00297 void kvp_frame_add_string(KvpFrame * frame, const char * path, const char* str);
00298 void kvp_frame_add_guid(KvpFrame * frame, const char * path, const GUID *guid);
00299 
00300 void kvp_frame_add_frame(KvpFrame *frame, const char *path, KvpFrame *chld);
00301 void kvp_frame_add_frame_nc(KvpFrame *frame, const char *path, KvpFrame *chld);
00302 
00303 /* The kvp_frame_add_value() routine will  add a copy of the value
00304  *    to the glist bag at the indicated path. If not all frame components
00305  *    of the path exist, they are created.  If there was another
00306  *    item previously stored at that path, then the path is converted
00307  *    to a bag, and the old value, along with the new value, is added
00308  *    to the bag.  This routine returns the pointer to the last frame
00309  *    (the actual frame to which the value was added), or NULL if there
00310  *    was an error of any sort (typically, a parse error in the path).
00311  * 
00312  *    The *_nc() routine is analogous, except that it doesn't copy the
00313  *    value.
00314  */
00315 KvpFrame * kvp_frame_add_value(KvpFrame * frame, const char * path, KvpValue *value);
00316 KvpFrame * kvp_frame_add_value_nc(KvpFrame * frame, const char * path, KvpValue *value);
00317 
00318 
00350 gint64      kvp_frame_get_gint64(const KvpFrame *frame, const char *path);
00351 double      kvp_frame_get_double(const KvpFrame *frame, const char *path);
00352 gnc_numeric kvp_frame_get_numeric(const KvpFrame *frame, const char *path);
00353 char      * kvp_frame_get_string(const KvpFrame *frame, const char *path);
00354 GUID      * kvp_frame_get_guid(const KvpFrame *frame, const char *path);
00355 void      * kvp_frame_get_binary(const KvpFrame *frame, const char *path,
00356                                    guint64 * size_return); 
00357 Timespec    kvp_frame_get_timespec(const KvpFrame *frame, const char *path);
00358 KvpValue  * kvp_frame_get_value(const KvpFrame *frame, const char *path);
00359 
00378 KvpFrame  * kvp_frame_get_frame(const KvpFrame *frame, const char *path);
00379 
00393 KvpFrame    * kvp_frame_get_frame_path (KvpFrame *frame, const char *,...);
00394 
00399 KvpFrame    * kvp_frame_get_frame_gslist (KvpFrame *frame,
00400                                            GSList *key_path);
00401 
00413 KvpFrame    * kvp_frame_get_frame_slash (KvpFrame *frame,
00414                                           const char *path);
00415 
00438 KvpValue * kvp_frame_replace_slot_nc (KvpFrame * frame, const char * slot,
00439                                  KvpValue * new_value);
00440 
00441 
00448 void          kvp_frame_set_slot(KvpFrame * frame, 
00449                                  const char * key, const KvpValue * value);
00458 void          kvp_frame_set_slot_nc(KvpFrame * frame, 
00459                                     const char * key, KvpValue * value);
00460 
00466 void          kvp_frame_set_slot_path (KvpFrame *frame,
00467                                        const KvpValue *value,
00468                                        const char *first_key, ...);
00469 
00475 void          kvp_frame_set_slot_path_gslist (KvpFrame *frame,
00476                                               const KvpValue *value,
00477                                               GSList *key_path);
00478 
00495 KvpValue   * kvp_frame_get_slot(const KvpFrame * frame, const char * key);
00496 
00500 KvpValue   * kvp_frame_get_slot_path (KvpFrame *frame,
00501                                        const char *first_key, ...);
00502 
00506 KvpValue   * kvp_frame_get_slot_path_gslist (KvpFrame *frame,
00507                                               GSList *key_path);
00508 
00512 gint          kvp_frame_compare(const KvpFrame *fa, const KvpFrame *fb);
00513 
00514 gint          double_compare(double v1, double v2);
00525 gint        kvp_glist_compare(const GList * list1, const GList * list2);
00526 
00532 GList     * kvp_glist_copy(const GList * list);
00533 
00539 void        kvp_glist_delete(GList * list);
00553 KvpValue   * kvp_value_new_gint64(gint64 value);
00554 KvpValue   * kvp_value_new_double(double value);
00555 
00560 #define kvp_value_new_gnc_numeric kvp_value_new_numeric
00561 KvpValue   * kvp_value_new_numeric(gnc_numeric value);
00562 KvpValue   * kvp_value_new_string(const char * value);
00563 KvpValue   * kvp_value_new_guid(const GUID * guid);
00564 KvpValue   * kvp_value_new_timespec(Timespec timespec);
00565 KvpValue   * kvp_value_new_binary(const void * data, guint64 datasize);
00566 KvpValue   * kvp_value_new_frame(const KvpFrame * value);
00567 
00570 KvpValue   * kvp_value_new_glist(const GList * value);
00571 
00574 KvpValue   * kvp_value_new_binary_nc(void * data, guint64 datasize);
00575 
00582 KvpValue   * kvp_value_new_glist_nc(GList *lst);
00583 
00586 KvpValue   * kvp_value_new_frame_nc(KvpFrame * value);
00587 
00589 void          kvp_value_delete(KvpValue * value);
00590 
00592 KvpValue   * kvp_value_copy(const KvpValue * value);
00593 
00595 KvpFrame * kvp_value_replace_frame_nc(KvpValue *value, KvpFrame * newframe);
00596 
00598 GList * kvp_value_replace_glist_nc(KvpValue *value, GList *newlist);
00599 
00609 KvpValueType kvp_value_get_type(const KvpValue * value);
00610 
00611 
00622 gint64      kvp_value_get_gint64(const KvpValue * value);
00623 double      kvp_value_get_double(const KvpValue * value);
00624 gnc_numeric kvp_value_get_numeric(const KvpValue * value);
00625 
00628 char        * kvp_value_get_string(const KvpValue * value);
00629 
00632 GUID        * kvp_value_get_guid(const KvpValue * value);
00633 
00636 void        * kvp_value_get_binary(const KvpValue * value,
00637                                    guint64 * size_return); 
00638 
00642 GList       * kvp_value_get_glist(const KvpValue * value);
00643 
00646 KvpFrame   * kvp_value_get_frame(const KvpValue * value);
00647 Timespec    kvp_value_get_timespec(const KvpValue * value);
00648 
00652 gint          kvp_value_compare(const KvpValue *va, const KvpValue *vb);
00653 
00660 gchar* kvp_value_to_bare_string(const KvpValue *val);
00661 
00667 gchar* kvp_value_to_string(const KvpValue *val);
00668 
00672 gboolean kvp_value_binary_append(KvpValue *v, void *data, guint64 size);
00673 
00681 void kvp_frame_for_each_slot(KvpFrame *f,
00682                              void (*proc)(const char *key,
00683                                           KvpValue *value,
00684                                           gpointer data),
00685                              gpointer data);
00686 
00690 gchar* kvp_frame_to_string(const KvpFrame *frame);
00691 gchar* binary_to_string(const void *data, guint32 size);
00692 gchar* kvp_value_glist_to_string(const GList *list);
00693 GHashTable* kvp_frame_get_hash(const KvpFrame *frame);
00694 
00696 #endif

Generated on Fri Oct 21 15:49:54 2005 for QOF by  doxygen 1.4.5