GnuCash
2.6.99
|
Files | |
file | qof-string-cache.h |
QOF String cache functions. | |
file | qofutil.h |
QOF utility functions. | |
Macros | |
#define | QOF_MOD_UTIL "qof.utilities" |
#define | CACHE_INSERT(str) qof_string_cache_insert((gconstpointer)(str)) |
#define | CACHE_REMOVE(str) qof_string_cache_remove((str)) |
#define | CACHE_REPLACE(dst, src) |
#define | QOF_CACHE_NEW(void) qof_string_cache_insert("") |
#define | QOF_MOD_UTIL "qof.utilities" |
#define | stpcpy g_stpcpy |
Functions | |
void | qof_string_cache_init (void) |
void | qof_string_cache_destroy (void) |
void | qof_string_cache_remove (gconstpointer key) |
gpointer | qof_string_cache_insert (gconstpointer key) |
void | g_hash_table_foreach_sorted (GHashTable *hash_table, GHFunc func, gpointer user_data, GCompareFunc compare_func) |
gboolean | qof_utf8_substr_nocase (const gchar *haystack, const gchar *needle) |
gint | safe_strcasecmp (const gchar *da, const gchar *db) |
gint | null_strcmp (const gchar *da, const gchar *db) |
gchar * | ultostr (gulong val, gint base) |
gboolean | gnc_strisnum (const gchar *s) |
gboolean | qof_begin_edit (QofInstance *inst) |
gboolean | qof_commit_edit (QofInstance *inst) |
gboolean | qof_commit_edit_part2 (QofInstance *inst, void(*on_error)(QofInstance *, QofBackendError), void(*on_done)(QofInstance *), void(*on_free)(QofInstance *)) |
Convenience wrappers | |
void | qof_init (void) |
Initialise the Query Object Framework. More... | |
void | qof_close (void) |
Safely close down the Query Object Framework. More... | |
#define AS_STRING_FUNC | ( | name, | |
list | |||
) |
#define AS_STRING_FUNC_NON_TYPEDEF | ( | name, | |
list | |||
) |
#define CACHE_REPLACE | ( | dst, | |
src | |||
) |
Definition at line 99 of file qof-string-cache.h.
#define DEFINE_ENUM | ( | name, | |
list | |||
) |
#define DEFINE_ENUM_NON_TYPEDEF | ( | name, | |
list | |||
) |
#define FROM_STRING_CASE | ( | name, | |
value | |||
) |
#define FROM_STRING_DEC | ( | name, | |
list | |||
) |
#define FROM_STRING_DEC_NON_TYPEDEF | ( | name, | |
list | |||
) |
#define FROM_STRING_FUNC | ( | name, | |
list | |||
) |
#define FROM_STRING_FUNC_NON_TYPEDEF | ( | name, | |
list | |||
) |
#define QOF_MOD_UTIL "qof.utilities" |
void g_hash_table_foreach_sorted | ( | GHashTable * | hash_table, |
GHFunc | func, | ||
gpointer | user_data, | ||
GCompareFunc | compare_func | ||
) |
Calls the given function for each of the key/value pairs in the GHashTable in an order determined by the GCompareFunc applied to the keys. The function is passed the key and value of each pair, and the given user_data parameter.
gboolean gnc_strisnum | ( | const gchar * | s | ) |
Returns true if string s is a number, possibly surrounded by whitespace.
gint null_strcmp | ( | const gchar * | da, |
const gchar * | db | ||
) |
The null_strcmp compares strings a and b the same way that strcmp() does, except that either may be null. This routine assumes that a null string is equal to the empty string.
gboolean qof_begin_edit | ( | QofInstance * | inst | ) |
begin_edit
inst | an instance of QofInstance |
The caller should use this macro first and then perform any other operations.
void qof_close | ( | void | ) |
Safely close down the Query Object Framework.
Use in place of separate close / shutdown functions (like qof_query_shutdown(), etc.) to protect against future changes.
gboolean qof_commit_edit | ( | QofInstance * | inst | ) |
commit_edit helpers
The caller should call PART1 as the first thing, then perform any local operations prior to calling the backend. Then call PART2. part1 – deal with the editlevel
inst | an instance of QofInstance |
gboolean qof_commit_edit_part2 | ( | QofInstance * | inst, |
void(*)(QofInstance *, QofBackendError) | on_error, | ||
void(*)(QofInstance *) | on_done, | ||
void(*)(QofInstance *) | on_free | ||
) |
part2 – deal with the backend
inst | an instance of QofInstance |
on_error | a function called if there is a backend error. void (*on_error)(inst, QofBackendError) |
on_done | a function called after the commit is completed successfully for an object which remained valid. void (*on_done)(inst) |
on_free | a function called if the commit succeeded and the instance is to be freed. void (*on_free)(inst) |
Note that only one callback will be called (or zero, if that callback is NULL). In particular, 'on_done' will not be called for an object which is to be freed.
Returns TRUE, if the commit succeeded, FALSE otherwise.
void qof_init | ( | void | ) |
Initialise the Query Object Framework.
Use in place of separate init functions (like qof_query_init(), etc.) to protect against future changes.
void qof_string_cache_destroy | ( | void | ) |
Destroy the qof_string_cache
void qof_string_cache_init | ( | void | ) |
The QOF String Cache:
Many strings used throughout QOF and QOF applications are likely to be duplicated.
QOF provides a reference counted cache system for the strings, which shares strings whenever possible.
Use qof_string_cache_insert to insert a string into the cache (it will return a pointer to the cached string). Basically you should use this instead of g_strdup.
Use qof_string_cache_remove (giving it a pointer to a cached string) if the string is unused. If this is the last reference to the string it will be removed from the cache, otherwise it will just decrement the reference count. Basically you should use this instead of g_free.
Just in case it's not clear: The remove function must NOT be called for the string you passed INTO the insert function. It must be called for the cached string that is returned by the insert function.
Note that all the work is done when inserting or removing. Once cached the strings are just plain C strings.
The string cache is demand-created on first use.Initialize the string cache
gpointer qof_string_cache_insert | ( | gconstpointer | key | ) |
You can use this function with g_hash_table_insert(), for the key (or value), as long as you use the destroy notifier above.
void qof_string_cache_remove | ( | gconstpointer | key | ) |
You can use this function as a destroy notifier for a GHashTable that uses common strings as keys (or values, for that matter.)
gboolean qof_utf8_substr_nocase | ( | const gchar * | haystack, |
const gchar * | needle | ||
) |
Search for an occurence of the substring needle in the string haystack, ignoring case. Return TRUE if one is found or FALSE otherwise.
gint safe_strcasecmp | ( | const gchar * | da, |
const gchar * | db | ||
) |
case sensitive comparison of strings da and db - either may be NULL. A non-NULL string is greater than a NULL string.
da | string 1. |
db | string 2. |
gchar* ultostr | ( | gulong | val, |
gint | base | ||
) |
The ultostr() subroutine is the inverse of strtoul(). It accepts a number and prints it in the indicated base. The returned string should be g_freed when done.