QOF  0.7.5
kvpframe.h
Go to the documentation of this file.
1 /********************************************************************\
2  * kvpframe.h -- Implements a key-value frame system *
3  * *
4  * This program is free software; you can redistribute it and/or *
5  * modify it under the terms of the GNU General Public License as *
6  * published by the Free Software Foundation; either version 2 of *
7  * the License, or (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License*
15  * along with this program; if not, contact: *
16  * *
17  * Free Software Foundation Voice: +1-617-542-5942 *
18  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
19  * Boston, MA 02110-1301, USA gnu@gnu.org *
20  * *
21 \********************************************************************/
63 #ifndef KVP_FRAME_H
64 #define KVP_FRAME_H
65 
66 #include "qofnumeric.h"
67 #include "guid.h"
68 #include "qoftime.h"
69 #include "qofutil.h"
70 
71 #define QOF_MOD_KVP "qof-kvp"
72 
74 typedef struct _KvpFrame KvpFrame;
75 
78 typedef struct _KvpValue KvpValue;
79 
87 typedef enum
88 {
119 #ifndef QOF_DISABLE_DEPRECATED
120 
122 #endif
123 
141 } KvpValueType;
142 
148 KvpFrame *
149 kvp_frame_new (void);
150 
152 void
153 kvp_frame_delete (KvpFrame * frame);
154 
157 KvpFrame *
158 kvp_frame_copy (const KvpFrame * frame);
159 
161 gboolean
162 kvp_frame_is_empty (KvpFrame * frame);
163 
174 void
175 kvp_frame_set_gint64 (KvpFrame * frame, const gchar * path, gint64 ival);
176 
181 void
182 kvp_frame_set_double (KvpFrame * frame, const gchar * path, gdouble dval);
183 
188 void
189 kvp_frame_set_numeric (KvpFrame * frame, const gchar * path,
190  QofNumeric nval);
191 
198 void
199 kvp_frame_set_string (KvpFrame * frame, const gchar * path,
200  const gchar *str);
201 
208 void
209 kvp_frame_set_guid (KvpFrame * frame, const gchar * path,
210  const GUID * guid);
211 
218 void
219 kvp_frame_set_time (KvpFrame * frame, const gchar *path, QofTime *qt);
220 
225 void
226 kvp_frame_set_boolean (KvpFrame * frame, const gchar * path, gboolean val);
227 
234 void
235 kvp_frame_set_frame (KvpFrame * frame, const gchar * path,
236  KvpFrame * chld);
237 
244 void kvp_frame_set_frame_nc (KvpFrame * frame, const gchar * path,
245  KvpFrame * chld);
246 
263 KvpFrame *
264 kvp_frame_set_value (KvpFrame * frame, const gchar * path,
265  const KvpValue * value);
266 
281 KvpFrame *
282 kvp_frame_set_value_nc (KvpFrame * frame, const gchar * path, KvpValue * value);
283 
292 KvpValue *
293 kvp_frame_replace_value_nc (KvpFrame * frame, const gchar * slot,
294  KvpValue * new_value);
308 void
309 kvp_frame_add_gint64 (KvpFrame * frame, const gchar * path, gint64 ival);
310 
318 void
319 kvp_frame_add_double (KvpFrame * frame, const gchar * path, gdouble dval);
320 
328 void
329 kvp_frame_add_numeric (KvpFrame * frame, const gchar * path,
330  QofNumeric nval);
331 
339 void
340 kvp_frame_add_time (KvpFrame * frame, const gchar *path, QofTime *qt);
341 
350 void kvp_frame_add_string (KvpFrame * frame, const gchar * path,
351  const gchar * str);
352 
353 void
354 kvp_frame_add_boolean (KvpFrame * frame, const gchar * path, gboolean val);
355 
363 void kvp_frame_add_guid (KvpFrame * frame, const gchar * path,
364  const GUID * guid);
365 
373 void kvp_frame_add_frame (KvpFrame * frame, const gchar * path,
374  KvpFrame * chld);
382 void kvp_frame_add_frame_nc (KvpFrame * frame, const gchar * path,
383  KvpFrame * chld);
384 
394 KvpFrame *
395 kvp_frame_add_value (KvpFrame * frame, const gchar * path,
396  KvpValue * value);
397 
398 /* \brief Add the value directly to the glist bag
399 
400  If not all frame components of the path exist, they are created.
401  If there was another item previously stored at that path, then the
402  path is converted to a bag, and the old value, along with the new
403  value, is added to the bag. This routine returns the pointer to the
404  last frame (the actual frame to which the value was added), or NULL
405  if there was an error of any sort (typically, a parse error in the path).
406 */
407 KvpFrame *
408 kvp_frame_add_value_nc (KvpFrame * frame, const gchar * path,
409  KvpValue * value);
410 
411 
443 gint64
444 kvp_frame_get_gint64 (const KvpFrame * frame, const gchar * path);
445 gdouble
446 kvp_frame_get_double (const KvpFrame * frame, const gchar * path);
447 QofNumeric
448 kvp_frame_get_numeric (const KvpFrame * frame, const gchar * path);
449 gchar *
450 kvp_frame_get_string (const KvpFrame * frame, const gchar * path);
451 GUID *
452 kvp_frame_get_guid (const KvpFrame * frame, const gchar * path);
453 gpointer
454 kvp_frame_get_binary (const KvpFrame * frame, const gchar * path,
455  guint64 * size_return);
456 
457 gboolean
458 kvp_frame_get_boolean (const KvpFrame * frame, const gchar * path);
459 
460 QofTime *
461 kvp_frame_get_time (const KvpFrame * frame, const gchar *path);
462 
463 KvpValue *kvp_frame_get_value (const KvpFrame * frame, const gchar * path);
464 
473 KvpFrame *kvp_frame_get_frame (const KvpFrame * frame, const gchar * path);
474 
479 KvpFrame *
480 kvp_frame_get_frame_path (KvpFrame * frame, const gchar *, ...);
481 
486 KvpFrame *
487 kvp_frame_get_frame_gslist (KvpFrame * frame, GSList * key_path);
488 
500 KvpFrame *kvp_frame_get_frame_slash (KvpFrame * frame, const gchar * path);
501 
524 KvpValue *
525 kvp_frame_replace_slot_nc (KvpFrame * frame, const gchar * slot,
526  KvpValue * new_value);
527 
528 
535 void kvp_frame_set_slot (KvpFrame * frame,
536  const gchar * key, const KvpValue * value);
545 void kvp_frame_set_slot_nc (KvpFrame * frame,
546  const gchar * key, KvpValue * value);
547 
553 void kvp_frame_set_slot_path (KvpFrame * frame,
554  const KvpValue * value,
555  const gchar * first_key, ...);
556 
563  const KvpValue * value,
564  GSList * key_path);
565 
582 KvpValue *kvp_frame_get_slot (const KvpFrame * frame, const gchar * key);
583 
588  const gchar * first_key, ...);
589 
594  GSList * key_path);
595 
604 gint kvp_glist_compare (const GList * list1, const GList * list2);
605 
611 GList *kvp_glist_copy (const GList * list);
612 
618 void kvp_glist_delete (GList * list);
619 
620 
629 KvpValue *kvp_value_new_gint64 (gint64 value);
630 KvpValue *kvp_value_new_double (double value);
631 
632 KvpValue *kvp_value_new_numeric (QofNumeric value);
633 KvpValue *kvp_value_new_string (const gchar * value);
634 KvpValue *kvp_value_new_guid (const GUID * guid);
635 KvpValue *kvp_value_new_time (QofTime *value);
637 KvpValue *kvp_value_new_boolean (gboolean value);
638 
639 KvpValue *kvp_value_new_binary (const void *data, guint64 datasize);
640 KvpValue *kvp_value_new_frame (const KvpFrame * value);
641 
644 KvpValue *kvp_value_new_glist (const GList * value);
645 
648 KvpValue *kvp_value_new_binary_nc (void *data, guint64 datasize);
649 
656 KvpValue *kvp_value_new_glist_nc (GList * lst);
657 
661 
663 void kvp_value_delete (KvpValue * value);
664 
666 KvpValue *kvp_value_copy (const KvpValue * value);
667 
670 
672 GList *kvp_value_replace_glist_nc (KvpValue * value, GList * newlist);
673 
682 KvpValueType kvp_value_get_type (const KvpValue * value);
683 
699 gint64 kvp_value_get_gint64 (const KvpValue * value);
700 gdouble kvp_value_get_double (const KvpValue * value);
701 QofNumeric kvp_value_get_numeric (const KvpValue * value);
702 
705 gchar *
706 kvp_value_get_string (const KvpValue * value);
707 
710 GUID *
711 kvp_value_get_guid (const KvpValue * value);
712 
715 gpointer
716 kvp_value_get_binary (const KvpValue * value, guint64 * size_return);
717 
721 GList *
722 kvp_value_get_glist (const KvpValue * value);
723 
726 KvpFrame *
727 kvp_value_get_frame (const KvpValue * value);
728 
729 
730 gboolean
731 kvp_value_get_boolean (const KvpValue * value);
732 
733 QofTime*
734 kvp_value_get_time (const KvpValue * value);
735 
739 gint
740 kvp_value_compare (const KvpValue * va, const KvpValue * vb);
741 
748 gchar *
749 kvp_value_to_bare_string (const KvpValue * val);
750 
756 gchar *
757 kvp_value_to_string (const KvpValue * val);
758 
762 gboolean
763 kvp_value_binary_append (KvpValue * v, gpointer data, guint64 size);
764 
770 typedef void (*KvpValueForeachCB) (const gchar *key, KvpValue * value, gpointer data);
771 
776 void
778 
782 #endif