summaryrefslogtreecommitdiffstats
path: root/sord
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-05-12 22:50:07 +0000
committerDavid Robillard <d@drobilla.net>2011-05-12 22:50:07 +0000
commit22f5f5c7e32b043433103edb404bfbe43effa15d (patch)
tree2bb579f0af8415d0fb78eef788ba1714079f3824 /sord
parentd1a185c160bf8767e9001a6357f46ac6cfc6f94d (diff)
downloadsord-22f5f5c7e32b043433103edb404bfbe43effa15d.tar.gz
sord-22f5f5c7e32b043433103edb404bfbe43effa15d.tar.bz2
sord-22f5f5c7e32b043433103edb404bfbe43effa15d.zip
Add base_uri parameter to sord_read_file.
Add sord_write_writer. Use command line base URI in sordi if given. Use correct output style options for output syntax in sordi. Use sord_write_writer in sordi instead of manual writing code. Abbreviate serialised model output for Turtle. Preserve UTF-8 length information for nodes from Serd. Use string lengths not including terminator (match new Serd). Add test suite. git-svn-id: http://svn.drobilla.net/sord/trunk@111 3d64ff67-21c5-427c-a301-fe4f08042e5a
Diffstat (limited to 'sord')
-rw-r--r--sord/sord.h9
-rw-r--r--sord/sordmm.hpp15
2 files changed, 19 insertions, 5 deletions
diff --git a/sord/sord.h b/sord/sord.h
index 4941291..d14e64a 100644
--- a/sord/sord.h
+++ b/sord/sord.h
@@ -427,12 +427,15 @@ sord_quad_match(const SordQuad x, const SordQuad y);
/**
Read a file into a model.
+
+ The @c base_uri may be NULL, in which case @c uri will be used.
*/
SORD_API
bool
sord_read_file(SordModel* model,
SerdEnv* env,
const uint8_t* uri,
+ const uint8_t* base_uri,
SordNode* graph,
const uint8_t* blank_prefix);
@@ -481,6 +484,12 @@ sord_write_file_handle(SordModel* model,
SordNode* graph,
const uint8_t* blank_prefix);
+SORD_API
+bool
+sord_write_writer(SordModel* model,
+ SerdWriter* writer,
+ SordNode* graph);
+
/**
Write a model to a string.
diff --git a/sord/sordmm.hpp b/sord/sordmm.hpp
index 854e647..6f9391b 100644
--- a/sord/sordmm.hpp
+++ b/sord/sordmm.hpp
@@ -390,13 +390,15 @@ public:
inline const Node& base_uri() const { return _base; }
- inline void load_file(SerdEnv* env, const std::string& uri);
+ inline void load_file(SerdEnv* env,
+ const std::string& uri,
+ const std::string& base_uri="");
inline void load_string(SerdEnv* env,
const char* str,
size_t len,
const std::string& base_uri,
- const std::string lang = "turtle");
+ const std::string lang="turtle");
inline void write_to_file_handle(FILE* fd, const char* lang);
inline void write_to_file(const std::string& uri, const char* lang);
@@ -451,11 +453,14 @@ inline Model::~Model()
}
inline void
-Model::load_file(SerdEnv* env, const std::string& data_uri)
+Model::load_file(SerdEnv* env,
+ const std::string& data_uri,
+ const std::string& base_uri)
{
// FIXME: blank prefix
- sord_read_file(_c_obj, env, (const uint8_t*)data_uri.c_str(), NULL,
- (const uint8_t*)"b");
+ sord_read_file(_c_obj, env, (const uint8_t*)data_uri.c_str(),
+ (base_uri == "") ? NULL : (const uint8_t*)base_uri.c_str(),
+ NULL, (const uint8_t*)"b");
}
inline void