aboutsummaryrefslogtreecommitdiffstats
path: root/src/serdi.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2017-01-06 14:48:03 -0500
committerDavid Robillard <d@drobilla.net>2017-01-06 21:39:01 -0500
commit5475750ecf496c774a082464b3e60f5adce9cc8a (patch)
tree57e844edc09637096d1b5ea16dcc5ebb69f88345 /src/serdi.c
parent52590dbeb23100320417d6f72e20fadf215479e5 (diff)
downloadserd-5475750ecf496c774a082464b3e60f5adce9cc8a.tar.gz
serd-5475750ecf496c774a082464b3e60f5adce9cc8a.tar.bz2
serd-5475750ecf496c774a082464b3e60f5adce9cc8a.zip
Add support for reading TriG
Diffstat (limited to 'src/serdi.c')
-rw-r--r--src/serdi.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/serdi.c b/src/serdi.c
index be52587c..80bba270 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -53,9 +53,9 @@ print_usage(const char* name, bool error)
fprintf(os, " -e Eat input one character at a time.\n");
fprintf(os, " -f Keep full URIs in input (don't qualify).\n");
fprintf(os, " -h Display this help and exit.\n");
- fprintf(os, " -i SYNTAX Input syntax (turtle, ntriples, or nquads).\n");
+ fprintf(os, " -i SYNTAX Input syntax: turtle/ntriples/trig/nquads.\n");
fprintf(os, " -l Lax (non-strict) parsing.\n");
- fprintf(os, " -o SYNTAX Output syntax (turtle, ntriples, or nquads).\n");
+ fprintf(os, " -o SYNTAX Output syntax: turtle/ntriples/nquads.\n");
fprintf(os, " -p PREFIX Add PREFIX to blank node IDs.\n");
fprintf(os, " -q Suppress all output except data.\n");
fprintf(os, " -r ROOT_URI Keep relative URIs within ROOT_URI.\n");
@@ -73,6 +73,8 @@ set_syntax(SerdSyntax* syntax, const char* name)
*syntax = SERD_NTRIPLES;
} else if (!strcmp(name, "nquads")) {
*syntax = SERD_NQUADS;
+ } else if (!strcmp(name, "trig")) {
+ *syntax = SERD_TRIG;
} else {
SERDI_ERRORF("unknown syntax `%s'\n", name);
return false;
@@ -200,16 +202,17 @@ main(int argc, char** argv)
SerdEnv* env = serd_env_new(&base);
int output_style = 0;
- if (output_syntax == SERD_NTRIPLES) {
+ if (output_syntax == SERD_NTRIPLES || output_syntax == SERD_NQUADS) {
output_style |= SERD_STYLE_ASCII;
- } else {
+ } else if (output_syntax == SERD_TURTLE) {
output_style |= SERD_STYLE_ABBREVIATED;
if (!full_uris) {
output_style |= SERD_STYLE_CURIED;
}
}
- if (input_syntax != SERD_NTRIPLES || (output_style & SERD_STYLE_CURIED)) {
+ if ((input_syntax == SERD_TURTLE || input_syntax == SERD_TRIG) ||
+ (output_style & SERD_STYLE_CURIED)) {
// Base URI may change and/or we're abbreviating URIs, so must resolve
output_style |= SERD_STYLE_RESOLVED; // Base may chan
}