aboutsummaryrefslogtreecommitdiffstats
path: root/include/serd
diff options
context:
space:
mode:
Diffstat (limited to 'include/serd')
-rw-r--r--include/serd/serd.h33
1 files changed, 19 insertions, 14 deletions
diff --git a/include/serd/serd.h b/include/serd/serd.h
index 80d6b230..3dacf6a9 100644
--- a/include/serd/serd.h
+++ b/include/serd/serd.h
@@ -76,11 +76,16 @@ typedef enum {
/// Bitwise OR of SerdNodeFlag values
typedef uint32_t SerdNodeFlags;
-/// An unterminated string fragment
+/**
+ An immutable slice of a string.
+
+ This type is used for many string parameters, to allow referring to slices
+ of strings in-place and to avoid redundant string measurement.
+*/
typedef struct {
- const char* SERD_NULLABLE buf; ///< Start of chunk
- size_t len; ///< Length of chunk in bytes
-} SerdChunk;
+ const char* SERD_NULLABLE buf; ///< Start of string
+ size_t len; ///< Length of string in bytes
+} SerdStringView;
/// A mutable buffer in memory
typedef struct {
@@ -217,12 +222,12 @@ typedef size_t (*SerdSink)(const void* SERD_NONNULL buf,
in-place without allocating memory.
*/
typedef struct {
- SerdChunk scheme; ///< Scheme
- SerdChunk authority; ///< Authority
- SerdChunk path_base; ///< Path prefix if relative
- SerdChunk path; ///< Path suffix
- SerdChunk query; ///< Query
- SerdChunk fragment; ///< Fragment
+ SerdStringView scheme; ///< Scheme
+ SerdStringView authority; ///< Authority
+ SerdStringView path_base; ///< Path prefix if relative
+ SerdStringView path; ///< Path suffix
+ SerdStringView query; ///< Query
+ SerdStringView fragment; ///< Fragment
} SerdURI;
static const SerdURI SERD_URI_NULL =
@@ -618,7 +623,7 @@ SERD_API bool
serd_env_qualify(const SerdEnv* SERD_NULLABLE env,
const SerdNode* SERD_NONNULL uri,
SerdNode* SERD_NONNULL prefix,
- SerdChunk* SERD_NONNULL suffix);
+ SerdStringView* SERD_NONNULL suffix);
/**
Expand `curie`.
@@ -629,8 +634,8 @@ serd_env_qualify(const SerdEnv* SERD_NULLABLE env,
SERD_API SerdStatus
serd_env_expand(const SerdEnv* SERD_NULLABLE env,
const SerdNode* SERD_NONNULL curie,
- SerdChunk* SERD_NONNULL uri_prefix,
- SerdChunk* SERD_NONNULL uri_suffix);
+ SerdStringView* SERD_NONNULL uri_prefix,
+ SerdStringView* SERD_NONNULL uri_suffix);
/**
Expand `node`, which must be a CURIE or URI, to a full URI.
@@ -868,7 +873,7 @@ serd_buffer_sink(const void* SERD_NONNULL buf,
void* SERD_NONNULL stream);
/**
- Finish a serialisation to a chunk with serd_buffer_sink().
+ Finish writing to a buffer with serd_buffer_sink().
The returned string is the result of the serialisation, which is null
terminated (by this function) and owned by the caller.