GnuCash
5.6-150-g038405b370+
|
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((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) |
The QOF String Cache: More... | |
void | qof_string_cache_destroy (void) |
Destroy the qof_string_cache. | |
void | qof_string_cache_remove (const char *key) |
You can use this function as a destroy notifier for a GHashTable that uses common strings as keys (or values, for that matter.) | |
const char * | qof_string_cache_insert (const char *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. | |
const char * | qof_string_cache_replace (const char *dst, const char *src) |
Same as CACHE_REPLACE below, but safe to call from C++. | |
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. More... | |
gboolean | qof_utf8_substr_nocase (const gchar *haystack, const gchar *needle) |
Search for an occurrence of the substring needle in the string haystack, ignoring case. More... | |
gint | safe_strcasecmp (const gchar *da, const gchar *db) |
case sensitive comparison of strings da and db - either may be NULL. More... | |
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. More... | |
gchar * | ultostr (gulong val, gint base) |
The ultostr() subroutine is the inverse of strtoul(). More... | |
gboolean | gnc_strisnum (const gchar *s) |
Returns true if string s is a number, possibly surrounded by whitespace. More... | |
gboolean | qof_begin_edit (QofInstance *inst) |
begin_edit More... | |
gboolean | qof_commit_edit (QofInstance *inst) |
commit_edit helpers More... | |
gboolean | qof_commit_edit_part2 (QofInstance *inst, void(*on_error)(QofInstance *, QofBackendError), void(*on_done)(QofInstance *), void(*on_free)(QofInstance *)) |
part2 – deal with the backend More... | |
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 103 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 | |||
) |
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.
Definition at line 40 of file qofutil.cpp.
gboolean gnc_strisnum | ( | const gchar * | s | ) |
Returns true if string s is a number, possibly surrounded by whitespace.
Definition at line 187 of file qofutil.cpp.
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.
Definition at line 123 of file qofutil.cpp.
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.
Definition at line 947 of file qofinstance.cpp.
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.
Definition at line 269 of file qofutil.cpp.
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 |
Definition at line 968 of file qofinstance.cpp.
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.
Definition at line 987 of file qofinstance.cpp.
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.
Definition at line 259 of file qofutil.cpp.
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
Definition at line 64 of file qof-string-cache.cpp.
gboolean qof_utf8_substr_nocase | ( | const gchar * | haystack, |
const gchar * | needle | ||
) |
Search for an occurrence of the substring needle in the string haystack, ignoring case.
Return TRUE if one is found or FALSE otherwise.
Definition at line 54 of file qofutil.cpp.
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. |
Definition at line 100 of file qofutil.cpp.
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.
Definition at line 137 of file qofutil.cpp.