aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-03-16 16:54:49 -0400
committerDavid Robillard <d@drobilla.net>2022-01-13 15:33:54 -0500
commitfaac2e52df494481dc28168a856058a414a913f2 (patch)
tree96f6d9433fc7f23a0e1aabdffd61404a273a28cc /include
parent97258f0e85834d71b17e3c1997a5c7dc136e0b98 (diff)
downloadserd-faac2e52df494481dc28168a856058a414a913f2.tar.gz
serd-faac2e52df494481dc28168a856058a414a913f2.tar.bz2
serd-faac2e52df494481dc28168a856058a414a913f2.zip
Rename SerdChunk to SerdStringView
Diffstat (limited to 'include')
-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 e3184c16..f971d417 100644
--- a/include/serd/serd.h
+++ b/include/serd/serd.h
@@ -91,11 +91,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 {
@@ -234,12 +239,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 =
@@ -659,7 +664,7 @@ 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`.
@@ -671,8 +676,8 @@ 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.
@@ -917,7 +922,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.