QOF 0.8.2

kvpframe.h

Go to the documentation of this file.
00001 /********************************************************************\
00002  * kvpframe.h -- Implements a key-value frame system                *
00003  *                                                                  *
00004  * This program is free software; you can redistribute it and/or    *
00005  * modify it under the terms of the GNU General Public License as   *
00006  * published by the Free Software Foundation; either version 2 of   *
00007  * the License, or (at your option) any later version.              *
00008  *                                                                  *
00009  * This program is distributed in the hope that it will be useful,  *
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00012  * GNU General Public License for more details.                     *
00013  *                                                                  *
00014  * You should have received a copy of the GNU General Public License*
00015  * along with this program; if not, contact:                        *
00016  *                                                                  *
00017  * Free Software Foundation           Voice:  +1-617-542-5942       *
00018  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
00019  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
00020  *                                                                  *
00021 \********************************************************************/
00063 #ifndef KVP_FRAME_H
00064 #define KVP_FRAME_H
00065 
00066 #include "qofnumeric.h"
00067 #include "guid.h"
00068 #include "qoftime.h"
00069 #include "qofutil.h"
00070 
00071 #define QOF_MOD_KVP "qof-kvp"
00072 
00074 typedef struct _KvpFrame KvpFrame;
00075 
00078 typedef struct _KvpValue KvpValue;
00079 
00087 typedef enum
00088 {
00094     KVP_TYPE_GINT64 = 1,
00100     KVP_TYPE_DOUBLE,
00106     KVP_TYPE_NUMERIC,
00112     KVP_TYPE_STRING,
00118     KVP_TYPE_GUID,
00124     KVP_TYPE_TIME,
00126     KVP_TYPE_BINARY,
00128     KVP_TYPE_GLIST,
00130     KVP_TYPE_FRAME,
00136     KVP_TYPE_BOOLEAN
00137 } KvpValueType;
00138 
00144 KvpFrame *
00145 kvp_frame_new (void);
00146 
00148 void 
00149 kvp_frame_delete (KvpFrame * frame);
00150 
00153 KvpFrame *
00154 kvp_frame_copy (const KvpFrame * frame);
00155 
00157 gboolean 
00158 kvp_frame_is_empty (KvpFrame * frame);
00159 
00170 void 
00171 kvp_frame_set_gint64 (KvpFrame * frame, const gchar * path, gint64 ival);
00172 
00177 void 
00178 kvp_frame_set_double (KvpFrame * frame, const gchar * path, gdouble dval);
00179 
00184 void 
00185 kvp_frame_set_numeric (KvpFrame * frame, const gchar * path,
00186                         QofNumeric nval);
00187 
00194 void 
00195 kvp_frame_set_string (KvpFrame * frame, const gchar * path,
00196                        const gchar *str);
00197 
00204 void 
00205 kvp_frame_set_guid (KvpFrame * frame, const gchar * path,
00206                      const GUID * guid);
00207 
00214 void
00215 kvp_frame_set_time (KvpFrame * frame, const gchar *path, QofTime *qt);
00216 
00221 void
00222 kvp_frame_set_boolean (KvpFrame * frame, const gchar * path, gboolean val);
00223 
00230 void 
00231 kvp_frame_set_frame (KvpFrame * frame, const gchar * path,
00232                       KvpFrame * chld);
00233 
00240 void kvp_frame_set_frame_nc (KvpFrame * frame, const gchar * path,
00241                              KvpFrame * chld);
00242 
00259 KvpFrame *
00260 kvp_frame_set_value (KvpFrame * frame, const gchar * path, 
00261                     const KvpValue * value);
00262 
00277 KvpFrame *
00278 kvp_frame_set_value_nc (KvpFrame * frame, const gchar * path, KvpValue * value);
00279 
00288 KvpValue *
00289 kvp_frame_replace_value_nc (KvpFrame * frame, const gchar * slot,
00290                               KvpValue * new_value);
00304 void 
00305 kvp_frame_add_gint64 (KvpFrame * frame, const gchar * path, gint64 ival);
00306 
00314 void 
00315 kvp_frame_add_double (KvpFrame * frame, const gchar * path, gdouble dval);
00316 
00324 void 
00325 kvp_frame_add_numeric (KvpFrame * frame, const gchar * path,
00326                         QofNumeric nval);
00327 
00335 void
00336 kvp_frame_add_time (KvpFrame * frame, const gchar *path, QofTime *qt);
00337 
00346 void kvp_frame_add_string (KvpFrame * frame, const gchar * path,
00347                            const gchar * str);
00348 
00349 void
00350 kvp_frame_add_boolean (KvpFrame * frame, const gchar * path, gboolean val);
00351 
00359 void kvp_frame_add_guid (KvpFrame * frame, const gchar * path,
00360                          const GUID * guid);
00361 
00369 void kvp_frame_add_frame (KvpFrame * frame, const gchar * path,
00370                           KvpFrame * chld);
00378 void kvp_frame_add_frame_nc (KvpFrame * frame, const gchar * path,
00379                              KvpFrame * chld);
00380 
00390 KvpFrame *
00391 kvp_frame_add_value (KvpFrame * frame, const gchar * path,
00392                        KvpValue * value);
00393 
00394 /* \brief Add the value directly to the glist bag
00395 
00396  If not all frame components of the path exist, they are created.
00397  If there was another item previously stored at that path, then the
00398  path is converted to a bag, and the old value, along with the new
00399  value, is added to the bag. This routine returns the pointer to the
00400  last frame (the actual frame to which the value was added), or NULL
00401  if there was an error of any sort (typically, a parse error in the path).
00402 */
00403 KvpFrame *
00404 kvp_frame_add_value_nc (KvpFrame * frame, const gchar * path,
00405                           KvpValue * value);
00406 
00407 
00439 gint64 
00440 kvp_frame_get_gint64 (const KvpFrame * frame, const gchar * path);
00441 gdouble 
00442 kvp_frame_get_double (const KvpFrame * frame, const gchar * path);
00443 QofNumeric 
00444 kvp_frame_get_numeric (const KvpFrame * frame, const gchar * path);
00445 gchar *
00446 kvp_frame_get_string (const KvpFrame * frame, const gchar * path);
00447 GUID *
00448 kvp_frame_get_guid (const KvpFrame * frame, const gchar * path);
00449 gpointer 
00450 kvp_frame_get_binary (const KvpFrame * frame, const gchar * path,
00451                     guint64 * size_return);
00452 
00453 gboolean
00454 kvp_frame_get_boolean (const KvpFrame * frame, const gchar * path);
00455 
00456 QofTime *
00457 kvp_frame_get_time (const KvpFrame * frame, const gchar *path);
00458 
00459 KvpValue *kvp_frame_get_value (const KvpFrame * frame, const gchar * path);
00460 
00469 KvpFrame *kvp_frame_get_frame (const KvpFrame * frame, const gchar * path);
00470 
00475 KvpFrame *
00476 kvp_frame_get_frame_path (KvpFrame * frame, const gchar *, ...);
00477 
00482 KvpFrame *
00483 kvp_frame_get_frame_gslist (KvpFrame * frame, GSList * key_path);
00484 
00496 KvpFrame *kvp_frame_get_frame_slash (KvpFrame * frame, const gchar * path);
00497 
00520 KvpValue *
00521 kvp_frame_replace_slot_nc (KvpFrame * frame, const gchar * slot,
00522                          KvpValue * new_value);
00523 
00524 
00531 void kvp_frame_set_slot (KvpFrame * frame,
00532                          const gchar * key, const KvpValue * value);
00541 void kvp_frame_set_slot_nc (KvpFrame * frame,
00542                             const gchar * key, KvpValue * value);
00543 
00549 void kvp_frame_set_slot_path (KvpFrame * frame,
00550                               const KvpValue * value,
00551                               const gchar * first_key, ...);
00552 
00558 void kvp_frame_set_slot_path_gslist (KvpFrame * frame,
00559                                      const KvpValue * value,
00560                                      GSList * key_path);
00561 
00578 KvpValue *kvp_frame_get_slot (const KvpFrame * frame, const gchar * key);
00579 
00583 KvpValue *kvp_frame_get_slot_path (KvpFrame * frame,
00584                                    const gchar * first_key, ...);
00585 
00589 KvpValue *kvp_frame_get_slot_path_gslist (KvpFrame * frame,
00590                                           GSList * key_path);
00591 
00600 gint kvp_glist_compare (const GList * list1, const GList * list2);
00601 
00607 GList *kvp_glist_copy (const GList * list);
00608 
00614 void kvp_glist_delete (GList * list);
00615 
00616 
00625 KvpValue *kvp_value_new_gint64 (gint64 value);
00626 KvpValue *kvp_value_new_double (double value);
00627 
00628 KvpValue *kvp_value_new_numeric (QofNumeric value);
00629 KvpValue *kvp_value_new_string (const gchar * value);
00630 KvpValue *kvp_value_new_guid (const GUID * guid);
00631 KvpValue *kvp_value_new_time (QofTime *value);
00633 KvpValue *kvp_value_new_boolean (gboolean value);
00634 
00635 KvpValue *kvp_value_new_binary (const void *data, guint64 datasize);
00636 KvpValue *kvp_value_new_frame (const KvpFrame * value);
00637 
00640 KvpValue *kvp_value_new_glist (const GList * value);
00641 
00644 KvpValue *kvp_value_new_binary_nc (void *data, guint64 datasize);
00645 
00652 KvpValue *kvp_value_new_glist_nc (GList * lst);
00653 
00656 KvpValue *kvp_value_new_frame_nc (KvpFrame * value);
00657 
00659 void kvp_value_delete (KvpValue * value);
00660 
00662 KvpValue *kvp_value_copy (const KvpValue * value);
00663 
00665 KvpFrame *kvp_value_replace_frame_nc (KvpValue * value, KvpFrame * newframe);
00666 
00668 GList *kvp_value_replace_glist_nc (KvpValue * value, GList * newlist);
00669 
00678 KvpValueType kvp_value_get_type (const KvpValue * value);
00679 
00695 gint64 kvp_value_get_gint64 (const KvpValue * value);
00696 gdouble kvp_value_get_double (const KvpValue * value);
00697 QofNumeric kvp_value_get_numeric (const KvpValue * value);
00698 
00701 gchar *
00702 kvp_value_get_string (const KvpValue * value);
00703 
00706 GUID *
00707 kvp_value_get_guid (const KvpValue * value);
00708 
00711 gpointer
00712 kvp_value_get_binary (const KvpValue * value, guint64 * size_return);
00713 
00717 GList *
00718 kvp_value_get_glist (const KvpValue * value);
00719 
00722 KvpFrame *
00723 kvp_value_get_frame (const KvpValue * value);
00724 
00725 
00726 gboolean
00727 kvp_value_get_boolean (const KvpValue * value);
00728 
00729 QofTime*
00730 kvp_value_get_time (const KvpValue * value);
00731 
00735 gint 
00736 kvp_value_compare (const KvpValue * va, const KvpValue * vb);
00737 
00744 gchar *
00745 kvp_value_to_bare_string (const KvpValue * val);
00746 
00752 gchar *
00753 kvp_value_to_string (const KvpValue * val);
00754 
00758 gboolean 
00759 kvp_value_binary_append (KvpValue * v, gpointer data, guint64 size);
00760 
00766 typedef void (*KvpValueForeachCB) (const gchar *key, KvpValue * value, gpointer data);
00767 
00772 void 
00773 kvp_frame_for_each_slot (KvpFrame * f, KvpValueForeachCB, gpointer data);
00774 
00778 #endif