QOF
0.7.5
|
Files | |
file | kvpframe.h |
A key-value frame system. | |
file | kvputil-p.h |
misc odd-job kvp utils engine-private routines | |
file | kvputil.h |
QOF KVP utility functions. | |
Data Structures | |
struct | GHashTableKVPair |
Macros | |
#define | QOF_MOD_KVP "qof-kvp" |
Typedefs | |
typedef struct _KvpFrame | KvpFrame |
typedef struct _KvpValue | KvpValue |
Enumerations | |
enum | KvpValueType { KVP_TYPE_GINT64 = 1, KVP_TYPE_DOUBLE, KVP_TYPE_NUMERIC, KVP_TYPE_STRING, KVP_TYPE_GUID, KVP_TYPE_TIMESPEC, KVP_TYPE_TIME, KVP_TYPE_BINARY, KVP_TYPE_GLIST, KVP_TYPE_FRAME, KVP_TYPE_BOOLEAN } |
possible types in the union KvpValue More... | |
Functions | |
gchar * | kvp_value_to_bare_string (const KvpValue *val) |
General purpose function to convert any KvpValue to a string. More... | |
gchar * | kvp_value_to_string (const KvpValue *val) |
Debug version. More... | |
gboolean | kvp_value_binary_append (KvpValue *v, gpointer data, guint64 size) |
gint | kvp_frame_compare (const KvpFrame *fa, const KvpFrame *fb) |
gchar * | kvp_frame_to_string (const KvpFrame *frame) |
gchar * | binary_to_string (const void *data, guint32 size) |
gchar * | kvp_value_glist_to_string (const GList *list) |
GHashTable * | kvp_frame_get_hash (const KvpFrame *frame) |
KvpFrame Constructors | |
KvpFrame * | kvp_frame_new (void) |
void | kvp_frame_delete (KvpFrame *frame) |
KvpFrame * | kvp_frame_copy (const KvpFrame *frame) |
gboolean | kvp_frame_is_empty (KvpFrame *frame) |
KvpFrame Basic Value Storing | |
void | kvp_frame_set_gint64 (KvpFrame *frame, const gchar *path, gint64 ival) |
store the value of the gint64 at the indicated path. More... | |
void | kvp_frame_set_double (KvpFrame *frame, const gchar *path, gdouble dval) |
store the value of the double at the indicated path. More... | |
void | kvp_frame_set_numeric (KvpFrame *frame, const gchar *path, QofNumeric nval) |
store the value of the QofNumeric at the indicated path. More... | |
void | kvp_frame_set_string (KvpFrame *frame, const gchar *path, const gchar *str) |
Store a copy of the string at the indicated path. More... | |
void | kvp_frame_set_guid (KvpFrame *frame, const gchar *path, const GUID *guid) |
Store a copy of the GUID at the indicated path. More... | |
void | kvp_frame_set_time (KvpFrame *frame, const gchar *path, QofTime *qt) |
Store a copy of the QofTime at the indicated path. More... | |
void | kvp_frame_set_boolean (KvpFrame *frame, const gchar *path, gboolean val) |
Store the value of the boolean at the indicated path. More... | |
void | kvp_frame_set_frame (KvpFrame *frame, const gchar *path, KvpFrame *chld) |
Store a copy of the KvpFrame at the indicated path. More... | |
void | kvp_frame_set_frame_nc (KvpFrame *frame, const gchar *path, KvpFrame *chld) |
Store a KvpFrame at the indicated path without copying. More... | |
KvpFrame * | kvp_frame_set_value (KvpFrame *frame, const gchar *path, const KvpValue *value) |
Copy the KvpValue into the frame. More... | |
KvpFrame * | kvp_frame_set_value_nc (KvpFrame *frame, const gchar *path, KvpValue *value) |
Store the KvpValue in the frame without copying. More... | |
KvpValue * | kvp_frame_replace_value_nc (KvpFrame *frame, const gchar *slot, KvpValue *new_value) |
KvpFrame Glist Bag Storing | |
void | kvp_frame_add_gint64 (KvpFrame *frame, const gchar *path, gint64 ival) |
add the value of the gint64 to the glist bag More... | |
void | kvp_frame_add_double (KvpFrame *frame, const gchar *path, gdouble dval) |
Add the value of the double to the glist bag. More... | |
void | kvp_frame_add_numeric (KvpFrame *frame, const gchar *path, QofNumeric nval) |
Add the value of the QofNumeric to the glist bag. More... | |
void | kvp_frame_add_time (KvpFrame *frame, const gchar *path, QofTime *qt) |
Add the value of the QofTime to the glist bag. More... | |
void | kvp_frame_add_string (KvpFrame *frame, const gchar *path, const gchar *str) |
Copy the string to the glist bag at the indicated path. More... | |
void | kvp_frame_add_boolean (KvpFrame *frame, const gchar *path, gboolean val) |
void | kvp_frame_add_guid (KvpFrame *frame, const gchar *path, const GUID *guid) |
Copy the GUID to the glist bag at the indicated path. More... | |
void | kvp_frame_add_frame (KvpFrame *frame, const gchar *path, KvpFrame *chld) |
Copy the frame to the glist bag at the indicated path. More... | |
void | kvp_frame_add_frame_nc (KvpFrame *frame, const gchar *path, KvpFrame *chld) |
Add the frame to the glist bag without copying. More... | |
KvpFrame * | kvp_frame_add_value (KvpFrame *frame, const gchar *path, KvpValue *value) |
Add a copy of the value to the glist bag. More... | |
KvpFrame * | kvp_frame_add_value_nc (KvpFrame *frame, const gchar *path, KvpValue *value) |
KvpFrame Value Fetching | |
Value accessors. These all take a unix-style slash-separated path as an argument, and return the value stored at that location. If the object at the end of that path is not of the type that was asked for, then a NULL or a zero is returned. So, for example, asking for a string when the path stored an int will return a NULL. In some future date, this may be changed to a looser type system, such as perl's automatic re-typing (e.g. an integer value might be converted to a printed string representing that value). If any part of the path does not exist, then NULL or zero will be returned. The values returned for GUID, binary, GList, KvpFrame and string are "non-copying" – the returned item is the actual item stored. Do not delete this item unless you take the required care to avoid possible bad pointer derefrences (i.e. core dumps). Also, be careful hanging on to those references if you are also storing at the same path names: the referenced item will be freed during the store. That is, if you get a string value (or guid, binary or frame), and then store something else at that path, the string that you've gotten will be freed during the store (internally, by the set_*() routines), and you will be left hanging onto an invalid pointer. | |
gint64 | kvp_frame_get_gint64 (const KvpFrame *frame, const gchar *path) |
gdouble | kvp_frame_get_double (const KvpFrame *frame, const gchar *path) |
QofNumeric | kvp_frame_get_numeric (const KvpFrame *frame, const gchar *path) |
gchar * | kvp_frame_get_string (const KvpFrame *frame, const gchar *path) |
GUID * | kvp_frame_get_guid (const KvpFrame *frame, const gchar *path) |
gpointer | kvp_frame_get_binary (const KvpFrame *frame, const gchar *path, guint64 *size_return) |
gboolean | kvp_frame_get_boolean (const KvpFrame *frame, const gchar *path) |
QofTime * | kvp_frame_get_time (const KvpFrame *frame, const gchar *path) |
KvpValue * | kvp_frame_get_value (const KvpFrame *frame, const gchar *path) |
KvpFrame * | kvp_frame_get_frame (const KvpFrame *frame, const gchar *path) |
KvpFrame * | kvp_frame_get_frame_path (KvpFrame *frame, const gchar *,...) |
KvpFrame * | kvp_frame_get_frame_gslist (KvpFrame *frame, GSList *key_path) |
KvpFrame * | kvp_frame_get_frame_slash (KvpFrame *frame, const gchar *path) |
KvpFrame KvpValue low-level storing routines. | |
You probably shouldn't be using these low-level routines All of the kvp_frame_set_slot_*() routines set the slot values "destructively", in that if there was an old value there, that old value is destroyed (and the memory freed). Thus, one should not hang on to value pointers, as these will get trashed if set_slot is called on the corresponding key. If you want the old value, use kvp_frame_replace_slot(). | |
KvpValue * | kvp_frame_replace_slot_nc (KvpFrame *frame, const gchar *slot, KvpValue *new_value) |
void | kvp_frame_set_slot (KvpFrame *frame, const gchar *key, const KvpValue *value) |
void | kvp_frame_set_slot_nc (KvpFrame *frame, const gchar *key, KvpValue *value) |
void | kvp_frame_set_slot_path (KvpFrame *frame, const KvpValue *value, const gchar *first_key,...) |
void | kvp_frame_set_slot_path_gslist (KvpFrame *frame, const KvpValue *value, GSList *key_path) |
KvpFrame KvpValue Low-Level Retrieval Routines | |
You probably shouldn't be using these low-level routines Returns the KvpValue in the given KvpFrame 'frame' that is associated with 'key'. If there is no key in the frame, NULL is returned. If the value associated with the key is NULL, NULL is returned. Pointers passed as arguments into get_slot are the responsibility of the caller. Pointers returned by get_slot are owned by the kvp_frame. Make copies as needed. | |
KvpValue * | kvp_frame_get_slot (const KvpFrame *frame, const gchar *key) |
KvpValue * | kvp_frame_get_slot_path (KvpFrame *frame, const gchar *first_key,...) |
KvpValue * | kvp_frame_get_slot_path_gslist (KvpFrame *frame, GSList *key_path) |
gint | kvp_glist_compare (const GList *list1, const GList *list2) |
GList * | kvp_glist_copy (const GList *list) |
void | kvp_glist_delete (GList *list) |
KvpValue Constructors | |
The following routines are constructors for kvp_value. Those with pointer arguments copy in the value. The *_nc() versions do not copy in their values, but use them directly. | |
KvpValue * | kvp_value_new_gint64 (gint64 value) |
KvpValue * | kvp_value_new_double (double value) |
KvpValue * | kvp_value_new_numeric (QofNumeric value) |
KvpValue * | kvp_value_new_string (const gchar *value) |
KvpValue * | kvp_value_new_guid (const GUID *guid) |
KvpValue * | kvp_value_new_time (QofTime *value) |
KvpValue * | kvp_value_new_boolean (gboolean value) |
KvpValue * | kvp_value_new_binary (const void *data, guint64 datasize) |
KvpValue * | kvp_value_new_frame (const KvpFrame *value) |
KvpValue * | kvp_value_new_glist (const GList *value) |
KvpValue * | kvp_value_new_binary_nc (void *data, guint64 datasize) |
KvpValue * | kvp_value_new_glist_nc (GList *lst) |
KvpValue * | kvp_value_new_frame_nc (KvpFrame *value) |
void | kvp_value_delete (KvpValue *value) |
KvpValue * | kvp_value_copy (const KvpValue *value) |
KvpFrame * | kvp_value_replace_frame_nc (KvpValue *value, KvpFrame *newframe) |
GList * | kvp_value_replace_glist_nc (KvpValue *value, GList *newlist) |
KvpValue Value access | |
KvpValueType | kvp_value_get_type (const KvpValue *value) |
gint64 | kvp_value_get_gint64 (const KvpValue *value) |
gdouble | kvp_value_get_double (const KvpValue *value) |
QofNumeric | kvp_value_get_numeric (const KvpValue *value) |
gchar * | kvp_value_get_string (const KvpValue *value) |
GUID * | kvp_value_get_guid (const KvpValue *value) |
gpointer | kvp_value_get_binary (const KvpValue *value, guint64 *size_return) |
GList * | kvp_value_get_glist (const KvpValue *value) |
KvpFrame * | kvp_value_get_frame (const KvpValue *value) |
gboolean | kvp_value_get_boolean (const KvpValue *value) |
QofTime * | kvp_value_get_time (const KvpValue *value) |
gint | kvp_value_compare (const KvpValue *va, const KvpValue *vb) |
Iterators | |
typedef void(* | KvpValueForeachCB )(const gchar *key, KvpValue *value, gpointer data) |
void | kvp_frame_for_each_slot (KvpFrame *f, KvpValueForeachCB, gpointer data) |
KvpBag Bags of GUID Pointers | |
KvpFrame * | qof_kvp_bag_add (KvpFrame *kvp_root, const gchar *path, QofTime *qt, const gchar *first_name,...) |
void | qof_kvp_bag_merge (KvpFrame *kvp_into, const gchar *intopath, KvpFrame *kvp_from, const gchar *frompath) |
KvpFrame * | qof_kvp_bag_find_by_guid (KvpFrame *root, const gchar *path, const gchar *guid_name, GUID *desired_guid) |
void | qof_kvp_bag_remove_frame (KvpFrame *root, const gchar *path, KvpFrame *fr) |
Hash Utilities | |
GSList * | g_hash_table_key_value_pairs (GHashTable *table) |
void | g_hash_table_kv_pair_free_gfunc (gpointer data, gpointer user_data) |
KvpFrame URL handling | |
void | kvp_frame_add_url_encoding (KvpFrame *frame, const gchar *enc) |
A KvpFrame is a set of associations between character strings (keys) and KvpValue structures. A KvpValue is a union with possible types enumerated in the KvpValueType enum, and includes, among other things, ints, doubles, strings, guid's, lists, time and numeric values. KvpValues may also be other frames, so KVP is inherently hierarchical.
Values are stored in a 'slot' associated with a key. Pointers passed as arguments into set_slot and get_slot are the responsibility of the caller. Pointers returned by get_slot are owned by the kvp_frame. Make copies as needed.
A 'path' is a sequence of keys that can be followed to a value. Paths may be specified as varargs (variable number of arguments to a subrutine, NULL-terminated), as a GSList, or as a standard URL-like path name. The later is parsed and treated in the same way as file paths would be: / separates keys, /./ is treated as / and /../ means backup one level. Repeated slashes are treated as one slash.
Note that although, in principle, keys may contain the / and . and .. characters, doing so may lead to confusion, and will make path-string parsing routines fail. In other words, don't use a key such as 'some/key' or 'some/./other/../key' because you may get unexpected results.
To set a value into a frame, you will want to use one of the kvp_frame_set_xxx() routines. Most of the other routines provide only low-level access that you probably shouldn't use.
typedef struct _KvpFrame KvpFrame |
Opaque frame structure
Definition at line 74 of file kvpframe.h.
typedef struct _KvpValue KvpValue |
A KvpValue is a union with possible types enumerated in the KvpValueType enum.
Definition at line 78 of file kvpframe.h.
typedef void(* KvpValueForeachCB)(const gchar *key, KvpValue *value, gpointer data) |
Definition at line 770 of file kvpframe.h.
enum KvpValueType |
possible types in the union KvpValue
Enumerator | |
---|---|
KVP_TYPE_GINT64 |
64bit integer
|
KVP_TYPE_DOUBLE |
standard C double type
|
KVP_TYPE_NUMERIC |
128bit denominator/numerator maths.
|
KVP_TYPE_STRING |
standard C string
|
KVP_TYPE_GUID |
Unique identifier.
|
KVP_TYPE_TIMESPEC |
|
KVP_TYPE_TIME |
64bit time/date handling.
|
KVP_TYPE_BINARY |
no QofType/GType/GLib equivalent. |
KVP_TYPE_GLIST |
no QofType/GType equivalent. |
KVP_TYPE_FRAME |
no QofType/GType/GLib equivalent. |
KVP_TYPE_BOOLEAN |
Simple boolean type.
|
Definition at line 87 of file kvpframe.h.
GSList* g_hash_table_key_value_pairs | ( | GHashTable * | table | ) |
Returns a GSList* of all the keys and values in a given hash table. Data elements of lists are actual hash elements, so be careful, and deallocation of the GHashTableKVPairs in the result list are the caller's responsibility. A typical sequence might look like this:
GSList *kvps = g_hash_table_key_value_pairs(hash); ... use kvps->data->key and kvps->data->val, etc. here ... g_slist_foreach(kvps, g_hash_table_kv_pair_free_gfunc, NULL); g_slist_free(kvps);
void kvp_frame_add_double | ( | KvpFrame * | frame, |
const gchar * | path, | ||
gdouble | dval | ||
) |
Add the value of the double to the glist bag.
If not all frame components of the path exist, they are created. If the value previously stored at this path was not a glist bag, then a bag will be formed there, the old value placed in the bag, and the new value added to the bag.
Definition at line 601 of file kvpframe.c.
Copy the frame to the glist bag at the indicated path.
If not all frame components of the path exist, they are created. If there was another item previously stored at that path, then the path is converted to a bag, and the old value, along with the new value, is added to the bag.
Definition at line 662 of file kvpframe.c.
Add the frame to the glist bag without copying.
If not all frame components of the path exist, they are created. If there was another item previously stored at that path, then the path is converted to a bag, and the old value, along with the new value, is added to the bag.
Definition at line 672 of file kvpframe.c.
void kvp_frame_add_gint64 | ( | KvpFrame * | frame, |
const gchar * | path, | ||
gint64 | ival | ||
) |
add the value of the gint64 to the glist bag
If not all frame components of the path exist, they are created. If the value previously stored at this path was not a glist bag, then a bag will be formed there, the old value placed in the bag, and the new value added to the bag.
Definition at line 591 of file kvpframe.c.
Copy the GUID to the glist bag at the indicated path.
If not all frame components of the path exist, they are created. If there was another item previously stored at that path, then the path is converted to a bag, and the old value, along with the new value, is added to the bag.
Definition at line 652 of file kvpframe.c.
void kvp_frame_add_numeric | ( | KvpFrame * | frame, |
const gchar * | path, | ||
QofNumeric | nval | ||
) |
Add the value of the QofNumeric to the glist bag.
If not all frame components of the path exist, they are created. If the value previously stored at this path was not a glist bag, then a bag will be formed there, the old value placed in the bag, and the new value added to the bag.
Definition at line 611 of file kvpframe.c.
void kvp_frame_add_string | ( | KvpFrame * | frame, |
const gchar * | path, | ||
const gchar * | str | ||
) |
Copy the string to the glist bag at the indicated path.
If not all frame components of the path exist, they are created. If there was another item previously stored at that path, then the path is converted to a bag, and the old value, along with the new value, is added to the bag.
Definition at line 642 of file kvpframe.c.
Add the value of the QofTime to the glist bag.
If not all frame components of the path exist, they are created. If the value previously stored at this path was not a glist bag, then a bag will be formed there, the old value placed in the bag, and the new value added to the bag.
Definition at line 622 of file kvpframe.c.
void kvp_frame_add_url_encoding | ( | KvpFrame * | frame, |
const gchar * | enc | ||
) |
The kvp_frame_add_url_encoding() routine will parse the value string, assuming it to be URL-encoded in the standard way, turning it into a set of key-value pairs, and adding those to the indicated frame. URL-encoded strings are the things that are returned by web browsers when a form is filled out. For example, 'start-date=June&end-date=November' consists of two keys, 'start-date' and 'end-date', which have the values 'June' and 'November', respectively. This routine also handles % encoding.
This routine treats all values as strings; it does not attempt to perform any type-conversion.
Definition at line 880 of file kvpframe.c.
Add a copy of the value to the glist bag.
If not all frame components of the path exist, they are created. If there was another item previously stored at that path, then the path is converted to a bag, and the old value, along with the new value, is added to the bag. This routine returns the pointer to the last frame (the actual frame to which the value was added), or NULL if there was an error of any sort (typically, a parse error in the path).
Definition at line 581 of file kvpframe.c.
Perform a deep (recursive) value copy, copying the frame, subframes, and the values as well.
Definition at line 156 of file kvpframe.c.
void kvp_frame_delete | ( | KvpFrame * | frame | ) |
Perform a deep (recursive) delete of the frame and any subframes.
Definition at line 118 of file kvpframe.c.
void kvp_frame_for_each_slot | ( | KvpFrame * | f, |
KvpValueForeachCB | , | ||
gpointer | data | ||
) |
Traverse all of the slots in the given kvp_frame. This function does not descend recursively to traverse any kvp_frames stored as slot values. You must handle that in proc, with a suitable recursive call if desired.
Definition at line 1650 of file kvpframe.c.
Value accessor. Takes a unix-style slash-separated path as an argument, and return the KvpFrame stored at that location. If the KvpFrame does not exist, then a NULL is returned.
Definition at line 984 of file kvpframe.c.
This routine returns the last frame of the path. If the frame path doesn't exist, it is created. Note that this is VERY DIFFERENT FROM kvp_frame_get_frame()
Definition at line 1002 of file kvpframe.c.
This routine returns the last frame of the path. If the frame path doesn't exist, it is created. Note that this is VERY DIFFERENT FROM kvp_frame_get_frame()
Definition at line 1024 of file kvpframe.c.
This routine returns the last frame of the path. If the frame path doesn't exist, it is created. Note that this is VERY DIFFERENT FROM kvp_frame_get_frame()
The kvp_frame_get_frame_slash() routine takes a single string where the keys are separated by slashes; thus, for example: /this/is/a/valid/path and///so//is////this/ Multiple slashes are compresed. Leading slash is optional. The pointers . and .. are not currently followed/obeyed. (This is a bug that needs fixing).
Definition at line 1045 of file kvpframe.c.
This routine return the value at the end of the path, or NULL if any portion of the path doesn't exist.
Definition at line 1060 of file kvpframe.c.
This routine return the value at the end of the path, or NULL if any portion of the path doesn't exist.
Definition at line 1098 of file kvpframe.c.
gboolean kvp_frame_is_empty | ( | KvpFrame * | frame | ) |
Return TRUE if the KvpFrame is empty
Definition at line 137 of file kvpframe.c.
KvpFrame* kvp_frame_new | ( | void | ) |
Return a new empty instance of KvpFrame
Definition at line 100 of file kvpframe.c.
The kvp_frame_replace_slot_nc() routine places the new value into the indicated frame, for the given key. It returns the old value, if any. It returns NULL if the slot doesn't exist, if there was some other an error, or if there was no old value. Passing in a NULL new_value has the effect of deleting that slot.
Definition at line 178 of file kvpframe.c.
The kvp_frame_replace_value_nc() routine places the new value at the indicated path. It returns the old value, if any. It returns NULL if there was an error, or if there was no old value. If the path doesn't exist, it is created, unless new_value is NULL. Passing in a NULL new_value has the effect of deleting the trailing slot (i.e. the trailing path element).
Definition at line 516 of file kvpframe.c.
void kvp_frame_set_boolean | ( | KvpFrame * | frame, |
const gchar * | path, | ||
gboolean | val | ||
) |
Store the value of the boolean at the indicated path.
If not all frame components of the path exist, they are created.
Definition at line 431 of file kvpframe.c.
void kvp_frame_set_double | ( | KvpFrame * | frame, |
const gchar * | path, | ||
gdouble | dval | ||
) |
store the value of the double at the indicated path.
If not all frame components of the path exist, they are created.
Definition at line 400 of file kvpframe.c.
Store a copy of the KvpFrame at the indicated path.
If not all frame components of the path exist, they are created. If there was another QofTime previously stored at that path, the old frame is deleted.
Definition at line 464 of file kvpframe.c.
Store a KvpFrame at the indicated path without copying.
If not all frame components of the path exist, they are created. If there was another QofTime previously stored at that path, the old frame is deleted.
Definition at line 474 of file kvpframe.c.
void kvp_frame_set_gint64 | ( | KvpFrame * | frame, |
const gchar * | path, | ||
gint64 | ival | ||
) |
store the value of the gint64 at the indicated path.
If not all frame components of the path exist, they are created.
Definition at line 390 of file kvpframe.c.
Store a copy of the GUID at the indicated path.
If not all frame components of the path exist, they are created. If there was another GUID previously stored at that path, the old copy is deleted.
Definition at line 453 of file kvpframe.c.
void kvp_frame_set_numeric | ( | KvpFrame * | frame, |
const gchar * | path, | ||
QofNumeric | nval | ||
) |
store the value of the QofNumeric at the indicated path.
If not all frame components of the path exist, they are created.
Definition at line 420 of file kvpframe.c.
The kvp_frame_set_slot() routine copies the value into the frame, associating it with a copy of 'key'. Pointers passed as arguments into kvp_frame_set_slot are the responsibility of the caller; the pointers are not taken over or managed. The old value at this location, if any, is destroyed.
Definition at line 684 of file kvpframe.c.
The kvp_frame_set_slot_nc() routine puts the value (without copying it) into the frame, associating it with a copy of 'key'. This routine is handy for avoiding excess memory allocations & frees. Note that because the KvpValue was grabbed, you can't just delete unless you remove the key as well (or unless you replace the value). The old value at this location, if any, is destroyed.
Definition at line 700 of file kvpframe.c.
void kvp_frame_set_slot_path | ( | KvpFrame * | frame, |
const KvpValue * | value, | ||
const gchar * | first_key, | ||
... | |||
) |
The kvp_frame_set_slot_path() routine walks the hierarchy, using the key values to pick each branch. When the terminal node is reached, the value is copied into it. The old value at this location, if any, is destroyed.
Definition at line 726 of file kvpframe.c.
The kvp_frame_set_slot_path_gslist() routine walks the hierarchy, using the key values to pick each branch. When the terminal node is reached, the value is copied into it. The old value at this location, if any, is destroyed.
Definition at line 779 of file kvpframe.c.
void kvp_frame_set_string | ( | KvpFrame * | frame, |
const gchar * | path, | ||
const gchar * | str | ||
) |
Store a copy of the string at the indicated path.
If not all frame components of the path exist, they are created. If there was another string previously stored at that path, the old copy is deleted.
Definition at line 442 of file kvpframe.c.
Store a copy of the QofTime at the indicated path.
If not all frame components of the path exist, they are created. If there was another QofTime previously stored at that path, the old copy is deleted.
Definition at line 410 of file kvpframe.c.
Copy the KvpValue into the frame.
If the path contains slashes '/', these are assumed to represent a sequence of keys. The old value at this location, if any, is destroyed.
Pointers passed as arguments into this routine remain the responsibility of the caller.
frame | The frame to hold the copied value. |
path | The location of the value in the frame. |
value | The value to be copied. |
Definition at line 499 of file kvpframe.c.
Store the KvpValue in the frame without copying.
If the path contains slashes '/', these are assumed to represent a sequence of keys.
The returned value is a pointer to the actual frame into which the value was inserted; it is NULL if the frame couldn't be found (and thus the value wasn't inserted). The old value at this location, if any, is destroyed. This routine is handy for avoiding excess memory allocations & frees. Note that because the KvpValue was grabbed, you can't just delete unless you remove the key as well (or unless you replace the value).
Definition at line 486 of file kvpframe.c.
gint kvp_glist_compare | ( | const GList * | list1, |
const GList * | list2 | ||
) |
kvp_glist_compare() compares GLists of KvpValue values (not to be confused with GLists of something else): it iterates over the list elements, performing a kvp_value_compare on each.
Definition at line 1170 of file kvpframe.c.
GList* kvp_glist_copy | ( | const GList * | list | ) |
kvp_glist_copy() performs a deep copy of a GList of kvp_values (not to be confused with GLists of something else): same as mapping kvp_value_copy() over the elements and then copying the spine.
Definition at line 1148 of file kvpframe.c.
void kvp_glist_delete | ( | GList * | list | ) |
kvp_glist_delete() performs a deep delete of a GList of kvp_values (not to be confused with GLists of something else): same as mapping * kvp_value_delete() over the elements and then deleting the GList.
Definition at line 1130 of file kvpframe.c.
gboolean kvp_value_binary_append | ( | KvpValue * | v, |
gpointer | data, | ||
guint64 | size | ||
) |
Manipulator:
copying - but more efficient than creating a new KvpValue manually.
void kvp_value_delete | ( | KvpValue * | value | ) |
gpointer kvp_value_get_binary | ( | const KvpValue * | value, |
guint64 * | size_return | ||
) |
Value accessor. This one is non-copying – the caller can modify the value directly.
Definition at line 1507 of file kvpframe.c.
Value accessor. This one is non-copying – the caller can modify the value directly.
Definition at line 1549 of file kvpframe.c.
gint64 kvp_value_get_gint64 | ( | const KvpValue * | value | ) |
Value accessors. Those for GUID, binary, GList, KvpFrame and string are non-copying – the caller can modify the value directly. Just don't free it, or you screw up everything. Note that if another value is stored at the key location that this value came from, then this value will be uncermoniously deleted, and you will be left pointing to garbage. So don't store values at the same time you are examining their contents.
Definition at line 1402 of file kvpframe.c.
GList* kvp_value_get_glist | ( | const KvpValue * | value | ) |
Returns the GList of kvp_frame's (not to be confused with GList's of something else!) from the given kvp_frame. This one is non-copying – the caller can modify the value directly.
Definition at line 1534 of file kvpframe.c.
Value accessor. This one is non-copying – the caller can modify the value directly.
Definition at line 1477 of file kvpframe.c.
gchar* kvp_value_get_string | ( | const KvpValue * | value | ) |
Value accessor. This one is non-copying – the caller can modify the value directly.
Definition at line 1447 of file kvpframe.c.
KvpValue* kvp_value_new_binary_nc | ( | void * | data, |
guint64 | datasize | ||
) |
value constructors (non-copying - KvpValue takes pointer ownership) values must have been allocated via glib allocators! (gnew, etc.)
KvpValue* kvp_value_new_boolean | ( | gboolean | value | ) |
value constructors (non-copying - KvpValue takes pointer ownership) values must have been allocated via glib allocators! (gnew, etc.)
Definition at line 1348 of file kvpframe.c.
KvpValue* kvp_value_new_glist | ( | const GList * | value | ) |
Creates a KvpValue from a GList of kvp_value's! (Not to be confused with GList's of something else!)
Definition at line 1309 of file kvpframe.c.
KvpValue* kvp_value_new_glist_nc | ( | GList * | lst | ) |
Creates a KvpValue from a GList of kvp_value's! (Not to be confused with GList's of something else!)
This value constructor is non-copying (KvpValue takes pointer ownership). The values must have been allocated via glib allocators! (gnew, etc.)
Definition at line 1322 of file kvpframe.c.
GList* kvp_value_replace_glist_nc | ( | KvpValue * | value, |
GList * | newlist | ||
) |
gchar* kvp_value_to_bare_string | ( | const KvpValue * | val | ) |
General purpose function to convert any KvpValue to a string.
Only the bare string is returned, there is no debugging information.
Definition at line 1848 of file kvpframe.c.
gchar* kvp_value_to_string | ( | const KvpValue * | val | ) |
Debug version.
This version is used only by ::qof_query_printValueForParam, itself a debugging and development utility function.
Definition at line 1941 of file kvpframe.c.
KvpFrame* qof_kvp_bag_add | ( | KvpFrame * | kvp_root, |
const gchar * | path, | ||
QofTime * | qt, | ||
const gchar * | first_name, | ||
... | |||
) |
The qof_kvp_bag_add() routine is used to maintain a collection of pointers in a kvp tree.
The thing being pointed at is uniquely identified by its GUID. This routine is typically used to create a linked list, and/or a collection of pointers to objects that are 'related' to each other in some way.
The var-args should be pairs of strings (const char *) followed by the corresponding GUID pointer (const GUID *). Terminate the varargs with a NULL as the last string argument.
The actual 'pointer' is stored in a subdirectory in a bag located at the node directory 'path'. A 'bag' is merely a collection of (unamed) values. The name of our bag is 'path'. A bag can contain any kind of values, including frames. This routine will create a frame, and put it in the bag. The frame will contain named data from the subroutine arguments. Thus, for example:
qof_kvp_array (kvp, "foo", secs, "acct_guid", aguid, "book_guid", bguid, NULL);
will create a frame containing "/acct_guid" and "/book_guid", whose values are aguid and bguid respecitvely. The frame will also contain "/date", whose value will be secs. This frame will be placed into the bag located at "foo".
This routine returns a pointer to the frame that was created, or NULL if an error occured.
Definition at line 67 of file kvputil.c.
KvpFrame* qof_kvp_bag_find_by_guid | ( | KvpFrame * | root, |
const gchar * | path, | ||
const gchar * | guid_name, | ||
GUID * | desired_guid | ||
) |
The qof_kvp_bag_find_by_guid() routine examines the bag pointed located at root. It looks for a frame in that bag that has the guid value of "desired_guid" filed under the key name "guid_name". If it finds that matching guid, then it returns a pointer to the KVP frame that contains it. If it is not found, or if there is any other error, NULL is returned.
Definition at line 89 of file kvputil.c.
void qof_kvp_bag_merge | ( | KvpFrame * | kvp_into, |
const gchar * | intopath, | ||
KvpFrame * | kvp_from, | ||
const gchar * | frompath | ||
) |
The qof_kvp_bag_merge() routine will move the bag contents from the 'kvp_from', to the 'into' bag. It will then delete the 'from' bag from the kvp tree.
Definition at line 186 of file kvputil.c.
Remove the given frame from the bag. The frame is removed, however, it is not deleted. Note that the frame pointer must be a pointer to the actual frame (for example, as returned by gnc_kvp_bag_find_by_guid() for by gnc_kvp_bag_add()), and not some copy of the frame.
Definition at line 119 of file kvputil.c.