summaryrefslogtreecommitdiffstats
path: root/src/libs/client/RDFWriter.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-12-02 22:47:23 +0000
committerDavid Robillard <d@drobilla.net>2006-12-02 22:47:23 +0000
commit26d0171f9bbc4af8036c704d3a4cb69a5d9fe942 (patch)
treebb70501477d56a59a3e85d5e4ddfa2bb469f82c8 /src/libs/client/RDFWriter.h
parenta2759d9b8d6923d7aed1bebdf90fc493fab8b59f (diff)
downloadingen-26d0171f9bbc4af8036c704d3a4cb69a5d9fe942.tar.gz
ingen-26d0171f9bbc4af8036c704d3a4cb69a5d9fe942.tar.bz2
ingen-26d0171f9bbc4af8036c704d3a4cb69a5d9fe942.zip
More serialization work
git-svn-id: http://svn.drobilla.net/lad/ingen@206 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/client/RDFWriter.h')
-rw-r--r--src/libs/client/RDFWriter.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/libs/client/RDFWriter.h b/src/libs/client/RDFWriter.h
new file mode 100644
index 00000000..7bc4b14f
--- /dev/null
+++ b/src/libs/client/RDFWriter.h
@@ -0,0 +1,71 @@
+/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard.
+ *
+ * Ingen is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef RDFWRITER_H
+#define RDFWRITER_H
+
+#include <stdexcept>
+#include <string>
+#include <map>
+#include <raptor.h>
+#include "raul/Atom.h"
+using std::string; using std::map;
+
+
+class RdfId {
+public:
+ enum Type { ANONYMOUS, RESOURCE };
+
+ RdfId(Type t, const string& s) : _type(t), _string(s) {}
+
+ Type type() const { return _type; }
+ const string& to_string() const { return _string; }
+
+private:
+ Type _type;
+ string _string; ///< URI or blank node ID, depending on _type
+};
+
+
+class RDFWriter {
+public:
+ RDFWriter();
+
+ void setup_prefixes();
+ string expand_uri(const string& uri);
+
+ void start_to_filename(const string& filename) throw (std::logic_error);
+ void start_to_string() throw (std::logic_error);
+ string finish() throw (std::logic_error);
+
+ bool serialization_in_progress() { return (_serializer != NULL); }
+
+ void write(const RdfId& subject,
+ const RdfId& predicate,
+ const RdfId& object);
+
+ void write(const RdfId& subject,
+ const RdfId& predicate,
+ const Atom& object);
+
+private:
+ raptor_serializer* _serializer;
+ unsigned char* _string_output;
+ map<string, string> _prefixes;
+};
+
+
+#endif // RDFWRITER_H