diff options
author | David Robillard <d@drobilla.net> | 2011-04-27 23:36:19 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-04-27 23:36:19 +0000 |
commit | f3b65ffd392579728490916ba0d0ad9cbcdcbf66 (patch) | |
tree | c32c5c64114d6bf49e6afa66fb001a5ceb446e45 | |
parent | bb2c564579a402a92dbaa513b6a4c9641523efc5 (diff) | |
download | sord-f3b65ffd392579728490916ba0d0ad9cbcdcbf66.tar.gz sord-f3b65ffd392579728490916ba0d0ad9cbcdcbf66.tar.bz2 sord-f3b65ffd392579728490916ba0d0ad9cbcdcbf66.zip |
Remove boost and glibmm dependencies from sordmm.hpp.
Add C++ (sordmm.hpp) compilation test.
Fix utilities only building with --test.
git-svn-id: http://svn.drobilla.net/sord/trunk@92 3d64ff67-21c5-427c-a301-fe4f08042e5a
-rw-r--r-- | sord/sordmm.hpp | 47 | ||||
-rw-r--r-- | src/sordi.c | 2 | ||||
-rw-r--r-- | src/sordmm_test.cpp | 25 | ||||
-rw-r--r-- | wscript | 31 |
4 files changed, 75 insertions, 30 deletions
diff --git a/sord/sordmm.hpp b/sord/sordmm.hpp index 8c0dc10..294f38f 100644 --- a/sord/sordmm.hpp +++ b/sord/sordmm.hpp @@ -24,12 +24,11 @@ #include <cassert> #include <cstring> +#include <cstdlib> #include <iostream> #include <set> #include <string> - -#include <boost/utility.hpp> -#include <glibmm/ustring.h> +#include <sstream> #include "serd/serd.h" #include "sord/sord.h" @@ -38,6 +37,16 @@ namespace Sord { +/** Utility base class to prevent copying. */ +class Noncopyable { +protected: + Noncopyable() {} + ~Noncopyable() {} +private: + Noncopyable(const Noncopyable&); + const Noncopyable& operator=(const Noncopyable&); +}; + /** C++ wrapper for a Sord object. */ template <typename T> class Wrapper { @@ -97,7 +106,7 @@ public: }; /** Sord library state. */ -class World : public boost::noncopyable, public Wrapper<SordWorld*> { +class World : public Noncopyable, public Wrapper<SordWorld*> { public: inline World() : _next_blank_id(0) @@ -374,22 +383,22 @@ struct Iter : public Wrapper<SordIter*> { /** An RDF Model (collection of triples). */ -class Model : public boost::noncopyable, public Wrapper<SordModel*> { +class Model : public Noncopyable, public Wrapper<SordModel*> { public: - inline Model(World& world, const Glib::ustring& base_uri="."); + inline Model(World& world, const std::string& base_uri="."); inline ~Model(); inline const Node& base_uri() const { return _base; } - inline void load_file(const Glib::ustring& uri); + inline void load_file(const std::string& uri); - inline void load_string(const char* str, - size_t len, - const Glib::ustring& base_uri, - const std::string lang = "turtle"); + inline void load_string(const char* str, + size_t len, + const std::string& base_uri, + const std::string lang = "turtle"); inline void write_to_file_handle(FILE* fd, const char* lang); - inline void write_to_file(const Glib::ustring& uri, const char* lang); + inline void write_to_file(const std::string& uri, const char* lang); inline std::string write_to_string(const char* lang); @@ -413,7 +422,7 @@ private: /** Create an empty in-memory RDF model. */ inline -Model::Model(World& world, const Glib::ustring& base_uri) +Model::Model(World& world, const std::string& base_uri) : _world(world) , _base(world, Node::URI, base_uri) , _writer(NULL) @@ -423,10 +432,10 @@ Model::Model(World& world, const Glib::ustring& base_uri) } inline void -Model::load_string(const char* str, - size_t len, - const Glib::ustring& base_uri, - const std::string lang) +Model::load_string(const char* str, + size_t len, + const std::string& base_uri, + const std::string lang) { sord_read_string(_c_obj, (const uint8_t*)str, @@ -439,7 +448,7 @@ inline Model::~Model() } inline void -Model::load_file(const Glib::ustring& data_uri) +Model::load_file(const std::string& data_uri) { // FIXME: blank prefix sord_read_file(_c_obj, (const uint8_t*)data_uri.c_str(), NULL, @@ -458,7 +467,7 @@ Model::write_to_file_handle(FILE* fd, const char* lang) } inline void -Model::write_to_file(const Glib::ustring& uri, const char* lang) +Model::write_to_file(const std::string& uri, const char* lang) { sord_write_file(_c_obj, _world.prefixes().c_obj(), diff --git a/src/sordi.c b/src/sordi.c index 123752a..dfcb85a 100644 --- a/src/sordi.c +++ b/src/sordi.c @@ -137,7 +137,7 @@ main(int argc, char** argv) SordQuad pat = { 0, 0, 0, 0 }; SordIter* iter = sord_find(sord, pat); for (; !sord_iter_end(iter); sord_iter_next(iter)) { - SordQuadConst tup; + SordQuad tup; sord_iter_get(iter, tup); const SordNode* s = tup[SORD_SUBJECT]; const SordNode* p = tup[SORD_PREDICATE]; diff --git a/src/sordmm_test.cpp b/src/sordmm_test.cpp new file mode 100644 index 0000000..bb53f52 --- /dev/null +++ b/src/sordmm_test.cpp @@ -0,0 +1,25 @@ +/* + Copyright 2011 David Robillard <http://drobilla.net> + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#include "sord/sordmm.hpp" + +int +main(int argc, char** argv) +{ + Sord::World world; + Sord::Model model(world); + return 0; +} @@ -110,16 +110,27 @@ def build(bld): cflags = test_cflags) autowaf.use_lib(bld, obj, 'GLIB SERD') - # Unit test programa - if bld.env['BUILD_UTILS']: - obj = bld(features = 'c cprogram', - source = 'src/sordi.c', - includes = ['.', './src'], - use = 'libsord_static', - linkflags = '-lgcov', - target = 'sordi_static', - install_path = '', - cflags = test_cflags) + # C++ build test + obj = bld(features = 'cxx cxxprogram', + source = 'src/sordmm_test.cpp', + includes = ['.', './src'], + use = 'libsord_static', + linkflags = '-lgcov', + target = 'sordmm_test', + install_path = '', + cflags = test_cflags) + autowaf.use_lib(bld, obj, 'GLIB SERD') + + # Command line utility + if bld.env['BUILD_UTILS']: + obj = bld(features = 'c cprogram', + source = 'src/sordi.c', + includes = ['.', './src'], + use = 'libsord_static', + linkflags = '-lgcov', + target = 'sordi_static', + install_path = '', + cflags = test_cflags) # Documentation autowaf.build_dox(bld, 'SORD', SORD_VERSION, top, out) |