QOF: kvpframe.h Source File

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 {
94 KVP_TYPE_GINT64 = 1,
100 KVP_TYPE_DOUBLE,
106 KVP_TYPE_NUMERIC,
112 KVP_TYPE_STRING,
118 KVP_TYPE_GUID,
119 #ifndef QOF_DISABLE_DEPRECATED
120
121 KVP_TYPE_TIMESPEC,
122 #endif
123
128 KVP_TYPE_TIME,
130 KVP_TYPE_BINARY,
132 KVP_TYPE_GLIST,
134 KVP_TYPE_FRAME,
140 KVP_TYPE_BOOLEAN
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
562 void kvp_frame_set_slot_path_gslist (KvpFrame * frame,
563 const KvpValue * value,
564 GSList * key_path);
565
582 KvpValue *kvp_frame_get_slot (const KvpFrame * frame, const gchar * key);
583
587 KvpValue *kvp_frame_get_slot_path (KvpFrame * frame,
588 const gchar * first_key, ...);
589
593 KvpValue *kvp_frame_get_slot_path_gslist (KvpFrame * frame,
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
660 KvpValue *kvp_value_new_frame_nc (KvpFrame * value);
661
663 void kvp_value_delete (KvpValue * value);
664
666 KvpValue *kvp_value_copy (const KvpValue * value);
667
669 KvpFrame *kvp_value_replace_frame_nc (KvpValue * value, KvpFrame * newframe);
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
777 kvp_frame_for_each_slot (KvpFrame * f, KvpValueForeachCB, gpointer data);
778
782 #endif
kvp_value_get_guid
GUID * kvp_value_get_guid(const KvpValue *value)
Definition: kvpframe.c:1477
KVP_TYPE_TIMESPEC
Definition: kvpframe.h:121
kvp_frame_get_frame_path
KvpFrame * kvp_frame_get_frame_path(KvpFrame *frame, const gchar *,...)
Definition: kvpframe.c:1024
kvp_frame_add_time
void kvp_frame_add_time(KvpFrame *frame, const gchar *path, QofTime *qt)
Add the value of the QofTime to the glist bag.
Definition: kvpframe.c:622
kvp_value_binary_append
gboolean kvp_value_binary_append(KvpValue *v, gpointer data, guint64 size)
kvp_value_replace_glist_nc
GList * kvp_value_replace_glist_nc(KvpValue *value, GList *newlist)
Definition: kvpframe.c:1581
kvp_glist_copy
GList * kvp_glist_copy(const GList *list)
Definition: kvpframe.c:1148
kvp_frame_set_guid
void kvp_frame_set_guid(KvpFrame *frame, const gchar *path, const GUID *guid)
Store a copy of the GUID at the indicated path.
Definition: kvpframe.c:453
KvpValueType
KvpValueType
possible types in the union KvpValue
Definition: kvpframe.h:87
qofnumeric.h
An exact-rational-number library for QOF.
kvp_frame_set_numeric
void kvp_frame_set_numeric(KvpFrame *frame, const gchar *path, QofNumeric nval)
store the value of the QofNumeric at the indicated path.
Definition: kvpframe.c:420
KVP_TYPE_GUID
Unique identifier.
Definition: kvpframe.h:118
kvp_frame_set_frame_nc
void kvp_frame_set_frame_nc(KvpFrame *frame, const gchar *path, KvpFrame *chld)
Store a KvpFrame at the indicated path without copying.
Definition: kvpframe.c:474
kvp_frame_set_time
void kvp_frame_set_time(KvpFrame *frame, const gchar *path, QofTime *qt)
Store a copy of the QofTime at the indicated path.
Definition: kvpframe.c:410
kvp_frame_add_value
KvpFrame * kvp_frame_add_value(KvpFrame *frame, const gchar *path, KvpValue *value)
Add a copy of the value to the glist bag.
Definition: kvpframe.c:581
kvp_frame_add_frame_nc
void kvp_frame_add_frame_nc(KvpFrame *frame, const gchar *path, KvpFrame *chld)
Add the frame to the glist bag without copying.
Definition: kvpframe.c:672
kvp_frame_get_frame_slash
KvpFrame * kvp_frame_get_frame_slash(KvpFrame *frame, const gchar *path)
Definition: kvpframe.c:1045
kvp_frame_copy
KvpFrame * kvp_frame_copy(const KvpFrame *frame)
Definition: kvpframe.c:156
KvpFrame
struct _KvpFrame KvpFrame
Definition: kvpframe.h:74
guid.h
globally unique ID User API
kvp_frame_set_slot_path
void kvp_frame_set_slot_path(KvpFrame *frame, const KvpValue *value, const gchar *first_key,...)
Definition: kvpframe.c:726
kvp_glist_compare
gint kvp_glist_compare(const GList *list1, const GList *list2)
Definition: kvpframe.c:1170
kvp_frame_set_gint64
void kvp_frame_set_gint64(KvpFrame *frame, const gchar *path, gint64 ival)
store the value of the gint64 at the indicated path.
Definition: kvpframe.c:390
kvp_value_new_boolean
KvpValue * kvp_value_new_boolean(gboolean value)
Definition: kvpframe.c:1226
KVP_TYPE_GLIST
Definition: kvpframe.h:132
KVP_TYPE_FRAME
Definition: kvpframe.h:134
kvp_frame_is_empty
gboolean kvp_frame_is_empty(KvpFrame *frame)
Definition: kvpframe.c:137
kvp_value_new_frame_nc
KvpValue * kvp_value_new_frame_nc(KvpFrame *value)
Definition: kvpframe.c:1348
kvp_frame_set_slot_path_gslist
void kvp_frame_set_slot_path_gslist(KvpFrame *frame, const KvpValue *value, GSList *key_path)
Definition: kvpframe.c:779
kvp_frame_get_frame_gslist
KvpFrame * kvp_frame_get_frame_gslist(KvpFrame *frame, GSList *key_path)
Definition: kvpframe.c:1002
kvp_frame_set_value
KvpFrame * kvp_frame_set_value(KvpFrame *frame, const gchar *path, const KvpValue *value)
Copy the KvpValue into the frame.
Definition: kvpframe.c:499
kvp_value_get_binary
gpointer kvp_value_get_binary(const KvpValue *value, guint64 *size_return)
Definition: kvpframe.c:1507
KVP_TYPE_NUMERIC
128bit denominator/numerator maths.
Definition: kvpframe.h:106
kvp_frame_delete
void kvp_frame_delete(KvpFrame *frame)
Definition: kvpframe.c:118
kvp_value_get_gint64
gint64 kvp_value_get_gint64(const KvpValue *value)
Definition: kvpframe.c:1402
kvp_frame_replace_value_nc
KvpValue * kvp_frame_replace_value_nc(KvpFrame *frame, const gchar *slot, KvpValue *new_value)
Definition: kvpframe.c:516
kvp_frame_set_frame
void kvp_frame_set_frame(KvpFrame *frame, const gchar *path, KvpFrame *chld)
Store a copy of the KvpFrame at the indicated path.
Definition: kvpframe.c:464
KvpValueForeachCB
void(* KvpValueForeachCB)(const gchar *key, KvpValue *value, gpointer data)
Definition: kvpframe.h:770
KvpValue
struct _KvpValue KvpValue
Definition: kvpframe.h:78
kvp_frame_replace_slot_nc
KvpValue * kvp_frame_replace_slot_nc(KvpFrame *frame, const gchar *slot, KvpValue *new_value)
Definition: kvpframe.c:178
kvp_frame_set_slot
void kvp_frame_set_slot(KvpFrame *frame, const gchar *key, const KvpValue *value)
Definition: kvpframe.c:684
kvp_value_copy
KvpValue * kvp_value_copy(const KvpValue *value)
Definition: kvpframe.c:1601
kvp_value_new_binary_nc
KvpValue * kvp_value_new_binary_nc(void *data, guint64 datasize)
KVP_TYPE_GINT64
64bit integer
Definition: kvpframe.h:94
_QofNumeric
Definition: qofnumeric.h:52
kvp_frame_add_double
void kvp_frame_add_double(KvpFrame *frame, const gchar *path, gdouble dval)
Add the value of the double to the glist bag.
Definition: kvpframe.c:601
kvp_frame_set_slot_nc
void kvp_frame_set_slot_nc(KvpFrame *frame, const gchar *key, KvpValue *value)
Definition: kvpframe.c:700
kvp_frame_set_boolean
void kvp_frame_set_boolean(KvpFrame *frame, const gchar *path, gboolean val)
Store the value of the boolean at the indicated path.
Definition: kvpframe.c:431
kvp_value_get_glist
GList * kvp_value_get_glist(const KvpValue *value)
Definition: kvpframe.c:1534
kvp_value_to_bare_string
gchar * kvp_value_to_bare_string(const KvpValue *val)
General purpose function to convert any KvpValue to a string.
Definition: kvpframe.c:1848
kvp_value_replace_frame_nc
KvpFrame * kvp_value_replace_frame_nc(KvpValue *value, KvpFrame *newframe)
Definition: kvpframe.c:1564
kvp_glist_delete
void kvp_glist_delete(GList *list)
Definition: kvpframe.c:1130
kvp_value_get_string
gchar * kvp_value_get_string(const KvpValue *value)
Definition: kvpframe.c:1447
kvp_frame_add_frame
void kvp_frame_add_frame(KvpFrame *frame, const gchar *path, KvpFrame *chld)
Copy the frame to the glist bag at the indicated path.
Definition: kvpframe.c:662
kvp_frame_add_string
void kvp_frame_add_string(KvpFrame *frame, const gchar *path, const gchar *str)
Copy the string to the glist bag at the indicated path.
Definition: kvpframe.c:642
kvp_frame_get_slot_path
KvpValue * kvp_frame_get_slot_path(KvpFrame *frame, const gchar *first_key,...)
Definition: kvpframe.c:1060
qoftime.h
64bit UTC Time handling routines
kvp_frame_set_value_nc
KvpFrame * kvp_frame_set_value_nc(KvpFrame *frame, const gchar *path, KvpValue *value)
Store the KvpValue in the frame without copying.
Definition: kvpframe.c:486
kvp_frame_for_each_slot
void kvp_frame_for_each_slot(KvpFrame *f, KvpValueForeachCB, gpointer data)
Definition: kvpframe.c:1650
_GUID
Definition: guid.h:53
kvp_value_new_glist
KvpValue * kvp_value_new_glist(const GList *value)
Definition: kvpframe.c:1309
kvp_value_new_glist_nc
KvpValue * kvp_value_new_glist_nc(GList *lst)
Definition: kvpframe.c:1322
QofTime
struct QofTime64 QofTime
Use a 64-bit signed int QofTime.
Definition: qoftime.h:120
KVP_TYPE_BOOLEAN
Simple boolean type.
Definition: kvpframe.h:140
kvp_frame_add_gint64
void kvp_frame_add_gint64(KvpFrame *frame, const gchar *path, gint64 ival)
add the value of the gint64 to the glist bag
Definition: kvpframe.c:591
KVP_TYPE_BINARY
Definition: kvpframe.h:130
KVP_TYPE_STRING
standard C string
Definition: kvpframe.h:112
kvp_frame_set_double
void kvp_frame_set_double(KvpFrame *frame, const gchar *path, gdouble dval)
store the value of the double at the indicated path.
Definition: kvpframe.c:400
kvp_frame_new
KvpFrame * kvp_frame_new(void)
Definition: kvpframe.c:100
kvp_value_get_frame
KvpFrame * kvp_value_get_frame(const KvpValue *value)
Definition: kvpframe.c:1549
KVP_TYPE_DOUBLE
standard C double type
Definition: kvpframe.h:100
kvp_frame_get_frame
KvpFrame * kvp_frame_get_frame(const KvpFrame *frame, const gchar *path)
Definition: kvpframe.c:984
kvp_value_delete
void kvp_value_delete(KvpValue *value)
Definition: kvpframe.c:1361
kvp_frame_get_slot_path_gslist
KvpValue * kvp_frame_get_slot_path_gslist(KvpFrame *frame, GSList *key_path)
Definition: kvpframe.c:1098
kvp_value_compare
gint kvp_value_compare(const KvpValue *va, const KvpValue *vb)
Definition: kvpframe.c:1662
kvp_value_to_string
gchar * kvp_value_to_string(const KvpValue *val)
Debug version.
Definition: kvpframe.c:1941
qofutil.h
QOF utility functions.
kvp_frame_set_string
void kvp_frame_set_string(KvpFrame *frame, const gchar *path, const gchar *str)
Store a copy of the string at the indicated path.
Definition: kvpframe.c:442
kvp_frame_add_numeric
void kvp_frame_add_numeric(KvpFrame *frame, const gchar *path, QofNumeric nval)
Add the value of the QofNumeric to the glist bag.
Definition: kvpframe.c:611
KVP_TYPE_TIME
64bit time/date handling.
Definition: kvpframe.h:128
kvp_frame_add_guid
void kvp_frame_add_guid(KvpFrame *frame, const gchar *path, const GUID *guid)
Copy the GUID to the glist bag at the indicated path.
Definition: kvpframe.c:652