GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
kvp_frame.h
Go to the documentation of this file.
1 /********************************************************************\
2  * kvp_frame.h -- Implements a key-value frame system *
3  * This program is free software; you can redistribute it and/or *
4  * modify it under the terms of the GNU General Public License as *
5  * published by the Free Software Foundation; either version 2 of *
6  * the License, or (at your option) any later version. *
7  * *
8  * This program is distributed in the hope that it will be useful, *
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
11  * GNU General Public License for more details. *
12  * *
13  * You should have received a copy of the GNU General Public License*
14  * along with this program; if not, contact: *
15  * *
16  * Free Software Foundation Voice: +1-617-542-5942 *
17  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
18  * Boston, MA 02110-1301, USA [email protected] *
19  * *
20 \********************************************************************/
61 #ifndef KVP_FRAME_H
62 #define KVP_FRAME_H
63 
64 #ifdef __cplusplus
65 extern "C"
66 {
67 #endif
68 
69 #include "gnc-date.h"
70 #include "gnc-numeric.h"
71 #include "guid.h"
72 
73 #define QOF_MOD_KVP "qof.kvp"
74 
76 typedef struct KvpFrameImpl KvpFrame;
77 
80 typedef struct KvpValueImpl KvpValue;
81 
93 typedef enum
94 {
95  KVP_TYPE_INVALID = -1,
102  KVP_TYPE_PLACEHOLDER_DONT_USE, /* Replaces KVP_TYPE_BINARY */
106 } KvpValueType;
107 
113 #define kvp_value_t KvpValueType
114 
120 KvpFrame * kvp_frame_new(void);
121 
127 void kvp_frame_delete(KvpFrame * frame);
128 
131 KvpFrame * kvp_frame_copy(const KvpFrame * frame);
132 
134 gboolean kvp_frame_is_empty(const KvpFrame * frame);
135 
151 const char ** kvp_frame_get_keys(const KvpFrame * frame);
152 
158 void kvp_frame_set_gint64(KvpFrame * frame, const gchar * path, gint64 ival);
164 void kvp_frame_set_double(KvpFrame * frame, const gchar * path, double dval);
165 
170 #define kvp_frame_set_gnc_numeric kvp_frame_set_numeric
171 
176 void kvp_frame_set_numeric(KvpFrame * frame, const gchar * path, gnc_numeric nval);
182 void kvp_frame_set_timespec(KvpFrame * frame, const gchar * path, Timespec ts);
183 
196 void kvp_frame_set_string(KvpFrame * frame, const gchar * path, const gchar* str);
197 void kvp_frame_set_guid(KvpFrame * frame, const gchar * path, const GncGUID *guid);
198 
199 void kvp_frame_set_frame(KvpFrame *frame, const gchar *path, KvpFrame *chld);
200 void kvp_frame_set_frame_nc(KvpFrame *frame, const gchar *path, KvpFrame *chld);
201 
213  const gchar * path, const KvpValue * value);
228  const gchar * path, KvpValue * value);
229 
238 KvpValue * kvp_frame_replace_value_nc (KvpFrame * frame, const gchar * slot,
239  KvpValue * new_value);
256 void kvp_frame_add_frame_nc(KvpFrame *frame, const gchar *path, KvpFrame *chld);
257 
258 
290 gint64 kvp_frame_get_gint64(const KvpFrame *frame, const gchar *path);
291 double kvp_frame_get_double(const KvpFrame *frame, const gchar *path);
292 gnc_numeric kvp_frame_get_numeric(const KvpFrame *frame, const gchar *path);
293 const gchar * kvp_frame_get_string(const KvpFrame *frame, const gchar *path);
294 GncGUID * kvp_frame_get_guid(const KvpFrame *frame, const gchar *path);
295 Timespec kvp_frame_get_timespec(const KvpFrame *frame, const gchar *path);
296 KvpValue * kvp_frame_get_value(const KvpFrame *frame, const gchar *path);
297 
316 /*@ dependent @*/
317 KvpFrame * kvp_frame_get_frame(const KvpFrame *frame, const gchar *path);
318 
319 KvpFrame * kvp_frame_get_frame_slash (KvpFrame *frame,
320  const gchar *path);
321 
344 /* KvpValue * kvp_frame_replace_slot_nc (KvpFrame * frame, const gchar * slot, */
345 /* KvpValue * new_value); */
346 
347 
354 void kvp_frame_set_slot(KvpFrame * frame,
355  const gchar * key, KvpValue * value);
364 void kvp_frame_set_slot_nc(KvpFrame * frame,
365  const gchar * key, KvpValue * value);
366 
372 void kvp_frame_set_slot_path (KvpFrame *frame,
373  KvpValue *value,
374  const gchar *first_key, ...);
375 
382  KvpValue *value,
383  GSList *key_path);
384 
401 KvpValue * kvp_frame_get_slot(const KvpFrame * frame, const gchar * key);
402 
407  const gchar *first_key, ...);
408 
413  const GSList *key_path);
414 
418 gint kvp_frame_compare(const KvpFrame *fa, const KvpFrame *fb);
419 
420 gint double_compare(double v1, double v2);
431 gint kvp_glist_compare(const GList * list1, const GList * list2);
432 
438 GList * kvp_glist_copy(const GList * list);
439 
445 void kvp_glist_delete(GList * list);
459 KvpValue * kvp_value_new_gint64(gint64 value);
460 KvpValue * kvp_value_new_double(double value);
461 
466 #define kvp_value_new_gnc_numeric kvp_value_new_numeric
467 KvpValue * kvp_value_new_numeric(gnc_numeric value);
468 KvpValue * kvp_value_new_string(const gchar * value);
469 KvpValue * kvp_value_new_guid(const GncGUID * guid);
470 KvpValue * kvp_value_new_timespec(Timespec timespec);
471 KvpValue * kvp_value_new_frame(const KvpFrame * value);
472 KvpValue * kvp_value_new_gdate(GDate date);
473 
476 KvpValue * kvp_value_new_glist(const GList * value);
477 
484 KvpValue * kvp_value_new_glist_nc(GList *lst);
485 
489 
491 void kvp_value_delete(KvpValue * value);
492 
494 KvpValue * kvp_value_copy(const KvpValue * value);
495 
498 
500 GList * kvp_value_replace_glist_nc(KvpValue *value, GList *newlist);
501 
511 KvpValueType kvp_value_get_type(const KvpValue * value);
512 
513 
524 gint64 kvp_value_get_gint64(const KvpValue * value);
525 double kvp_value_get_double(const KvpValue * value);
526 gnc_numeric kvp_value_get_numeric(const KvpValue * value);
527 
530 char * kvp_value_get_string(const KvpValue * value);
531 
534 GncGUID * kvp_value_get_guid(const KvpValue * value);
535 
539 GList * kvp_value_get_glist(const KvpValue * value);
540 
543 /*@ dependent @*/
544 KvpFrame * kvp_value_get_frame(const KvpValue * value);
545 Timespec kvp_value_get_timespec(const KvpValue * value);
546 
548 GDate kvp_value_get_gdate(const KvpValue * value);
549 
553 gint kvp_value_compare(const KvpValue *va, const KvpValue *vb);
554 
562 gchar* kvp_value_to_string(const KvpValue *val);
563 
572  void (*proc)(const gchar *key,
573  KvpValue *value,
574  gpointer data),
575  gpointer data);
576 
580 gchar* kvp_frame_to_string(const KvpFrame *frame);
581 
587 typedef struct
588 {
589  const gchar *key;
590  GValue *value;
591 }KvpItem;
592 
607 GValue *kvp_frame_get_gvalue (KvpFrame *frame, const gchar *key);
608 
623 void kvp_frame_set_gvalue (KvpFrame *frame, const gchar *key, const GValue *value);
624 
630 void gnc_gvalue_free (GValue *value);
631 
632 GType gnc_value_list_get_type (void);
633 #define GNC_TYPE_VALUE_LIST (gnc_value_list_get_type ())
634 
636 #ifdef __cplusplus
637 }
638 #endif
639 
640 #endif
void kvp_frame_set_gvalue(KvpFrame *frame, const gchar *key, const GValue *value)
void kvp_frame_set_slot_path_gslist(KvpFrame *frame, KvpValue *value, GSList *key_path)
void kvp_frame_set_slot(KvpFrame *frame, const gchar *key, KvpValue *value)
void kvp_frame_set_timespec(KvpFrame *frame, const gchar *path, Timespec ts)
Date and Time handling routines.
GList * kvp_value_replace_glist_nc(KvpValue *value, GList *newlist)
GList * kvp_glist_copy(const GList *list)
gboolean kvp_frame_is_empty(const KvpFrame *frame)
An exact-rational-number library for gnucash. (to be renamed qofnumeric.h in libqof2) ...
KvpValueType
possible types in the union KvpValue
Definition: kvp_frame.h:93
void kvp_frame_add_frame_nc(KvpFrame *frame, const gchar *path, KvpFrame *chld)
Store the given kvp_frame to the glist bag at the indicated path (non-copying)
gint kvp_frame_compare(const KvpFrame *fa, const KvpFrame *fb)
KvpFrame * kvp_frame_copy(const KvpFrame *frame)
globally unique ID User API
Use a 64-bit unsigned int timespec.
Definition: gnc-date.h:299
void kvp_frame_set_gint64(KvpFrame *frame, const gchar *path, gint64 ival)
Transfer of KVP to and from GValue, with the key.
Definition: kvp_frame.h:587
KvpValue * kvp_value_new_frame_nc(KvpFrame *value)
KvpFrame * kvp_frame_set_value(KvpFrame *frame, const gchar *path, const KvpValue *value)
void kvp_frame_delete(KvpFrame *frame)
void kvp_frame_set_slot_path(KvpFrame *frame, KvpValue *value, const gchar *first_key,...)
Definition: guid.h:65
gint64 kvp_value_get_gint64(const KvpValue *value)
KvpValue * kvp_frame_replace_value_nc(KvpFrame *frame, const gchar *slot, KvpValue *new_value)
void gnc_gvalue_free(GValue *value)
Convenience function to release the value in a GValue acquired by kvp_frame_get_gvalue and to free th...
char * kvp_value_get_string(const KvpValue *value)
KvpValue * kvp_value_copy(const KvpValue *value)
GValue * kvp_frame_get_gvalue(KvpFrame *frame, const gchar *key)
const char ** kvp_frame_get_keys(const KvpFrame *frame)
void kvp_frame_set_slot_nc(KvpFrame *frame, const gchar *key, KvpValue *value)
GList * kvp_value_get_glist(const KvpValue *value)
void kvp_frame_set_numeric(KvpFrame *frame, const gchar *path, gnc_numeric nval)
KvpFrame * kvp_value_replace_frame_nc(KvpValue *value, KvpFrame *newframe)
void kvp_glist_delete(GList *list)
GncGUID * kvp_value_get_guid(const KvpValue *value)
KvpValue * kvp_frame_get_slot_path(KvpFrame *frame, const gchar *first_key,...)
gchar * kvp_frame_to_string(const KvpFrame *frame)
KvpFrame * kvp_frame_set_value_nc(KvpFrame *frame, const gchar *path, KvpValue *value)
KvpValue * kvp_value_new_glist(const GList *value)
void kvp_frame_for_each_slot(KvpFrame *f, void(*proc)(const gchar *key, KvpValue *value, gpointer data), gpointer data)
void kvp_frame_set_double(KvpFrame *frame, const gchar *path, double dval)
KvpValue * kvp_value_new_glist_nc(GList *lst)
struct KvpFrameImpl KvpFrame
Definition: kvp_frame.h:76
GDate kvp_value_get_gdate(const KvpValue *value)
KvpFrame * kvp_frame_new(void)
KvpFrame * kvp_value_get_frame(const KvpValue *value)
KvpFrame * kvp_frame_get_frame(const KvpFrame *frame, const gchar *path)
void kvp_value_delete(KvpValue *value)
gint kvp_value_compare(const KvpValue *va, const KvpValue *vb)
gchar * kvp_value_to_string(const KvpValue *val)
Debug version of kvp_value_to_string.
void kvp_frame_set_string(KvpFrame *frame, const gchar *path, const gchar *str)
Store a copy of the string at the indicated path.
struct KvpValueImpl KvpValue
Definition: kvp_frame.h:80
KvpValue * kvp_frame_get_slot_path_gslist(KvpFrame *frame, const GSList *key_path)