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,
00119 #ifndef QOF_DISABLE_DEPRECATED
00120 
00121     KVP_TYPE_TIMESPEC,
00122 #endif
00123 
00128     KVP_TYPE_TIME,
00130     KVP_TYPE_BINARY,
00132     KVP_TYPE_GLIST,
00134     KVP_TYPE_FRAME,
00140     KVP_TYPE_BOOLEAN
00141 } KvpValueType;
00142 
00148 KvpFrame *
00149 kvp_frame_new (void);
00150 
00152 void 
00153 kvp_frame_delete (KvpFrame * frame);
00154 
00157 KvpFrame *
00158 kvp_frame_copy (const KvpFrame * frame);
00159 
00161 gboolean 
00162 kvp_frame_is_empty (KvpFrame * frame);
00163 
00174 void 
00175 kvp_frame_set_gint64 (KvpFrame * frame, const gchar * path, gint64 ival);
00176 
00181 void 
00182 kvp_frame_set_double (KvpFrame * frame, const gchar * path, gdouble dval);
00183 
00188 void 
00189 kvp_frame_set_numeric (KvpFrame * frame, const gchar * path,
00190                         QofNumeric nval);
00191 
00198 void 
00199 kvp_frame_set_string (KvpFrame * frame, const gchar * path,
00200                        const gchar *str);
00201 
00208 void 
00209 kvp_frame_set_guid (KvpFrame * frame, const gchar * path,
00210                      const GUID * guid);
00211 
00218 void
00219 kvp_frame_set_time (KvpFrame * frame, const gchar *path, QofTime *qt);
00220 
00225 void
00226 kvp_frame_set_boolean (KvpFrame * frame, const gchar * path, gboolean val);
00227 
00234 void 
00235 kvp_frame_set_frame (KvpFrame * frame, const gchar * path,
00236                       KvpFrame * chld);
00237 
00244 void kvp_frame_set_frame_nc (KvpFrame * frame, const gchar * path,
00245                              KvpFrame * chld);
00246 
00263 KvpFrame *
00264 kvp_frame_set_value (KvpFrame * frame, const gchar * path, 
00265                     const KvpValue * value);
00266 
00281 KvpFrame *
00282 kvp_frame_set_value_nc (KvpFrame * frame, const gchar * path, KvpValue * value);
00283 
00292 KvpValue *
00293 kvp_frame_replace_value_nc (KvpFrame * frame, const gchar * slot,
00294                               KvpValue * new_value);
00308 void 
00309 kvp_frame_add_gint64 (KvpFrame * frame, const gchar * path, gint64 ival);
00310 
00318 void 
00319 kvp_frame_add_double (KvpFrame * frame, const gchar * path, gdouble dval);
00320 
00328 void 
00329 kvp_frame_add_numeric (KvpFrame * frame, const gchar * path,
00330                         QofNumeric nval);
00331 
00339 void
00340 kvp_frame_add_time (KvpFrame * frame, const gchar *path, QofTime *qt);
00341 
00350 void kvp_frame_add_string (KvpFrame * frame, const gchar * path,
00351                            const gchar * str);
00352 
00353 void
00354 kvp_frame_add_boolean (KvpFrame * frame, const gchar * path, gboolean val);
00355 
00363 void kvp_frame_add_guid (KvpFrame * frame, const gchar * path,
00364                          const GUID * guid);
00365 
00373 void kvp_frame_add_frame (KvpFrame * frame, const gchar * path,
00374                           KvpFrame * chld);
00382 void kvp_frame_add_frame_nc (KvpFrame * frame, const gchar * path,
00383                              KvpFrame * chld);
00384 
00394 KvpFrame *
00395 kvp_frame_add_value (KvpFrame * frame, const gchar * path,
00396                        KvpValue * value);
00397 
00398 /* \brief Add the value directly to the glist bag
00399 
00400  If not all frame components of the path exist, they are created.
00401  If there was another item previously stored at that path, then the
00402  path is converted to a bag, and the old value, along with the new
00403  value, is added to the bag. This routine returns the pointer to the
00404  last frame (the actual frame to which the value was added), or NULL
00405  if there was an error of any sort (typically, a parse error in the path).
00406 */
00407 KvpFrame *
00408 kvp_frame_add_value_nc (KvpFrame * frame, const gchar * path,
00409                           KvpValue * value);
00410 
00411 
00443 gint64 
00444 kvp_frame_get_gint64 (const KvpFrame * frame, const gchar * path);
00445 gdouble 
00446 kvp_frame_get_double (const KvpFrame * frame, const gchar * path);
00447 QofNumeric 
00448 kvp_frame_get_numeric (const KvpFrame * frame, const gchar * path);
00449 gchar *
00450 kvp_frame_get_string (const KvpFrame * frame, const gchar * path);
00451 GUID *
00452 kvp_frame_get_guid (const KvpFrame * frame, const gchar * path);
00453 gpointer 
00454 kvp_frame_get_binary (const KvpFrame * frame, const gchar * path,
00455                     guint64 * size_return);
00456 
00457 gboolean
00458 kvp_frame_get_boolean (const KvpFrame * frame, const gchar * path);
00459 
00460 QofTime *
00461 kvp_frame_get_time (const KvpFrame * frame, const gchar *path);
00462 
00463 KvpValue *kvp_frame_get_value (const KvpFrame * frame, const gchar * path);
00464 
00473 KvpFrame *kvp_frame_get_frame (const KvpFrame * frame, const gchar * path);
00474 
00479 KvpFrame *
00480 kvp_frame_get_frame_path (KvpFrame * frame, const gchar *, ...);
00481 
00486 KvpFrame *
00487 kvp_frame_get_frame_gslist (KvpFrame * frame, GSList * key_path);
00488 
00500 KvpFrame *kvp_frame_get_frame_slash (KvpFrame * frame, const gchar * path);
00501 
00524 KvpValue *
00525 kvp_frame_replace_slot_nc (KvpFrame * frame, const gchar * slot,
00526                          KvpValue * new_value);
00527 
00528 
00535 void kvp_frame_set_slot (KvpFrame * frame,
00536                          const gchar * key, const KvpValue * value);
00545 void kvp_frame_set_slot_nc (KvpFrame * frame,
00546                             const gchar * key, KvpValue * value);
00547 
00553 void kvp_frame_set_slot_path (KvpFrame * frame,
00554                               const KvpValue * value,
00555                               const gchar * first_key, ...);
00556 
00562 void kvp_frame_set_slot_path_gslist (KvpFrame * frame,
00563                                      const KvpValue * value,
00564                                      GSList * key_path);
00565 
00582 KvpValue *kvp_frame_get_slot (const KvpFrame * frame, const gchar * key);
00583 
00587 KvpValue *kvp_frame_get_slot_path (KvpFrame * frame,
00588                                    const gchar * first_key, ...);
00589 
00593 KvpValue *kvp_frame_get_slot_path_gslist (KvpFrame * frame,
00594                                           GSList * key_path);
00595 
00604 gint kvp_glist_compare (const GList * list1, const GList * list2);
00605 
00611 GList *kvp_glist_copy (const GList * list);
00612 
00618 void kvp_glist_delete (GList * list);
00619 
00620 
00629 KvpValue *kvp_value_new_gint64 (gint64 value);
00630 KvpValue *kvp_value_new_double (double value);
00631 
00632 KvpValue *kvp_value_new_numeric (QofNumeric value);
00633 KvpValue *kvp_value_new_string (const gchar * value);
00634 KvpValue *kvp_value_new_guid (const GUID * guid);
00635 KvpValue *kvp_value_new_time (QofTime *value);
00637 KvpValue *kvp_value_new_boolean (gboolean value);
00638 
00639 KvpValue *kvp_value_new_binary (const void *data, guint64 datasize);
00640 KvpValue *kvp_value_new_frame (const KvpFrame * value);
00641 
00644 KvpValue *kvp_value_new_glist (const GList * value);
00645 
00648 KvpValue *kvp_value_new_binary_nc (void *data, guint64 datasize);
00649 
00656 KvpValue *kvp_value_new_glist_nc (GList * lst);
00657 
00660 KvpValue *kvp_value_new_frame_nc (KvpFrame * value);
00661 
00663 void kvp_value_delete (KvpValue * value);
00664 
00666 KvpValue *kvp_value_copy (const KvpValue * value);
00667 
00669 KvpFrame *kvp_value_replace_frame_nc (KvpValue * value, KvpFrame * newframe);
00670 
00672 GList *kvp_value_replace_glist_nc (KvpValue * value, GList * newlist);
00673 
00682 KvpValueType kvp_value_get_type (const KvpValue * value);
00683 
00699 gint64 kvp_value_get_gint64 (const KvpValue * value);
00700 gdouble kvp_value_get_double (const KvpValue * value);
00701 QofNumeric kvp_value_get_numeric (const KvpValue * value);
00702 
00705 gchar *
00706 kvp_value_get_string (const KvpValue * value);
00707 
00710 GUID *
00711 kvp_value_get_guid (const KvpValue * value);
00712 
00715 gpointer
00716 kvp_value_get_binary (const KvpValue * value, guint64 * size_return);
00717 
00721 GList *
00722 kvp_value_get_glist (const KvpValue * value);
00723 
00726 KvpFrame *
00727 kvp_value_get_frame (const KvpValue * value);
00728 
00729 
00730 gboolean
00731 kvp_value_get_boolean (const KvpValue * value);
00732 
00733 QofTime*
00734 kvp_value_get_time (const KvpValue * value);
00735 
00739 gint 
00740 kvp_value_compare (const KvpValue * va, const KvpValue * vb);
00741 
00748 gchar *
00749 kvp_value_to_bare_string (const KvpValue * val);
00750 
00756 gchar *
00757 kvp_value_to_string (const KvpValue * val);
00758 
00762 gboolean 
00763 kvp_value_binary_append (KvpValue * v, gpointer data, guint64 size);
00764 
00770 typedef void (*KvpValueForeachCB) (const gchar *key, KvpValue * value, gpointer data);
00771 
00776 void 
00777 kvp_frame_for_each_slot (KvpFrame * f, KvpValueForeachCB, gpointer data);
00778 
00782 #endif

Generated on Thu Jan 31 22:50:25 2008 for QOF by  doxygen 1.5.4