mpd/src/util/UriRelative.hxx

34 lines
868 B
C++
Raw Normal View History

// SPDX-License-Identifier: BSD-2-Clause
// author: Max Kellermann <max.kellermann@gmail.com>
2019-08-09 15:54:13 +02:00
#pragma once
2019-08-09 15:54:13 +02:00
#include <string>
#include <string_view>
2019-08-09 15:54:13 +02:00
/**
* Check whether #child specifies a resource "inside" the directory
* specified by #parent. If the strings are equal, the function
* returns false.
*/
[[gnu::pure]] [[gnu::nonnull]]
2019-08-09 15:54:13 +02:00
bool
uri_is_child(const char *parent, const char *child) noexcept;
[[gnu::pure]] [[gnu::nonnull]]
2019-08-09 15:54:13 +02:00
bool
uri_is_child_or_same(const char *parent, const char *child) noexcept;
/**
* Translate the given URI in the context of #base. For example,
* uri_apply_base("foo", "http://bar/a/")=="http://bar/a/foo".
*/
[[gnu::pure]]
2019-08-09 15:54:13 +02:00
std::string
uri_apply_base(std::string_view uri, std::string_view base) noexcept;
2019-08-09 15:54:13 +02:00
[[gnu::pure]]
std::string
uri_apply_relative(std::string_view relative_uri,
std::string_view base_uri) noexcept;