[tracker/wip/carlosg/http-endpoint: 6/12] libtracker-sparql: Hook XML/JSON serializers to constructor




commit 9b884eef2d5544caeb417f5ba1a440e082025791
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Dec 12 15:57:10 2020 +0100

    libtracker-sparql: Hook XML/JSON serializers to constructor
    
    So they can be used just giving the expected TrackerSerializerFormat.

 src/libtracker-sparql/tracker-serializer.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
---
diff --git a/src/libtracker-sparql/tracker-serializer.c b/src/libtracker-sparql/tracker-serializer.c
index f96b439ab..4109bfafe 100644
--- a/src/libtracker-sparql/tracker-serializer.c
+++ b/src/libtracker-sparql/tracker-serializer.c
@@ -22,6 +22,8 @@
 #include "config.h"
 
 #include "tracker-serializer.h"
+#include "tracker-serializer-json.h"
+#include "tracker-serializer-xml.h"
 
 #include "tracker-private.h"
 
@@ -125,7 +127,23 @@ GInputStream *
 tracker_serializer_new (TrackerSparqlCursor     *cursor,
                         TrackerSerializerFormat  format)
 {
-       return NULL;
+       GType type;
+
+       g_return_val_if_fail (TRACKER_IS_SPARQL_CURSOR (cursor), NULL);
+
+       switch (format) {
+       case TRACKER_SERIALIZER_FORMAT_JSON:
+               type = TRACKER_TYPE_SERIALIZER_JSON;
+               break;
+       case TRACKER_SERIALIZER_FORMAT_XML:
+               type = TRACKER_TYPE_SERIALIZER_XML;
+               break;
+       default:
+               g_warn_if_reached ();
+               return NULL;
+       }
+
+       return g_object_new (type, "cursor", cursor, NULL);
 }
 
 TrackerSparqlCursor *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]