aboutsummaryrefslogtreecommitdiffstats
path: root/serd
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-06-03 22:15:53 +0200
committerDavid Robillard <d@drobilla.net>2018-12-31 11:37:47 -0500
commit5246440bc489b9b8168d0e26700cf5f343895169 (patch)
tree345fd9e2916a0e92205186e011721d9c8459c047 /serd
parentc10db88a4eac181e83acff319e77308291c59645 (diff)
downloadserd-5246440bc489b9b8168d0e26700cf5f343895169.tar.gz
serd-5246440bc489b9b8168d0e26700cf5f343895169.tar.bz2
serd-5246440bc489b9b8168d0e26700cf5f343895169.zip
Add SerdCursor to public API
Diffstat (limited to 'serd')
-rw-r--r--serd/serd.h51
1 files changed, 43 insertions, 8 deletions
diff --git a/serd/serd.h b/serd/serd.h
index 73acf9d6..6f8dece4 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.
Represents the state required to resolve a CURIE or relative URI, e.g. the
@@ -262,12 +267,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;
/**
@@ -1071,7 +1074,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);
/**
@@ -1079,7 +1082,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.
@@ -1262,6 +1267,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);
+
+/**
+ @}
@}
*/