From 71cd886e99a401bf25a9fa91fc39d40df7a44e30 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sat, 20 Aug 2011 03:45:08 +0000 Subject: [PATCH] Remove unused functions from kvp_frame git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21193 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/libqof/qof/kvp_frame.c | 157 +-------------------------- src/libqof/qof/kvp_frame.h | 41 ------- src/libqof/qof/test/test-kvp_frame.c | 2 +- 3 files changed, 3 insertions(+), 197 deletions(-) diff --git a/src/libqof/qof/kvp_frame.c b/src/libqof/qof/kvp_frame.c index c237da634c..f588e3514b 100644 --- a/src/libqof/qof/kvp_frame.c +++ b/src/libqof/qof/kvp_frame.c @@ -417,15 +417,6 @@ kvp_frame_set_numeric(KvpFrame * frame, const char * path, gnc_numeric nval) if (!frame) kvp_value_delete (value); } -void -kvp_frame_set_gdate(KvpFrame * frame, const char * path, GDate nval) -{ - KvpValue *value; - value = kvp_value_new_gdate (nval); - frame = kvp_frame_set_value_nc (frame, path, value); - if (!frame) kvp_value_delete (value); -} - void kvp_frame_set_string(KvpFrame * frame, const char * path, const char* str) { @@ -709,7 +700,7 @@ kvp_frame_set_slot_path_gslist (KvpFrame *frame, return; } } - +#if 8 /* ============================================================ */ /* decode url-encoded string, do it in place * + == space @@ -767,7 +758,7 @@ decode (char *enc) } /* ============================================================ */ - +#endif gint64 kvp_frame_get_gint64(const KvpFrame *frame, const char *path) @@ -776,7 +767,6 @@ kvp_frame_get_gint64(const KvpFrame *frame, const char *path) frame = get_trailer_or_null (frame, path, &key); return kvp_value_get_gint64(kvp_frame_get_slot (frame, key)); } - double kvp_frame_get_double(const KvpFrame *frame, const char *path) { @@ -809,15 +799,6 @@ kvp_frame_get_guid(const KvpFrame *frame, const char *path) return kvp_value_get_guid(kvp_frame_get_slot (frame, key)); } -void * -kvp_frame_get_binary(const KvpFrame *frame, const char *path, - guint64 * size_return) -{ - char *key = NULL; - frame = get_trailer_or_null (frame, path, &key); - return kvp_value_get_binary(kvp_frame_get_slot (frame, key), size_return); -} - Timespec kvp_frame_get_timespec(const KvpFrame *frame, const char *path) { @@ -844,44 +825,6 @@ kvp_frame_get_value(const KvpFrame *frame, const char *path) /* ============================================================ */ -KvpFrame * -kvp_frame_get_frame_gslist (KvpFrame *frame, const GSList *key_path) -{ - if (!frame) return frame; - - while (key_path) - { - const char *key = key_path->data; - - if (!key) return frame; /* an unusual but valid exit for this routine. */ - - frame = get_or_make (frame, key); - if (!frame) return frame; /* this should never happen */ - - key_path = key_path->next; - } - return frame; /* this is the normal exit for this func */ -} - -KvpFrame * -kvp_frame_get_frame_path (KvpFrame *frame, const char *key, ...) -{ - va_list ap; - if (!frame || !key) return frame; - - va_start (ap, key); - - while (key) - { - frame = get_or_make (frame, key); - if (!frame) break; /* error, should never occur */ - key = va_arg (ap, const char *); - } - - va_end (ap); - return frame; -} - KvpFrame * kvp_frame_get_frame_slash (KvpFrame *frame, const char *key_path) { @@ -1631,102 +1574,6 @@ init_static_test_pointers( void ) /* ----- */ -static gchar* -kvp_value_to_bare_string(const KvpValue *val); - -static void -kvp_frame_to_bare_string_helper(gpointer key, gpointer value, gpointer data) -{ - gchar **str = (gchar**)data; - *str = g_strdup_printf("%s", kvp_value_to_bare_string((KvpValue *)value)); -} - -static gchar* -kvp_value_to_bare_string(const KvpValue *val) -{ - gchar *tmp1; - gchar *tmp2; - const gchar *ctmp; - - g_return_val_if_fail(val, NULL); - tmp1 = g_strdup(""); - switch (kvp_value_get_type(val)) - { - case KVP_TYPE_GINT64: - return g_strdup_printf("%" G_GINT64_FORMAT, kvp_value_get_gint64(val)); - break; - - case KVP_TYPE_DOUBLE: - return g_strdup_printf("(%g)", kvp_value_get_double(val)); - break; - - case KVP_TYPE_NUMERIC: - tmp1 = gnc_numeric_to_string(kvp_value_get_numeric(val)); - tmp2 = g_strdup_printf("%s", tmp1 ? tmp1 : ""); - g_free(tmp1); - return tmp2; - break; - - case KVP_TYPE_STRING: - tmp1 = kvp_value_get_string (val); - return g_strdup_printf("%s", tmp1 ? tmp1 : ""); - break; - - case KVP_TYPE_GUID: - ctmp = guid_to_string(kvp_value_get_guid(val)); - tmp2 = g_strdup_printf("%s", ctmp ? ctmp : ""); - return tmp2; - break; - - case KVP_TYPE_TIMESPEC: - { - time_t t; - t = timespecToTime_t(kvp_value_get_timespec(val)); - qof_date_format_set(QOF_DATE_FORMAT_UTC); - return qof_print_date(t); - break; - } - case KVP_TYPE_BINARY: - { - guint64 len; - void *data; - data = kvp_value_get_binary(val, &len); - tmp1 = binary_to_string(data, len); - return g_strdup_printf("%s", tmp1 ? tmp1 : ""); - } - break; - - case KVP_TYPE_GLIST: - /* borked. kvp_value_glist_to_string is a debug fcn */ - { - tmp1 = kvp_value_glist_to_string(kvp_value_get_glist(val)); - tmp2 = g_strdup_printf("%s", tmp1 ? tmp1 : ""); - g_free(tmp1); - return tmp2; - break; - } - case KVP_TYPE_FRAME: - { - KvpFrame *frame; - - frame = kvp_value_get_frame(val); - if (frame->hash) - { - tmp1 = g_strdup(""); - g_hash_table_foreach(frame->hash, kvp_frame_to_bare_string_helper, &tmp1); - } - return tmp1; - } - case KVP_TYPE_GDATE: - return g_strdup_printf("%04d-%02d-%02d", - g_date_get_year(&val->value.gdate), - g_date_get_month(&val->value.gdate), - g_date_get_day(&val->value.gdate)); - } - g_assert(FALSE); /* must not be reached */ - return g_strdup(""); -} - gchar* kvp_value_to_string(const KvpValue *val) { diff --git a/src/libqof/qof/kvp_frame.h b/src/libqof/qof/kvp_frame.h index de6ac9a3e3..3b9aae68d9 100644 --- a/src/libqof/qof/kvp_frame.h +++ b/src/libqof/qof/kvp_frame.h @@ -166,12 +166,6 @@ void kvp_frame_set_numeric(KvpFrame * frame, const gchar * path, gnc_numeric nva * the path exist, they are created. */ void kvp_frame_set_timespec(KvpFrame * frame, const gchar * path, Timespec ts); -/** store the value of the - * GDate at the indicated path. - * If not all frame components of - * the path exist, they are created. - */ -void kvp_frame_set_gdate(KvpFrame * frame, const gchar * path, GDate date); /** \deprecated @@ -290,8 +284,6 @@ double kvp_frame_get_double(const KvpFrame *frame, const gchar *path); gnc_numeric kvp_frame_get_numeric(const KvpFrame *frame, const gchar *path); const gchar * kvp_frame_get_string(const KvpFrame *frame, const gchar *path); GncGUID * kvp_frame_get_guid(const KvpFrame *frame, const gchar *path); -void * kvp_frame_get_binary(const KvpFrame *frame, const gchar *path, - guint64 * size_return); Timespec kvp_frame_get_timespec(const KvpFrame *frame, const gchar *path); KvpValue * kvp_frame_get_value(const KvpFrame *frame, const gchar *path); @@ -316,39 +308,6 @@ KvpValue * kvp_frame_get_value(const KvpFrame *frame, const gchar *path); /*@ dependent @*/ KvpFrame * kvp_frame_get_frame(const KvpFrame *frame, const gchar *path); -/** 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* like kvp_frame_get_frame() - * - * @note The semantics of this function implemented the gnucash-1.8 - * behaviour of kvp_frame_get_frame: In gnucash-1.8, if the KvpFrame - * did not exist, kvp_frame_get_frame automatically created one and - * returned it. However, now that one will return NULL in this case - * and the caller has to create a KvpFrame on his own. The old - * functionality is implemented by this - * kvp_frame_get_frame_path(). This happened on 2003-09-14, revision - * 1.31. - */ -KvpFrame * kvp_frame_get_frame_path (KvpFrame *frame, const gchar *, ...); - -/** 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() - */ -KvpFrame * kvp_frame_get_frame_gslist (KvpFrame *frame, - const GSList *key_path); - -/** 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). - */ KvpFrame * kvp_frame_get_frame_slash (KvpFrame *frame, const gchar *path); diff --git a/src/libqof/qof/test/test-kvp_frame.c b/src/libqof/qof/test/test-kvp_frame.c index b7b4f2e995..3bd21b53a5 100644 --- a/src/libqof/qof/test/test-kvp_frame.c +++ b/src/libqof/qof/test/test-kvp_frame.c @@ -1482,4 +1482,4 @@ test_suite_kvp_frame( void ) GNC_TEST_ADD( suitename, "get or make", Fixture, NULL, setup_static, test_get_or_make, teardown_static ); GNC_TEST_ADD( suitename, "kvp frame get frame or null slash trash", Fixture, NULL, setup_static, test_kvp_frame_get_frame_or_null_slash_trash, teardown_static ); GNC_TEST_ADD( suitename, "get trailer or null", Fixture, NULL, setup_static, test_get_trailer_or_null, teardown_static ); -} \ No newline at end of file +}