From 26d0171f9bbc4af8036c704d3a4cb69a5d9fe942 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 2 Dec 2006 22:47:23 +0000 Subject: More serialization work git-svn-id: http://svn.drobilla.net/lad/ingen@206 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/client/RDFWriter.h | 71 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/libs/client/RDFWriter.h (limited to 'src/libs/client/RDFWriter.h') 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 +#include +#include +#include +#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 _prefixes; +}; + + +#endif // RDFWRITER_H -- cgit v1.2.1