77 using World = std::shared_ptr< World_ >;
97 Container, Bag, Sequence, Alternative, aboutEach,
100 List, first, rest, nil,
106 Resource, Class, subClassOf, type, Property, subPropertyOf,
107 domain, range, ConstraintProperty, ConstraintResource,
110 Description, label, seeAlso, comment, isDefinedBy
127 class URI :
public std::shared_ptr< URI_ >
137 URI(
World,
const std::string &uri_string );
143 URI(
const std::string & filename,
World );
147 URI(
const std::string &uri_string,
URI source_uri,
URI base_uri );
150 URI(
URI base_uri,
const std::string &uri_string );
153 URI(
const std::string &local_name,
URI basr_uri );
161 class Model :
public std::shared_ptr< Model_ >
179 Model(
World,
const std::string & storage_type,
180 const std::string & storage_name =
"",
181 const std::string & storage_options =
"",
182 const std::string & model_options =
"" );
188 using Node = std::shared_ptr< Node_ >;
267 class Parser :
public std::shared_ptr< Parser_ >
278 const std::string & syntax_mime = std::string() );
301 const std::string & syntax_mime =
"" );
313 class Stream :
public std::shared_ptr< Stream_ >
335 class Query :
public std::shared_ptr< Query_ >
339 Query(
World,
const std::string & query,
const std::string & lang =
"sparql" );
342 Query(
World,
const std::string & query,
URI base_uri,
const std::string & lang =
"sparql" );
361 virtual void handleError(
const std::string & message ) = 0;
364 virtual void handleWarning(
const std::string & message ) = 0;
384 std::map< std::string, World > worlds;
431 std::map< std::string, URI > uriForPrefix;
432 std::map< std::string, std::string > prefixForURI;
433 static int anonCounter;
448 void base(
const std::string & filename );
462 void insert(
const std::string &prefix,
URI );
465 URI find(
const std::string & );
471 void update(
const std::string &oldPrefix,
const std::string &newPrefix,
URI );
474 void remove(
const std::string & );
485 std::map< std::string, URI >::iterator
begin() {
return uriForPrefix.begin(); }
488 std::map< std::string, URI >::iterator
end() {
return uriForPrefix.end(); }
503 String, Boolean, Decimal, Integer,
509 Data, Time, DateTime, DateTimeStamp,
512 Year, Month, Day, YearMonth, MonthDay, Duration, YearMonthDuration,
516 Byte, Short, Int, Long, UnsignedByte, UnsignedShort, UnsignedLong,
517 PositiveInteger, NonNegativeInteger, NegativeInteger, NonPositiveInteger,
520 HexBinary, Base64Binary,
523 AnyURI, Language, NormalizedString, Token, NMTOKEN, Name, NCName
540 static std::map< DataType, std::string > xsd_types;
541 static std::map< DataType, std::string > names;
542 static void initXSDtypes();
545 std::string mLanguage;
555 Literal(
const std::string &val );
561 Literal(
const std::string &val,
const std::string &lan );
564 Literal(
const std::string &val,
DataType,
const std::string &lan =
"en" );
576 void language(
const std::string & lang ) { mLanguage = lang; }
582 void value(
const std::string & v ) { mValue = v; }
614 static std::string toTypeName(
DataType );
618 static DataType asDataType(
const std::string & type_name );
620 static std::vector< std::string > getDataTypeNames();
671 virtual int size()
const = 0;
674 virtual bool sync() = 0;
702 virtual std::vector< Node >
objects(
Node subject,
Node predicate ) = 0;
708 virtual std::vector< Node >
arcsIn(
Node object ) = 0;
711 virtual std::vector< Node >
arcsOut(
Node subject ) = 0;
729 virtual std::string
toString()
const = 0;
741 virtual bool isBlank()
const = 0;
759 virtual std::string
toString()
const = 0;
779 virtual std::string
toString()
const = 0;
796 virtual std::string
toString()
const = 0;
853 virtual int count()
const = 0;
865 virtual std::string
toString()
const = 0;
881 virtual bool success()
const = 0;
893 class iterator :
public std::iterator< std::forward_iterator_tag, QueryResult_ >
939 std::map<std::string, std::string> prefixes;
940 std::string variables;
941 std::vector<std::string> conditions;
944 std::string get_string();
952 void addPrefix(
const std::string &
id,
const std::string & uri);
961 void orderBy(
const std::string & order);
964 operator std::string();
983 virtual bool toFile(
const std::string &filename,
Model ) = 0;
986 virtual bool toFile(
const std::string &filename,
Model,
URI base_uri ) = 0;
1031 virtual void clear() = 0;
1034 virtual std::string
toString()
const = 0;
1061 virtual bool end() = 0;
1064 virtual bool next() = 0;
1092 virtual std::string
toString()
const = 0;
1119 template <
class C,
class P,
typename T >
1123 P* c =
static_cast< P*
>( a.get() );
1135 #define DEREF( A, b, c ) deref< A##_, _##A, b >( c )
A shared pointer with constructors for the Query_ class.
Definition: rdfxx.h:335
virtual int count() const =0
Get the number of bound values in the result.
QueryString()
Create empty query.
Definition: rdfxx.h:948
Prefixes(World)
Constructor.
virtual bool match(Statement) const =0
Compare if the non-null nodes arethe same.
virtual std::vector< Node > objects(Node subject, Node predicate)=0
Get a list of objects that are linked to a subject by a particular predicate.
A shared pointer with constructors for the Serializer_ class.
Definition: rdfxx.h:290
virtual bool success() const =0
Check if the query got any results.
Literal(const char *val)
Create a PlainLiteral with English language.
Definition: rdfxx.h:558
T * deref(std::shared_ptr< C > a)
A template function that converts a shared pointer into the corresponding librdf pointer.
Definition: rdfxx.h:1120
void dataType(DataType t)
Set the data type.
Definition: rdfxx.h:579
virtual bool sync()=0
Save the model to its storage.
An exception object with stream semantics.
virtual URI toURI() const =0
Get the URI for a Node.
An abstract class defining the methods for an RDF URI.
Definition: rdfxx.h:1079
virtual ~ErrorClient()
Virtual destructor.
Definition: rdfxx.h:358
virtual bool isResource() const =0
Check if the node is a resource.
virtual bool isBlank() const =0
Check if the node is blank.
virtual Node getBoundValue(int offset) const =0
Get a value at a position.
virtual std::vector< Node > predicates(Node subject, Node object)=0
Get a list of predicates that link a subject and object.
void update(const std::string &oldPrefix, const std::string &newPrefix, URI)
Update a prefix and namespace.
virtual Statement copy() const =0
Clone the statement.
virtual std::string toString() const =0
Get a string representation.
virtual ~Node_()
Virtual destructor.
Definition: rdfxx.h:726
World world(const std::string &name)
Create, or return an existing world object.
virtual World getWorld()=0
Return a reference to the model's world.
virtual ~Stream_()
Virtual destructor.
Definition: rdfxx.h:1058
virtual int size() const =0
Get number of statements if possible. May return <0 if not known.
void anonymous(URI uri)
insert an anonymous namespace
URI find(const std::string &)
Find the namespace URI with the supplied prefix.
virtual bool contains(Statement) const =0
Check if a statement is in the model.
std::shared_ptr< World_ > World
A shared pointer to a World object.
Definition: rdfxx.h:77
iterator()
Default constructor.
Stream()
Create a nullptr shared pointer.
virtual bool next()=0
Move to the next statement in the stream.
static Universe & instance()
Get a reference to the universe object.
DataType
A enumeration of the data types available for RDF literals.
Definition: rdfxx.h:495
Manages the prefixes and namespaces for a World.
Definition: rdfxx.h:425
A shared pointer with constructors for the LiteralNode_ class.
Definition: rdfxx.h:212
Concept
An enumeration of RDF and RDFS concepts.
Definition: rdfxx.h:94
virtual ~Serializer_()
Virtual destructor.
Definition: rdfxx.h:977
virtual iterator begin() const =0
Get iterator at start of result set.
A shared pointer with constructors for the Model_ class.
Definition: rdfxx.h:161
std::string prefixForm(URI)
Convert a URI and fragment to its prefix and fragment.
std::string language() const
Get the language.
Definition: rdfxx.h:597
virtual bool operator==(Statement) const =0
Compare with another statement.
virtual Stream toStream()=0
Get a pointer to a stream. The user controls its lifetime.
void base(URI uri)
Set the base URI.
Definition: rdfxx.h:442
Provide a C++ iterator over the results of a RDF query.
Definition: rdfxx.h:893
ResourceNode(World, URI)
Create resource node based on a URI.
DataType dataType() const
Get the data type.
Definition: rdfxx.h:591
virtual URI toURI() const =0
Get the URI for a Node.
An abstract class defining the methods for an RDF Stream.
Definition: rdfxx.h:1054
std::shared_ptr< QueryResults_ > QueryResults
A shared pointer to a set of query results.
Definition: rdfxx.h:86
bool asBoolean() const
Get the value as a boolean.
virtual ~QueryResults_()
Virtual destructor.
Definition: rdfxx.h:878
virtual ~World_()
Virtual destructor.
Definition: rdfxx.h:639
An abstract class defining the methods for an RDF Parser.
Definition: rdfxx.h:808
An abstract class defining the methods for an RDF Serializer.
Definition: rdfxx.h:973
virtual StatementRef current()=0
Get a reference to the current statement.
bool isBase(URI) const
Check if a URI is the base URI.
An abstract class defining the methods for an RDF Literal Node.
Definition: rdfxx.h:775
A shared pointer with constructors for the BlankNode_ class.
Definition: rdfxx.h:226
virtual std::string toString() const =0
Convert all the names and values to a string.
virtual void registerErrorClient(ErrorClient *, bool warnings, bool errors)=0
Register a client object to receive error and/or error messages.
virtual std::string toString() const =0
Get a string representation of the node.
virtual bool operator==(URI) const =0
Compare with another URI.
virtual ~URI_()
Virtual destructor.
Definition: rdfxx.h:1083
static DataType toDataType(const std::string &xsd_type)
Convert an xsd form into a data type.
Statement()
Create a nullptr based default statement.
An abstract class defining the methods for an RDF Statement.
Definition: rdfxx.h:997
virtual Serializer defaultSerializer()=0
Get a default serialiser - depreicated.
virtual bool setNamespace(URI, const std::string &prefix)=0
Add a namespace and prefix to the output.
virtual Literal toLiteral() const =0
Get the Literal data for the node.
bool operator==(Statement, Statement)
Check for equality of two statements.
URI uriForm(const std::string &)
Convert a prefix and fragment to a URI and fragment.
iterator & operator=(const QueryResult_ &)=delete
No assignment allowed for these iterators.
void addCondition(const std::string &condition)
Add a condition to the query.
virtual std::vector< Node > arcsIn(Node object)=0
Get a list of predicates connected to an object.
An abstract class defining the methods for an RDF Node.
Definition: rdfxx.h:722
virtual void handleError(const std::string &message)=0
The function that will be called when an error is detected.
void value(const std::string &v)
Set the value.
Definition: rdfxx.h:582
A class for assistingin the preparation of a SPARQL query.
Definition: rdfxx.h:936
An abstract class defining the methods for an RDF Resource Node.
Definition: rdfxx.h:755
std::weak_ptr< Statement_ > StatementRef
A weak shared pointer to a statement.
Definition: rdfxx.h:89
void addPrefix(const std::string &id, const std::string &uri)
Add a prefix and namespace to the query.
LiteralNode(World, const Literal &)
Create a literal node using a literal value.
Model()
Create an empty model.
Definition: rdfxx.h:165
virtual NodeRef predicate() const =0
Get a reference to the predicate node.
std::string toString() const
Default conversion to a string.
std::map< std::string, URI >::iterator end()
get the end iterator for the saves prefixes.
Definition: rdfxx.h:488
Literal()
Default constructor.
Serializer()
Create a nullptr shared pointer.
URI()
Default constructor.
Definition: rdfxx.h:131
BlankNode(World, const std::string &id="")
Create a blank node using a supplied identifier.
An abstract class defining the methods for an RDF Query.
Definition: rdfxx.h:827
virtual int getLimit() const =0
Get the max number of results to be returned.
virtual iterator & operator++()
Move to next result.
A shared pointer with constructors for the ResourceNode_ class.
Definition: rdfxx.h:193
Hold the value, language and data type for an RDF literal.
Definition: rdfxx.h:537
virtual std::string toString() const =0
Get a string representaion of the statement.
An abstract class defining the methods for a set of Query Results.
Definition: rdfxx.h:874
virtual ~Query_()
Virtual destructor.
Definition: rdfxx.h:831
virtual QueryResult_ & operator*() const
Dereference the iterator to get a result.
std::weak_ptr< Node_ > NodeRef
A weak shared pointer to a Node object.
Definition: rdfxx.h:83
void setVariables(const std::string &variables)
Set the variables to search for.
std::string asString() const
Get the value as a string.
Definition: rdfxx.h:600
virtual bool operator!=(const iterator &) const
Check for inequality.
Query(World, const std::string &query, const std::string &lang="sparql")
Create a query.
An abstract class defining the methods for an RDF Query Result.
Definition: rdfxx.h:849
virtual iterator end() const =0
Get iterator past the end of result set.
virtual ~Model_()
Virtual destructor.
Definition: rdfxx.h:665
An abstract class defining the methods for an RDF Model.
Definition: rdfxx.h:661
virtual URI trim(World) const =0
Strip off fragment.
virtual bool isFileName() const =0
Check if URI represents a file path.
double asDouble() const
Get the value as a double.
static std::string toXSD(DataType)
Convert a data type into an xsd form,.
virtual std::string getBoundName(int offset) const =0
Get the variable name at a position.
virtual bool add(Node subject, Node predicate, Node object)=0
Add the nodes of a statement to the model.
An abstract class defining the methods for an RDF World.
Definition: rdfxx.h:635
virtual bool toFile(const std::string &filename, Model)=0
Write the model to a file.
virtual void clear()=0
Remove the nodes.
static std::vector< std::string > listParsers(World)
Get a list of parser names with their syntax URIs.
virtual std::string toString() const =0
Get a string representation of the node.
virtual bool end()=0
Check if at the end of the stream.
virtual void deregisterErrorClient(ErrorClient *)=0
Remove a client that was to get error messages.
virtual URI copy() const =0
Clonethe URI.
virtual NodeRef subject() const =0
Get a reference to the subject node.
virtual int listItemOrdinal() const =0
Get the ordinal value for a list item.
A singleton class responsible for managing the World objects.
Definition: rdfxx.h:377
URI dataTypeURI(World) const
Get the data type as a URI.
virtual bool parseIntoModel(Model, URI uri, URI base_uri)=0
Parse a data source into a model.
A shared pointer with constructors for the Statement_ class.
Definition: rdfxx.h:242
virtual std::vector< Node > subjects(Node predicate, Node object)=0
Get a list of subjects that are linked to an object by a particular predicate.
URI base() const
Get the base URI.
Definition: rdfxx.h:451
A shared pointer with constructors for the Stream_ class.
Definition: rdfxx.h:313
Client that is notified of errors and/or warnings.
Definition: rdfxx.h:354
A shared pointer with constructors for the URI_ class.
Definition: rdfxx.h:127
virtual bool update(Statement old, Statement _new)=0
Update a statement in the model.
int asInteger() const
Get the value as an integer.
std::shared_ptr< Node_ > Node
A shared pointer to a Node object.
Definition: rdfxx.h:188
An abstract class defining the methods for an RDF blank Node.
Definition: rdfxx.h:792
virtual NodeRef object() const =0
Get a reference to the object node.
virtual void handleWarning(const std::string &message)=0
The function that will be called when a warning is detected.
virtual ~Statement_()
Virtual destructor.
Definition: rdfxx.h:1001
virtual std::string toString() const =0
Get a string representation of the node.
virtual bool isLiteral() const =0
Check if the node is a literal.
std::string removeBase(URI) const
Strip the base URI from a URI.
virtual std::string toFileName() const =0
Convert the URI to a file path name.
Parser(World, const std::string &name, const std::string &syntax_mime=std::string())
Create an RDF parser using the specified parsing engine.
virtual ~Parser_()
Virtual destructor.
Definition: rdfxx.h:812
virtual bool setLimit(int)=0
Set the max number of results returned.
virtual std::vector< Node > arcsOut(Node subject)=0
Get a list of predicates connected to a ssubject.
virtual bool isComplete() const =0
Check if all three nodes are defined.
void insert(const std::string &prefix, URI)
Save a prefix and its corresponding namespace URI.
std::weak_ptr< World_ > WorldRef
A weak shared pointer to a World object.
Definition: rdfxx.h:80
virtual bool operator==(const iterator &) const
Check for equality.
void language(const std::string &lang)
Set the language.
Definition: rdfxx.h:576
virtual std::string toString() const =0
Get a string representation of the node.
virtual Prefixes & prefixes()=0
Get a reference to the saved prefixes.
void orderBy(const std::string &order)
Add an ordering clause to the query.
virtual std::string toString()=0
Convert all results to a string. This consumes the results.
std::map< std::string, URI >::iterator begin()
Get an iterator for the saved prefixes.
Definition: rdfxx.h:485
A shared pointer with constructors for the Parser_ class.
Definition: rdfxx.h:267
virtual QueryResults execute(Model)=0
Run the query on a model.