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   KVP_TYPE_GINT64=1,   
00090   KVP_TYPE_DOUBLE,     
00091   KVP_TYPE_NUMERIC,    
00092   KVP_TYPE_STRING,     
00093   KVP_TYPE_GUID,       
00094   KVP_TYPE_TIMESPEC,   
00095   KVP_TYPE_BINARY,     
00096   KVP_TYPE_GLIST,      
00097   KVP_TYPE_FRAME       
00098 } KvpValueType;
00099 
00104 #define kvp_frame KvpFrame
00105 
00106 #define kvp_value KvpValue
00107 
00108 #define kvp_value_t KvpValueType
00109   
00115 KvpFrame   * kvp_frame_new(void);
00116 
00122 void         kvp_frame_delete(KvpFrame * frame);
00123 
00126 KvpFrame   * kvp_frame_copy(const KvpFrame * frame);
00127 
00129 gboolean     kvp_frame_is_empty(KvpFrame * frame);
00130 
00142 void kvp_frame_set_gint64(KvpFrame * frame, const gchar * path, gint64 ival);
00148 void kvp_frame_set_double(KvpFrame * frame, const gchar * path, double dval);
00149 
00154 #define kvp_frame_set_gnc_numeric kvp_frame_set_numeric
00155 
00160 void kvp_frame_set_numeric(KvpFrame * frame, const gchar * path, gnc_numeric nval);
00166 void kvp_frame_set_timespec(KvpFrame * frame, const gchar * path, Timespec ts);
00167 
00172 #define kvp_frame_set_str kvp_frame_set_string
00173 
00186 void kvp_frame_set_string(KvpFrame * frame, const gchar * path, const char* str);
00187 void kvp_frame_set_guid(KvpFrame * frame, const gchar * path, const GUID *guid);
00188 
00189 void kvp_frame_set_frame(KvpFrame *frame, const gchar *path, KvpFrame *chld);
00190 void kvp_frame_set_frame_nc(KvpFrame *frame, const gchar *path, KvpFrame *chld);
00191 
00202 KvpFrame *   kvp_frame_set_value(KvpFrame * frame, 
00203                                  const gchar * path, const KvpValue * value);
00217 KvpFrame *    kvp_frame_set_value_nc(KvpFrame * frame, 
00218                                  const gchar * path, KvpValue * value);
00219 
00228 KvpValue * kvp_frame_replace_value_nc (KvpFrame * frame, const gchar * slot,
00229                                        KvpValue * new_value);
00246 void     kvp_frame_add_url_encoding (KvpFrame *frame, const gchar *enc);
00264 void kvp_frame_add_gint64(KvpFrame * frame, const gchar * path, gint64 ival);
00265 void kvp_frame_add_double(KvpFrame * frame, const gchar * path, double dval);
00270 #define kvp_frame_add_gnc_numeric kvp_frame_add_numeric
00271 
00272 void kvp_frame_add_numeric(KvpFrame * frame, const gchar * path, gnc_numeric nval);
00273 void kvp_frame_add_timespec(KvpFrame * frame, const gchar * path, Timespec ts);
00274 
00279 #define kvp_frame_add_str kvp_frame_add_string
00280 
00295 void kvp_frame_add_string(KvpFrame * frame, const gchar * path, const gchar* str);
00296 void kvp_frame_add_guid(KvpFrame * frame, const gchar * path, const GUID *guid);
00297 
00298 void kvp_frame_add_frame(KvpFrame *frame, const gchar *path, KvpFrame *chld);
00299 void kvp_frame_add_frame_nc(KvpFrame *frame, const gchar *path, KvpFrame *chld);
00300 
00301 /* The kvp_frame_add_value() routine will  add a copy of the value
00302  *    to the glist bag at the indicated path. If not all frame components
00303  *    of the path exist, they are created.  If there was another
00304  *    item previously stored at that path, then the path is converted
00305  *    to a bag, and the old value, along with the new value, is added
00306  *    to the bag.  This routine returns the pointer to the last frame
00307  *    (the actual frame to which the value was added), or NULL if there
00308  *    was an error of any sort (typically, a parse error in the path).
00309  * 
00310  *    The *_nc() routine is analogous, except that it doesn't copy the
00311  *    value.
00312  */
00313 KvpFrame * kvp_frame_add_value(KvpFrame * frame, const gchar * path, KvpValue *value);
00314 KvpFrame * kvp_frame_add_value_nc(KvpFrame * frame, const gchar * path, KvpValue *value);
00315 
00316 
00348 gint64      kvp_frame_get_gint64(const KvpFrame *frame, const gchar *path);
00349 double      kvp_frame_get_double(const KvpFrame *frame, const gchar *path);
00350 gnc_numeric kvp_frame_get_numeric(const KvpFrame *frame, const gchar *path);
00351 gchar     * kvp_frame_get_string(const KvpFrame *frame, const gchar *path);
00352 GUID      * kvp_frame_get_guid(const KvpFrame *frame, const gchar *path);
00353 void      * kvp_frame_get_binary(const KvpFrame *frame, const gchar *path,
00354                                    guint64 * size_return); 
00355 Timespec    kvp_frame_get_timespec(const KvpFrame *frame, const gchar *path);
00356 KvpValue  * kvp_frame_get_value(const KvpFrame *frame, const gchar *path);
00357 
00376 KvpFrame  * kvp_frame_get_frame(const KvpFrame *frame, const gchar *path);
00377 
00391 KvpFrame    * kvp_frame_get_frame_path (KvpFrame *frame, const gchar *,...);
00392 
00397 KvpFrame    * kvp_frame_get_frame_gslist (KvpFrame *frame,
00398                                            GSList *key_path);
00399 
00411 KvpFrame    * kvp_frame_get_frame_slash (KvpFrame *frame,
00412                                           const gchar *path);
00413 
00436 KvpValue * kvp_frame_replace_slot_nc (KvpFrame * frame, const gchar * slot,
00437                                  KvpValue * new_value);
00438 
00439 
00446 void          kvp_frame_set_slot(KvpFrame * frame, 
00447                                  const gchar * key, const KvpValue * value);
00456 void          kvp_frame_set_slot_nc(KvpFrame * frame, 
00457                                     const gchar * key, KvpValue * value);
00458 
00464 void          kvp_frame_set_slot_path (KvpFrame *frame,
00465                                        const KvpValue *value,
00466                                        const gchar *first_key, ...);
00467 
00473 void          kvp_frame_set_slot_path_gslist (KvpFrame *frame,
00474                                               const KvpValue *value,
00475                                               GSList *key_path);
00476 
00493 KvpValue   * kvp_frame_get_slot(const KvpFrame * frame, const gchar * key);
00494 
00498 KvpValue   * kvp_frame_get_slot_path (KvpFrame *frame,
00499                                        const gchar *first_key, ...);
00500 
00504 KvpValue   * kvp_frame_get_slot_path_gslist (KvpFrame *frame,
00505                                               GSList *key_path);
00506 
00510 gint          kvp_frame_compare(const KvpFrame *fa, const KvpFrame *fb);
00511 
00512 gint          double_compare(double v1, double v2);
00523 gint        kvp_glist_compare(const GList * list1, const GList * list2);
00524 
00530 GList     * kvp_glist_copy(const GList * list);
00531 
00537 void        kvp_glist_delete(GList * list);
00551 KvpValue   * kvp_value_new_gint64(gint64 value);
00552 KvpValue   * kvp_value_new_double(double value);
00553 
00558 #define kvp_value_new_gnc_numeric kvp_value_new_numeric
00559 KvpValue   * kvp_value_new_numeric(gnc_numeric value);
00560 KvpValue   * kvp_value_new_string(const gchar * value);
00561 KvpValue   * kvp_value_new_guid(const GUID * guid);
00562 KvpValue   * kvp_value_new_timespec(Timespec timespec);
00563 KvpValue   * kvp_value_new_binary(const void * data, guint64 datasize);
00564 KvpValue   * kvp_value_new_frame(const KvpFrame * value);
00565 
00568 KvpValue   * kvp_value_new_glist(const GList * value);
00569 
00572 KvpValue   * kvp_value_new_binary_nc(void * data, guint64 datasize);
00573 
00580 KvpValue   * kvp_value_new_glist_nc(GList *lst);
00581 
00584 KvpValue   * kvp_value_new_frame_nc(KvpFrame * value);
00585 
00587 void          kvp_value_delete(KvpValue * value);
00588 
00590 KvpValue   * kvp_value_copy(const KvpValue * value);
00591 
00593 KvpFrame * kvp_value_replace_frame_nc(KvpValue *value, KvpFrame * newframe);
00594 
00596 GList * kvp_value_replace_glist_nc(KvpValue *value, GList *newlist);
00597 
00607 KvpValueType kvp_value_get_type(const KvpValue * value);
00608 
00609 
00620 gint64      kvp_value_get_gint64(const KvpValue * value);
00621 double      kvp_value_get_double(const KvpValue * value);
00622 gnc_numeric kvp_value_get_numeric(const KvpValue * value);
00623 
00626 char        * kvp_value_get_string(const KvpValue * value);
00627 
00630 GUID        * kvp_value_get_guid(const KvpValue * value);
00631 
00634 void        * kvp_value_get_binary(const KvpValue * value,
00635                                    guint64 * size_return); 
00636 
00640 GList       * kvp_value_get_glist(const KvpValue * value);
00641 
00644 KvpFrame   * kvp_value_get_frame(const KvpValue * value);
00645 Timespec    kvp_value_get_timespec(const KvpValue * value);
00646 
00650 gint          kvp_value_compare(const KvpValue *va, const KvpValue *vb);
00651 
00658 gchar* kvp_value_to_bare_string(const KvpValue *val);
00659 
00665 gchar* kvp_value_to_string(const KvpValue *val);
00666 
00670 gboolean kvp_value_binary_append(KvpValue *v, void *data, guint64 size);
00671 
00679 void kvp_frame_for_each_slot(KvpFrame *f,
00680                              void (*proc)(const char *key,
00681                                           KvpValue *value,
00682                                           gpointer data),
00683                              gpointer data);
00684 
00688 gchar* kvp_frame_to_string(const KvpFrame *frame);
00689 gchar* binary_to_string(const void *data, guint32 size);
00690 gchar* kvp_value_glist_to_string(const GList *list);
00691 GHashTable* kvp_frame_get_hash(const KvpFrame *frame);
00692 
00694 #endif

Generated on Fri May 12 17:57:20 2006 for QOF by  doxygen 1.4.4