aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-03-16 16:54:49 -0400
committerDavid Robillard <d@drobilla.net>2020-10-27 13:13:58 +0100
commit3eff44c4784c6f0cfdc8c857ff47f8bdd3ae713c (patch)
tree87346d71b5aa60b980055620597f1a6119c226b0
parent085e63e53502adfc16c3830ed6b0b941314b8f8a (diff)
downloadserd-3eff44c4784c6f0cfdc8c857ff47f8bdd3ae713c.tar.gz
serd-3eff44c4784c6f0cfdc8c857ff47f8bdd3ae713c.tar.bz2
serd-3eff44c4784c6f0cfdc8c857ff47f8bdd3ae713c.zip
Rename SerdChunk to SerdStringView
-rw-r--r--NEWS1
-rw-r--r--serd/serd.h26
-rw-r--r--src/env.c10
-rw-r--r--src/uri.c2
-rw-r--r--src/uri_utils.h6
-rw-r--r--src/writer.c11
-rw-r--r--tests/env_test.c4
7 files changed, 30 insertions, 30 deletions
diff --git a/NEWS b/NEWS
index 95c20ea9..86f0e2e2 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ serd (1.0.1) unstable;
* Add SerdBuffer for mutable buffers to keep SerdChunk const-correct
* Remove useless character counting from API
+ * Rename SerdChunk to SerdStringView
* Use char* for strings in public API
-- David Robillard <d@drobilla.net> Sat, 19 Jan 2019 12:31:12 +0000
diff --git a/serd/serd.h b/serd/serd.h
index adb0f476..b3ecb850 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -225,12 +225,12 @@ typedef struct {
} SerdNode;
/**
- An unterminated string fragment.
+ An unterminated immutable slice of a string.
*/
typedef struct {
const char* buf; /**< Start of chunk */
size_t len; /**< Length of chunk in bytes */
-} SerdChunk;
+} SerdStringView;
/**
A mutable buffer in memory.
@@ -255,17 +255,17 @@ typedef struct {
/**
A parsed URI.
- This struct directly refers to chunks in other strings, it does not own any
+ This struct directly refers to slices in other strings, it does not own any
memory itself. Thus, URIs can be parsed and/or resolved against a base URI
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;
/**
@@ -735,7 +735,7 @@ bool
serd_env_qualify(const SerdEnv* env,
const SerdNode* uri,
SerdNode* prefix,
- SerdChunk* suffix);
+ SerdStringView* suffix);
/**
Expand `curie`.
@@ -747,8 +747,8 @@ SERD_API
SerdStatus
serd_env_expand(const SerdEnv* env,
const SerdNode* curie,
- SerdChunk* uri_prefix,
- SerdChunk* uri_suffix);
+ SerdStringView* uri_prefix,
+ SerdStringView* uri_suffix);
/**
Expand `node`, which must be a CURIE or URI, to a full URI.
@@ -991,7 +991,7 @@ size_t
serd_buffer_sink(const void* buf, size_t len, void* stream);
/**
- Finish a serialisation to a chunk with serd_buffer_sink().
+ Finish a serialisation 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.
diff --git a/src/env.c b/src/env.c
index 3bdd65c3..c52f6ce4 100644
--- a/src/env.c
+++ b/src/env.c
@@ -166,7 +166,7 @@ bool
serd_env_qualify(const SerdEnv* env,
const SerdNode* uri,
SerdNode* prefix,
- SerdChunk* suffix)
+ SerdStringView* suffix)
{
for (size_t i = 0; i < env->n_prefixes; ++i) {
const SerdNode* const prefix_uri = &env->prefixes[i].uri;
@@ -185,8 +185,8 @@ serd_env_qualify(const SerdEnv* env,
SerdStatus
serd_env_expand(const SerdEnv* env,
const SerdNode* curie,
- SerdChunk* uri_prefix,
- SerdChunk* uri_suffix)
+ SerdStringView* uri_prefix,
+ SerdStringView* uri_suffix)
{
const char* const colon = (const char*)memchr(
curie->buf, ':', curie->n_bytes + 1);
@@ -219,8 +219,8 @@ serd_env_expand_node(const SerdEnv* env,
return serd_node_new_uri_from_node(node, &env->base_uri, &ignored);
}
case SERD_CURIE: {
- SerdChunk prefix;
- SerdChunk suffix;
+ SerdStringView prefix;
+ SerdStringView suffix;
if (serd_env_expand(env, node, &prefix, &suffix)) {
return SERD_NODE_NULL;
}
diff --git a/src/uri.c b/src/uri.c
index 1d46ab20..726b0f54 100644
--- a/src/uri.c
+++ b/src/uri.c
@@ -286,7 +286,7 @@ remove_dot_segments(const char* path, size_t len, size_t* up)
/// Merge `base` and `path` in-place
static void
-merge(SerdChunk* base, SerdChunk* path)
+merge(SerdStringView* base, SerdStringView* path)
{
size_t up = 0;
const char* begin = remove_dot_segments(path->buf, path->len, &up);
diff --git a/src/uri_utils.h b/src/uri_utils.h
index 28d74be4..28779d41 100644
--- a/src/uri_utils.h
+++ b/src/uri_utils.h
@@ -22,7 +22,7 @@
#include <string.h>
static inline bool
-chunk_equals(const SerdChunk* a, const SerdChunk* b)
+slice_equals(const SerdStringView* a, const SerdStringView* b)
{
return a->len == b->len && !strncmp(a->buf, b->buf, a->len);
}
@@ -51,8 +51,8 @@ static inline size_t
uri_rooted_index(const SerdURI* uri, const SerdURI* root)
{
if (!root || !root->scheme.len ||
- !chunk_equals(&root->scheme, &uri->scheme) ||
- !chunk_equals(&root->authority, &uri->authority)) {
+ !slice_equals(&root->scheme, &uri->scheme) ||
+ !slice_equals(&root->authority, &uri->authority)) {
return 0;
}
diff --git a/src/writer.c b/src/writer.c
index 39acd75b..bf4ccaa8 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -500,8 +500,8 @@ write_uri_node(SerdWriter* const writer,
const Field field,
const SerdStatementFlags flags)
{
- SerdNode prefix;
- SerdChunk suffix;
+ SerdNode prefix;
+ SerdStringView suffix;
if (is_inline_start(writer, field, flags)) {
++writer->indent;
@@ -560,10 +560,9 @@ write_curie(SerdWriter* const writer,
const Field field,
const SerdStatementFlags flags)
{
- SerdChunk prefix = {NULL, 0};
- SerdChunk suffix = {NULL, 0};
- SerdStatus st = SERD_SUCCESS;
-
+ SerdStringView prefix = {NULL, 0};
+ SerdStringView suffix = {NULL, 0};
+ SerdStatus st = SERD_SUCCESS;
switch (writer->syntax) {
case SERD_NTRIPLES:
case SERD_NQUADS:
diff --git a/tests/env_test.c b/tests/env_test.c
index 1bd88edd..4131e4cf 100644
--- a/tests/env_test.c
+++ b/tests/env_test.c
@@ -44,8 +44,8 @@ test_env(void)
assert(serd_env_set_base_uri(env, &SERD_NODE_NULL));
assert(serd_node_equals(serd_env_get_base_uri(env, NULL), &SERD_NODE_NULL));
- SerdChunk prefix;
- SerdChunk suffix;
+ SerdStringView prefix;
+ SerdStringView suffix;
assert(serd_env_expand(env, &b, &prefix, &suffix));
SerdNode xnode = serd_env_expand_node(env, &SERD_NODE_NULL);