[gimp/metadata-wip-rebased] libgimpbase: change the metadata serialize format to XML
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/metadata-wip-rebased] libgimpbase: change the metadata serialize format to XML
- Date: Wed, 23 Oct 2013 17:55:17 +0000 (UTC)
commit c1b8964e60c22f4aba64c5c7ea7c99c4debe70e5
Author: Michael Natterer <mitch gimp org>
Date: Wed Oct 23 19:54:24 2013 +0200
libgimpbase: change the metadata serialize format to XML
libgimpbase/gimpbase.def | 2 -
libgimpbase/gimpmetadata.c | 155 +------------------------------------------
libgimpbase/gimpmetadata.h | 4 +-
3 files changed, 5 insertions(+), 156 deletions(-)
---
diff --git a/libgimpbase/gimpbase.def b/libgimpbase/gimpbase.def
index 853e53a..6d87e07 100644
--- a/libgimpbase/gimpbase.def
+++ b/libgimpbase/gimpbase.def
@@ -51,13 +51,11 @@ EXPORTS
gimp_memsize_to_string
gimp_message_handler_type_get_type
gimp_metadata_deserialize
- gimp_metadata_deserialize_xml
gimp_metadata_get_resolution
gimp_metadata_is_tag_supported
gimp_metadata_load_from_file
gimp_metadata_save_to_file
gimp_metadata_serialize
- gimp_metadata_serialize_to_xml
gimp_metadata_set_bits_per_sample
gimp_metadata_set_pixel_size
gimp_metadata_set_resolution
diff --git a/libgimpbase/gimpmetadata.c b/libgimpbase/gimpmetadata.c
index 8c34033..cbe5a21 100644
--- a/libgimpbase/gimpmetadata.c
+++ b/libgimpbase/gimpmetadata.c
@@ -127,77 +127,6 @@ static const guint8 wilber_jpg[] =
static const guint wilber_jpg_len = G_N_ELEMENTS (wilber_jpg);
-/**
- * Deserializes metadata from a string
- **/
-GExiv2Metadata *
-gimp_metadata_deserialize (const gchar *metadata_string)
-{
- GExiv2Metadata *metadata = NULL;
- GString *buffer;
- gint i;
- gint j;
- gchar **meta_info = NULL;
- gchar **tag_info = NULL;
- gint num;
- gchar *value;
- GError **error = NULL;
-
- g_return_val_if_fail (metadata_string != NULL, NULL);
-
- if (gexiv2_initialize ())
- {
- metadata = gexiv2_metadata_new ();
-
- if (! gexiv2_metadata_open_buf (metadata, wilber_jpg, wilber_jpg_len,
- error))
- {
- return NULL;
- }
- }
-
- if (metadata)
- {
- meta_info = g_strsplit (metadata_string, TAG_LINE_DELIMITER, -1);
-
- if (meta_info)
- {
- for (i = 0; meta_info[i] != NULL; i++)
- {
- num = gimp_metadata_length (meta_info[i], TAG_TAG_DELIMITER);
- tag_info = g_strsplit (meta_info[i], TAG_TAG_DELIMITER, -1);
- if (num > 0)
- {
- if (num > 1)
- {
- buffer = g_string_new (NULL);
- for (j = 1; j < (num + 1); j++)
- {
- g_string_append_printf (buffer, "%s%s",
- tag_info[j], TAG_TAG_DELIMITER); /* recreates value */
- }
- value = g_strndup (buffer->str, buffer->len - 1); /* to avoid the trailing '#' */
- g_string_free (buffer, TRUE);
- }
- else
- {
- value = tag_info[1];
- }
-
- gexiv2_metadata_set_tag_string (metadata, tag_info[0], value);
- }
- }
-
- g_strfreev (meta_info);
- }
- }
-
- if (tag_info)
- g_strfreev (tag_info);
-
- return metadata;
-}
-
typedef struct
{
gchar name[1024];
@@ -299,14 +228,14 @@ gimp_metadata_deserialize_error (GMarkupParseContext *context,
* Deserializes metadata from a string
**/
GExiv2Metadata *
-gimp_metadata_deserialize_xml (const gchar *metadata_string)
+gimp_metadata_deserialize (const gchar *metadata_xml)
{
GExiv2Metadata *metadata = NULL;
GMarkupParser markup_parser;
GimpMetadataParseData parse_data;
GMarkupParseContext *context;
- g_return_val_if_fail (metadata_string != NULL, NULL);
+ g_return_val_if_fail (metadata_xml != NULL, NULL);
if (gexiv2_initialize ())
{
@@ -330,7 +259,7 @@ gimp_metadata_deserialize_xml (const gchar *metadata_string)
context = g_markup_parse_context_new (&markup_parser, 0, &parse_data, NULL);
g_markup_parse_context_parse (context,
- metadata_string, strlen (metadata_string),
+ metadata_xml, strlen (metadata_xml),
NULL);
g_markup_parse_context_unref (context);
@@ -342,83 +271,7 @@ gimp_metadata_deserialize_xml (const gchar *metadata_string)
* Serializing metadata as a string
*/
gchar *
-gimp_metadata_serialize (GExiv2Metadata *metadata)
-{
- GString *string;
- gchar **exif_data = NULL;
- gchar **iptc_data = NULL;
- gchar **xmp_data = NULL;
- gchar *value;
- gint i;
- gint n;
-
- g_return_val_if_fail (GEXIV2_IS_METADATA (metadata), NULL);
-
- n = 0;
- string = g_string_new (NULL);
-
- exif_data = gexiv2_metadata_get_exif_tags (metadata);
-
- if (exif_data)
- {
- for (i = 0; exif_data[i] != NULL; i++)
- {
- value = gexiv2_metadata_get_tag_string (metadata, exif_data[i]);
- g_string_append_printf (string, "%s%s%s%s", exif_data[i],
- TAG_TAG_DELIMITER,
- value,
- TAG_LINE_DELIMITER);
- g_free (value);
- n++;
- }
-
- g_strfreev (exif_data);
- }
-
- xmp_data = gexiv2_metadata_get_xmp_tags (metadata);
-
- if (xmp_data)
- {
- for (i = 0; xmp_data[i] != NULL; i++)
- {
- value = gexiv2_metadata_get_tag_string (metadata, xmp_data[i]);
- g_string_append_printf (string, "%s%s%s%s", xmp_data[i],
- TAG_TAG_DELIMITER,
- value,
- TAG_LINE_DELIMITER);
- g_free (value);
- n++;
- }
-
- g_strfreev (xmp_data);
- }
-
- iptc_data = gexiv2_metadata_get_iptc_tags (metadata);
-
- if (iptc_data)
- {
- for (i = 0; iptc_data[i] != NULL; i++)
- {
- value = gexiv2_metadata_get_tag_string (metadata, iptc_data[i]);
- g_string_append_printf (string, "%s%s%s%s", iptc_data[i],
- TAG_TAG_DELIMITER,
- value,
- TAG_LINE_DELIMITER);
- g_free (value);
- n++;
- }
-
- g_strfreev (iptc_data);
- }
-
- return g_string_free (string, FALSE);
-}
-
-/**
- * Serializing metadata as a string
- */
-gchar *
-gimp_metadata_serialize_to_xml (GimpMetadata *metadata)
+gimp_metadata_serialize (GimpMetadata *metadata)
{
GString *string;
gchar **exif_data = NULL;
diff --git a/libgimpbase/gimpmetadata.h b/libgimpbase/gimpmetadata.h
index b5e7f54..4f3e215 100644
--- a/libgimpbase/gimpmetadata.h
+++ b/libgimpbase/gimpmetadata.h
@@ -39,10 +39,8 @@ typedef enum
} GimpMetadataSaveFlags;
-GimpMetadata * gimp_metadata_deserialize (const gchar *metadata_string);
-GimpMetadata * gimp_metadata_deserialize_xml (const gchar *metadata_string);
+GimpMetadata * gimp_metadata_deserialize (const gchar *metadata_xml);
gchar * gimp_metadata_serialize (GimpMetadata *metadata);
-gchar * gimp_metadata_serialize_to_xml (GimpMetadata *metadata);
GimpMetadata * gimp_metadata_load_from_file (GFile *file,
GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]