diff options
author | David Robillard <d@drobilla.net> | 2023-09-10 13:39:56 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:07 -0500 |
commit | d80b2a1c153f81685d026f8e09c12175abed3d03 (patch) | |
tree | 8207788e58ee9de94ca224433a02a88e8fed3801 /src/reader.c | |
parent | 76fabe903adb09e6fe4d084ff6be49115285e086 (diff) | |
download | serd-d80b2a1c153f81685d026f8e09c12175abed3d03.tar.gz serd-d80b2a1c153f81685d026f8e09c12175abed3d03.tar.bz2 serd-d80b2a1c153f81685d026f8e09c12175abed3d03.zip |
Separate Turtle and TriG reading code
Diffstat (limited to 'src/reader.c')
-rw-r--r-- | src/reader.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/src/reader.c b/src/reader.c index 1c99b033..d7c87c47 100644 --- a/src/reader.c +++ b/src/reader.c @@ -8,8 +8,11 @@ #include "node.h" #include "read_nquads.h" #include "read_ntriples.h" +#include "read_trig.h" +#include "read_turtle.h" #include "stack.h" #include "statement.h" +#include "string_utils.h" #include "system.h" #include "world.h" @@ -149,6 +152,14 @@ push_node(SerdReader* const reader, return push_node_padded(reader, length, type, str, length); } +int +tokcmp(const SerdNode* const node, const char* const tok, const size_t n) +{ + return ((!node || node->length != n) + ? -1 + : serd_strncasecmp(serd_node_string(node), tok, n)); +} + SerdStatus emit_statement(SerdReader* const reader, const ReadContext ctx, @@ -188,13 +199,13 @@ serd_reader_read_document(SerdReader* const reader) case SERD_SYNTAX_EMPTY: break; case SERD_TURTLE: - return read_turtleTrigDoc(reader); + return read_turtleDoc(reader); case SERD_NTRIPLES: return read_ntriplesDoc(reader); case SERD_NQUADS: return read_nquadsDoc(reader); case SERD_TRIG: - return read_turtleTrigDoc(reader); + return read_trigDoc(reader); } return SERD_SUCCESS; @@ -367,9 +378,23 @@ serd_reader_read_chunk(SerdReader* const reader) return SERD_FAILURE; } - return st ? st - : (reader->syntax == SERD_NQUADS) ? read_nquads_line(reader) - : read_n3_statement(reader); + if (st) { + return st; + } + + switch (reader->syntax) { + case SERD_SYNTAX_EMPTY: + break; + case SERD_TURTLE: + case SERD_NTRIPLES: + return read_turtle_statement(reader); + case SERD_NQUADS: + return read_nquads_line(reader); + case SERD_TRIG: + return read_trig_statement(reader); + } + + return SERD_FAILURE; } SerdStatus |