diff options
author | David Robillard <d@drobilla.net> | 2018-06-03 22:15:53 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-11-25 22:12:47 +0100 |
commit | 47e35393464abc9d92f92974ecef173c7e1b372f (patch) | |
tree | 8c1b1a473e804d07fb73c135d9fc78625f8ce3f6 /serd | |
parent | 191392584bebb14bed9bb325f54a035e0072622a (diff) | |
download | serd-47e35393464abc9d92f92974ecef173c7e1b372f.tar.gz serd-47e35393464abc9d92f92974ecef173c7e1b372f.tar.bz2 serd-47e35393464abc9d92f92974ecef173c7e1b372f.zip |
Add SerdCursor to public API
Diffstat (limited to 'serd')
-rw-r--r-- | serd/serd.h | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/serd/serd.h b/serd/serd.h index 825726d6..4fa5a70d 100644 --- a/serd/serd.h +++ b/serd/serd.h @@ -70,6 +70,11 @@ typedef struct SerdWorldImpl SerdWorld; typedef struct SerdStatementImpl SerdStatement; /** + Cursor, the origin of a statement in a document. +*/ +typedef struct SerdCursorImpl SerdCursor; + +/** Environment. Represents the state required to resolve a CURIE or relative URI, e.g. the @@ -263,12 +268,10 @@ typedef struct { An error description. */ typedef struct { - SerdStatus status; /**< Error code */ - const char* filename; /**< File where error was encountered, or NULL */ - unsigned line; /**< Line where error was encountered, or 0 */ - unsigned col; /**< Column where error was encountered */ - const char* fmt; /**< Message format string (printf style) */ - va_list* args; /**< Arguments for fmt */ + SerdStatus status; /**< Error code */ + const SerdCursor* cursor; /**< Origin of error, or NULL */ + const char* fmt; /**< Message format string (printf style) */ + va_list* args; /**< Arguments for fmt */ } SerdError; /** @@ -1074,7 +1077,7 @@ serd_reader_start_stream(SerdReader* reader, SerdReadFunc read_func, SerdStreamErrorFunc error_func, void* stream, - const char* name, + const SerdNode* name, size_t page_size); /** @@ -1082,7 +1085,9 @@ serd_reader_start_stream(SerdReader* reader, */ SERD_API SerdStatus -serd_reader_start_string(SerdReader* reader, const char* utf8); +serd_reader_start_string(SerdReader* reader, + const char* utf8, + const SerdNode* name); /** Read a single "chunk" of data during an incremental read. @@ -1265,6 +1270,36 @@ serd_statement_get_graph(const SerdStatement* statement); /** @} + @name Cursor + @{ +*/ + +/** + Return the document name. + + This is typically a file URI, but may be a descriptive string node for + statements that originate from streams. +*/ +SERD_API +const SerdNode* +serd_cursor_get_name(const SerdCursor* cursor); + +/** + Return the one-relative line number in the document. +*/ +SERD_API +unsigned +serd_cursor_get_line(const SerdCursor* cursor); + +/** + Return the zero-relative column number in the line. +*/ +SERD_API +unsigned +serd_cursor_get_column(const SerdCursor* cursor); + +/** + @} @} */ |