6 #ifndef RAPTOR_WRAPPER_HPP_
7 #define RAPTOR_WRAPPER_HPP_
10 #include "boost/assert.hpp"
11 #include "boost/bind.hpp"
12 #include "boost/function.hpp"
13 #include "boost/shared_ptr.hpp"
17 typedef struct raptor_parser_s raptor_parser;
18 typedef struct raptor_world_s raptor_world;
19 typedef struct raptor_uri_s raptor_uri;
26 typedef void (*handle_statement_fun_t)(
void *,
const void*);
27 typedef bool (*stop_parsing_fun_t)(
const void *);
29 static char* blank_prefix_char() {
30 static char pref[] =
"b";
36 static std::string
const& blank_prefix() {
37 static const std::string pref(blank_prefix_char());
43 template<
class Sink>
void operator()(std::istream& stream, Sink& sink) {
44 setup(&sink, &handle_statement<Sink>);
48 template<
class Sink>
void operator()(std::string
const& file, Sink& sink) {
49 setup(&sink, &handle_statement<Sink>);
53 const boost::function<void()> abort_call() {
54 return boost::bind(&Raptor_wrapper::abort_parse,
this);
58 boost::shared_ptr<raptor_world> world_;
59 boost::shared_ptr<raptor_parser> parser_;
60 bool abort_requested_;
64 void setup(
void* sink, handle_statement_fun_t hs_fun);
66 void parse(std::istream&);
68 void parse(std::string
const&);
70 template<
class Sink>
static void handle_statement(
void* data,
const void* rs) {
71 static_cast<Sink*
>(data)->insert(rs);