From 47e35393464abc9d92f92974ecef173c7e1b372f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 3 Jun 2018 22:15:53 +0200 Subject: Add SerdCursor to public API --- serd/serd.h | 51 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 8 deletions(-) (limited to 'serd') diff --git a/serd/serd.h b/serd/serd.h index 825726d6..4fa5a70d 100644 --- a/serd/serd.h +++ b/serd/serd.h @@ -69,6 +69,11 @@ typedef struct SerdWorldImpl SerdWorld; */ typedef struct SerdStatementImpl SerdStatement; +/** + Cursor, the origin of a statement in a document. +*/ +typedef struct SerdCursorImpl SerdCursor; + /** Environment. @@ -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. @@ -1263,6 +1268,36 @@ SERD_API const SerdNode* 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); + /** @} @} -- cgit v1.2.1