aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-08-30 20:43:05 -0400
committerDavid Robillard <d@drobilla.net>2023-12-02 18:49:08 -0500
commit258ea2ff59bbd2127ea446cf4b9676ad3d7fe53d (patch)
treed7be35c7b4b3d466049352f2975e2c88c298f4b8
parentb13ad41a4d65b577b4db67660a9edf3056bdf7af (diff)
downloadserd-258ea2ff59bbd2127ea446cf4b9676ad3d7fe53d.tar.gz
serd-258ea2ff59bbd2127ea446cf4b9676ad3d7fe53d.tar.bz2
serd-258ea2ff59bbd2127ea446cf4b9676ad3d7fe53d.zip
Use ZixStringView directly
-rw-r--r--NEWS4
-rw-r--r--doc/conf.py.in1
-rw-r--r--include/serd/env.h20
-rw-r--r--include/serd/log.h6
-rw-r--r--include/serd/node.h40
-rw-r--r--include/serd/serd.h1
-rw-r--r--include/serd/string_view.h80
-rw-r--r--include/serd/uri.h18
-rw-r--r--include/serd/writer.h4
-rw-r--r--meson.build3
-rw-r--r--src/canon.c11
-rw-r--r--src/env.c51
-rw-r--r--src/env.h14
-rw-r--r--src/log.c6
-rw-r--r--src/node.c73
-rw-r--r--src/node_spec.h20
-rw-r--r--src/node_syntax.c6
-rw-r--r--src/nodes.c22
-rw-r--r--src/read_turtle.c16
-rw-r--r--src/uri.c12
-rw-r--r--src/uri_utils.h4
-rw-r--r--src/world.c16
-rw-r--r--src/writer.c19
-rw-r--r--test/headers/.clang-tidy2
-rw-r--r--test/test_canon.c17
-rw-r--r--test/test_env.c108
-rw-r--r--test/test_log.c4
-rw-r--r--test/test_model.c73
-rw-r--r--test/test_node.c86
-rw-r--r--test/test_node_syntax.c27
-rw-r--r--test/test_nodes.c51
-rw-r--r--test/test_overflow.c5
-rw-r--r--test/test_reader.c26
-rw-r--r--test/test_reader_writer.c21
-rw-r--r--test/test_terse_write.c6
-rw-r--r--test/test_uri.c19
-rw-r--r--test/test_writer.c39
-rw-r--r--tools/console.c23
-rw-r--r--tools/console.h6
-rw-r--r--tools/serd-filter.c4
-rw-r--r--tools/serd-pipe.c4
41 files changed, 451 insertions, 517 deletions
diff --git a/NEWS b/NEWS
index 69166105..f6f6ce97 100644
--- a/NEWS
+++ b/NEWS
@@ -18,7 +18,7 @@ serd (1.1.1) unstable; urgency=medium
* Remove serd_uri_to_path()
* Remove support for reading Turtle named inline nodes extension
* Remove useless character counting from API
- * Rename SerdChunk to SerdStringView
+ * Replace SerdChunk with ZixStringView
* Replace serdi with more focused tools
* Simplify statement flags
* Simplify writer style options and write UTF-8 by default
@@ -27,7 +27,7 @@ serd (1.1.1) unstable; urgency=medium
* Use a fixed-size reader stack
* Use char* for strings in public API
- -- David Robillard <d@drobilla.net> Wed, 13 Jul 2022 23:12:23 +0000
+ -- David Robillard <d@drobilla.net> Mon, 19 Dec 2022 20:54:56 +0000
serd (0.32.0) stable; urgency=medium
diff --git a/doc/conf.py.in b/doc/conf.py.in
index 2ae43555..b72d0882 100644
--- a/doc/conf.py.in
+++ b/doc/conf.py.in
@@ -39,6 +39,7 @@ _opaque = [
"SerdStatementImpl",
"SerdWorldImpl",
"SerdWriterImpl",
+ "ZixStringView",
"int16_t",
"int32_t",
"int64_t",
diff --git a/include/serd/env.h b/include/serd/env.h
index 553905f7..fdcc2190 100644
--- a/include/serd/env.h
+++ b/include/serd/env.h
@@ -9,8 +9,8 @@
#include "serd/node.h"
#include "serd/sink.h"
#include "serd/status.h"
-#include "serd/string_view.h"
#include "zix/attributes.h"
+#include "zix/string_view.h"
#include <stdbool.h>
@@ -27,7 +27,7 @@ typedef struct SerdEnvImpl SerdEnv;
/// Create a new environment
SERD_API SerdEnv* ZIX_ALLOCATED
-serd_env_new(SerdAllocator* ZIX_NULLABLE allocator, SerdStringView base_uri);
+serd_env_new(SerdAllocator* ZIX_NULLABLE allocator, ZixStringView base_uri);
/// Copy an environment
SERD_API SerdEnv* ZIX_ALLOCATED
@@ -48,7 +48,7 @@ serd_env_base_uri(const SerdEnv* ZIX_NULLABLE env);
/// Set the current base URI
SERD_API SerdStatus
-serd_env_set_base_uri(SerdEnv* ZIX_NONNULL env, SerdStringView uri);
+serd_env_set_base_uri(SerdEnv* ZIX_NONNULL env, ZixStringView uri);
/**
Set the current base URI to a filesystem path.
@@ -58,7 +58,7 @@ serd_env_set_base_uri(SerdEnv* ZIX_NONNULL env, SerdStringView uri);
actually exist.
*/
SERD_API SerdStatus
-serd_env_set_base_path(SerdEnv* ZIX_NONNULL env, SerdStringView path);
+serd_env_set_base_path(SerdEnv* ZIX_NONNULL env, ZixStringView path);
/**
Set a namespace prefix.
@@ -69,8 +69,8 @@ serd_env_set_base_path(SerdEnv* ZIX_NONNULL env, SerdStringView path);
*/
SERD_API SerdStatus
serd_env_set_prefix(SerdEnv* ZIX_NONNULL env,
- SerdStringView name,
- SerdStringView uri);
+ ZixStringView name,
+ ZixStringView uri);
/**
Qualify `uri` into a prefix and suffix (like a CURIE) if possible.
@@ -90,9 +90,9 @@ serd_env_set_prefix(SerdEnv* ZIX_NONNULL env,
*/
SERD_API SerdStatus
serd_env_qualify(const SerdEnv* ZIX_NULLABLE env,
- SerdStringView uri,
- SerdStringView* ZIX_NONNULL prefix,
- SerdStringView* ZIX_NONNULL suffix);
+ ZixStringView uri,
+ ZixStringView* ZIX_NONNULL prefix,
+ ZixStringView* ZIX_NONNULL suffix);
/**
Expand `curie` to an absolute URI if possible.
@@ -104,7 +104,7 @@ serd_env_qualify(const SerdEnv* ZIX_NULLABLE env,
Returns null if `node` can not be expanded.
*/
SERD_API SerdNode* ZIX_ALLOCATED
-serd_env_expand_curie(const SerdEnv* ZIX_NULLABLE env, SerdStringView curie);
+serd_env_expand_curie(const SerdEnv* ZIX_NULLABLE env, ZixStringView curie);
/**
Expand `node` to an absolute URI if possible.
diff --git a/include/serd/log.h b/include/serd/log.h
index a9261131..b0c43d61 100644
--- a/include/serd/log.h
+++ b/include/serd/log.h
@@ -7,9 +7,9 @@
#include "serd/attributes.h"
#include "serd/caret.h"
#include "serd/status.h"
-#include "serd/string_view.h"
#include "serd/world.h"
#include "zix/attributes.h"
+#include "zix/string_view.h"
#include <stdarg.h>
#include <stddef.h>
@@ -70,7 +70,7 @@ typedef SerdStatus (*SerdLogFunc)(void* ZIX_NULLABLE handle,
SerdLogLevel level,
size_t n_fields,
const SerdLogField* ZIX_NULLABLE fields,
- SerdStringView message);
+ ZixStringView message);
/// A #SerdLogFunc that does nothing (for suppressing log output)
SERD_CONST_API SerdStatus
@@ -78,7 +78,7 @@ serd_quiet_log_func(void* ZIX_NULLABLE handle,
SerdLogLevel level,
size_t n_fields,
const SerdLogField* ZIX_NULLABLE fields,
- SerdStringView message);
+ ZixStringView message);
/**
Set a function to be called with log messages (typically errors).
diff --git a/include/serd/node.h b/include/serd/node.h
index 8dbdbde4..31caad88 100644
--- a/include/serd/node.h
+++ b/include/serd/node.h
@@ -6,11 +6,11 @@
#include "serd/attributes.h"
#include "serd/memory.h"
-#include "serd/string_view.h"
#include "serd/uri.h"
#include "serd/value.h"
#include "serd/write_result.h"
#include "zix/attributes.h"
+#include "zix/string_view.h"
#include <stdbool.h>
#include <stddef.h>
@@ -140,8 +140,8 @@ typedef enum {
/// The data for #SERD_NODE_ARGS_TOKEN
typedef struct {
- SerdNodeType type;
- SerdStringView string;
+ SerdNodeType type;
+ ZixStringView string;
} SerdNodeTokenArgs;
/// The data for #SERD_NODE_ARGS_PARSED_URI
@@ -151,15 +151,15 @@ typedef struct {
/// The data for #SERD_NODE_ARGS_FILE_URI
typedef struct {
- SerdStringView path;
- SerdStringView hostname;
+ ZixStringView path;
+ ZixStringView hostname;
} SerdNodeFileURIArgs;
/// The data for #SERD_NODE_ARGS_LITERAL
typedef struct {
- SerdStringView string;
- SerdNodeFlags flags;
- SerdStringView meta;
+ ZixStringView string;
+ SerdNodeFlags flags;
+ ZixStringView meta;
} SerdNodeLiteralArgs;
/// The data for #SERD_NODE_ARGS_PRIMITIVE
@@ -215,7 +215,7 @@ typedef struct {
#SERD_IS_LONG flag.
*/
SERD_CONST_API SerdNodeArgs
-serd_a_token(SerdNodeType type, SerdStringView string);
+serd_a_token(SerdNodeType type, ZixStringView string);
/// A URI node from a parsed URI
SERD_CONST_API SerdNodeArgs
@@ -223,7 +223,7 @@ serd_a_parsed_uri(SerdURIView uri);
/// A file URI node from a path and optional hostname
SERD_CONST_API SerdNodeArgs
-serd_a_file_uri(SerdStringView path, SerdStringView hostname);
+serd_a_file_uri(ZixStringView path, ZixStringView hostname);
/**
A literal node with an optional datatype or language.
@@ -244,11 +244,11 @@ serd_a_file_uri(SerdStringView path, SerdStringView hostname);
Otherwise, it is ignored.
*/
SERD_CONST_API SerdNodeArgs
-serd_a_literal(SerdStringView string, SerdNodeFlags flags, SerdStringView meta);
+serd_a_literal(ZixStringView string, SerdNodeFlags flags, ZixStringView meta);
/// A simple string literal node from a string view
ZIX_CONST_FUNC static inline SerdNodeArgs
-serd_a_string_view(SerdStringView string)
+serd_a_string_view(ZixStringView string)
{
return serd_a_token(SERD_LITERAL, string);
}
@@ -257,12 +257,12 @@ serd_a_string_view(SerdStringView string)
ZIX_CONST_FUNC static inline SerdNodeArgs
serd_a_string(const char* ZIX_NONNULL string)
{
- return serd_a_string_view(serd_string(string));
+ return serd_a_string_view(zix_string(string));
}
/// A blank node from a string view
ZIX_CONST_FUNC static inline SerdNodeArgs
-serd_a_blank(SerdStringView name)
+serd_a_blank(ZixStringView name)
{
return serd_a_token(SERD_BLANK, name);
}
@@ -271,12 +271,12 @@ serd_a_blank(SerdStringView name)
ZIX_CONST_FUNC static inline SerdNodeArgs
serd_a_blank_string(const char* ZIX_NONNULL name)
{
- return serd_a_blank(serd_string(name));
+ return serd_a_blank(zix_string(name));
}
/// A URI node from a string view
ZIX_CONST_FUNC static inline SerdNodeArgs
-serd_a_uri(SerdStringView uri)
+serd_a_uri(ZixStringView uri)
{
return serd_a_token(SERD_URI, uri);
}
@@ -289,7 +289,7 @@ serd_a_uri(SerdStringView uri)
ZIX_CONST_FUNC static inline SerdNodeArgs
serd_a_uri_string(const char* ZIX_NONNULL uri)
{
- return serd_a_uri(serd_string(uri));
+ return serd_a_uri(zix_string(uri));
}
/**
@@ -299,7 +299,7 @@ serd_a_uri_string(const char* ZIX_NONNULL uri)
@param datatype The absolute URI of the datatype.
*/
ZIX_CONST_FUNC static inline SerdNodeArgs
-serd_a_typed_literal(const SerdStringView string, const SerdStringView datatype)
+serd_a_typed_literal(const ZixStringView string, const ZixStringView datatype)
{
return serd_a_literal(string, SERD_HAS_DATATYPE, datatype);
}
@@ -311,7 +311,7 @@ serd_a_typed_literal(const SerdStringView string, const SerdStringView datatype)
@param language A language tag like "en-ca".
*/
ZIX_CONST_FUNC static inline SerdNodeArgs
-serd_a_plain_literal(const SerdStringView string, const SerdStringView language)
+serd_a_plain_literal(const ZixStringView string, const ZixStringView language)
{
return serd_a_literal(string, SERD_HAS_LANGUAGE, language);
}
@@ -475,7 +475,7 @@ serd_node_string(const SerdNode* ZIX_NONNULL node);
This is a convenience wrapper for serd_node_string() and serd_node_length()
that can be used to get both in a single call.
*/
-SERD_PURE_API SerdStringView
+SERD_PURE_API ZixStringView
serd_node_string_view(const SerdNode* ZIX_NONNULL node);
/**
diff --git a/include/serd/serd.h b/include/serd/serd.h
index 5d208d97..2814ed00 100644
--- a/include/serd/serd.h
+++ b/include/serd/serd.h
@@ -47,7 +47,6 @@
*/
#include "serd/string.h"
-#include "serd/string_view.h"
#include "serd/syntax.h"
#include "serd/write_result.h"
diff --git a/include/serd/string_view.h b/include/serd/string_view.h
deleted file mode 100644
index 6b8e078c..00000000
--- a/include/serd/string_view.h
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright 2011-2021 David Robillard <d@drobilla.net>
-// SPDX-License-Identifier: ISC
-
-#ifndef SERD_STRING_VIEW_H
-#define SERD_STRING_VIEW_H
-
-#include "serd/attributes.h"
-#include "zix/attributes.h"
-
-#include <stddef.h>
-#include <string.h>
-
-SERD_BEGIN_DECLS
-
-/**
- @defgroup serd_string_view String View
- @ingroup serd_utilities
- @{
-*/
-
-/**
- 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* ZIX_NONNULL data; ///< Start of string
- size_t length; ///< Length of string in bytes
-} SerdStringView;
-
-/// Return a view of an empty string
-ZIX_ALWAYS_INLINE_FUNC ZIX_CONST_FUNC static inline SerdStringView
-serd_empty_string(void)
-{
- const SerdStringView view = {"", 0U};
- return view;
-}
-
-/**
- Return a view of a substring, or a premeasured string.
-
- This makes either a view of a slice of a string (which may not be null
- terminated), or a view of a string that has already been measured. This is
- faster than serd_string() for dynamic strings since it does not call
- `strlen`, so should be used when the length of the string is already known.
-
- @param str Pointer to the start of the substring.
-
- @param len Length of the substring in bytes, not including the trailing null
- terminator if present.
-*/
-ZIX_ALWAYS_INLINE_FUNC ZIX_CONST_FUNC static inline SerdStringView
-serd_substring(const char* const ZIX_NONNULL str, const size_t len)
-{
- const SerdStringView view = {str, len};
- return view;
-}
-
-/**
- Return a view of an entire string by measuring it.
-
- This makes a view of the given string by measuring it with `strlen`.
-
- @param str Pointer to the start of a null-terminated C string, or null.
-*/
-ZIX_ALWAYS_INLINE_FUNC ZIX_PURE_FUNC static inline SerdStringView
-// NOLINTNEXTLINE(clang-diagnostic-unused-function)
-serd_string(const char* const ZIX_NULLABLE str)
-{
- return str ? serd_substring(str, strlen(str)) : serd_empty_string();
-}
-
-/**
- @}
-*/
-
-SERD_END_DECLS
-
-#endif // SERD_STRING_VIEW_H
diff --git a/include/serd/uri.h b/include/serd/uri.h
index c978782f..efdf68aa 100644
--- a/include/serd/uri.h
+++ b/include/serd/uri.h
@@ -7,8 +7,8 @@
#include "serd/attributes.h"
#include "serd/memory.h"
#include "serd/stream.h"
-#include "serd/string_view.h"
#include "zix/attributes.h"
+#include "zix/string_view.h"
#include <stdbool.h>
#include <stddef.h>
@@ -40,12 +40,12 @@ SERD_BEGIN_DECLS
number of up-references ("../") that must be prepended to the path.
*/
typedef struct {
- SerdStringView scheme; ///< Scheme
- SerdStringView authority; ///< Authority
- SerdStringView path_prefix; ///< Path prefix for relative/resolved paths
- SerdStringView path; ///< Path suffix
- SerdStringView query; ///< Query
- SerdStringView fragment; ///< Fragment
+ ZixStringView scheme; ///< Scheme
+ ZixStringView authority; ///< Authority
+ ZixStringView path_prefix; ///< Path prefix for relative/resolved paths
+ ZixStringView path; ///< Path suffix
+ ZixStringView query; ///< Query
+ ZixStringView fragment; ///< Fragment
} SerdURIView;
static const SerdURIView SERD_URI_NULL =
@@ -173,8 +173,8 @@ serd_write_uri(SerdURIView uri,
terminator, which is not written)
*/
SERD_API size_t
-serd_write_file_uri(SerdStringView path,
- SerdStringView hostname,
+serd_write_file_uri(ZixStringView path,
+ ZixStringView hostname,
SerdWriteFunc ZIX_NONNULL sink,
void* ZIX_NONNULL stream);
diff --git a/include/serd/writer.h b/include/serd/writer.h
index 73f6fb0b..bf54c46c 100644
--- a/include/serd/writer.h
+++ b/include/serd/writer.h
@@ -9,10 +9,10 @@
#include "serd/output_stream.h"
#include "serd/sink.h"
#include "serd/status.h"
-#include "serd/string_view.h"
#include "serd/syntax.h"
#include "serd/world.h"
#include "zix/attributes.h"
+#include "zix/string_view.h"
#include <stddef.h>
#include <stdint.h>
@@ -129,7 +129,7 @@ serd_writer_sink(SerdWriter* ZIX_NONNULL writer);
it defaults to the base URI, so no up-references will be created at all.
*/
SERD_API SerdStatus
-serd_writer_set_root_uri(SerdWriter* ZIX_NONNULL writer, SerdStringView uri);
+serd_writer_set_root_uri(SerdWriter* ZIX_NONNULL writer, ZixStringView uri);
/**
Finish a write.
diff --git a/meson.build b/meson.build
index 37330570..fe582fd5 100644
--- a/meson.build
+++ b/meson.build
@@ -152,7 +152,6 @@ c_headers = files(
'include/serd/status.h',
'include/serd/stream.h',
'include/serd/string.h',
- 'include/serd/string_view.h',
'include/serd/syntax.h',
'include/serd/uri.h',
'include/serd/value.h',
@@ -228,6 +227,7 @@ libserd = library(
# Declare dependency for internal meson dependants
serd_dep = declare_dependency(
compile_args: extra_c_args,
+ dependencies: [zix_dep],
include_directories: include_dirs,
link_with: libserd,
)
@@ -239,6 +239,7 @@ pkg.generate(
extra_cflags: extra_c_args,
filebase: versioned_name,
name: get_option('title'),
+ requires: ['zix-0'],
subdirs: [versioned_name],
version: meson.project_version(),
)
diff --git a/src/canon.c b/src/canon.c
index c0ce8ef4..2ef28e07 100644
--- a/src/canon.c
+++ b/src/canon.c
@@ -18,9 +18,9 @@
#include "serd/sink.h"
#include "serd/statement.h"
#include "serd/status.h"
-#include "serd/string_view.h"
#include "serd/world.h"
#include "zix/attributes.h"
+#include "zix/string_view.h"
#include <assert.h>
#include <stdbool.h>
@@ -113,11 +113,10 @@ build_tagged(SerdAllocator* const ZIX_NONNULL allocator,
}
// Make a new literal that is otherwise identical
- *out =
- serd_node_new(allocator,
- serd_a_literal(serd_node_string_view(node),
- serd_node_flags(node),
- serd_substring(canonical_lang, lang_len)));
+ *out = serd_node_new(allocator,
+ serd_a_literal(serd_node_string_view(node),
+ serd_node_flags(node),
+ zix_substring(canonical_lang, lang_len)));
const ExessResult r = {EXESS_SUCCESS, node_len};
return r;
diff --git a/src/env.c b/src/env.c
index e90b68a4..d17910f9 100644
--- a/src/env.c
+++ b/src/env.c
@@ -13,6 +13,7 @@
#include "zix/allocator.h"
#include "zix/attributes.h"
#include "zix/filesystem.h"
+#include "zix/string_view.h"
#include <assert.h>
#include <stdbool.h>
@@ -33,7 +34,7 @@ struct SerdEnvImpl {
};
SerdEnv*
-serd_env_new(SerdAllocator* const allocator, const SerdStringView base_uri)
+serd_env_new(SerdAllocator* const allocator, const ZixStringView base_uri)
{
SerdEnv* env =
(SerdEnv*)serd_acalloc(allocator, 1, sizeof(struct SerdEnvImpl));
@@ -138,7 +139,7 @@ serd_env_base_uri(const SerdEnv* const env)
}
SerdStatus
-serd_env_set_base_uri(SerdEnv* const env, const SerdStringView uri)
+serd_env_set_base_uri(SerdEnv* const env, const ZixStringView uri)
{
assert(env);
@@ -168,12 +169,12 @@ serd_env_set_base_uri(SerdEnv* const env, const SerdStringView uri)
}
SerdStatus
-serd_env_set_base_path(SerdEnv* const env, const SerdStringView path)
+serd_env_set_base_path(SerdEnv* const env, const ZixStringView path)
{
assert(env);
if (!path.data || !path.length) {
- return serd_env_set_base_uri(env, serd_empty_string());
+ return serd_env_set_base_uri(env, zix_empty_string());
}
char* const real_path = zix_canonical_path(NULL, path.data);
@@ -192,12 +193,12 @@ serd_env_set_base_path(SerdEnv* const env, const SerdStringView path)
base_path[real_path_len] = path_last;
base_node = serd_node_new(
- NULL, serd_a_file_uri(serd_string(base_path), serd_empty_string()));
+ NULL, serd_a_file_uri(zix_string(base_path), zix_empty_string()));
serd_afree(env->allocator, base_path);
} else {
base_node = serd_node_new(
- NULL, serd_a_file_uri(serd_string(real_path), serd_empty_string()));
+ NULL, serd_a_file_uri(zix_string(real_path), zix_empty_string()));
}
serd_env_set_base_uri(env, serd_node_string_view(base_node));
@@ -207,8 +208,8 @@ serd_env_set_base_path(SerdEnv* const env, const SerdStringView path)
return SERD_SUCCESS;
}
-SerdStringView
-serd_env_find_prefix(const SerdEnv* const env, const SerdStringView name)
+ZixStringView
+serd_env_find_prefix(const SerdEnv* const env, const ZixStringView name)
{
for (size_t i = 0; i < env->n_prefixes; ++i) {
const SerdNode* const prefix_name = env->prefixes[i].name;
@@ -219,7 +220,7 @@ serd_env_find_prefix(const SerdEnv* const env, const SerdStringView name)
}
}
- return serd_empty_string();
+ return zix_empty_string();
}
ZIX_PURE_FUNC static SerdPrefix*
@@ -240,7 +241,7 @@ serd_env_find(const SerdEnv* const env,
static SerdStatus
serd_env_add(SerdEnv* const env,
- const SerdStringView name,
+ const ZixStringView name,
const SerdNode* const uri)
{
SerdPrefix* const prefix = serd_env_find(env, name.data, name.length);
@@ -276,9 +277,9 @@ serd_env_add(SerdEnv* const env,
}
SerdStatus
-serd_env_set_prefix(SerdEnv* const env,
- const SerdStringView name,
- const SerdStringView uri)
+serd_env_set_prefix(SerdEnv* const env,
+ const ZixStringView name,
+ const ZixStringView uri)
{
assert(env);
@@ -316,10 +317,10 @@ serd_env_set_prefix(SerdEnv* const env,
}
SerdStatus
-serd_env_qualify(const SerdEnv* const env,
- const SerdStringView uri,
- SerdStringView* const prefix,
- SerdStringView* const suffix)
+serd_env_qualify(const SerdEnv* const env,
+ const ZixStringView uri,
+ ZixStringView* const prefix,
+ ZixStringView* const suffix)
{
for (size_t i = 0; i < env->n_prefixes; ++i) {
const SerdNode* const prefix_uri = env->prefixes[i].uri;
@@ -341,10 +342,10 @@ serd_env_qualify(const SerdEnv* const env,
}
SerdStatus
-serd_env_expand_in_place(const SerdEnv* const env,
- const SerdStringView curie,
- SerdStringView* const uri_prefix,
- SerdStringView* const uri_suffix)
+serd_env_expand_in_place(const SerdEnv* const env,
+ const ZixStringView curie,
+ ZixStringView* const uri_prefix,
+ ZixStringView* const uri_suffix)
{
const char* const str = curie.data;
const char* const colon =
@@ -367,15 +368,15 @@ serd_env_expand_in_place(const SerdEnv* const env,
}
SerdNode*
-serd_env_expand_curie(const SerdEnv* const env, const SerdStringView curie)
+serd_env_expand_curie(const SerdEnv* const env, const ZixStringView curie)
{
if (!env) {
return NULL;
}
- SerdStringView prefix = serd_empty_string();
- SerdStringView suffix = serd_empty_string();
- SerdStatus st = serd_env_expand_in_place(env, curie, &prefix, &suffix);
+ ZixStringView prefix = zix_empty_string();
+ ZixStringView suffix = zix_empty_string();
+ SerdStatus st = serd_env_expand_in_place(env, curie, &prefix, &suffix);
if (st || !prefix.data || !suffix.data) {
return NULL;
}
diff --git a/src/env.h b/src/env.h
index 64a0abc1..54ae84e1 100644
--- a/src/env.h
+++ b/src/env.h
@@ -6,17 +6,17 @@
#include "serd/env.h"
#include "serd/status.h"
-#include "serd/string_view.h"
#include "serd/uri.h"
#include "zix/attributes.h"
+#include "zix/string_view.h"
/**
Return the URI for the prefix with the given name.
If no such prefix is known, returns an empty string view.
*/
-ZIX_PURE_FUNC SerdStringView
-serd_env_find_prefix(const SerdEnv* env, SerdStringView name);
+ZIX_PURE_FUNC ZixStringView
+serd_env_find_prefix(const SerdEnv* env, ZixStringView name);
/**
Expand `curie`.
@@ -25,10 +25,10 @@ serd_env_find_prefix(const SerdEnv* env, SerdStringView name);
not defined in `env`.
*/
SerdStatus
-serd_env_expand_in_place(const SerdEnv* env,
- SerdStringView curie,
- SerdStringView* uri_prefix,
- SerdStringView* uri_suffix);
+serd_env_expand_in_place(const SerdEnv* env,
+ ZixStringView curie,
+ ZixStringView* uri_prefix,
+ ZixStringView* uri_suffix);
ZIX_PURE_FUNC SerdURIView
serd_env_base_uri_view(const SerdEnv* env);
diff --git a/src/log.c b/src/log.c
index 6ba885c6..a13bfd9a 100644
--- a/src/log.c
+++ b/src/log.c
@@ -10,9 +10,9 @@
#include "serd/log.h"
#include "serd/node.h"
#include "serd/status.h"
-#include "serd/string_view.h"
#include "serd/world.h"
#include "zix/attributes.h"
+#include "zix/string_view.h"
#if USE_ISATTY
# include <unistd.h>
@@ -120,7 +120,7 @@ serd_quiet_log_func(void* const handle,
const SerdLogLevel level,
const size_t n_fields,
const SerdLogField* const fields,
- const SerdStringView message)
+ const ZixStringView message)
{
(void)handle;
(void)level;
@@ -219,7 +219,7 @@ serd_vxlogf(const SerdWorld* const world,
level,
n_fields,
fields,
- serd_substring(message, (size_t)r));
+ zix_substring(message, (size_t)r));
}
return serd_default_vxlogf(
diff --git a/src/node.c b/src/node.c
index b4cd14fa..f38cdb78 100644
--- a/src/node.c
+++ b/src/node.c
@@ -10,11 +10,11 @@
#include "exess/exess.h"
#include "serd/node.h"
#include "serd/status.h"
-#include "serd/string_view.h"
#include "serd/uri.h"
#include "serd/value.h"
#include "serd/write_result.h"
#include "zix/attributes.h"
+#include "zix/string_view.h"
#include <assert.h>
#include <stdbool.h>
@@ -49,7 +49,7 @@ static const ExessDatatype value_type_datatypes[] = {
// Argument constructors
SerdNodeArgs
-serd_a_token(const SerdNodeType type, const SerdStringView string)
+serd_a_token(const SerdNodeType type, const ZixStringView string)
{
const SerdNodeArgs args = {SERD_NODE_ARGS_TOKEN, {{type, string}}};
return args;
@@ -65,7 +65,7 @@ serd_a_parsed_uri(const SerdURIView uri)
}
SerdNodeArgs
-serd_a_file_uri(const SerdStringView path, const SerdStringView hostname)
+serd_a_file_uri(const ZixStringView path, const ZixStringView hostname)
{
SerdNodeArgs args;
args.type = SERD_NODE_ARGS_FILE_URI;
@@ -75,9 +75,9 @@ serd_a_file_uri(const SerdStringView path, const SerdStringView hostname)
}
SerdNodeArgs
-serd_a_literal(const SerdStringView string,
- const SerdNodeFlags flags,
- const SerdStringView meta)
+serd_a_literal(const ZixStringView string,
+ const SerdNodeFlags flags,
+ const ZixStringView meta)
{
SerdNodeArgs args;
args.type = SERD_NODE_ARGS_LITERAL;
@@ -247,14 +247,15 @@ result(const SerdStatus status, const size_t count)
}
static SerdWriteResult
-serd_node_construct_simple(const size_t buf_size,
- void* const buf,
- const SerdNodeType type,
- const SerdNodeFlags flags,
- const SerdStringView string)
+serd_node_construct_simple(const size_t buf_size,
+ void* const buf,
+ const SerdNodeType type,
+ const SerdNodeFlags flags,
+ const ZixStringView string)
{
const size_t total_size =
sizeof(SerdNode) + serd_node_pad_length(string.length);
+
if (!buf || total_size > buf_size) {
return result(SERD_OVERFLOW, total_size);
}
@@ -274,7 +275,7 @@ serd_node_construct_simple(const size_t buf_size,
}
ZIX_PURE_FUNC static bool
-is_langtag(const SerdStringView string)
+is_langtag(const ZixStringView string)
{
// First character must be a letter
size_t i = 0;
@@ -303,11 +304,11 @@ is_langtag(const SerdStringView string)
}
static SerdWriteResult
-serd_node_construct_literal(const size_t buf_size,
- void* const buf,
- const SerdStringView string,
- const SerdNodeFlags flags,
- const SerdStringView meta)
+serd_node_construct_literal(const size_t buf_size,
+ void* const buf,
+ const ZixStringView string,
+ const SerdNodeFlags flags,
+ const ZixStringView meta)
{
if (!(flags & (SERD_HAS_DATATYPE | SERD_HAS_LANGUAGE))) {
return serd_node_construct_simple(
@@ -469,9 +470,9 @@ serd_node_construct_value(const size_t buf_size,
return serd_node_construct_literal(buf_size,
buf,
- serd_substring(temp, r.count),
+ zix_substring(temp, r.count),
SERD_HAS_DATATYPE,
- serd_string(datatype_uri));
+ zix_string(datatype_uri));
}
static SerdWriteResult
@@ -486,9 +487,9 @@ serd_node_construct_decimal(const size_t buf_size,
return serd_node_construct_literal(buf_size,
buf,
- serd_substring(temp, r.count),
+ zix_substring(temp, r.count),
SERD_HAS_DATATYPE,
- serd_string(EXESS_XSD_URI "decimal"));
+ zix_string(EXESS_XSD_URI "decimal"));
}
static SerdWriteResult
@@ -502,18 +503,18 @@ serd_node_construct_integer(const size_t buf_size,
return serd_node_construct_literal(buf_size,
buf,
- serd_substring(temp, r.count),
+ zix_substring(temp, r.count),
SERD_HAS_DATATYPE,
- serd_string(NS_XSD "integer"));
+ zix_string(NS_XSD "integer"));
}
static SerdWriteResult
serd_node_construct_binary(
- const size_t buf_size,
- void* const buf,
- const size_t value_size,
- const void* const value,
- const SerdStringView datatype_uri,
+ const size_t buf_size,
+ void* const buf,
+ const size_t value_size,
+ const void* const value,
+ const ZixStringView datatype_uri,
ExessResult (*write_func)(size_t, const void*, size_t, char*))
{
// Verify argument sanity
@@ -825,10 +826,10 @@ construct_write(const void* const buf,
}
static SerdWriteResult
-serd_node_construct_file_uri(const size_t buf_size,
- void* const buf,
- const SerdStringView path,
- const SerdStringView hostname)
+serd_node_construct_file_uri(const size_t buf_size,
+ void* const buf,
+ const ZixStringView path,
+ const ZixStringView hostname)
{
SerdNode* const node = (SerdNode*)buf;
ConstructWriteHead head = {(char*)buf, buf_size, 0U};
@@ -902,7 +903,7 @@ serd_node_construct(const size_t buf_size,
buf,
args.data.as_blob.size,
args.data.as_blob.data,
- serd_string(NS_XSD "hexBinary"),
+ zix_string(NS_XSD "hexBinary"),
exess_write_hex);
case SERD_NODE_ARGS_BASE64:
@@ -910,7 +911,7 @@ serd_node_construct(const size_t buf_size,
buf,
args.data.as_blob.size,
args.data.as_blob.data,
- serd_string(NS_XSD "base64Binary"),
+ zix_string(NS_XSD "base64Binary"),
exess_write_base64);
}
@@ -941,12 +942,12 @@ serd_node_length(const SerdNode* const node)
return node->length;
}
-SerdStringView
+ZixStringView
serd_node_string_view(const SerdNode* const node)
{
assert(node);
- const SerdStringView r = {(const char*)(node + 1), node->length};
+ const ZixStringView r = {(const char*)(node + 1), node->length};
return r;
}
diff --git a/src/node_spec.h b/src/node_spec.h
index 97243bf6..2daee100 100644
--- a/src/node_spec.h
+++ b/src/node_spec.h
@@ -5,7 +5,7 @@
#define SERD_SRC_NODE_SPEC_H
#include "serd/node.h"
-#include "serd/string_view.h"
+#include "zix/string_view.h"
/**
A lightweight "specification" of a node.
@@ -16,23 +16,23 @@
allocate one.
*/
typedef struct {
- SerdNodeType type; ///< Basic type of this node
- SerdStringView string; ///< String contents of this node
- SerdNodeFlags flags; ///< Additional node flags
- SerdStringView meta; ///< String contents of datatype or language node
+ SerdNodeType type; ///< Basic type of this node
+ ZixStringView string; ///< String contents of this node
+ SerdNodeFlags flags; ///< Additional node flags
+ ZixStringView meta; ///< String contents of datatype or language node
} NodeSpec;
static inline NodeSpec
-token_spec(const SerdNodeType type, const SerdStringView string)
+token_spec(const SerdNodeType type, const ZixStringView string)
{
- NodeSpec spec = {type, string, 0U, serd_empty_string()};
+ NodeSpec spec = {type, string, 0U, zix_empty_string()};
return spec;
}
static inline NodeSpec
-literal_spec(const SerdStringView string,
- const SerdNodeFlags flags,
- const SerdStringView meta)
+literal_spec(const ZixStringView string,
+ const SerdNodeFlags flags,
+ const ZixStringView meta)
{
NodeSpec spec = {SERD_LITERAL, string, flags, meta};
return spec;
diff --git a/src/node_syntax.c b/src/node_syntax.c
index b40bc0dc..a66c6e22 100644
--- a/src/node_syntax.c
+++ b/src/node_syntax.c
@@ -16,10 +16,10 @@
#include "serd/sink.h"
#include "serd/statement.h"
#include "serd/status.h"
-#include "serd/string_view.h"
#include "serd/syntax.h"
#include "serd/world.h"
#include "serd/writer.h"
+#include "zix/string_view.h"
#include <assert.h>
#include <stdio.h>
@@ -112,7 +112,7 @@ serd_node_from_syntax(SerdAllocator* const allocator,
if (env) {
node = serd_node_from_syntax_in(temp_world, str, syntax, env);
} else {
- SerdEnv* const temp_env = serd_env_new(allocator, serd_empty_string());
+ SerdEnv* const temp_env = serd_env_new(allocator, zix_empty_string());
if (temp_env) {
node = serd_node_from_syntax_in(temp_world, str, syntax, temp_env);
}
@@ -177,7 +177,7 @@ serd_node_to_syntax(SerdAllocator* const allocator,
if (env) {
string = serd_node_to_syntax_in(temp_world, node, syntax, env);
} else {
- SerdEnv* const temp_env = serd_env_new(allocator, serd_empty_string());
+ SerdEnv* const temp_env = serd_env_new(allocator, zix_empty_string());
if (temp_env) {
string = serd_node_to_syntax_in(temp_world, node, syntax, temp_env);
}
diff --git a/src/nodes.c b/src/nodes.c
index 68d9cf3c..22ee3146 100644
--- a/src/nodes.c
+++ b/src/nodes.c
@@ -14,12 +14,12 @@
#include "serd/memory.h"
#include "serd/nodes.h"
-#include "serd/string_view.h"
#include "serd/write_result.h"
#include "zix/allocator.h"
#include "zix/attributes.h"
#include "zix/digest.h"
#include "zix/hash.h"
+#include "zix/string_view.h"
#include <assert.h>
#include <stdbool.h>
@@ -137,9 +137,9 @@ nodes_key(const NodesEntry* const entry)
}
static ZixHashCode
-token_hash(const ZixHashCode seed,
- const SerdNodeType type,
- const SerdStringView string)
+token_hash(const ZixHashCode seed,
+ const SerdNodeType type,
+ const ZixStringView string)
{
const SerdNode node_header = {string.length, 0U, type};
ZixHashCode h = seed;
@@ -378,9 +378,9 @@ serd_nodes_manage_entry_node(SerdNodes* const nodes, SerdNode* const node)
}
static const SerdNode*
-serd_nodes_token(SerdNodes* const nodes,
- const SerdNodeType type,
- const SerdStringView string)
+serd_nodes_token(SerdNodes* const nodes,
+ const SerdNodeType type,
+ const ZixStringView string)
{
// Calculate a hash code for the token without actually constructing it
const NodeSpec key = token_spec(type, string);
@@ -406,10 +406,10 @@ serd_nodes_token(SerdNodes* const nodes,
}
static const SerdNode*
-serd_nodes_literal(SerdNodes* const nodes,
- const SerdStringView string,
- const SerdNodeFlags flags,
- const SerdStringView meta)
+serd_nodes_literal(SerdNodes* const nodes,
+ const ZixStringView string,
+ const SerdNodeFlags flags,
+ const ZixStringView meta)
{
// Calculate a hash code for the literal without actually constructing it
const NodeSpec spec = literal_spec(string, flags, meta);
diff --git a/src/read_turtle.c b/src/read_turtle.c
index 03d1950f..c6982327 100644
--- a/src/read_turtle.c
+++ b/src/read_turtle.c
@@ -21,9 +21,9 @@
#include "serd/sink.h"
#include "serd/statement.h"
#include "serd/status.h"
-#include "serd/string_view.h"
#include "serd/uri.h"
#include "zix/attributes.h"
+#include "zix/string_view.h"
#include <assert.h>
#include <stdbool.h>
@@ -396,8 +396,8 @@ read_PrefixedName(SerdReader* const reader,
skip_byte(reader, ':');
// Search environment for the prefix URI
- const SerdStringView prefix = serd_node_string_view(dest);
- const SerdStringView prefix_uri = serd_env_find_prefix(reader->env, prefix);
+ const ZixStringView prefix = serd_node_string_view(dest);
+ const ZixStringView prefix_uri = serd_env_find_prefix(reader->env, prefix);
if (!prefix_uri.length) {
return r_err(reader, st, "unknown prefix \"%s\"", prefix.data);
}
@@ -645,7 +645,7 @@ read_anon(SerdReader* const reader,
}
static bool
-node_has_string(const SerdNode* const node, const SerdStringView string)
+node_has_string(const SerdNode* const node, const ZixStringView string)
{
return node->length == string.length &&
!memcmp(serd_node_string(node), string.data, string.length);
@@ -657,10 +657,10 @@ read_named_object(SerdReader* const reader,
SerdNode** const dest,
bool* const ate_dot)
{
- static const char* const XSD_BOOLEAN = NS_XSD "boolean";
- static const size_t XSD_BOOLEAN_LEN = 40;
- static const SerdStringView true_string = {"true", 4U};
- static const SerdStringView false_string = {"false", 5U};
+ static const char* const XSD_BOOLEAN = NS_XSD "boolean";
+ static const size_t XSD_BOOLEAN_LEN = 40;
+ static const ZixStringView true_string = ZIX_STATIC_STRING("true");
+ static const ZixStringView false_string = ZIX_STATIC_STRING("false");
/* This function deals with nodes that start with some letters. Unlike
everything else, the cases here aren't nicely distinguished by leading
diff --git a/src/uri.c b/src/uri.c
index 234bf834..53574600 100644
--- a/src/uri.c
+++ b/src/uri.c
@@ -9,8 +9,8 @@
#include "serd/memory.h"
#include "serd/status.h"
#include "serd/stream.h"
-#include "serd/string_view.h"
#include "serd/uri.h"
+#include "zix/string_view.h"
#include <assert.h>
#include <stdbool.h>
@@ -245,7 +245,7 @@ remove_dot_segments(const char* const path, const size_t len, size_t* const up)
/// Merge `base` and `path` in-place
static void
-merge(SerdStringView* const base, SerdStringView* const path)
+merge(ZixStringView* const base, ZixStringView* const path)
{
size_t up = 0;
const char* begin = remove_dot_segments(path->data, path->length, &up);
@@ -543,10 +543,10 @@ is_dir_sep(const char c)
}
size_t
-serd_write_file_uri(const SerdStringView path,
- const SerdStringView hostname,
- const SerdWriteFunc sink,
- void* const stream)
+serd_write_file_uri(const ZixStringView path,
+ const ZixStringView hostname,
+ const SerdWriteFunc sink,
+ void* const stream)
{
const bool is_windows = is_windows_path(path.data);
size_t len = 0U;
diff --git a/src/uri_utils.h b/src/uri_utils.h
index 76060d6a..63e67d62 100644
--- a/src/uri_utils.h
+++ b/src/uri_utils.h
@@ -7,8 +7,8 @@
#include "string_utils.h"
#include "serd/attributes.h"
-#include "serd/string_view.h"
#include "serd/uri.h"
+#include "zix/string_view.h"
#include <stdbool.h>
#include <string.h>
@@ -19,7 +19,7 @@ typedef struct {
} SlashIndexes;
static inline bool
-slice_equals(const SerdStringView* a, const SerdStringView* b)
+slice_equals(const ZixStringView* a, const ZixStringView* b)
{
return a->length == b->length && !strncmp(a->data, b->data, a->length);
}
diff --git a/src/world.c b/src/world.c
index 37cfe301..b4fe4ebc 100644
--- a/src/world.c
+++ b/src/world.c
@@ -10,8 +10,8 @@
#include "serd/node.h"
#include "serd/status.h"
-#include "serd/string_view.h"
#include "serd/world.h"
+#include "zix/string_view.h"
#include <assert.h>
#include <stdio.h>
@@ -34,13 +34,13 @@ serd_world_new(SerdAllocator* const allocator)
return NULL;
}
- const SerdStringView rdf_first = serd_string(NS_RDF "first");
- const SerdStringView rdf_nil = serd_string(NS_RDF "nil");
- const SerdStringView rdf_rest = serd_string(NS_RDF "rest");
- const SerdStringView rdf_type = serd_string(NS_RDF "type");
- const SerdStringView xsd_boolean = serd_string(NS_XSD "boolean");
- const SerdStringView xsd_decimal = serd_string(NS_XSD "decimal");
- const SerdStringView xsd_integer = serd_string(NS_XSD "integer");
+ static const ZixStringView rdf_first = ZIX_STATIC_STRING(NS_RDF "first");
+ static const ZixStringView rdf_nil = ZIX_STATIC_STRING(NS_RDF "nil");
+ static const ZixStringView rdf_rest = ZIX_STATIC_STRING(NS_RDF "rest");
+ static const ZixStringView rdf_type = ZIX_STATIC_STRING(NS_RDF "type");
+ static const ZixStringView xsd_boolean = ZIX_STATIC_STRING(NS_XSD "boolean");
+ static const ZixStringView xsd_decimal = ZIX_STATIC_STRING(NS_XSD "decimal");
+ static const ZixStringView xsd_integer = ZIX_STATIC_STRING(NS_XSD "integer");
world->limits.reader_stack_size = 1048576U;
world->limits.writer_max_depth = 128U;
diff --git a/src/writer.c b/src/writer.c
index 7b821145..b87df07a 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -25,11 +25,10 @@
#include "serd/sink.h"
#include "serd/statement.h"
#include "serd/status.h"
-#include "serd/string_view.h"
#include "serd/syntax.h"
#include "serd/uri.h"
#include "serd/world.h"
-#include "serd/writer.h"
+#include "zix/string_view.h"
#include <assert.h>
#include <errno.h>
@@ -836,9 +835,9 @@ write_uri_node(SerdWriter* const writer,
const SerdNode* const node,
const SerdField field)
{
- SerdStatus st = SERD_SUCCESS;
- const SerdStringView string = serd_node_string_view(node);
- const bool has_scheme = serd_uri_string_has_scheme(string.data);
+ SerdStatus st = SERD_SUCCESS;
+ const ZixStringView string = serd_node_string_view(node);
+ const bool has_scheme = serd_uri_string_has_scheme(string.data);
if (supports_abbrev(writer)) {
if (!(writer->flags & SERD_WRITE_LONGHAND) && field == SERD_PREDICATE &&
@@ -850,8 +849,8 @@ write_uri_node(SerdWriter* const writer,
return esink("()", 2, writer);
}
- SerdStringView prefix = {NULL, 0};
- SerdStringView suffix = {NULL, 0};
+ ZixStringView prefix = {NULL, 0};
+ ZixStringView suffix = {NULL, 0};
if (has_scheme && !(writer->flags & SERD_WRITE_EXPANDED) &&
!serd_env_qualify(writer->env, string, &prefix, &suffix)) {
TRY(st, write_lname(writer, prefix.data, prefix.length));
@@ -1387,8 +1386,8 @@ serd_writer_set_base_uri(SerdWriter* writer, const SerdNode* uri)
return SERD_BAD_ARG;
}
- const SerdStringView uri_string =
- uri ? serd_node_string_view(uri) : serd_empty_string();
+ const ZixStringView uri_string =
+ uri ? serd_node_string_view(uri) : zix_empty_string();
if (uri && (writer->syntax == SERD_TURTLE || writer->syntax == SERD_TRIG)) {
TRY(st, terminate_context(writer));
@@ -1403,7 +1402,7 @@ serd_writer_set_base_uri(SerdWriter* writer, const SerdNode* uri)
}
SerdStatus
-serd_writer_set_root_uri(SerdWriter* writer, const SerdStringView uri)
+serd_writer_set_root_uri(SerdWriter* writer, const ZixStringView uri)
{
assert(writer);
diff --git a/test/headers/.clang-tidy b/test/headers/.clang-tidy
index 2d823c5a..36e379b5 100644
--- a/test/headers/.clang-tidy
+++ b/test/headers/.clang-tidy
@@ -8,5 +8,5 @@ Checks: >
-modernize-macro-to-enum,
-readability-identifier-length,
WarningsAsErrors: '*'
-HeaderFilterRegex: '.*'
+HeaderFilterRegex: '.*/serd/.*\.h'
FormatStyle: file
diff --git a/test/test_canon.c b/test/test_canon.c
index 89d1312b..ce3cfc67 100644
--- a/test/test_canon.c
+++ b/test/test_canon.c
@@ -11,8 +11,8 @@
#include "serd/nodes.h"
#include "serd/sink.h"
#include "serd/status.h"
-#include "serd/string_view.h"
#include "serd/world.h"
+#include "zix/string_view.h"
#include <assert.h>
#include <stddef.h>
@@ -56,11 +56,13 @@ test_new_failed_alloc(void)
static void
test_write_failed_alloc(void)
{
- const SerdStringView s_string = serd_string("http://example.org/s");
- const SerdStringView p_string = serd_string("http://example.org/p");
- const SerdStringView o_string = serd_string("012.340");
- const SerdStringView xsd_float =
- serd_string("http://www.w3.org/2001/XMLSchema#float");
+#define NS_EG "http://example.org/s"
+#define NS_XSD "http://www.w3.org/2001/XMLSchema#"
+
+ static const ZixStringView s_string = ZIX_STATIC_STRING(NS_EG "s");
+ static const ZixStringView p_string = ZIX_STATIC_STRING(NS_EG "p");
+ static const ZixStringView o_string = ZIX_STATIC_STRING("012.340");
+ static const ZixStringView xsd_float = ZIX_STATIC_STRING(NS_XSD "float");
SerdFailingAllocator allocator = serd_failing_allocator();
SerdWorld* const world = serd_world_new(&allocator.base);
@@ -92,6 +94,9 @@ test_write_failed_alloc(void)
serd_sink_free(target);
serd_nodes_free(nodes);
serd_world_free(world);
+
+#undef NS_XSD
+#undef NS_EG
}
int
diff --git a/test/test_env.c b/test/test_env.c
index 5a4c95df..9539798d 100644
--- a/test/test_env.c
+++ b/test/test_env.c
@@ -11,7 +11,7 @@
#include "serd/nodes.h"
#include "serd/sink.h"
#include "serd/status.h"
-#include "serd/string_view.h"
+#include "zix/string_view.h"
#include <assert.h>
#include <stdio.h>
@@ -25,14 +25,14 @@ test_new_failed_alloc(void)
SerdFailingAllocator allocator = serd_failing_allocator();
// Successfully allocate a env to count the number of allocations
- SerdEnv* const env = serd_env_new(&allocator.base, serd_empty_string());
+ SerdEnv* const env = serd_env_new(&allocator.base, zix_empty_string());
assert(env);
// Test that each allocation failing is handled gracefully
const size_t n_new_allocs = allocator.n_allocations;
for (size_t i = 0; i < n_new_allocs; ++i) {
allocator.n_remaining = i;
- assert(!serd_env_new(&allocator.base, serd_empty_string()));
+ assert(!serd_env_new(&allocator.base, zix_empty_string()));
}
serd_env_free(env);
@@ -47,9 +47,9 @@ test_copy_failed_alloc(void)
SerdFailingAllocator allocator = serd_failing_allocator();
// Create a simple env
- SerdEnv* const env = serd_env_new(&allocator.base, serd_empty_string());
- assert(!serd_env_set_prefix(env, serd_string(name), serd_string(uri)));
- assert(!serd_env_set_base_uri(env, serd_string(uri)));
+ SerdEnv* const env = serd_env_new(&allocator.base, zix_empty_string());
+ assert(!serd_env_set_prefix(env, zix_string(name), zix_string(uri)));
+ assert(!serd_env_set_base_uri(env, zix_string(uri)));
// Successfully copy the env to count the number of allocations
const size_t n_setup_allocs = allocator.n_allocations;
@@ -70,7 +70,8 @@ test_copy_failed_alloc(void)
static void
test_set_prefix_absolute_failed_alloc(void)
{
- const SerdStringView base_uri = serd_string("http://example.org/");
+ static const ZixStringView base_uri =
+ ZIX_STATIC_STRING("http://example.org/");
SerdFailingAllocator allocator = serd_failing_allocator();
@@ -83,7 +84,7 @@ test_set_prefix_absolute_failed_alloc(void)
const size_t n_setup_allocs = allocator.n_allocations;
// Successfully set an absolute prefix to count the number of allocations
- st = serd_env_set_prefix(env, serd_string(name), serd_string(uri));
+ st = serd_env_set_prefix(env, zix_string(name), zix_string(uri));
assert(st == SERD_SUCCESS);
// Test that each allocation failing is handled gracefully
@@ -94,7 +95,7 @@ test_set_prefix_absolute_failed_alloc(void)
snprintf(name, sizeof(name), "eg%zu", i);
snprintf(uri, sizeof(name), "http://example.org/%zu", i);
- st = serd_env_set_prefix(env, serd_string(name), serd_string(uri));
+ st = serd_env_set_prefix(env, zix_string(name), zix_string(uri));
assert(st == SERD_BAD_ALLOC);
}
@@ -104,7 +105,8 @@ test_set_prefix_absolute_failed_alloc(void)
static void
test_set_prefix_relative_failed_alloc(void)
{
- const SerdStringView base_uri = serd_string("http://example.org/");
+ static const ZixStringView base_uri =
+ ZIX_STATIC_STRING("http://example.org/");
SerdFailingAllocator allocator = serd_failing_allocator();
@@ -113,7 +115,7 @@ test_set_prefix_relative_failed_alloc(void)
// Successfully set an absolute prefix to count the number of allocations
SerdEnv* env = serd_env_new(&allocator.base, base_uri);
- SerdStatus st = serd_env_set_prefix(env, serd_string(name), serd_string(uri));
+ SerdStatus st = serd_env_set_prefix(env, zix_string(name), zix_string(uri));
assert(st == SERD_SUCCESS);
serd_env_free(env);
@@ -127,7 +129,7 @@ test_set_prefix_relative_failed_alloc(void)
env = serd_env_new(&allocator.base, base_uri);
if (env) {
- st = serd_env_set_prefix(env, serd_string(name), serd_string(uri));
+ st = serd_env_set_prefix(env, zix_string(name), zix_string(uri));
assert(st == SERD_BAD_ALLOC);
}
@@ -141,22 +143,21 @@ test_copy(void)
assert(!serd_env_copy(NULL, NULL));
SerdEnv* const env =
- serd_env_new(NULL, serd_string("http://example.org/base/"));
+ serd_env_new(NULL, zix_string("http://example.org/base/"));
- serd_env_set_prefix(
- env, serd_string("eg"), serd_string("http://example.org/"));
+ serd_env_set_prefix(env, zix_string("eg"), zix_string("http://example.org/"));
SerdEnv* const env_copy = serd_env_copy(NULL, env);
assert(serd_env_equals(env, env_copy));
serd_env_set_prefix(
- env_copy, serd_string("test"), serd_string("http://example.org/test"));
+ env_copy, zix_string("test"), zix_string("http://example.org/test"));
assert(!serd_env_equals(env, env_copy));
serd_env_set_prefix(
- env, serd_string("test2"), serd_string("http://example.org/test2"));
+ env, zix_string("test2"), zix_string("http://example.org/test2"));
assert(!serd_env_equals(env, env_copy));
@@ -167,7 +168,7 @@ test_copy(void)
static void
test_comparison(void)
{
- SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* const env = serd_env_new(NULL, zix_empty_string());
assert(!serd_env_equals(env, NULL));
assert(!serd_env_equals(NULL, env));
@@ -203,16 +204,16 @@ static void
test_base_uri(void)
{
SerdNodes* const nodes = serd_nodes_new(NULL);
- SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* const env = serd_env_new(NULL, zix_empty_string());
const SerdNode* const eg = serd_nodes_get(nodes, serd_a_uri_string(NS_EG));
// Test that invalid calls work as expected
assert(!serd_env_base_uri(env));
- assert(!serd_env_set_base_uri(env, serd_empty_string()));
+ assert(!serd_env_set_base_uri(env, zix_empty_string()));
assert(!serd_env_base_uri(env));
// Try setting a relative prefix with no base URI
- assert(serd_env_set_prefix(env, serd_string("eg.3"), serd_string("rel")) ==
+ assert(serd_env_set_prefix(env, zix_string("eg.3"), zix_string("rel")) ==
SERD_BAD_ARG);
// Set a valid base URI
@@ -220,7 +221,7 @@ test_base_uri(void)
assert(serd_node_equals(serd_env_base_uri(env), eg));
// Reset the base URI
- assert(!serd_env_set_base_uri(env, serd_empty_string()));
+ assert(!serd_env_set_base_uri(env, zix_empty_string()));
assert(!serd_env_base_uri(env));
serd_env_free(env);
@@ -230,13 +231,13 @@ test_base_uri(void)
static void
test_set_prefix(void)
{
- const SerdStringView eg = serd_string(NS_EG);
- const SerdStringView name1 = serd_string("eg.1");
- const SerdStringView name2 = serd_string("eg.2");
- const SerdStringView rel = serd_string("rel");
- const SerdStringView base = serd_string("http://example.org/");
+ static const ZixStringView eg = ZIX_STATIC_STRING(NS_EG);
+ static const ZixStringView name1 = ZIX_STATIC_STRING("eg.1");
+ static const ZixStringView name2 = ZIX_STATIC_STRING("eg.2");
+ static const ZixStringView rel = ZIX_STATIC_STRING("rel");
+ static const ZixStringView base = ZIX_STATIC_STRING("http://example.org/");
- SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* const env = serd_env_new(NULL, zix_empty_string());
// Set a valid prefix
assert(!serd_env_set_prefix(env, name1, eg));
@@ -248,7 +249,7 @@ test_set_prefix(void)
// Test setting a prefix from strings
assert(!serd_env_set_prefix(
- env, serd_string("eg.3"), serd_string("http://example.org/three")));
+ env, zix_string("eg.3"), zix_string("http://example.org/three")));
size_t n_prefixes = 0;
SerdSink* const count_prefixes_sink =
@@ -266,7 +267,7 @@ test_expand_untyped_literal(void)
{
SerdNodes* const nodes = serd_nodes_new(NULL);
const SerdNode* const untyped = serd_nodes_get(nodes, serd_a_string("data"));
- SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* const env = serd_env_new(NULL, zix_empty_string());
assert(!serd_env_expand_node(env, untyped));
@@ -277,14 +278,14 @@ test_expand_untyped_literal(void)
static void
test_expand_bad_uri_datatype(void)
{
- const SerdStringView type = serd_string("Type");
+ static const ZixStringView type = ZIX_STATIC_STRING("Type");
SerdNodes* const nodes = serd_nodes_new(NULL);
const SerdNode* const typed =
- serd_nodes_get(nodes, serd_a_typed_literal(serd_string("data"), type));
+ serd_nodes_get(nodes, serd_a_typed_literal(zix_string("data"), type));
- SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* const env = serd_env_new(NULL, zix_empty_string());
assert(!serd_env_expand_node(env, typed));
@@ -295,7 +296,7 @@ test_expand_bad_uri_datatype(void)
static void
test_expand_uri(void)
{
- const SerdStringView base = serd_string("http://example.org/b/");
+ static const ZixStringView base = ZIX_STATIC_STRING("http://example.org/b/");
SerdNodes* const nodes = serd_nodes_new(NULL);
SerdEnv* const env = serd_env_new(NULL, base);
@@ -317,7 +318,7 @@ test_expand_uri(void)
static void
test_expand_empty_uri_ref(void)
{
- const SerdStringView base = serd_string("http://example.org/b/");
+ static const ZixStringView base = ZIX_STATIC_STRING("http://example.org/b/");
SerdNodes* const nodes = serd_nodes_new(NULL);
SerdEnv* const env = serd_env_new(NULL, base);
@@ -335,7 +336,7 @@ static void
test_expand_bad_uri(void)
{
SerdNodes* const nodes = serd_nodes_new(NULL);
- SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* const env = serd_env_new(NULL, zix_empty_string());
const SerdNode* const bad_uri =
serd_nodes_get(nodes, serd_a_uri_string("rel"));
@@ -349,15 +350,14 @@ test_expand_bad_uri(void)
static void
test_expand_curie(void)
{
- const SerdStringView name = serd_string("eg.1");
- const SerdStringView eg = serd_string(NS_EG);
+ static const ZixStringView name = ZIX_STATIC_STRING("eg.1");
+ static const ZixStringView eg = ZIX_STATIC_STRING(NS_EG);
- SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* const env = serd_env_new(NULL, zix_empty_string());
assert(!serd_env_set_prefix(env, name, eg));
- SerdNode* const expanded =
- serd_env_expand_curie(env, serd_string("eg.1:foo"));
+ SerdNode* const expanded = serd_env_expand_curie(env, zix_string("eg.1:foo"));
assert(expanded);
assert(!strcmp(serd_node_string(expanded), "http://example.org/foo"));
@@ -369,12 +369,12 @@ test_expand_curie(void)
static void
test_expand_bad_curie(void)
{
- SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* const env = serd_env_new(NULL, zix_empty_string());
- assert(!serd_env_expand_curie(NULL, serd_empty_string()));
- assert(!serd_env_expand_curie(NULL, serd_string("what:ever")));
- assert(!serd_env_expand_curie(env, serd_string("eg.1:foo")));
- assert(!serd_env_expand_curie(env, serd_string("nocolon")));
+ assert(!serd_env_expand_curie(NULL, zix_empty_string()));
+ assert(!serd_env_expand_curie(NULL, zix_string("what:ever")));
+ assert(!serd_env_expand_curie(env, zix_string("eg.1:foo")));
+ assert(!serd_env_expand_curie(env, zix_string("nocolon")));
serd_env_free(env);
}
@@ -384,9 +384,9 @@ test_expand_blank(void)
{
SerdNodes* const nodes = serd_nodes_new(NULL);
const SerdNode* const blank =
- serd_nodes_get(nodes, serd_a_blank(serd_string("b1")));
+ serd_nodes_get(nodes, serd_a_blank(zix_string("b1")));
- SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* const env = serd_env_new(NULL, zix_empty_string());
assert(!serd_env_expand_node(env, blank));
@@ -397,9 +397,9 @@ test_expand_blank(void)
static void
test_equals(void)
{
- const SerdStringView name1 = serd_string("n1");
- const SerdStringView base1 = serd_string(NS_EG "b1/");
- const SerdStringView base2 = serd_string(NS_EG "b2/");
+ static const ZixStringView name1 = ZIX_STATIC_STRING("n1");
+ static const ZixStringView base1 = ZIX_STATIC_STRING(NS_EG "b1/");
+ static const ZixStringView base2 = ZIX_STATIC_STRING(NS_EG "b2/");
SerdEnv* const env1 = serd_env_new(NULL, base1);
SerdEnv* const env2 = serd_env_new(NULL, base2);
@@ -412,11 +412,11 @@ test_equals(void)
serd_env_set_base_uri(env2, base1);
assert(serd_env_equals(env1, env2));
- assert(!serd_env_set_prefix(env1, name1, serd_string(NS_EG "n1")));
+ assert(!serd_env_set_prefix(env1, name1, zix_string(NS_EG "n1")));
assert(!serd_env_equals(env1, env2));
- assert(!serd_env_set_prefix(env2, name1, serd_string(NS_EG "othern1")));
+ assert(!serd_env_set_prefix(env2, name1, zix_string(NS_EG "othern1")));
assert(!serd_env_equals(env1, env2));
- assert(!serd_env_set_prefix(env2, name1, serd_string(NS_EG "n1")));
+ assert(!serd_env_set_prefix(env2, name1, zix_string(NS_EG "n1")));
assert(serd_env_equals(env1, env2));
serd_env_set_base_uri(env2, base2);
diff --git a/test/test_log.c b/test/test_log.c
index aba9fe23..ca4343a2 100644
--- a/test/test_log.c
+++ b/test/test_log.c
@@ -7,8 +7,8 @@
#include "serd/log.h"
#include "serd/node.h"
#include "serd/status.h"
-#include "serd/string_view.h"
#include "serd/world.h"
+#include "zix/string_view.h"
#include <assert.h>
#include <stdbool.h>
@@ -19,7 +19,7 @@ custom_log_func(void* const handle,
const SerdLogLevel level,
const size_t n_fields,
const SerdLogField* const fields,
- const SerdStringView message)
+ const ZixStringView message)
{
(void)message;
diff --git a/test/test_model.c b/test/test_model.c
index feb35440..2e3a7847 100644
--- a/test/test_model.c
+++ b/test/test_model.c
@@ -20,11 +20,11 @@
#include "serd/sink.h"
#include "serd/statement.h"
#include "serd/status.h"
-#include "serd/string_view.h"
#include "serd/syntax.h"
#include "serd/world.h"
#include "serd/writer.h"
#include "zix/attributes.h"
+#include "zix/string_view.h"
#include <assert.h>
#include <stdbool.h>
@@ -88,19 +88,19 @@ generate(SerdWorld* world,
const SerdNode* hello = serd_nodes_get(nodes, serd_a_string("hello"));
const SerdNode* hello_gb = serd_nodes_get(
- nodes, serd_a_plain_literal(serd_string("hello"), serd_string("en-gb")));
+ nodes, serd_a_plain_literal(zix_string("hello"), zix_string("en-gb")));
const SerdNode* hello_us = serd_nodes_get(
- nodes, serd_a_plain_literal(serd_string("hello"), serd_string("en-us")));
+ nodes, serd_a_plain_literal(zix_string("hello"), zix_string("en-us")));
const SerdNode* hello_t4 =
serd_nodes_get(nodes,
- serd_a_typed_literal(serd_string("hello"),
+ serd_a_typed_literal(zix_string("hello"),
serd_node_string_view(uri(world, 4))));
const SerdNode* hello_t5 =
serd_nodes_get(nodes,
- serd_a_typed_literal(serd_string("hello"),
+ serd_a_typed_literal(zix_string("hello"),
serd_node_string_view(uri(world, 5))));
assert(!serd_model_add(model, uri(world, 98), uri(world, 4), hello, graph));
@@ -127,10 +127,10 @@ generate(SerdWorld* world,
// (14 6 "bonjour"@fr) and (14 6 "salut"@fr)
const SerdNode* const bonjour = serd_nodes_get(
- nodes, serd_a_plain_literal(serd_string("bonjour"), serd_string("fr")));
+ nodes, serd_a_plain_literal(zix_string("bonjour"), zix_string("fr")));
const SerdNode* const salut = serd_nodes_get(
- nodes, serd_a_plain_literal(serd_string("salut"), serd_string("fr")));
+ nodes, serd_a_plain_literal(zix_string("salut"), zix_string("fr")));
assert(!serd_model_add(model, uri(world, 14), uri(world, 6), bonjour, graph));
assert(!serd_model_add(model, uri(world, 14), uri(world, 6), salut, graph));
@@ -140,7 +140,7 @@ generate(SerdWorld* world,
// Add a blank node subject
const SerdNode* ablank =
- serd_nodes_get(nodes, serd_a_blank(serd_string("ablank")));
+ serd_nodes_get(nodes, serd_a_blank(zix_string("ablank")));
assert(!serd_model_add(model, ablank, uri(world, 6), salut, graph));
@@ -177,7 +177,7 @@ test_read(SerdWorld* world,
assert(serd_cursor_advance(cursor) == SERD_BAD_CURSOR);
serd_cursor_free(NULL, cursor);
- const SerdStringView s = serd_string("hello");
+ static const ZixStringView s = ZIX_STATIC_STRING("hello");
const SerdNode* plain_hello = serd_nodes_get(nodes, serd_a_string_view(s));
@@ -188,10 +188,10 @@ test_read(SerdWorld* world,
nodes, serd_a_typed_literal(s, serd_node_string_view(uri(world, 5))));
const SerdNode* gb_hello =
- serd_nodes_get(nodes, serd_a_plain_literal(s, serd_string("en-gb")));
+ serd_nodes_get(nodes, serd_a_plain_literal(s, zix_string("en-gb")));
const SerdNode* us_hello =
- serd_nodes_get(nodes, serd_a_plain_literal(s, serd_string("en-us")));
+ serd_nodes_get(nodes, serd_a_plain_literal(s, zix_string("en-us")));
#define NUM_PATTERNS 18
@@ -265,7 +265,7 @@ test_read(SerdWorld* world,
// Query blank node subject
const SerdNode* ablank =
- serd_nodes_get(nodes, serd_a_blank(serd_string("ablank")));
+ serd_nodes_get(nodes, serd_a_blank(zix_string("ablank")));
Quad pat = {ablank, 0, 0};
int num_results = 0;
@@ -328,7 +328,7 @@ expected_error(void* const handle,
const SerdLogLevel level,
const size_t n_fields,
const SerdLogField* const fields,
- const SerdStringView message)
+ const ZixStringView message)
{
(void)level;
(void)n_fields;
@@ -344,7 +344,7 @@ ignore_only_index_error(void* const handle,
const SerdLogLevel level,
const size_t n_fields,
const SerdLogField* const fields,
- const SerdStringView message)
+ const ZixStringView message)
{
(void)handle;
(void)level;
@@ -761,8 +761,7 @@ test_add_with_caret(SerdWorld* world, const unsigned n_quads)
const SerdNode* lit = serd_nodes_get(nodes, serd_a_string("string"));
const SerdNode* uri = serd_nodes_get(nodes, serd_a_uri_string("urn:uri"));
- const SerdNode* blank =
- serd_nodes_get(nodes, serd_a_blank(serd_string("b1")));
+ const SerdNode* blank = serd_nodes_get(nodes, serd_a_blank(zix_string("b1")));
SerdModel* model = serd_model_new(world, SERD_ORDER_SPO, 0U);
@@ -1097,8 +1096,8 @@ test_write_flat_range(SerdWorld* world, const unsigned n_quads)
const SerdNode* s = serd_nodes_get(nodes, serd_a_uri_string("urn:s"));
const SerdNode* p = serd_nodes_get(nodes, serd_a_uri_string("urn:p"));
- const SerdNode* b1 = serd_nodes_get(nodes, serd_a_blank(serd_string("b1")));
- const SerdNode* b2 = serd_nodes_get(nodes, serd_a_blank(serd_string("b2")));
+ const SerdNode* b1 = serd_nodes_get(nodes, serd_a_blank(zix_string("b1")));
+ const SerdNode* b2 = serd_nodes_get(nodes, serd_a_blank(zix_string("b2")));
const SerdNode* o = serd_nodes_get(nodes, serd_a_uri_string("urn:o"));
serd_model_add(model, s, p, b1, NULL);
@@ -1107,7 +1106,7 @@ test_write_flat_range(SerdWorld* world, const unsigned n_quads)
serd_model_add(model, b2, p, o, NULL);
SerdBuffer buffer = {NULL, NULL, 0};
- SerdEnv* env = serd_env_new(alloc, serd_empty_string());
+ SerdEnv* env = serd_env_new(alloc, zix_empty_string());
SerdOutputStream out = serd_open_output_buffer(&buffer);
SerdWriter* writer = serd_writer_new(world, SERD_TURTLE, 0, env, &out, 1);
@@ -1160,17 +1159,15 @@ test_write_bad_list(SerdWorld* world, const unsigned n_quads)
const SerdNode* s = serd_nodes_get(nodes, serd_a_uri_string("urn:s"));
const SerdNode* p = serd_nodes_get(nodes, serd_a_uri_string("urn:p"));
- const SerdNode* list1 =
- serd_nodes_get(nodes, serd_a_blank(serd_string("l1")));
+ const SerdNode* list1 = serd_nodes_get(nodes, serd_a_blank(zix_string("l1")));
- const SerdNode* list2 =
- serd_nodes_get(nodes, serd_a_blank(serd_string("l2")));
+ const SerdNode* list2 = serd_nodes_get(nodes, serd_a_blank(zix_string("l2")));
const SerdNode* nofirst =
- serd_nodes_get(nodes, serd_a_blank(serd_string("nof")));
+ serd_nodes_get(nodes, serd_a_blank(zix_string("nof")));
const SerdNode* norest =
- serd_nodes_get(nodes, serd_a_blank(serd_string("nor")));
+ serd_nodes_get(nodes, serd_a_blank(zix_string("nor")));
const SerdNode* pfirst = serd_nodes_get(nodes, serd_a_uri_string(RDF_FIRST));
const SerdNode* prest = serd_nodes_get(nodes, serd_a_uri_string(RDF_REST));
@@ -1190,7 +1187,7 @@ test_write_bad_list(SerdWorld* world, const unsigned n_quads)
serd_model_add(model, norest, pfirst, val2, NULL);
SerdBuffer buffer = {NULL, NULL, 0};
- SerdEnv* env = serd_env_new(alloc, serd_empty_string());
+ SerdEnv* env = serd_env_new(alloc, zix_empty_string());
SerdOutputStream out = serd_open_output_buffer(&buffer);
SerdWriter* writer = serd_writer_new(world, SERD_TURTLE, 0, env, &out, 1);
@@ -1239,11 +1236,9 @@ test_write_infinite_list(SerdWorld* world, const unsigned n_quads)
const SerdNode* s = serd_nodes_get(nodes, serd_a_uri_string("urn:s"));
const SerdNode* p = serd_nodes_get(nodes, serd_a_uri_string("urn:p"));
- const SerdNode* list1 =
- serd_nodes_get(nodes, serd_a_blank(serd_string("l1")));
+ const SerdNode* list1 = serd_nodes_get(nodes, serd_a_blank(zix_string("l1")));
- const SerdNode* list2 =
- serd_nodes_get(nodes, serd_a_blank(serd_string("l2")));
+ const SerdNode* list2 = serd_nodes_get(nodes, serd_a_blank(zix_string("l2")));
const SerdNode* pfirst = serd_nodes_get(nodes, serd_a_uri_string(RDF_FIRST));
const SerdNode* prest = serd_nodes_get(nodes, serd_a_uri_string(RDF_REST));
@@ -1258,7 +1253,7 @@ test_write_infinite_list(SerdWorld* world, const unsigned n_quads)
serd_model_add(model, list2, prest, list1, NULL);
SerdBuffer buffer = {NULL, NULL, 0};
- SerdEnv* env = serd_env_new(alloc, serd_empty_string());
+ SerdEnv* env = serd_env_new(alloc, zix_empty_string());
SerdOutputStream out = serd_open_output_buffer(&buffer);
SerdWriter* writer = serd_writer_new(world, SERD_TURTLE, 0, env, &out, 1);
@@ -1266,8 +1261,8 @@ test_write_infinite_list(SerdWorld* world, const unsigned n_quads)
serd_env_set_prefix(
env,
- serd_string("rdf"),
- serd_string("http://www.w3.org/1999/02/22-rdf-syntax-ns#"));
+ zix_string("rdf"),
+ zix_string("http://www.w3.org/1999/02/22-rdf-syntax-ns#"));
SerdCursor* all = serd_model_begin(NULL, model);
serd_describe_range(NULL, all, serd_writer_sink(writer), 0);
@@ -1333,9 +1328,9 @@ test_write_error_in_list_subject(SerdWorld* world, const unsigned n_quads)
const SerdNode* p = serd_nodes_get(nodes, serd_a_uri_string("urn:p"));
const SerdNode* o = serd_nodes_get(nodes, serd_a_uri_string("urn:o"));
- const SerdNode* l1 = serd_nodes_get(nodes, serd_a_blank(serd_string("l1")));
+ const SerdNode* l1 = serd_nodes_get(nodes, serd_a_blank(zix_string("l1")));
const SerdNode* one = serd_nodes_get(nodes, serd_a_integer(1));
- const SerdNode* l2 = serd_nodes_get(nodes, serd_a_blank(serd_string("l2")));
+ const SerdNode* l2 = serd_nodes_get(nodes, serd_a_blank(zix_string("l2")));
const SerdNode* two = serd_nodes_get(nodes, serd_a_integer(2));
const SerdNode* rdf_first =
@@ -1351,7 +1346,7 @@ test_write_error_in_list_subject(SerdWorld* world, const unsigned n_quads)
serd_model_add(model, l2, rdf_rest, rdf_nil, NULL);
serd_model_add(model, l1, p, o, NULL);
- SerdEnv* env = serd_env_new(alloc, serd_empty_string());
+ SerdEnv* env = serd_env_new(alloc, zix_empty_string());
for (size_t max_successes = 0; max_successes < 18; ++max_successes) {
FailingWriteFuncState state = {0, max_successes};
@@ -1393,9 +1388,9 @@ test_write_error_in_list_object(SerdWorld* world, const unsigned n_quads)
const SerdNode* s = serd_nodes_get(nodes, serd_a_uri_string("urn:s"));
const SerdNode* p = serd_nodes_get(nodes, serd_a_uri_string("urn:p"));
- const SerdNode* l1 = serd_nodes_get(nodes, serd_a_blank(serd_string("l1")));
+ const SerdNode* l1 = serd_nodes_get(nodes, serd_a_blank(zix_string("l1")));
const SerdNode* one = serd_nodes_get(nodes, serd_a_integer(1));
- const SerdNode* l2 = serd_nodes_get(nodes, serd_a_blank(serd_string("l2")));
+ const SerdNode* l2 = serd_nodes_get(nodes, serd_a_blank(zix_string("l2")));
const SerdNode* two = serd_nodes_get(nodes, serd_a_integer(2));
const SerdNode* rdf_first =
@@ -1411,7 +1406,7 @@ test_write_error_in_list_object(SerdWorld* world, const unsigned n_quads)
serd_model_add(model, l2, rdf_first, two, NULL);
serd_model_add(model, l2, rdf_rest, rdf_nil, NULL);
- SerdEnv* env = serd_env_new(alloc, serd_empty_string());
+ SerdEnv* env = serd_env_new(alloc, zix_empty_string());
for (size_t max_successes = 0; max_successes < 21; ++max_successes) {
FailingWriteFuncState state = {0, max_successes};
diff --git a/test/test_node.c b/test/test_node.c
index 7ed6e3c5..10e0765c 100644
--- a/test/test_node.c
+++ b/test/test_node.c
@@ -5,10 +5,10 @@
#include "serd/node.h"
#include "serd/status.h"
-#include "serd/string_view.h"
#include "serd/uri.h"
#include "serd/value.h"
#include "serd/write_result.h"
+#include "zix/string_view.h"
#include <assert.h>
#include <math.h>
@@ -52,7 +52,7 @@ static void
test_new(void)
{
const SerdNodeArgs bad_args = {(SerdNodeArgsType)-1,
- {{(SerdNodeType)-1, {NULL, 0U}}}};
+ {{SERD_LITERAL, zix_string("invalid")}}};
assert(!serd_node_new(NULL, bad_args));
}
@@ -191,7 +191,7 @@ check_get_bool(const char* string,
const bool expected)
{
SerdNode* const node = serd_node_new(
- NULL, serd_a_typed_literal(serd_string(string), serd_string(datatype_uri)));
+ NULL, serd_a_typed_literal(zix_string(string), zix_string(datatype_uri)));
assert(node);
@@ -293,7 +293,7 @@ check_get_double(const char* string,
const double expected)
{
SerdNode* const node = serd_node_new(
- NULL, serd_a_typed_literal(serd_string(string), serd_string(datatype_uri)));
+ NULL, serd_a_typed_literal(zix_string(string), zix_string(datatype_uri)));
assert(node);
@@ -366,7 +366,7 @@ check_get_float(const char* string,
const float expected)
{
SerdNode* const node = serd_node_new(
- NULL, serd_a_typed_literal(serd_string(string), serd_string(datatype_uri)));
+ NULL, serd_a_typed_literal(zix_string(string), zix_string(datatype_uri)));
assert(node);
@@ -435,7 +435,7 @@ check_get_integer(const char* string,
const int64_t expected)
{
SerdNode* const node = serd_node_new(
- NULL, serd_a_typed_literal(serd_string(string), serd_string(datatype_uri)));
+ NULL, serd_a_typed_literal(zix_string(string), zix_string(datatype_uri)));
assert(node);
@@ -547,7 +547,7 @@ static void
check_decode(const char* string, const char* datatype_uri, const char* expected)
{
SerdNode* const node = serd_node_new(
- NULL, serd_a_typed_literal(serd_string(string), serd_string(datatype_uri)));
+ NULL, serd_a_typed_literal(zix_string(string), zix_string(datatype_uri)));
assert(node);
@@ -580,8 +580,8 @@ test_decode(void)
{
SerdNode* const node =
serd_node_new(NULL,
- serd_a_typed_literal(serd_string("Zm9v"),
- serd_string(NS_XSD "base64Binary")));
+ serd_a_typed_literal(zix_string("Zm9v"),
+ zix_string(NS_XSD "base64Binary")));
const SerdWriteResult r = serd_node_decode(node, sizeof(small), small);
@@ -602,8 +602,8 @@ test_decode(void)
{
SerdNode* const unknown = serd_node_new(
NULL,
- serd_a_typed_literal(serd_string("secret"),
- serd_string("http://example.org/Datatype")));
+ serd_a_typed_literal(zix_string("secret"),
+ zix_string("http://example.org/Datatype")));
assert(serd_node_decoded_size(unknown) == 0U);
@@ -620,7 +620,7 @@ test_node_equals(void)
{
static const uint8_t replacement_char_str[] = {0xEF, 0xBF, 0xBD, 0};
- static const SerdStringView replacement_char = {
+ static const ZixStringView replacement_char = {
(const char*)replacement_char_str, 3};
SerdNode* lhs = serd_node_new(NULL, serd_a_string_view(replacement_char));
@@ -660,7 +660,7 @@ static void
test_node_from_substring(void)
{
SerdNode* const a_b =
- serd_node_new(NULL, serd_a_string_view(serd_substring("a\"bc", 3)));
+ serd_node_new(NULL, serd_a_string_view(zix_substring("a\"bc", 3)));
assert(serd_node_length(a_b) == 3);
assert(!serd_node_flags(a_b));
@@ -682,17 +682,18 @@ check_copy_equals(const SerdNode* const node)
static void
test_uri(void)
{
- const SerdStringView base = serd_string("http://example.org/base/");
- const SerdStringView rel = serd_string("a/b");
- const SerdStringView abs = serd_string("http://example.org/base/a/b");
+#define NS_EG "http://example.org/"
+
+ static const ZixStringView base = ZIX_STATIC_STRING(NS_EG "base/");
+ static const ZixStringView rel = ZIX_STATIC_STRING("a/b");
+ static const ZixStringView abs = ZIX_STATIC_STRING(NS_EG "base/a/b");
const SerdURIView base_uri = serd_parse_uri(base.data);
const SerdURIView rel_uri = serd_parse_uri(rel.data);
const SerdURIView abs_uri = serd_resolve_uri(rel_uri, base_uri);
SerdNode* const from_string = serd_node_new(NULL, serd_a_uri(abs));
-
- SerdNode* const from_uri = serd_node_new(NULL, serd_a_parsed_uri(abs_uri));
+ SerdNode* const from_uri = serd_node_new(NULL, serd_a_parsed_uri(abs_uri));
assert(from_string);
assert(from_uri);
@@ -700,36 +701,38 @@ test_uri(void)
serd_node_free(NULL, from_uri);
serd_node_free(NULL, from_string);
+
+#undef NS_EG
}
static void
test_literal(void)
{
- const SerdStringView hello_str = serd_string("hello");
- const SerdStringView empty_str = serd_empty_string();
+ static const ZixStringView hello_str = ZIX_STATIC_STRING("hello");
+ static const ZixStringView empty_str = ZIX_STATIC_STRING("");
assert(!serd_node_new(NULL,
serd_a_literal(hello_str,
SERD_HAS_DATATYPE | SERD_HAS_LANGUAGE,
- serd_string("whatever"))));
+ zix_string("whatever"))));
assert(!serd_node_new(NULL, serd_a_typed_literal(hello_str, empty_str)));
assert(!serd_node_new(NULL, serd_a_plain_literal(hello_str, empty_str)));
assert(
- !serd_node_new(NULL, serd_a_typed_literal(hello_str, serd_string("Type"))));
+ !serd_node_new(NULL, serd_a_typed_literal(hello_str, zix_string("Type"))));
assert(
- !serd_node_new(NULL, serd_a_typed_literal(hello_str, serd_string("de"))));
+ !serd_node_new(NULL, serd_a_typed_literal(hello_str, zix_string("de"))));
assert(
- !serd_node_new(NULL, serd_a_plain_literal(hello_str, serd_string("3n"))));
+ !serd_node_new(NULL, serd_a_plain_literal(hello_str, zix_string("3n"))));
assert(
- !serd_node_new(NULL, serd_a_plain_literal(hello_str, serd_string("d3"))));
+ !serd_node_new(NULL, serd_a_plain_literal(hello_str, zix_string("d3"))));
assert(
- !serd_node_new(NULL, serd_a_plain_literal(hello_str, serd_string("d3"))));
+ !serd_node_new(NULL, serd_a_plain_literal(hello_str, zix_string("d3"))));
assert(
- !serd_node_new(NULL, serd_a_plain_literal(hello_str, serd_string("en-!"))));
+ !serd_node_new(NULL, serd_a_plain_literal(hello_str, zix_string("en-!"))));
SerdNode* hello2 = serd_node_new(NULL, serd_a_string("hello\""));
@@ -738,18 +741,17 @@ test_literal(void)
check_copy_equals(hello2);
- assert(
- !serd_node_new(NULL,
- serd_a_typed_literal(serd_string("plain"),
- serd_string(NS_RDF "langString"))));
+ assert(!serd_node_new(NULL,
+ serd_a_typed_literal(zix_string("plain"),
+ zix_string(NS_RDF "langString"))));
serd_node_free(NULL, hello2);
const char* lang_lit_str = "\"Hello\"@en-ca";
SerdNode* sliced_lang_lit =
serd_node_new(NULL,
- serd_a_plain_literal(serd_substring(lang_lit_str + 1, 5),
- serd_substring(lang_lit_str + 8, 5)));
+ serd_a_plain_literal(zix_substring(lang_lit_str + 1, 5),
+ zix_substring(lang_lit_str + 8, 5)));
assert(!strcmp(serd_node_string(sliced_lang_lit), "Hello"));
@@ -762,8 +764,8 @@ test_literal(void)
const char* type_lit_str = "\"Hallo\"^^<http://example.org/Greeting>";
SerdNode* sliced_type_lit =
serd_node_new(NULL,
- serd_a_typed_literal(serd_substring(type_lit_str + 1, 5),
- serd_substring(type_lit_str + 10, 27)));
+ serd_a_typed_literal(zix_substring(type_lit_str + 1, 5),
+ zix_substring(type_lit_str + 10, 27)));
assert(!strcmp(serd_node_string(sliced_type_lit), "Hallo"));
@@ -789,13 +791,13 @@ test_compare(void)
SerdNode* angst = serd_node_new(NULL, serd_a_string("angst"));
SerdNode* angst_de = serd_node_new(
- NULL, serd_a_plain_literal(serd_string("angst"), serd_string("de")));
+ NULL, serd_a_plain_literal(zix_string("angst"), zix_string("de")));
SerdNode* angst_en = serd_node_new(
- NULL, serd_a_plain_literal(serd_string("angst"), serd_string("en")));
+ NULL, serd_a_plain_literal(zix_string("angst"), zix_string("en")));
SerdNode* hallo = serd_node_new(
- NULL, serd_a_plain_literal(serd_string("Hallo"), serd_string("de")));
+ NULL, serd_a_plain_literal(zix_string("Hallo"), zix_string("de")));
SerdNode* hello = serd_node_new(NULL, serd_a_string("Hello"));
SerdNode* universe = serd_node_new(NULL, serd_a_string("Universe"));
@@ -806,13 +808,13 @@ test_compare(void)
SerdNode* aardvark = serd_node_new(
NULL,
- serd_a_typed_literal(serd_string("alex"),
- serd_string("http://example.org/Aardvark")));
+ serd_a_typed_literal(zix_string("alex"),
+ zix_string("http://example.org/Aardvark")));
SerdNode* badger = serd_node_new(
NULL,
- serd_a_typed_literal(serd_string("bobby"),
- serd_string("http://example.org/Badger")));
+ serd_a_typed_literal(zix_string("bobby"),
+ zix_string("http://example.org/Badger")));
// Types are ordered according to their SerdNodeType (more or less arbitrary)
assert(serd_node_compare(integer, hello) < 0);
diff --git a/test/test_node_syntax.c b/test/test_node_syntax.c
index d1d913ec..5e106a94 100644
--- a/test/test_node_syntax.c
+++ b/test/test_node_syntax.c
@@ -10,9 +10,9 @@
#include "serd/node.h"
#include "serd/node_syntax.h"
#include "serd/nodes.h"
-#include "serd/string_view.h"
#include "serd/syntax.h"
#include "serd/value.h"
+#include "zix/string_view.h"
#include <assert.h>
#include <stdbool.h>
@@ -64,7 +64,7 @@ check(const SerdSyntax syntax,
const char* const expected)
{
SerdEnv* const env =
- serd_env_new(NULL, serd_string("http://example.org/base/"));
+ serd_env_new(NULL, zix_string("http://example.org/base/"));
char* const str = serd_node_to_syntax(NULL, node, syntax, env);
SerdNode* const copy = serd_node_from_syntax(NULL, str, syntax, env);
@@ -82,33 +82,34 @@ test_common(const SerdSyntax syntax)
{
static const uint8_t data[] = {19U, 17U, 13U, 7U};
- const SerdStringView datatype = serd_string("http://example.org/Datatype");
+ static const ZixStringView datatype =
+ ZIX_STATIC_STRING("http://example.org/Datatype");
SerdNodes* const nodes = serd_nodes_new(NULL);
assert(
check(syntax, serd_nodes_get(nodes, serd_a_string("node")), "\"node\""));
- assert(check(
- syntax,
- serd_nodes_get(
- nodes, serd_a_plain_literal(serd_string("hallo"), serd_string("de"))),
- "\"hallo\"@de"));
+ assert(
+ check(syntax,
+ serd_nodes_get(
+ nodes, serd_a_plain_literal(zix_string("hallo"), zix_string("de"))),
+ "\"hallo\"@de"));
assert(check(
syntax,
- serd_nodes_get(nodes, serd_a_typed_literal(serd_string("X"), datatype)),
+ serd_nodes_get(nodes, serd_a_typed_literal(zix_string("X"), datatype)),
"\"X\"^^<http://example.org/Datatype>"));
assert(check(syntax,
- serd_nodes_get(nodes, serd_a_blank(serd_string("blank"))),
+ serd_nodes_get(nodes, serd_a_blank(zix_string("blank"))),
"_:blank"));
assert(check(
- syntax, serd_nodes_get(nodes, serd_a_blank(serd_string("b0"))), "_:b0"));
+ syntax, serd_nodes_get(nodes, serd_a_blank(zix_string("b0"))), "_:b0"));
assert(check(syntax,
- serd_nodes_get(nodes, serd_a_blank(serd_string("named1"))),
+ serd_nodes_get(nodes, serd_a_blank(zix_string("named1"))),
"_:named1"));
assert(check(syntax,
@@ -151,7 +152,7 @@ test_ntriples(void)
// If a relative URI can be expanded then all's well
SerdEnv* const env =
- serd_env_new(NULL, serd_string("http://example.org/base/"));
+ serd_env_new(NULL, zix_string("http://example.org/base/"));
char* const str = serd_node_to_syntax(NULL, rel, SERD_NTRIPLES, env);
assert(!strcmp(str, "<http://example.org/base/rel/uri>"));
diff --git a/test/test_nodes.c b/test/test_nodes.c
index 7c2c8508..b220f6d7 100644
--- a/test/test_nodes.c
+++ b/test/test_nodes.c
@@ -8,15 +8,16 @@
#include "serd/memory.h"
#include "serd/node.h"
#include "serd/nodes.h"
-#include "serd/string_view.h"
#include "serd/uri.h"
#include "serd/value.h"
+#include "zix/string_view.h"
#include <assert.h>
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
+#define NS_EG "http://example.org/"
#define NS_XSD "http://www.w3.org/2001/XMLSchema#"
static void
@@ -98,7 +99,7 @@ test_intern(void)
static void
test_string(void)
{
- const SerdStringView string = serd_string("string");
+ static const ZixStringView string = ZIX_STATIC_STRING("string");
SerdAllocator* const allocator = serd_default_allocator();
@@ -115,7 +116,7 @@ test_string(void)
assert(!strcmp(serd_node_string(node), string.data));
const SerdNode* const long_node = serd_nodes_get(
- nodes, serd_a_literal(string, SERD_IS_LONG, serd_empty_string()));
+ nodes, serd_a_literal(string, SERD_IS_LONG, zix_empty_string()));
assert(long_node);
assert(long_node != node);
@@ -137,19 +138,19 @@ test_invalid_literal(void)
SerdNodes* const nodes = serd_nodes_new(allocator);
assert(!serd_nodes_get(nodes,
- serd_a_literal(serd_string("double meta"),
+ serd_a_literal(zix_string("double meta"),
SERD_HAS_LANGUAGE | SERD_HAS_DATATYPE,
- serd_string("What am I?"))));
+ zix_string("What am I?"))));
assert(!serd_nodes_get(nodes,
- serd_a_literal(serd_string("empty language"),
+ serd_a_literal(zix_string("empty language"),
SERD_HAS_LANGUAGE,
- serd_empty_string())));
+ zix_empty_string())));
assert(!serd_nodes_get(nodes,
- serd_a_literal(serd_string("empty datatype"),
+ serd_a_literal(zix_string("empty datatype"),
SERD_HAS_DATATYPE,
- serd_empty_string())));
+ zix_empty_string())));
serd_nodes_free(nodes);
}
@@ -157,8 +158,8 @@ test_invalid_literal(void)
static void
test_plain_literal(void)
{
- const SerdStringView string = serd_string("string");
- const SerdStringView language = serd_string("en");
+ static const ZixStringView string = ZIX_STATIC_STRING("string");
+ static const ZixStringView language = ZIX_STATIC_STRING("en");
SerdAllocator* const allocator = serd_default_allocator();
@@ -191,7 +192,7 @@ test_plain_literal(void)
assert(long_version != node);
const SerdNode* const other =
- serd_nodes_get(nodes, serd_a_plain_literal(string, serd_string("de")));
+ serd_nodes_get(nodes, serd_a_plain_literal(string, zix_string("de")));
assert(other != node);
@@ -210,8 +211,8 @@ test_plain_literal(void)
static void
test_typed_literal(void)
{
- const SerdStringView string = serd_string("string");
- const SerdStringView datatype = serd_string("http://example.org/Type");
+ static const ZixStringView string = ZIX_STATIC_STRING("string");
+ static const ZixStringView datatype = ZIX_STATIC_STRING(NS_EG "Type");
SerdAllocator* const allocator = serd_default_allocator();
@@ -395,7 +396,7 @@ test_base64(void)
static void
test_uri(void)
{
- const SerdStringView string = serd_string("http://example.org/");
+ static const ZixStringView string = ZIX_STATIC_STRING("http://example.org/");
SerdAllocator* const allocator = serd_default_allocator();
SerdNodes* const nodes = serd_nodes_new(allocator);
@@ -416,7 +417,7 @@ test_uri(void)
static void
test_parsed_uri(void)
{
- const SerdStringView string = serd_string("http://example.org/");
+ static const ZixStringView string = ZIX_STATIC_STRING("http://example.org/");
SerdAllocator* const allocator = serd_default_allocator();
@@ -436,8 +437,8 @@ test_parsed_uri(void)
assert(alias == node);
- const SerdNode* const other = serd_nodes_get(
- nodes, serd_a_parsed_uri(serd_parse_uri("http://example.org/x")));
+ const SerdNode* const other =
+ serd_nodes_get(nodes, serd_a_parsed_uri(serd_parse_uri(NS_EG "x")));
assert(other != node);
@@ -449,17 +450,19 @@ test_file_uri(void)
{
SerdAllocator* const allocator = serd_default_allocator();
- const SerdStringView local_string = serd_string("file:///d/f.txt");
- const SerdStringView local_path = serd_string("/d/f.txt");
- const SerdStringView remote_host = serd_string("server");
- const SerdStringView remote_string = serd_string("file://server/d/f.txt");
+ static const ZixStringView local_string =
+ ZIX_STATIC_STRING("file:///d/f.txt");
+ static const ZixStringView local_path = ZIX_STATIC_STRING("/d/f.txt");
+ static const ZixStringView remote_host = ZIX_STATIC_STRING("s");
+ static const ZixStringView remote_string =
+ ZIX_STATIC_STRING("file://s/d/f.txt");
SerdNodes* const nodes = serd_nodes_new(allocator);
const SerdNode* const local_uri =
serd_nodes_get(nodes, serd_a_uri(local_string));
const SerdNode* const local_file_uri =
- serd_nodes_get(nodes, serd_a_file_uri(local_path, serd_empty_string()));
+ serd_nodes_get(nodes, serd_a_file_uri(local_path, zix_empty_string()));
assert(local_uri);
assert(local_file_uri);
@@ -492,7 +495,7 @@ test_file_uri(void)
static void
test_blank(void)
{
- const SerdStringView string = serd_string("b42");
+ static const ZixStringView string = ZIX_STATIC_STRING("b42");
SerdAllocator* const allocator = serd_default_allocator();
diff --git a/test/test_overflow.c b/test/test_overflow.c
index abc7d989..f2ff184b 100644
--- a/test/test_overflow.c
+++ b/test/test_overflow.c
@@ -4,6 +4,7 @@
#undef NDEBUG
#include "serd/serd.h"
+#include "zix/string_view.h"
#include <assert.h>
#include <stdio.h>
@@ -24,8 +25,8 @@ test_size(SerdWorld* const world,
SerdNodes* const nodes = serd_world_nodes(world);
SerdAllocator* const alloc = serd_world_allocator(world);
- SerdSink* sink = serd_sink_new(alloc, NULL, NULL, NULL);
- SerdEnv* const env = serd_env_new(alloc, serd_empty_string());
+ SerdSink* const sink = serd_sink_new(alloc, NULL, NULL, NULL);
+ SerdEnv* const env = serd_env_new(alloc, zix_empty_string());
SerdReader* const reader = serd_reader_new(world, syntax, flags, env, sink);
if (!reader) {
return SERD_BAD_STACK;
diff --git a/test/test_reader.c b/test/test_reader.c
index 3d59af8e..325f8c23 100644
--- a/test/test_reader.c
+++ b/test/test_reader.c
@@ -16,13 +16,13 @@
#include "serd/statement.h"
#include "serd/status.h"
#include "serd/stream.h"
-#include "serd/string_view.h"
#include "serd/syntax.h"
#include "serd/world.h"
#include "zix/allocator.h"
#include "zix/attributes.h"
#include "zix/filesystem.h"
#include "zix/path.h"
+#include "zix/string_view.h"
#ifdef _WIN32
# include <windows.h>
@@ -69,7 +69,7 @@ test_new_failed_alloc(void)
SerdFailingAllocator allocator = serd_failing_allocator();
SerdWorld* const world = serd_world_new(&allocator.base);
- SerdEnv* const env = serd_env_new(&allocator.base, serd_empty_string());
+ SerdEnv* const env = serd_env_new(&allocator.base, zix_empty_string());
size_t ignored = 0U;
SerdSink* const sink =
serd_sink_new(&allocator.base, &ignored, test_sink, NULL);
@@ -105,7 +105,7 @@ test_start_failed_alloc(const char* const path)
fseek(f, 0L, SEEK_SET);
SerdWorld* world = serd_world_new(&allocator.base);
- SerdEnv* env = serd_env_new(&allocator.base, serd_empty_string());
+ SerdEnv* env = serd_env_new(&allocator.base, zix_empty_string());
size_t ignored = 0U;
SerdSink* sink = serd_sink_new(&allocator.base, &ignored, test_sink, NULL);
SerdReader* reader = serd_reader_new(world, SERD_TURTLE, 0U, env, sink);
@@ -175,8 +175,9 @@ test_prepare_error(const char* const path)
SerdSink* const sink = serd_sink_new(NULL, &rt, test_sink, NULL);
assert(sink);
- SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* const env = serd_env_new(NULL, zix_empty_string());
SerdReader* const reader = serd_reader_new(world, SERD_TURTLE, 0, env, sink);
+
assert(reader);
SerdInputStream in =
@@ -206,8 +207,9 @@ test_read_string(void)
SerdSink* sink = serd_sink_new(NULL, &rt, test_sink, NULL);
assert(sink);
- SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* const env = serd_env_new(NULL, zix_empty_string());
SerdReader* const reader = serd_reader_new(world, SERD_TURTLE, 0U, env, sink);
+
assert(reader);
static const char* const string1 =
@@ -307,7 +309,7 @@ test_read_eof_by_page(const char* const path)
SerdWorld* const world = serd_world_new(NULL);
ReaderTest rt = {0, 0, 0, 0};
SerdSink* const sink = serd_sink_new(NULL, &rt, test_sink, NULL);
- SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* const env = serd_env_new(NULL, zix_empty_string());
SerdReader* reader = serd_reader_new(world, SERD_TURTLE, 0U, env, sink);
SerdInputStream in =
@@ -335,7 +337,7 @@ test_read_eof_by_byte(void)
SerdWorld* const world = serd_world_new(NULL);
ReaderTest rt = {0, 0, 0, 0};
SerdSink* const sink = serd_sink_new(NULL, &rt, test_sink, NULL);
- SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* const env = serd_env_new(NULL, zix_empty_string());
SerdReader* reader = serd_reader_new(world, SERD_TURTLE, 0U, env, sink);
size_t n_reads = 0U;
@@ -387,7 +389,7 @@ test_read_nquads_chunks(const char* const path)
SerdSink* const sink = serd_sink_new(NULL, &rt, test_sink, NULL);
assert(sink);
- SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* const env = serd_env_new(NULL, zix_empty_string());
assert(env);
SerdReader* const reader = serd_reader_new(world, SERD_TURTLE, 0U, env, sink);
@@ -473,7 +475,7 @@ test_read_turtle_chunks(const char* const path)
SerdSink* const sink = serd_sink_new(NULL, &rt, test_sink, NULL);
assert(sink);
- SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* const env = serd_env_new(NULL, zix_empty_string());
assert(env);
SerdReader* const reader = serd_reader_new(world, SERD_TURTLE, 0U, env, sink);
@@ -562,7 +564,7 @@ test_read_empty(const char* const path)
SerdSink* const sink = serd_sink_new(NULL, &rt, test_sink, NULL);
assert(sink);
- SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* const env = serd_env_new(NULL, zix_empty_string());
assert(env);
SerdReader* const reader =
@@ -617,8 +619,8 @@ test_error_cursor(void)
SerdNodes* const nodes = serd_world_nodes(world);
bool called = false;
SerdSink* const sink = serd_sink_new(NULL, &called, check_cursor, NULL);
- SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
- SerdReader* const reader = serd_reader_new(world, SERD_TURTLE, 0U, env, sink);
+ SerdEnv* const env = serd_env_new(NULL, zix_empty_string());
+ SerdReader* const reader = serd_reader_new(world, SERD_TURTLE, 0, env, sink);
assert(sink);
assert(reader);
diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c
index 7a57daed..1858d570 100644
--- a/test/test_reader_writer.c
+++ b/test/test_reader_writer.c
@@ -14,13 +14,13 @@
#include "serd/reader.h"
#include "serd/sink.h"
#include "serd/status.h"
-#include "serd/string_view.h"
#include "serd/syntax.h"
#include "serd/world.h"
#include "serd/writer.h"
#include "zix/allocator.h"
#include "zix/filesystem.h"
#include "zix/path.h"
+#include "zix/string_view.h"
#include <assert.h>
#include <errno.h>
@@ -110,7 +110,7 @@ test_write_errors(void)
ctx.n_written = 0;
ctx.error_offset = o;
- SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* const env = serd_env_new(NULL, zix_empty_string());
SerdOutputStream out =
serd_open_output_stream(faulty_sink, NULL, NULL, &ctx);
@@ -144,7 +144,7 @@ test_writer(const char* const path)
{
SerdWorld* world = serd_world_new(NULL);
SerdNodes* nodes = serd_world_nodes(world);
- SerdEnv* env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* env = serd_env_new(NULL, zix_empty_string());
SerdOutputStream output = serd_open_output_file(path);
@@ -161,7 +161,7 @@ test_writer(const char* const path)
assert(serd_sink_write_end(iface, lit));
static const uint8_t bad_buf[] = {0xEF, 0xBF, 0xBD, 0};
- const SerdStringView bad_buf_view = {(const char*)bad_buf, 3};
+ const ZixStringView bad_buf_view = {(const char*)bad_buf, 3};
const SerdNode* s =
serd_nodes_get(nodes, serd_a_uri_string("http://example.org"));
@@ -177,15 +177,16 @@ test_writer(const char* const path)
assert(serd_sink_write(iface, 0, junk[i][0], junk[i][1], junk[i][2], NULL));
}
- const SerdStringView urn_Type = serd_string("urn:Type");
- const SerdStringView en = serd_string("en");
- const SerdNode* const o = serd_nodes_get(nodes, serd_a_string("o"));
+ static const ZixStringView urn_Type = ZIX_STATIC_STRING("urn:Type");
+ static const ZixStringView en = ZIX_STATIC_STRING("en");
+
+ const SerdNode* const o = serd_nodes_get(nodes, serd_a_string("o"));
const SerdNode* const t =
- serd_nodes_get(nodes, serd_a_typed_literal(serd_string("t"), urn_Type));
+ serd_nodes_get(nodes, serd_a_typed_literal(zix_string("t"), urn_Type));
const SerdNode* const l =
- serd_nodes_get(nodes, serd_a_plain_literal(serd_string("l"), en));
+ serd_nodes_get(nodes, serd_a_plain_literal(zix_string("l"), en));
const SerdNode* good[][3] = {{s, p, o}, {s, p, t}, {s, p, l}};
@@ -246,7 +247,7 @@ test_reader(const char* path)
SerdSink* const sink = serd_sink_new(NULL, &rt, test_sink, NULL);
assert(sink);
- SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* const env = serd_env_new(NULL, zix_empty_string());
assert(env);
// Test that too little stack space fails gracefully
diff --git a/test/test_terse_write.c b/test/test_terse_write.c
index 2a516c04..0c55eb9d 100644
--- a/test/test_terse_write.c
+++ b/test/test_terse_write.c
@@ -11,10 +11,10 @@
#include "serd/output_stream.h"
#include "serd/sink.h"
#include "serd/statement.h"
-#include "serd/string_view.h"
#include "serd/syntax.h"
#include "serd/world.h"
#include "serd/writer.h"
+#include "zix/string_view.h"
#include <assert.h>
#include <stdio.h>
@@ -43,7 +43,7 @@ test(void)
SerdWorld* world = serd_world_new(NULL);
SerdAllocator* alloc = serd_world_allocator(world);
SerdBuffer buffer = {NULL, NULL, 0};
- SerdEnv* env = serd_env_new(alloc, serd_empty_string());
+ SerdEnv* env = serd_env_new(alloc, zix_empty_string());
SerdNodes* nodes = serd_nodes_new(alloc);
const SerdNode* b1 = serd_nodes_get(nodes, serd_a_blank_string("b1"));
@@ -64,7 +64,7 @@ test(void)
const SerdNode* rdf_nil =
serd_nodes_get(nodes, serd_a_uri_string(NS_RDF "nil"));
- serd_env_set_prefix(env, serd_string("rdf"), serd_string(NS_RDF));
+ serd_env_set_prefix(env, zix_string("rdf"), zix_string(NS_RDF));
SerdOutputStream output = serd_open_output_buffer(&buffer);
SerdWriter* const writer =
diff --git a/test/test_uri.c b/test/test_uri.c
index b1af8a02..bf4fa0f3 100644
--- a/test/test_uri.c
+++ b/test/test_uri.c
@@ -8,8 +8,8 @@
#include "serd/memory.h"
#include "serd/node.h"
#include "serd/nodes.h"
-#include "serd/string_view.h"
#include "serd/uri.h"
+#include "zix/string_view.h"
#include <assert.h>
#include <stdbool.h>
@@ -79,7 +79,7 @@ test_file_uri(const char* const hostname,
SerdNodes* const nodes = serd_nodes_new(NULL);
const SerdNode* node = serd_nodes_get(
- nodes, serd_a_file_uri(serd_string(path), serd_string(hostname)));
+ nodes, serd_a_file_uri(zix_string(path), zix_string(hostname)));
const char* node_str = serd_node_string(node);
char* out_hostname = NULL;
@@ -164,7 +164,8 @@ test_uri_parsing(void)
static void
test_parse_uri(void)
{
- const SerdStringView base = serd_string("http://example.org/a/b/c/");
+ static const ZixStringView base =
+ ZIX_STATIC_STRING("http://example.org/a/b/c/");
const SerdURIView base_uri = serd_parse_uri(base.data);
const SerdURIView empty_uri = serd_parse_uri("");
@@ -215,7 +216,7 @@ test_is_within(void)
}
static inline bool
-chunk_equals(const SerdStringView* a, const SerdStringView* b)
+chunk_equals(const ZixStringView* a, const ZixStringView* b)
{
return (!a->length && !b->length && !a->data && !b->data) ||
(a->length && b->length && a->data && b->data &&
@@ -374,11 +375,11 @@ check_uri_string(const SerdURIView uri, const char* const expected)
static void
test_uri_resolution(void)
{
- const SerdStringView top = serd_string("http://example.org/t/");
- const SerdStringView base = serd_string("http://example.org/t/b/");
- const SerdStringView sub = serd_string("http://example.org/t/b/s");
- const SerdStringView deep = serd_string("http://example.org/t/b/s/d");
- const SerdStringView other = serd_string("http://example.org/o");
+ const ZixStringView top = ZIX_STATIC_STRING("http://example.org/t/");
+ const ZixStringView base = ZIX_STATIC_STRING("http://example.org/t/b/");
+ const ZixStringView sub = ZIX_STATIC_STRING("http://example.org/t/b/s");
+ const ZixStringView deep = ZIX_STATIC_STRING("http://example.org/t/b/s/d");
+ const ZixStringView other = ZIX_STATIC_STRING("http://example.org/o");
const SerdURIView top_uri = serd_parse_uri(top.data);
const SerdURIView base_uri = serd_parse_uri(base.data);
diff --git a/test/test_writer.c b/test/test_writer.c
index 60f50308..17790527 100644
--- a/test/test_writer.c
+++ b/test/test_writer.c
@@ -15,10 +15,10 @@
#include "serd/sink.h"
#include "serd/statement.h"
#include "serd/status.h"
-#include "serd/string_view.h"
#include "serd/syntax.h"
#include "serd/world.h"
#include "serd/writer.h"
+#include "zix/string_view.h"
#include <assert.h>
#include <stdint.h>
@@ -30,7 +30,7 @@ static void
test_writer_new(void)
{
SerdWorld* world = serd_world_new(NULL);
- SerdEnv* env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* env = serd_env_new(NULL, zix_empty_string());
SerdBuffer buffer = {NULL, NULL, 0};
SerdOutputStream output = serd_open_output_buffer(&buffer);
@@ -46,7 +46,7 @@ test_new_failed_alloc(void)
SerdFailingAllocator allocator = serd_failing_allocator();
SerdWorld* const world = serd_world_new(&allocator.base);
- SerdEnv* env = serd_env_new(&allocator.base, serd_empty_string());
+ SerdEnv* env = serd_env_new(&allocator.base, zix_empty_string());
SerdBuffer buffer = {&allocator.base, NULL, 0};
SerdOutputStream output = serd_open_output_buffer(&buffer);
const size_t n_world_allocs = allocator.n_allocations;
@@ -76,7 +76,7 @@ test_write_failed_alloc(void)
SerdWorld* world = serd_world_new(&allocator.base);
SerdNodes* nodes = serd_world_nodes(world);
- SerdEnv* env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* env = serd_env_new(NULL, zix_empty_string());
SerdBuffer buffer = {&allocator.base, NULL, 0};
SerdOutputStream output = serd_open_output_buffer(&buffer);
@@ -135,7 +135,7 @@ static void
test_write_bad_event(void)
{
SerdWorld* world = serd_world_new(NULL);
- SerdEnv* env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* env = serd_env_new(NULL, zix_empty_string());
SerdBuffer buffer = {NULL, NULL, 0};
SerdOutputStream output = serd_open_output_buffer(&buffer);
@@ -164,7 +164,7 @@ test_write_long_literal(void)
{
SerdWorld* world = serd_world_new(NULL);
SerdNodes* nodes = serd_world_nodes(world);
- SerdEnv* env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* env = serd_env_new(NULL, zix_empty_string());
SerdBuffer buffer = {NULL, NULL, 0};
SerdOutputStream output = serd_open_output_buffer(&buffer);
@@ -180,9 +180,9 @@ test_write_long_literal(void)
const SerdNode* o =
serd_nodes_get(nodes,
- serd_a_literal(serd_string("hello \"\"\"world\"\"\"!"),
+ serd_a_literal(zix_string("hello \"\"\"world\"\"\"!"),
SERD_IS_LONG,
- serd_empty_string()));
+ zix_empty_string()));
assert(serd_node_flags(o) & SERD_IS_LONG);
assert(!serd_sink_write(serd_writer_sink(writer), 0, s, p, o, NULL));
@@ -222,7 +222,7 @@ test_writer_cleanup(void)
SerdStatus st = SERD_SUCCESS;
SerdWorld* world = serd_world_new(NULL);
SerdNodes* nodes = serd_world_nodes(world);
- SerdEnv* env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* env = serd_env_new(NULL, zix_empty_string());
SerdOutputStream output =
serd_open_output_stream(null_sink, NULL, NULL, NULL);
@@ -237,7 +237,7 @@ test_writer_cleanup(void)
const SerdNode* const p =
serd_nodes_get(nodes, serd_a_uri_string("http://example.org/p"));
- const SerdNode* o = serd_nodes_get(nodes, serd_a_blank(serd_string("start")));
+ const SerdNode* o = serd_nodes_get(nodes, serd_a_blank(zix_string("start")));
st = serd_sink_write(sink, SERD_ANON_O, s, p, o, NULL);
assert(!st);
@@ -275,7 +275,7 @@ test_strict_write(void)
SerdWorld* world = serd_world_new(NULL);
SerdNodes* nodes = serd_world_nodes(world);
- SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* const env = serd_env_new(NULL, zix_empty_string());
SerdOutputStream out = serd_open_output_stream(null_sink, NULL, NULL, fd);
SerdWriter* const writer =
serd_writer_new(world, SERD_TURTLE, 0U, env, &out, 1U);
@@ -328,7 +328,7 @@ test_write_error(void)
{
SerdWorld* const world = serd_world_new(NULL);
SerdNodes* const nodes = serd_world_nodes(world);
- SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* const env = serd_env_new(NULL, zix_empty_string());
SerdOutputStream out = serd_open_output_stream(error_sink, NULL, NULL, NULL);
SerdStatus st = SERD_SUCCESS;
@@ -352,9 +352,10 @@ test_write_error(void)
static void
test_writer_stack_overflow(void)
{
- SerdWorld* world = serd_world_new(NULL);
- SerdNodes* nodes = serd_world_nodes(world);
- SerdEnv* env = serd_env_new(NULL, serd_empty_string());
+ SerdWorld* world = serd_world_new(NULL);
+ SerdNodes* nodes = serd_world_nodes(world);
+ SerdEnv* env = serd_env_new(NULL, zix_empty_string());
+
SerdOutputStream output =
serd_open_output_stream(null_sink, NULL, NULL, NULL);
@@ -403,7 +404,7 @@ test_write_empty_syntax(void)
{
SerdWorld* world = serd_world_new(NULL);
SerdNodes* nodes = serd_world_nodes(world);
- SerdEnv* env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* env = serd_env_new(NULL, zix_empty_string());
const SerdNode* s =
serd_nodes_get(nodes, serd_a_uri_string("http://example.org/s"));
@@ -441,7 +442,7 @@ check_pname_escape(const char* const lname, const char* const expected)
{
SerdWorld* world = serd_world_new(NULL);
SerdNodes* nodes = serd_world_nodes(world);
- SerdEnv* env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* env = serd_env_new(NULL, zix_empty_string());
SerdBuffer buffer = {NULL, NULL, 0};
SerdOutputStream output = serd_open_output_buffer(&buffer);
@@ -452,7 +453,7 @@ check_pname_escape(const char* const lname, const char* const expected)
static const char* const prefix = "http://example.org/";
const size_t prefix_len = strlen(prefix);
- serd_env_set_prefix(env, serd_string("eg"), serd_string(prefix));
+ serd_env_set_prefix(env, zix_string("eg"), zix_string(prefix));
const SerdNode* s =
serd_nodes_get(nodes, serd_a_uri_string("http://example.org/s"));
@@ -517,7 +518,7 @@ test_write_bad_uri(void)
{
SerdWorld* world = serd_world_new(NULL);
SerdNodes* nodes = serd_world_nodes(world);
- SerdEnv* env = serd_env_new(NULL, serd_empty_string());
+ SerdEnv* env = serd_env_new(NULL, zix_empty_string());
const SerdNode* s =
serd_nodes_get(nodes, serd_a_uri_string("http://example.org/s"));
diff --git a/tools/console.c b/tools/console.c
index 89223eaf..53e86389 100644
--- a/tools/console.c
+++ b/tools/console.c
@@ -11,6 +11,7 @@
#include "serd/uri.h"
#include "serd/version.h"
#include "zix/attributes.h"
+#include "zix/string_view.h"
#ifdef _WIN32
# ifdef _MSC_VER
@@ -223,7 +224,7 @@ serd_choose_syntax(SerdWorld* const world,
}
SerdStatus
-serd_set_input_option(const SerdStringView name,
+serd_set_input_option(const ZixStringView name,
SerdSyntax* const syntax,
SerdReaderFlags* const flags)
{
@@ -268,7 +269,7 @@ serd_parse_input_argument(OptionIter* const iter,
if (!(st = serd_get_argument(iter, &argument))) {
if ((st = serd_set_input_option(
- serd_string(argument), &options->syntax, &options->flags))) {
+ zix_string(argument), &options->syntax, &options->flags))) {
fprintf(stderr, "%s: unknown option \"%s\"\n", iter->argv[0], argument);
} else if (!strcmp(argument, "empty") || options->syntax) {
options->overridden = true;
@@ -279,7 +280,7 @@ serd_parse_input_argument(OptionIter* const iter,
}
SerdStatus
-serd_set_output_option(const SerdStringView name,
+serd_set_output_option(const ZixStringView name,
SerdSyntax* const syntax,
SerdWriterFlags* const flags)
{
@@ -325,7 +326,7 @@ serd_parse_output_argument(OptionIter* const iter,
if (!(st = serd_get_argument(iter, &argument))) {
if ((st = serd_set_output_option(
- serd_string(argument), &options->syntax, &options->flags))) {
+ zix_string(argument), &options->syntax, &options->flags))) {
fprintf(stderr, "%s: unknown option \"%s\"\n", iter->argv[0], argument);
} else if (!strcmp(argument, "empty") || options->syntax) {
options->overridden = true;
@@ -397,7 +398,7 @@ serd_create_env(SerdAllocator* const allocator,
const char* const out_filename)
{
if (serd_uri_string_has_scheme(base_string)) {
- return serd_env_new(allocator, serd_string(base_string));
+ return serd_env_new(allocator, zix_string(base_string));
}
const bool is_rebase = !strcmp(base_string, "rebase");
@@ -407,14 +408,14 @@ serd_create_env(SerdAllocator* const allocator,
return NULL;
}
- SerdEnv* const env = serd_env_new(allocator, serd_empty_string());
- serd_env_set_base_path(env, serd_string(out_filename));
+ SerdEnv* const env = serd_env_new(allocator, zix_empty_string());
+ serd_env_set_base_path(env, zix_string(out_filename));
return env;
}
- SerdEnv* const env = serd_env_new(allocator, serd_empty_string());
- const SerdStringView base = serd_string(base_string);
- const SerdStatus st = serd_env_set_base_path(env, base);
+ SerdEnv* const env = serd_env_new(allocator, zix_empty_string());
+ const ZixStringView base = zix_string(base_string);
+ const SerdStatus st = serd_env_set_base_path(env, base);
if (st) {
fprintf(stderr, "%s: invalid base URI \"%s\"\n", program, base_string);
serd_env_free(env);
@@ -506,7 +507,7 @@ serd_read_inputs(SerdWorld* const world,
// Use the filename as the base URI if possible if user didn't override it
const char* const in_path = inputs[i];
if (!opts.base_uri[0] && !!strcmp(in_path, "-")) {
- serd_env_set_base_path(env, serd_string(in_path));
+ serd_env_set_base_path(env, zix_string(in_path));
}
// Open the input stream
diff --git a/tools/console.h b/tools/console.h
index ed59264a..7e59862d 100644
--- a/tools/console.h
+++ b/tools/console.h
@@ -12,10 +12,10 @@
#include "serd/reader.h"
#include "serd/sink.h"
#include "serd/status.h"
-#include "serd/string_view.h"
#include "serd/syntax.h"
#include "serd/world.h"
#include "serd/writer.h"
+#include "zix/string_view.h"
#include <stdbool.h>
#include <stdint.h>
@@ -89,7 +89,7 @@ SerdStatus
serd_get_size_argument(OptionIter* iter, size_t* argument);
SerdStatus
-serd_set_input_option(SerdStringView name,
+serd_set_input_option(ZixStringView name,
SerdSyntax* syntax,
SerdReaderFlags* flags);
@@ -97,7 +97,7 @@ SerdStatus
serd_parse_input_argument(OptionIter* iter, SerdSyntaxOptions* options);
SerdStatus
-serd_set_output_option(SerdStringView name,
+serd_set_output_option(ZixStringView name,
SerdSyntax* syntax,
SerdWriterFlags* flags);
diff --git a/tools/serd-filter.c b/tools/serd-filter.c
index 53424e62..464a727e 100644
--- a/tools/serd-filter.c
+++ b/tools/serd-filter.c
@@ -16,10 +16,10 @@
#include "serd/sink.h"
#include "serd/statement.h"
#include "serd/status.h"
-#include "serd/string_view.h"
#include "serd/syntax.h"
#include "serd/world.h"
#include "serd/writer.h"
+#include "zix/string_view.h"
#include <stdarg.h>
#include <stdbool.h>
@@ -84,7 +84,7 @@ parse_pattern(SerdWorld* const world,
const bool inclusive)
{
SerdAllocator* const allocator = serd_world_allocator(world);
- SerdEnv* const env = serd_env_new(allocator, serd_empty_string());
+ SerdEnv* const env = serd_env_new(allocator, zix_empty_string());
PatternEventContext ctx = {allocator, {NULL, NULL, NULL, NULL}};
SerdSink* in_sink = serd_sink_new(allocator, &ctx, on_pattern_event, NULL);
diff --git a/tools/serd-pipe.c b/tools/serd-pipe.c
index 569119fb..06c8e55e 100644
--- a/tools/serd-pipe.c
+++ b/tools/serd-pipe.c
@@ -9,9 +9,9 @@
#include "serd/reader.h"
#include "serd/sink.h"
#include "serd/status.h"
-#include "serd/string_view.h"
#include "serd/syntax.h"
#include "serd/writer.h"
+#include "zix/string_view.h"
#include <stdbool.h>
#include <stdint.h>
@@ -48,7 +48,7 @@ run(const Options opts)
serd_set_log_func(app.world, serd_quiet_log_func, NULL);
}
- serd_writer_set_root_uri(app.writer, serd_string(opts.root_uri));
+ serd_writer_set_root_uri(app.writer, zix_string(opts.root_uri));
// Set up the output pipeline: [canon] -> writer
const SerdSink* const target = serd_writer_sink(app.writer);