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-numeric.h"
00065 #include "guid.h"
00066 #include "qoftime.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,
00092     KVP_TYPE_DOUBLE,   
00093     KVP_TYPE_NUMERIC,  
00094     KVP_TYPE_STRING,   
00095     KVP_TYPE_GUID,     
00096 #ifndef QOF_DISABLE_DEPRECATED
00097     KVP_TYPE_TIMESPEC, 
00098 #endif
00099     KVP_TYPE_TIME,     
00100     KVP_TYPE_BINARY,   
00101     KVP_TYPE_GLIST,    
00102     KVP_TYPE_FRAME     
00103 } KvpValueType;
00104 
00109 #define kvp_frame KvpFrame
00110 
00111 #define kvp_value KvpValue
00112 
00113 #define kvp_value_t KvpValueType
00114 
00120 KvpFrame *kvp_frame_new (void);
00121 
00127 void kvp_frame_delete (KvpFrame * frame);
00128 
00131 KvpFrame *kvp_frame_copy (const KvpFrame * frame);
00132 
00134 gboolean kvp_frame_is_empty (KvpFrame * frame);
00135 
00147 void kvp_frame_set_gint64 (KvpFrame * frame, const gchar * path, gint64 ival);
00153 void kvp_frame_set_double (KvpFrame * frame, const gchar * path, double dval);
00154 
00159 #define kvp_frame_set_gnc_numeric kvp_frame_set_numeric
00160 
00165 void kvp_frame_set_numeric (KvpFrame * frame, const gchar * path,
00166                             gnc_numeric nval);
00167 
00172 #define kvp_frame_set_str kvp_frame_set_string
00173 
00186 void 
00187 kvp_frame_set_string (KvpFrame * frame, const gchar * path,
00188                            const gchar *str);
00189 void 
00190 kvp_frame_set_guid (KvpFrame * frame, const gchar * path,
00191                          const GUID * guid);
00192 void
00193 kvp_frame_set_time (KvpFrame * frame, const gchar *path, QofTime *qt);
00194 
00195 void kvp_frame_set_frame (KvpFrame * frame, const gchar * path,
00196                           KvpFrame * chld);
00197 void kvp_frame_set_frame_nc (KvpFrame * frame, const gchar * path,
00198                              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_url_encoding (KvpFrame * frame, const gchar * enc);
00272 void kvp_frame_add_gint64 (KvpFrame * frame, const gchar * path, gint64 ival);
00273 void kvp_frame_add_double (KvpFrame * frame, const gchar * path, double dval);
00278 #define kvp_frame_add_gnc_numeric kvp_frame_add_numeric
00279 
00280 void kvp_frame_add_numeric (KvpFrame * frame, const gchar * path,
00281                             gnc_numeric nval);
00282 void
00283 kvp_frame_add_time (KvpFrame * frame, const gchar *path, QofTime *qt);
00284 
00289 #define kvp_frame_add_str kvp_frame_add_string
00290 
00305 void kvp_frame_add_string (KvpFrame * frame, const gchar * path,
00306                            const gchar * str);
00307 void kvp_frame_add_guid (KvpFrame * frame, const gchar * path,
00308                          const GUID * guid);
00309 
00310 void kvp_frame_add_frame (KvpFrame * frame, const gchar * path,
00311                           KvpFrame * chld);
00312 void kvp_frame_add_frame_nc (KvpFrame * frame, const gchar * path,
00313                              KvpFrame * chld);
00314 
00315 /* The kvp_frame_add_value() routine will  add a copy of the value
00316  *    to the glist bag at the indicated path. If not all frame components
00317  *    of the path exist, they are created.  If there was another
00318  *    item previously stored at that path, then the path is converted
00319  *    to a bag, and the old value, along with the new value, is added
00320  *    to the bag.  This routine returns the pointer to the last frame
00321  *    (the actual frame to which the value was added), or NULL if there
00322  *    was an error of any sort (typically, a parse error in the path).
00323  * 
00324  *    The *_nc() routine is analogous, except that it doesn't copy the
00325  *    value.
00326  */
00327 KvpFrame *kvp_frame_add_value (KvpFrame * frame, const gchar * path,
00328                                KvpValue * value);
00329 KvpFrame *kvp_frame_add_value_nc (KvpFrame * frame, const gchar * path,
00330                                   KvpValue * value);
00331 
00332 
00364 gint64 kvp_frame_get_gint64 (const KvpFrame * frame, const gchar * path);
00365 double kvp_frame_get_double (const KvpFrame * frame, const gchar * path);
00366 gnc_numeric kvp_frame_get_numeric (const KvpFrame * frame,
00367                                    const gchar * path);
00368 gchar *kvp_frame_get_string (const KvpFrame * frame, const gchar * path);
00369 GUID *kvp_frame_get_guid (const KvpFrame * frame, const gchar * path);
00370 void *kvp_frame_get_binary (const KvpFrame * frame, const gchar * path,
00371                             guint64 * size_return);
00372 QofTime *
00373 kvp_frame_get_time (const KvpFrame * frame, const gchar *path);
00374 KvpValue *kvp_frame_get_value (const KvpFrame * frame, const gchar * path);
00375 
00394 KvpFrame *kvp_frame_get_frame (const KvpFrame * frame, const gchar * path);
00395 
00409 KvpFrame *kvp_frame_get_frame_path (KvpFrame * frame, const gchar *, ...);
00410 
00415 KvpFrame *kvp_frame_get_frame_gslist (KvpFrame * frame, GSList * key_path);
00416 
00428 KvpFrame *kvp_frame_get_frame_slash (KvpFrame * frame, const gchar * path);
00429 
00452 KvpValue *kvp_frame_replace_slot_nc (KvpFrame * frame, const gchar * slot,
00453                                      KvpValue * new_value);
00454 
00455 
00462 void kvp_frame_set_slot (KvpFrame * frame,
00463                          const gchar * key, const KvpValue * value);
00472 void kvp_frame_set_slot_nc (KvpFrame * frame,
00473                             const gchar * key, KvpValue * value);
00474 
00480 void kvp_frame_set_slot_path (KvpFrame * frame,
00481                               const KvpValue * value,
00482                               const gchar * first_key, ...);
00483 
00489 void kvp_frame_set_slot_path_gslist (KvpFrame * frame,
00490                                      const KvpValue * value,
00491                                      GSList * key_path);
00492 
00509 KvpValue *kvp_frame_get_slot (const KvpFrame * frame, const gchar * key);
00510 
00514 KvpValue *kvp_frame_get_slot_path (KvpFrame * frame,
00515                                    const gchar * first_key, ...);
00516 
00520 KvpValue *kvp_frame_get_slot_path_gslist (KvpFrame * frame,
00521                                           GSList * key_path);
00522 
00526 gint kvp_frame_compare (const KvpFrame * fa, const KvpFrame * fb);
00527 
00528 gint double_compare (double v1, double v2);
00539 gint kvp_glist_compare (const GList * list1, const GList * list2);
00540 
00546 GList *kvp_glist_copy (const GList * list);
00547 
00553 void kvp_glist_delete (GList * list);
00567 KvpValue *kvp_value_new_gint64 (gint64 value);
00568 KvpValue *kvp_value_new_double (double value);
00569 
00574 #define kvp_value_new_gnc_numeric kvp_value_new_numeric
00575 KvpValue *kvp_value_new_numeric (gnc_numeric value);
00576 KvpValue *kvp_value_new_string (const gchar * value);
00577 KvpValue *kvp_value_new_guid (const GUID * guid);
00578 KvpValue *kvp_value_new_time (QofTime *value);
00579 KvpValue *kvp_value_new_binary (const void *data, guint64 datasize);
00580 KvpValue *kvp_value_new_frame (const KvpFrame * value);
00581 
00584 KvpValue *kvp_value_new_glist (const GList * value);
00585 
00588 KvpValue *kvp_value_new_binary_nc (void *data, guint64 datasize);
00589 
00596 KvpValue *kvp_value_new_glist_nc (GList * lst);
00597 
00600 KvpValue *kvp_value_new_frame_nc (KvpFrame * value);
00601 
00603 void kvp_value_delete (KvpValue * value);
00604 
00606 KvpValue *kvp_value_copy (const KvpValue * value);
00607 
00609 KvpFrame *kvp_value_replace_frame_nc (KvpValue * value, KvpFrame * newframe);
00610 
00612 GList *kvp_value_replace_glist_nc (KvpValue * value, GList * newlist);
00613 
00623 KvpValueType kvp_value_get_type (const KvpValue * value);
00624 
00625 
00636 gint64 kvp_value_get_gint64 (const KvpValue * value);
00637 double kvp_value_get_double (const KvpValue * value);
00638 gnc_numeric kvp_value_get_numeric (const KvpValue * value);
00639 
00642 char *kvp_value_get_string (const KvpValue * value);
00643 
00646 GUID *kvp_value_get_guid (const KvpValue * value);
00647 
00650 void *kvp_value_get_binary (const KvpValue * value, guint64 * size_return);
00651 
00655 GList *kvp_value_get_glist (const KvpValue * value);
00656 
00659 KvpFrame *kvp_value_get_frame (const KvpValue * value);
00660 QofTime*
00661 kvp_value_get_time (const KvpValue * value);
00662 
00666 gint kvp_value_compare (const KvpValue * va, const KvpValue * vb);
00667 
00674 gchar *kvp_value_to_bare_string (const KvpValue * val);
00675 
00681 gchar *kvp_value_to_string (const KvpValue * val);
00682 
00686 gboolean kvp_value_binary_append (KvpValue * v, void *data, guint64 size);
00687 
00695 void kvp_frame_for_each_slot (KvpFrame * f,
00696                               void (*proc) (const char *key,
00697                                             KvpValue * value,
00698                                             gpointer data), gpointer data);
00699 
00703 gchar *kvp_frame_to_string (const KvpFrame * frame);
00704 gchar *binary_to_string (const void *data, guint32 size);
00705 gchar *kvp_value_glist_to_string (const GList * list);
00706 GHashTable *kvp_frame_get_hash (const KvpFrame * frame);
00707 
00709 #endif

Generated on Mon May 21 17:42:21 2007 for QOF by  doxygen 1.5.1