aboutsummaryrefslogtreecommitdiffstats
path: root/include/serd
diff options
context:
space:
mode:
Diffstat (limited to 'include/serd')
-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
7 files changed, 44 insertions, 125 deletions
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.