diff options
author | David Robillard <d@drobilla.net> | 2007-01-10 17:41:25 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-01-10 17:41:25 +0000 |
commit | e45e85dae29af1a8fef5442aa7c72fa991ac83f1 (patch) | |
tree | 04b874fb5202b014352f095f23d031416e394979 /raul/RDFWriter.h | |
parent | 4014067a1668d94000b059d72832482a06cf8369 (diff) | |
download | raul-e45e85dae29af1a8fef5442aa7c72fa991ac83f1.tar.gz raul-e45e85dae29af1a8fef5442aa7c72fa991ac83f1.tar.bz2 raul-e45e85dae29af1a8fef5442aa7c72fa991ac83f1.zip |
Moved RDFWriter to RAUL.
More work on LADSPA->LV2 converter (use RAUL's RDFWriter now).
git-svn-id: http://svn.drobilla.net/lad/raul@246 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'raul/RDFWriter.h')
-rw-r--r-- | raul/RDFWriter.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/raul/RDFWriter.h b/raul/RDFWriter.h new file mode 100644 index 0000000..c67645e --- /dev/null +++ b/raul/RDFWriter.h @@ -0,0 +1,73 @@ +/* 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 add_prefix(const string& prefix, const string& uri); + 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: + void setup_prefixes(); + + raptor_serializer* _serializer; + unsigned char* _string_output; + map<string, string> _prefixes; +}; + + +#endif // RDFWRITER_H |