|
1 | | -⚠️ This repo is work-in-progress! Before v0.1.0 all APIs are considered unstable and might be subject to change. ⚠️ |
| 1 | +[](https://rdf4cpp.readthedocs.io/en/latest/) |
| 2 | +[](https://conan.dice-research.org/ui/packages/conan:%2F%2Frdf4cpp) |
| 3 | +[](https://github.com/rdf4cpp/rdf4cpp/releases) |
| 4 | + |
| 5 | + |
2 | 6 |
|
3 | 7 | # rdf4cpp |
4 | 8 |
|
5 | | -rdf4cpp aims to be a stable, modern RDF library for C++, implementing the following standards: |
6 | | -- [W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes](https://www.w3.org/TR/xmlschema11-2/) |
7 | | -- [XPath and XQuery Functions and Operators 3.1 ](https://www.w3.org/TR/xpath-functions-31/) |
8 | | -- [OWL Real and Rational](https://www.w3.org/TR/owl2-syntax/#Datatype_Maps) |
| 9 | +_rdf4cpp_ is a modern C++23 library providing basic RDF support. |
| 10 | + |
| 11 | +The focus is **correctness**, **performance** and **ease-of-use** for **basic building blocks** like: |
| 12 | + |
| 13 | +- parsing, validating and writing RDF data ([N-Triples](https://www.w3.org/TR/n-triples/), [Turtle](https://www.w3.org/TR/turtle/), [N-Quads](https://www.w3.org/TR/n-quads/), [TriG](https://www.w3.org/TR/trig/)) |
| 14 | +- Complete and extensible literal datatypes (validation, functions, operations, subtype and promotion casting, mapping to C++ types, error handling, ...) |
| 15 | +- Managing RDF nodes efficiently |
| 16 | +- Blank node scoping (e.g., for RDF datasets) |
| 17 | + |
| 18 | +_rdf4cpp_ is **not** a **SPARQL engine** or **reasoning engine**, although it provides very basic support for triple/quad |
| 19 | +pattern matching on RDF graphs/datasets. _rdf4cpp_ rather provides the necessary primitives to implement such engines. |
| 20 | + |
| 21 | +We implement the following W3C standards: |
9 | 22 |
|
10 | | -Current documentation: https://rdf4cpp.readthedocs.io/en/latest/ |
| 23 | +- [RDF 1.1 Concepts and Abstract Syntax](https://www.w3.org/TR/rdf11-concepts/) |
| 24 | +- [XML XSD 1.1 Part 2: Datatypes](https://www.w3.org/TR/xmlschema11-2/) (RDF related parts) |
| 25 | +- [OWL Real and Rational](https://www.w3.org/TR/owl2-syntax/#Datatype_Maps) |
| 26 | +- [XPath and XQuery Functions and Operators 3.1](https://www.w3.org/TR/xpath-functions-31/) (SPARQL related parts) |
| 27 | + |
| 28 | +## Example |
| 29 | + |
| 30 | +```c++ |
| 31 | +#include <iostream> |
| 32 | +#include <rdf4cpp.hpp> |
| 33 | + |
| 34 | +int main() { |
| 35 | + using namespace ::rdf4cpp; |
| 36 | + using namespace ::rdf4cpp::shorthands; |
| 37 | + using namespace ::rdf4cpp::namespaces; |
| 38 | + using namespace ::rdf4cpp::datatypes; |
| 39 | + |
| 40 | + /// 1) basic dataset, graph and RDF node usage |
| 41 | + // using namespaces |
| 42 | + FOAF foaf{}; // common, predefined namespace |
| 43 | + Namespace const ex{"http://example.com/"}; // self-declared namespace |
| 44 | + |
| 45 | + Dataset dataset; |
| 46 | + // populate a named graph in the dataset |
| 47 | + auto &graph = dataset.graph(IRI{"http://ex.com/MyGraph"}); // IRI constructor |
| 48 | + graph.add({"http://example.com/Bob"_iri, "http://example.com/knows"_iri, "http://example.com/Alice"_iri}); // IRI shorthand |
| 49 | + graph.add({ex + "Alice", foaf + "knows", ex + "Bob"}); // using namespaces |
| 50 | + graph.add({ex + "Bob", foaf + "name", "Bob"_xsd_string}); // Literal datatype shorthand |
| 51 | + |
| 52 | + // serialize the dataset as N-Quads |
| 53 | + std::cout << "Dataset as N-Quads: \n" |
| 54 | + << dataset << std::endl; |
| 55 | + |
| 56 | + // 2) Using datatypes and arithmetics |
| 57 | + // typed Literal instantiation |
| 58 | + auto const d = Literal::make_typed_from_value<xsd::Double>(2.3); // factory function |
| 59 | + auto const ui = 42_xsd_uint; // Literal datatype shorthand |
| 60 | + auto const dec = "42.1"_xsd_decimal; // infinite precision decimals |
| 61 | + |
| 62 | + // basic arithmetics with automatic result type deduction |
| 63 | + auto const r1 = d * dec; // double * decimal → double |
| 64 | + auto const r2 = (ui + dec).round(); // round(integer + decimal) → decimal |
| 65 | + |
| 66 | + std::cout << "Using XSD datatypes, functions and operators: \n" |
| 67 | + << std::format("{} * {} = {}\n", d, dec, r1) |
| 68 | + << std::format("ceil({} + {}) = {}", ui, dec, r2) << std::endl; |
| 69 | + |
| 70 | + return 0; |
| 71 | +} |
| 72 | +``` |
11 | 73 |
|
12 | | -## Usage |
13 | | -check out the [examples](./examples) directory. |
| 74 | +## Using _rdf4cpp_ |
14 | 75 |
|
15 | | -### As Conan Package |
| 76 | +_rdf4cpp_ is consumed via Conan 2 but it is not available via [Conan Center](https://conan.io/center). |
| 77 | +Instead, it can be found on the artifactory of the [DICE Research Group](https://dice-research.org/). |
16 | 78 |
|
17 | | -Until its first stable release, rdf4cpp will not be available via Conan Center. Instead, it is available via the artifactory of the [DICE Research Group](https://dice-research.org/). |
| 79 | +You need the package manager [conan](https://conan.io/downloads.html) installed and set up. You can add the DICE |
| 80 | +artifactory with: |
18 | 81 |
|
19 | | -You need the [package manager Conan](https://conan.io/downloads.html) installed and set up. You can add the DICE artifactory with: |
20 | 82 | ```shell |
21 | 83 | conan remote add dice-group https://conan.dice-research.org/artifactory/api/conan/tentris |
22 | 84 | ``` |
23 | 85 |
|
24 | | -To use rdf4cpp, add it to your `conanfile.txt`: |
| 86 | +To use _rdf4cpp_, add it to your `conanfile.txt`: |
| 87 | + |
25 | 88 | ``` |
26 | 89 | [requires] |
27 | | -rdf4cpp/0.0.58 |
| 90 | +rdf4cpp/0.1.0 |
28 | 91 | ``` |
29 | 92 |
|
30 | | -Note: |
| 93 | +For getting started how to use rdf4cpp, check out the [examples](./examples) directory and refer to our documentation. |
31 | 94 |
|
32 | | -If you want to include rdf4cpp without using conan, make sure you also include its dependencies exposed via the rdf4cpp API. |
33 | 95 |
|
34 | | -## Build |
35 | 96 |
|
36 | | -### Requirements |
| 97 | +## Developing _rdf4cpp_ |
37 | 98 |
|
38 | | -Currently, rdf4cpp builds only on linux with a C++20 compatible compiler. |
39 | | -CI builds and tests rdf4cpp with gcc-{13}, clang-{17,18,19} with libstdc++-13 on ubuntu 22.04. |
40 | | - |
41 | | -### Dependencies |
42 | | -It is recommended to include build dependencies via conan. Set up Conan as follows on Ubuntu 22.04+: |
43 | | -```shell |
44 | | -sudo apt install python3-pip |
45 | | -pip3 install --user conan |
46 | | -conan user |
47 | | -conan profile new --detect default |
48 | | -conan profile update settings.compiler.libcxx=libstdc++11 default |
49 | | -conan remote add dice-group https://conan.dice-research.org/artifactory/api/conan/tentris |
50 | | -``` |
| 99 | +### Compile |
51 | 100 |
|
| 101 | +_rdf4cpp_ uses CMake and Conan 2. To build it, run: |
52 | 102 |
|
53 | | -### Compile |
54 | | -rdf4cpp uses CMake and conan 2. To build it, run: |
55 | 103 | ```shell |
56 | 104 | wget https://github.com/conan-io/cmake-conan/raw/develop2/conan_provider.cmake -O conan_provider.cmake # download conan provider |
57 | 105 | cmake -B build_dir -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider.cmake # configure and generate |
58 | 106 | cmake --build build_dir # compile |
59 | 107 | ``` |
60 | 108 |
|
61 | 109 | To install it to your system, run afterward: |
| 110 | + |
62 | 111 | ```shell |
63 | 112 | cd build_dir |
64 | 113 | sudo make install |
65 | 114 | ``` |
66 | 115 |
|
67 | 116 | ### Additional CMake config options: |
68 | 117 |
|
69 | | -`-DBUILD_EXAMPLES=ON/OFF [default: OFF]`: Build the examples. |
| 118 | +- `-DBUILD_EXAMPLES=ON/OFF [default: OFF]`: Build the examples. |
| 119 | +- `-DBUILD_TESTING=ON/OFF [default: OFF]`: Build the tests. |
| 120 | +- `-DBUILD_SHARED_LIBS=ON/OFF [default: OFF]`: Build a shared library instead of a static one. |
| 121 | + |
| 122 | + |
| 123 | +## Supported Platforms |
| 124 | + |
| 125 | +- **Linux distributions (x86_64, AArch64)** (e.g. Ubuntu 22.04+, Fedora 42+, etc.) with: |
| 126 | + - GCC 13+ (libstdc++ 13+; used with both GCC and Clang) |
| 127 | + - Clang 17+ (except Clang 18 does not work on AArch64) |
| 128 | + - glibc 2.35+ or musl 1.2.4+ |
| 129 | +- **macOS (ARM64)**: macOS Sonoma (14)+ with GCC 13 (via Homebrew) |
| 130 | + |
| 131 | +## Stability |
| 132 | + |
| 133 | +### API Stability |
| 134 | + |
| 135 | +From version 0.1 onwards (before 1.0.0), all high-level public API that the average user is expected to interact with is |
| 136 | +considered stable. |
| 137 | +This includes basically everything, except what is in the `rdf4cpp::storage` and `rdf4cpp::datatypes::registry` |
| 138 | +namespaces. |
| 139 | +Should we ever break anything in these high-level interfaces, we will bump the minor version (for example, from 0.1.0 to |
| 140 | +0.2.0). |
| 141 | + |
| 142 | +### ABI Stability |
| 143 | + |
| 144 | +ABI stability is not guaranteed. |
70 | 145 |
|
71 | | -`-DBUILD_TESTING=ON/OFF [default: OFF]`: Build the tests. |
| 146 | +### POBR Stability |
72 | 147 |
|
73 | | -`-DBUILD_SHARED_LIBS=ON/OFF [default: OFF]`: Build a shared library instead of a static one. |
| 148 | +The POBR (Persisted Object Binary Representation) version tracks on-disk format stability (e.g., with allocators |
| 149 | +like [Metall](https://github.com/LLNL/metall)). |
| 150 | +This includes everything in `rdf4cpp::storage::identifiers` but nothing else. |
| 151 | +The current POBR version can be retrieved via `rdf4cpp::pobr_version`. |
0 commit comments