diff options
author | David Robillard <d@drobilla.net> | 2023-08-30 20:43:05 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:08 -0500 |
commit | 258ea2ff59bbd2127ea446cf4b9676ad3d7fe53d (patch) | |
tree | d7be35c7b4b3d466049352f2975e2c88c298f4b8 /src/env.c | |
parent | b13ad41a4d65b577b4db67660a9edf3056bdf7af (diff) | |
download | serd-258ea2ff59bbd2127ea446cf4b9676ad3d7fe53d.tar.gz serd-258ea2ff59bbd2127ea446cf4b9676ad3d7fe53d.tar.bz2 serd-258ea2ff59bbd2127ea446cf4b9676ad3d7fe53d.zip |
Use ZixStringView directly
Diffstat (limited to 'src/env.c')
-rw-r--r-- | src/env.c | 51 |
1 files changed, 26 insertions, 25 deletions
@@ -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; } |