Added support for completely disabling noexcept using MIJIN_TEST_NO_NOEXCEPT (for testing).
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include "../internal/common.hpp"
|
||||
#include "../util/string.hpp"
|
||||
|
||||
namespace mijin
|
||||
@@ -28,37 +29,38 @@ private:
|
||||
string_view_t pathQueryFragment_;
|
||||
std::uint16_t port_ = 0;
|
||||
public:
|
||||
constexpr URLBase() noexcept = default;
|
||||
constexpr URLBase() MIJIN_NOEXCEPT = default;
|
||||
constexpr URLBase(const URLBase&) = default;
|
||||
constexpr URLBase(URLBase&&) noexcept = default;
|
||||
constexpr URLBase(string_t base) noexcept : base_(std::move(base)) { parse(); }
|
||||
constexpr URLBase(URLBase&&) MIJIN_NOEXCEPT = default;
|
||||
constexpr URLBase(string_t base) MIJIN_NOEXCEPT : base_(std::move(base)) { parse(); }
|
||||
constexpr URLBase(string_view_t base) : URLBase(string_t(base.begin(), base.end())) {}
|
||||
constexpr URLBase(const TChar* base) : URLBase(string_t(base)) {}
|
||||
|
||||
constexpr URLBase& operator=(const URLBase&) = default;
|
||||
constexpr URLBase& operator=(URLBase&&) noexcept = default;
|
||||
constexpr URLBase& operator=(URLBase&&) MIJIN_NOEXCEPT = default;
|
||||
|
||||
[[nodiscard]] constexpr bool isValid() const noexcept { return !base_.empty(); }
|
||||
[[nodiscard]] constexpr string_view_t getScheme() const noexcept { return scheme_; }
|
||||
[[nodiscard]] constexpr string_view_t getUserInfo() const noexcept { return userinfo_; }
|
||||
[[nodiscard]] constexpr string_view_t getHost() const noexcept { return host_; }
|
||||
[[nodiscard]] constexpr string_view_t getPath() const noexcept { return path_; }
|
||||
[[nodiscard]] constexpr string_view_t getQuery() const noexcept { return query_; }
|
||||
[[nodiscard]] constexpr string_view_t getFragment() const noexcept { return fragment_; }
|
||||
[[nodiscard]] constexpr string_view_t getPathQueryFragment() const noexcept { return pathQueryFragment_; }
|
||||
[[nodiscard]] constexpr std::uint16_t getPort() const noexcept { return port_; }
|
||||
[[nodiscard]] constexpr bool isValid() const MIJIN_NOEXCEPT { return !base_.empty(); }
|
||||
[[nodiscard]] constexpr const string_t& getBase() const MIJIN_NOEXCEPT { return base_; }
|
||||
[[nodiscard]] constexpr string_view_t getScheme() const MIJIN_NOEXCEPT { return scheme_; }
|
||||
[[nodiscard]] constexpr string_view_t getUserInfo() const MIJIN_NOEXCEPT { return userinfo_; }
|
||||
[[nodiscard]] constexpr string_view_t getHost() const MIJIN_NOEXCEPT { return host_; }
|
||||
[[nodiscard]] constexpr string_view_t getPath() const MIJIN_NOEXCEPT { return path_; }
|
||||
[[nodiscard]] constexpr string_view_t getQuery() const MIJIN_NOEXCEPT { return query_; }
|
||||
[[nodiscard]] constexpr string_view_t getFragment() const MIJIN_NOEXCEPT { return fragment_; }
|
||||
[[nodiscard]] constexpr string_view_t getPathQueryFragment() const MIJIN_NOEXCEPT { return pathQueryFragment_; }
|
||||
[[nodiscard]] constexpr std::uint16_t getPort() const MIJIN_NOEXCEPT { return port_; }
|
||||
|
||||
|
||||
constexpr void clear() noexcept;
|
||||
constexpr void clear() MIJIN_NOEXCEPT;
|
||||
private:
|
||||
constexpr void parse() noexcept;
|
||||
constexpr bool parseAuthority(string_view_t authority) noexcept;
|
||||
constexpr void parse() MIJIN_NOEXCEPT;
|
||||
constexpr bool parseAuthority(string_view_t authority) MIJIN_NOEXCEPT;
|
||||
};
|
||||
|
||||
using URL = URLBase<char>;
|
||||
|
||||
template<typename TChar, typename TTraits, typename TAllocator>
|
||||
constexpr void URLBase<TChar, TTraits, TAllocator>::clear() noexcept
|
||||
constexpr void URLBase<TChar, TTraits, TAllocator>::clear() MIJIN_NOEXCEPT
|
||||
{
|
||||
base_.clear();
|
||||
scheme_ = {};
|
||||
@@ -71,7 +73,7 @@ constexpr void URLBase<TChar, TTraits, TAllocator>::clear() noexcept
|
||||
}
|
||||
|
||||
template<typename TChar, typename TTraits, typename TAllocator>
|
||||
constexpr void URLBase<TChar, TTraits, TAllocator>::parse() noexcept
|
||||
constexpr void URLBase<TChar, TTraits, TAllocator>::parse() MIJIN_NOEXCEPT
|
||||
{
|
||||
if (base_.empty())
|
||||
{
|
||||
@@ -135,7 +137,7 @@ constexpr void URLBase<TChar, TTraits, TAllocator>::parse() noexcept
|
||||
}
|
||||
|
||||
template<typename TChar, typename TTraits, typename TAllocator>
|
||||
constexpr bool URLBase<TChar, TTraits, TAllocator>::parseAuthority(string_view_t authority) noexcept
|
||||
constexpr bool URLBase<TChar, TTraits, TAllocator>::parseAuthority(string_view_t authority) MIJIN_NOEXCEPT
|
||||
{
|
||||
string_view_t toParse = authority;
|
||||
typename string_view_t::size_type pos = toParse.find(TChar('@'));
|
||||
|
||||
Reference in New Issue
Block a user