diff options
author | David Robillard <d@drobilla.net> | 2018-05-27 15:32:12 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 16:27:02 -0500 |
commit | 6552a427d194572b4408150512efea17d884d35f (patch) | |
tree | 57cebfc6a08e8af5577c54cf0916745dd5664b45 /include/serd/syntax.h | |
parent | 58d63871ab308d24624ebfa322301281d85ec07c (diff) | |
download | serd-6552a427d194572b4408150512efea17d884d35f.tar.gz serd-6552a427d194572b4408150512efea17d884d35f.tar.bz2 serd-6552a427d194572b4408150512efea17d884d35f.zip |
Move syntax name/extension utilities to public API
Diffstat (limited to 'include/serd/syntax.h')
-rw-r--r-- | include/serd/syntax.h | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/include/serd/syntax.h b/include/serd/syntax.h index 21847438..c3a33ff5 100644 --- a/include/serd/syntax.h +++ b/include/serd/syntax.h @@ -6,6 +6,8 @@ #include "serd/attributes.h" +#include <stdbool.h> + SERD_BEGIN_DECLS /** @@ -14,15 +16,41 @@ SERD_BEGIN_DECLS @{ */ -/// RDF syntax type +/// Syntax supported by serd typedef enum { - SERD_TURTLE = 1, ///< Terse triples http://www.w3.org/TR/turtle - SERD_NTRIPLES = 2, ///< Line-based triples http://www.w3.org/TR/n-triples/ - SERD_NQUADS = 3, ///< Line-based quads http://www.w3.org/TR/n-quads/ - SERD_TRIG = 4, ///< Terse quads http://www.w3.org/TR/trig/ + SERD_TURTLE = 1U, ///< Terse triples http://www.w3.org/TR/turtle + SERD_NTRIPLES = 2U, ///< Line-based triples http://www.w3.org/TR/n-triples/ + SERD_NQUADS = 3U, ///< Line-based quads http://www.w3.org/TR/n-quads/ + SERD_TRIG = 4U, ///< Terse quads http://www.w3.org/TR/trig/ } SerdSyntax; /** + Get a syntax by name. + + Case-insensitive, supports "Turtle", "NTriples", "NQuads", and "TriG". Zero + is returned if the name is not recognized. +*/ +SERD_PURE_API SerdSyntax +serd_syntax_by_name(const char* SERD_NONNULL name); + +/** + Guess a syntax from a filename. + + This uses the file extension to guess the syntax of a file. Zero is + returned if the extension is not recognized. +*/ +SERD_PURE_API SerdSyntax +serd_guess_syntax(const char* SERD_NONNULL filename); + +/** + Return whether a syntax can represent multiple graphs in one document. + + @return True for #SERD_NQUADS and #SERD_TRIG, false otherwise. +*/ +SERD_CONST_API bool +serd_syntax_has_graphs(SerdSyntax syntax); + +/** @} */ |