43 #define QOF_MOD_UTIL "qof-utilities"
48 #define ENUM_BODY(name, value) \
51 #define AS_STRING_CASE(name, value) \
52 case name: { return #name; }
54 #define FROM_STRING_CASE(name, value) \
55 if (strcmp(str, #name) == 0) { \
58 #define DEFINE_ENUM(name, list) \
63 #define AS_STRING_DEC(name, list) \
64 const gchar* name##asString(name n);
66 #define AS_STRING_FUNC(name, list) \
67 const gchar* name##asString(name n) { \
69 list(AS_STRING_CASE) \
70 default: return ""; } }
72 #define FROM_STRING_DEC(name, list) \
73 name name##fromString \
76 #define FROM_STRING_FUNC(name, list) \
77 name name##fromString \
78 (const gchar* str) { \
79 if(str == NULL) { return 0; } \
80 list(FROM_STRING_CASE) \
98 #define DEFINE_ENUM_NON_TYPEDEF(name, list) \
103 #define FROM_STRING_DEC_NON_TYPEDEF(name, list) \
104 void name##fromString \
105 (const gchar* str, enum name *type);
107 #define FROM_STRING_CASE_NON_TYPEDEF(name, value) \
108 if (strcmp(str, #name) == 0) { *type = name; }
110 #define FROM_STRING_FUNC_NON_TYPEDEF(name, list) \
111 void name##fromString \
112 (const gchar* str, enum name *type) { \
113 if(str == NULL) { return; } \
114 list(FROM_STRING_CASE_NON_TYPEDEF) }
116 #define AS_STRING_DEC_NON_TYPEDEF(name, list) \
117 const gchar* name##asString(enum name n);
119 #define AS_STRING_FUNC_NON_TYPEDEF(name, list) \
120 const gchar* name##asString(enum name n) { \
122 list(AS_STRING_CASE_NON_TYPEDEF) \
123 default: return ""; } }
125 #define AS_STRING_CASE_NON_TYPEDEF(name, value) \
126 case name: { return #name; }
166 gint
safe_strcmp (
const gchar * da,
const gchar * db);
186 gint
null_strcmp (
const gchar * da,
const gchar * db);
191 extern gchar *
strncasestr (
const guchar * str1,
const guchar * str2,
195 extern gchar *strcasestr (
const gchar * str1,
const gchar * str2);
201 gchar *
ultostr (gulong val, gint base);
213 #define stpcpy g_stpcpy
259 const gchar * value_string);
315 #define CACHE_INSERT(str) qof_util_string_cache_insert((gconstpointer)(str))
316 #define CACHE_REMOVE(str) qof_util_string_cache_remove((str))
325 #define CACHE_REPLACE(dst, src) do { \
326 gpointer tmp = CACHE_INSERT((src)); \
327 CACHE_REMOVE((dst)); \
331 #define QOF_CACHE_NEW(void) qof_util_string_cache_insert("")