mirror of
https://github.com/boostorg/url.git
synced 2026-07-21 13:43:32 +00:00
@@ -9,7 +9,12 @@ x64
|
||||
|
||||
cmake-build-*/
|
||||
cmake-build/
|
||||
build/*
|
||||
!build/Jamfile
|
||||
local/
|
||||
tmp/
|
||||
AGENTS.md
|
||||
CLAUDE.md
|
||||
.roadmap/
|
||||
.idea/
|
||||
doc/modules/reference/
|
||||
@@ -684,6 +684,38 @@ parsing_urls()
|
||||
// end::snippet_parsing_url_3[]
|
||||
BOOST_TEST(v.buffer() == "/path/to/file.txt#anchor");
|
||||
}
|
||||
|
||||
#if defined(BOOST_URL_HAS_CXX20_CONSTEXPR)
|
||||
{
|
||||
// tag::snippet_constexpr_parsing_1[]
|
||||
// Parse and validate a URL at compile time (C++20).
|
||||
// value() on an error produces a compile error,
|
||||
// so invalid URLs are caught at build time.
|
||||
constexpr url_view api_base =
|
||||
parse_uri("https://api.example.com/v2").value();
|
||||
|
||||
// A malformed literal would fail to compile:
|
||||
// constexpr url_view bad =
|
||||
// parse_uri("ht tp://bad url").value();
|
||||
// end::snippet_constexpr_parsing_1[]
|
||||
BOOST_TEST(api_base.scheme() == "https");
|
||||
}
|
||||
{
|
||||
// tag::snippet_constexpr_parsing_2[]
|
||||
// Pre-parsed URL constants have zero runtime cost.
|
||||
// Parsing happens entirely at compile time.
|
||||
constexpr url_view default_endpoint =
|
||||
parse_uri("https://api.example.com:8443/v1").value();
|
||||
constexpr url_view fallback_endpoint =
|
||||
parse_uri("http://localhost:9090/debug").value();
|
||||
|
||||
// Components are available at runtime with no parsing overhead
|
||||
assert(default_endpoint.port_number() == 8443);
|
||||
assert(fallback_endpoint.scheme() == "http");
|
||||
// end::snippet_constexpr_parsing_2[]
|
||||
BOOST_TEST(default_endpoint.port_number() == 8443);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -246,3 +246,26 @@ include::example$unit/snippets.cpp[tag=snippet_parsing_url_1b,indent=0]
|
||||
Check the reference for cpp:result[] for a synopsis of the type.
|
||||
|
||||
|
||||
== Constexpr Parsing
|
||||
|
||||
In {cpp}20 and later, all parse functions are `constexpr`.
|
||||
This means URLs can be parsed and validated at compile time, which is useful when one side of a comparison is a fixed string that should be pre-parsed and checked for correctness.
|
||||
|
||||
For instance, a `constexpr` cpp:url_view[] parsed from a valid string literal is fully resolved at compile time.
|
||||
If the literal is malformed, `value()` attempts to throw, which is not permitted during constant evaluation, so the program fails to compile:
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
include::example$unit/snippets.cpp[tag=snippet_constexpr_parsing_1,indent=0]
|
||||
----
|
||||
|
||||
Pre-parsed `constexpr` URL views can also serve as zero-cost constants.
|
||||
All parsing is done at compile time; at runtime the components are accessed with no parsing overhead:
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
include::example$unit/snippets.cpp[tag=snippet_constexpr_parsing_2,indent=0]
|
||||
----
|
||||
|
||||
Because cpp:url_view[] does not own its character buffer, `constexpr` URL views always reference string literals.
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -25,6 +26,15 @@
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
|
||||
class url_base;
|
||||
|
||||
namespace implementation_defined {
|
||||
struct authority_rule_t;
|
||||
struct uri_rule_t;
|
||||
struct relative_ref_rule_t;
|
||||
struct absolute_uri_rule_t;
|
||||
} // implementation_defined
|
||||
|
||||
/** A non-owning reference to a valid authority
|
||||
|
||||
Objects of this type represent valid authority
|
||||
@@ -79,17 +89,27 @@ namespace urls {
|
||||
@see
|
||||
@ref parse_authority.
|
||||
*/
|
||||
class BOOST_URL_DECL
|
||||
class BOOST_SYMBOL_VISIBLE
|
||||
authority_view
|
||||
: private detail::parts_base
|
||||
{
|
||||
detail::url_impl u_;
|
||||
|
||||
friend struct detail::url_impl;
|
||||
friend struct implementation_defined::authority_rule_t;
|
||||
friend struct implementation_defined::uri_rule_t;
|
||||
friend struct implementation_defined::relative_ref_rule_t;
|
||||
friend struct implementation_defined::absolute_uri_rule_t;
|
||||
friend class url_view_base;
|
||||
friend class url_base;
|
||||
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
explicit
|
||||
authority_view(
|
||||
detail::url_impl const& u) noexcept;
|
||||
detail::url_impl const& u) noexcept
|
||||
: u_(u)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
//--------------------------------------------
|
||||
@@ -100,8 +120,15 @@ public:
|
||||
|
||||
/** Destructor
|
||||
*/
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
virtual
|
||||
~authority_view();
|
||||
~authority_view()
|
||||
{
|
||||
// Empty body instead of = default because
|
||||
// some GCC versions reject a defaulted
|
||||
// virtual constexpr destructor in constexpr
|
||||
// evaluation ("used before its definition").
|
||||
}
|
||||
|
||||
/** Constructor
|
||||
|
||||
@@ -115,7 +142,11 @@ public:
|
||||
|
||||
@par Specification
|
||||
*/
|
||||
authority_view() noexcept;
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
authority_view() noexcept
|
||||
: u_(from::authority)
|
||||
{
|
||||
}
|
||||
|
||||
/** Construct from a string.
|
||||
|
||||
@@ -154,13 +185,15 @@ public:
|
||||
@see
|
||||
@ref parse_authority.
|
||||
*/
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
explicit
|
||||
authority_view(core::string_view s);
|
||||
|
||||
/** Constructor
|
||||
*/
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
authority_view(
|
||||
authority_view const&) noexcept;
|
||||
authority_view const&) noexcept = default;
|
||||
|
||||
/** Assignment
|
||||
|
||||
@@ -173,9 +206,10 @@ public:
|
||||
@par Exception Safety
|
||||
Throws nothing.
|
||||
*/
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
authority_view&
|
||||
operator=(
|
||||
authority_view const& other) noexcept;
|
||||
authority_view const& other) noexcept = default;
|
||||
|
||||
//--------------------------------------------
|
||||
//
|
||||
@@ -317,6 +351,7 @@ public:
|
||||
@ref userinfo.
|
||||
|
||||
*/
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
bool
|
||||
has_userinfo() const noexcept;
|
||||
|
||||
@@ -416,6 +451,7 @@ public:
|
||||
@ref user,
|
||||
@ref userinfo.
|
||||
*/
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
pct_string_view
|
||||
encoded_userinfo() const noexcept;
|
||||
|
||||
@@ -519,6 +555,7 @@ public:
|
||||
@ref user,
|
||||
@ref userinfo.
|
||||
*/
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
pct_string_view
|
||||
encoded_user() const noexcept;
|
||||
|
||||
@@ -562,6 +599,7 @@ public:
|
||||
@ref user,
|
||||
@ref userinfo.
|
||||
*/
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
bool
|
||||
has_password() const noexcept;
|
||||
|
||||
@@ -659,6 +697,7 @@ public:
|
||||
@ref user,
|
||||
@ref userinfo.
|
||||
*/
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
pct_string_view
|
||||
encoded_password() const noexcept;
|
||||
|
||||
@@ -782,6 +821,7 @@ public:
|
||||
@li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2"
|
||||
>3.2.2. Host (rfc3986)</a>
|
||||
*/
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
pct_string_view
|
||||
encoded_host() const noexcept;
|
||||
|
||||
@@ -901,6 +941,7 @@ public:
|
||||
@li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2"
|
||||
>3.2.2. Host (rfc3986)</a>
|
||||
*/
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
pct_string_view
|
||||
encoded_host_address() const noexcept;
|
||||
|
||||
@@ -942,6 +983,7 @@ public:
|
||||
@li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2"
|
||||
>3.2.2. Host (rfc3986)</a>
|
||||
*/
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
ipv4_address
|
||||
host_ipv4_address() const noexcept;
|
||||
|
||||
@@ -991,6 +1033,7 @@ public:
|
||||
@li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2"
|
||||
>3.2.2. Host (rfc3986)</a>
|
||||
*/
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
ipv6_address
|
||||
host_ipv6_address() const noexcept;
|
||||
|
||||
@@ -1025,6 +1068,7 @@ public:
|
||||
@li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2"
|
||||
>3.2.2. Host (rfc3986)</a>
|
||||
*/
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
core::string_view
|
||||
host_ipvfuture() const noexcept;
|
||||
|
||||
@@ -1112,6 +1156,7 @@ public:
|
||||
@li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2"
|
||||
>3.2.2. Host (rfc3986)</a>
|
||||
*/
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
pct_string_view
|
||||
encoded_host_name() const noexcept;
|
||||
|
||||
@@ -1155,6 +1200,7 @@ public:
|
||||
@ref port,
|
||||
@ref port_number.
|
||||
*/
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
bool
|
||||
has_port() const noexcept;
|
||||
|
||||
@@ -1192,6 +1238,7 @@ public:
|
||||
@ref has_port,
|
||||
@ref port_number.
|
||||
*/
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
core::string_view
|
||||
port() const noexcept;
|
||||
|
||||
@@ -1229,6 +1276,7 @@ public:
|
||||
@ref has_port,
|
||||
@ref port.
|
||||
*/
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
std::uint16_t
|
||||
port_number() const noexcept;
|
||||
|
||||
@@ -1270,6 +1318,7 @@ public:
|
||||
|
||||
@return The host and port
|
||||
*/
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
pct_string_view
|
||||
encoded_host_and_port() const noexcept;
|
||||
|
||||
@@ -1537,14 +1586,19 @@ operator<<(
|
||||
@see
|
||||
@ref authority_view.
|
||||
*/
|
||||
BOOST_URL_DECL
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
system::result<authority_view>
|
||||
parse_authority(
|
||||
core::string_view s) noexcept;
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
// When rfc/authority_rule.hpp is being processed,
|
||||
// it will include impl/authority_view.hpp itself
|
||||
// after declaring authority_rule.
|
||||
#if !defined(BOOST_URL_RFC_AUTHORITY_RULE_HPP)
|
||||
#include <boost/url/impl/authority_view.hpp>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -54,7 +54,6 @@ public:
|
||||
// True if the sequence is empty
|
||||
bool empty = false;
|
||||
|
||||
BOOST_URL_DECL
|
||||
virtual
|
||||
~any_params_iter() noexcept = 0;
|
||||
|
||||
@@ -93,7 +92,6 @@ struct BOOST_SYMBOL_VISIBLE
|
||||
: any_params_iter
|
||||
{
|
||||
// ne = never empty
|
||||
BOOST_URL_DECL
|
||||
explicit
|
||||
query_string_iter(
|
||||
core::string_view s,
|
||||
@@ -154,14 +152,12 @@ protected:
|
||||
{}
|
||||
|
||||
// return encoded size
|
||||
BOOST_URL_DECL
|
||||
void
|
||||
measure_impl(
|
||||
std::size_t& n,
|
||||
param_view const& p) noexcept;
|
||||
|
||||
// encode to dest
|
||||
BOOST_URL_DECL
|
||||
void
|
||||
copy_impl(
|
||||
char*& dest,
|
||||
@@ -264,14 +260,12 @@ private:
|
||||
struct params_encoded_iter_base
|
||||
{
|
||||
protected:
|
||||
BOOST_URL_DECL
|
||||
static
|
||||
void
|
||||
measure_impl(
|
||||
std::size_t& n,
|
||||
param_view const& v) noexcept;
|
||||
|
||||
BOOST_URL_DECL
|
||||
static
|
||||
void
|
||||
copy_impl(
|
||||
@@ -430,4 +424,6 @@ make_params_encoded_iter(
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#include <boost/url/detail/impl/any_params_iter.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -105,10 +105,10 @@ private:
|
||||
struct segments_iter_base
|
||||
{
|
||||
protected:
|
||||
BOOST_URL_DECL static void
|
||||
static void
|
||||
measure_impl(std::size_t&,
|
||||
core::string_view, bool) noexcept;
|
||||
BOOST_URL_DECL static void
|
||||
static void
|
||||
copy_impl(char*&, char const*,
|
||||
core::string_view, bool) noexcept;
|
||||
};
|
||||
@@ -219,10 +219,10 @@ private:
|
||||
struct segments_encoded_iter_base
|
||||
{
|
||||
protected:
|
||||
BOOST_URL_DECL static void
|
||||
static void
|
||||
measure_impl(std::size_t&,
|
||||
core::string_view, bool) noexcept;
|
||||
BOOST_URL_DECL static void
|
||||
static void
|
||||
copy_impl(char*&, char const*,
|
||||
core::string_view, bool) noexcept;
|
||||
};
|
||||
@@ -324,4 +324,6 @@ make_segments_encoded_iter(
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#include <boost/url/detail/impl/any_segments_iter.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,7 +25,42 @@
|
||||
# define BOOST_URL_BUILD_DLL
|
||||
#endif
|
||||
|
||||
// Set visibility flags
|
||||
// Visibility flags
|
||||
//
|
||||
// BOOST_URL_DECL — class-level export/import for compiled classes
|
||||
//
|
||||
// Static lib: (nothing)
|
||||
// Shared, source: BOOST_SYMBOL_EXPORT
|
||||
// Win: __declspec(dllexport) ELF: visibility("default")
|
||||
// Shared, consumer: BOOST_SYMBOL_IMPORT
|
||||
// Win: __declspec(dllimport) ELF: (nothing)
|
||||
//
|
||||
// Always applied to the class, never to individual functions.
|
||||
//
|
||||
// BOOST_SYMBOL_VISIBLE — typeinfo identity across shared libs
|
||||
//
|
||||
// On ELF with -fvisibility=hidden, each shared library gets
|
||||
// its own typeinfo copy at a different address. Operations
|
||||
// comparing typeinfo across boundaries silently fail:
|
||||
// dynamic_cast returns null, catch clauses don't match.
|
||||
// BOOST_SYMBOL_VISIBLE ensures a single typeinfo (and vtable,
|
||||
// if any). Use on any type whose identity is compared across
|
||||
// boundaries — e.g. error categories, API-facing base classes.
|
||||
// Win: (no-op) ELF: visibility("default") on the class
|
||||
//
|
||||
// MSVC limitation with mixed classes
|
||||
//
|
||||
// Unlike GCC and Clang, MSVC exports ALL members of a
|
||||
// __declspec(dllexport) class — including inline ones.
|
||||
// This causes LNK2005 (duplicate symbol) for any class
|
||||
// that mixes compiled and inline members, and there is no
|
||||
// portable workaround. Each class must therefore follow
|
||||
// exactly one of two policies:
|
||||
// (a) Fully compiled with `class BOOST_URL_DECL C`.
|
||||
// All members in .cpp files. No inline/constexpr members.
|
||||
// (b) Fully header-only with `class BOOST_SYMBOL_VISIBLE C`.
|
||||
// All inline/constexpr/template. No .cpp file.
|
||||
//
|
||||
#if !defined(BOOST_URL_BUILD_DLL)
|
||||
# define BOOST_URL_DECL /* static library */
|
||||
#elif defined(BOOST_URL_SOURCE)
|
||||
@@ -60,19 +95,86 @@
|
||||
# define BOOST_URL_CONSTEXPR constexpr
|
||||
#endif
|
||||
|
||||
// Add source location to error codes
|
||||
#ifdef BOOST_URL_NO_SOURCE_LOCATION
|
||||
# define BOOST_URL_ERR(ev) (::boost::system::error_code(ev))
|
||||
# define BOOST_URL_RETURN_EC(ev) return (ev)
|
||||
# define BOOST_URL_POS ::boost::source_location()
|
||||
// C++14 constexpr (relaxed constexpr)
|
||||
#define BOOST_URL_CXX14_CONSTEXPR BOOST_CXX14_CONSTEXPR
|
||||
|
||||
#if defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
# define BOOST_URL_CXX14_CONSTEXPR_OR_INLINE inline
|
||||
# define BOOST_URL_CXX14_CONSTEXPR_OR_FORCEINLINE BOOST_FORCEINLINE
|
||||
#else
|
||||
# define BOOST_URL_ERR(ev) (::boost::system::error_code( (ev), [] { \
|
||||
# define BOOST_URL_CXX14_CONSTEXPR_OR_INLINE constexpr
|
||||
# define BOOST_URL_CXX14_CONSTEXPR_OR_FORCEINLINE constexpr
|
||||
#endif
|
||||
|
||||
// C++20 constexpr (constexpr virtual, constexpr destructors)
|
||||
// Detection aligned with Boost.System's BOOST_SYSTEM_HAS_CXX20_CONSTEXPR:
|
||||
// uses the feature-test macro for P1064R0 (constexpr virtual functions).
|
||||
#if defined(__cpp_constexpr) && __cpp_constexpr >= 201907L
|
||||
# define BOOST_URL_HAS_CXX20_CONSTEXPR
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_CLANG_VERSION, < 110000)
|
||||
# undef BOOST_URL_HAS_CXX20_CONSTEXPR
|
||||
#endif
|
||||
|
||||
// MSVC ICEs on constexpr URL parsing (error C1001 in p1_init.c)
|
||||
#if defined(BOOST_MSVC)
|
||||
# undef BOOST_URL_HAS_CXX20_CONSTEXPR
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_URL_HAS_CXX20_CONSTEXPR)
|
||||
# define BOOST_URL_CXX20_CONSTEXPR constexpr
|
||||
# define BOOST_URL_CXX20_CONSTEXPR_OR_INLINE constexpr
|
||||
#else
|
||||
# define BOOST_URL_CXX20_CONSTEXPR
|
||||
# define BOOST_URL_CXX20_CONSTEXPR_OR_INLINE inline
|
||||
#endif
|
||||
|
||||
// __builtin_is_constant_evaluated detection
|
||||
// Following the pattern from Boost.Hash2 and Boost.UUID.
|
||||
#if defined(__has_builtin)
|
||||
# if __has_builtin(__builtin_is_constant_evaluated)
|
||||
# define BOOST_URL_HAS_BUILTIN_IS_CONSTANT_EVALUATED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_URL_HAS_BUILTIN_IS_CONSTANT_EVALUATED) \
|
||||
&& defined(BOOST_MSVC) && BOOST_MSVC >= 1925
|
||||
# define BOOST_URL_HAS_BUILTIN_IS_CONSTANT_EVALUATED
|
||||
#endif
|
||||
|
||||
// Add source location to error codes
|
||||
#define BOOST_URL_ERR(ev) \
|
||||
(::boost::system::error_code( (ev), [] { \
|
||||
static constexpr auto loc((BOOST_CURRENT_LOCATION)); \
|
||||
return &loc; }()))
|
||||
# define BOOST_URL_RETURN_EC(ev) \
|
||||
#define BOOST_URL_RETURN_EC(ev) \
|
||||
static constexpr auto loc ## __LINE__((BOOST_CURRENT_LOCATION)); \
|
||||
return ::boost::system::error_code((ev), &loc ## __LINE__)
|
||||
# define BOOST_URL_POS (BOOST_CURRENT_LOCATION)
|
||||
#define BOOST_URL_POS (BOOST_CURRENT_LOCATION)
|
||||
|
||||
// Error return for BOOST_URL_CXX20_CONSTEXPR functions.
|
||||
//
|
||||
// C++20: the function is constexpr, so we branch on
|
||||
// is_constant_evaluated(). At compile time: returns the
|
||||
// error enum directly. At runtime: attaches source location.
|
||||
//
|
||||
// Pre-C++20: the function is not constexpr
|
||||
// (BOOST_URL_CXX20_CONSTEXPR is empty), so we always
|
||||
// attach source location.
|
||||
#if defined(BOOST_URL_HAS_CXX20_CONSTEXPR)
|
||||
# define BOOST_URL_CONSTEXPR_RETURN_EC(ev) \
|
||||
do { \
|
||||
if (__builtin_is_constant_evaluated()) { \
|
||||
return (ev); \
|
||||
} \
|
||||
return [](auto e) { \
|
||||
BOOST_URL_RETURN_EC(e); \
|
||||
}(ev); \
|
||||
} while(0)
|
||||
#else
|
||||
# define BOOST_URL_CONSTEXPR_RETURN_EC(ev) \
|
||||
BOOST_URL_RETURN_EC(ev)
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX20_HDR_CONCEPTS) && defined(__cpp_lib_concepts)
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_DETAIL_FNV_1A_HPP
|
||||
#define BOOST_URL_DETAIL_FNV_1A_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
namespace detail {
|
||||
|
||||
class fnv_1a
|
||||
{
|
||||
public:
|
||||
using digest_type = std::size_t;
|
||||
|
||||
#if BOOST_URL_ARCH == 64
|
||||
static constexpr std::size_t const prime =
|
||||
static_cast<std::size_t>(0x100000001B3ULL);
|
||||
static constexpr std::size_t init_hash =
|
||||
static_cast<std::size_t>(0xcbf29ce484222325ULL);
|
||||
#else
|
||||
static constexpr std::size_t const prime =
|
||||
static_cast<std::size_t>(0x01000193UL);
|
||||
static constexpr std::size_t init_hash =
|
||||
static_cast<std::size_t>(0x811C9DC5UL);
|
||||
#endif
|
||||
|
||||
explicit
|
||||
fnv_1a(std::size_t salt) noexcept
|
||||
: h_(init_hash + salt)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
put(char c) noexcept
|
||||
{
|
||||
h_ ^= c;
|
||||
h_ *= prime;
|
||||
}
|
||||
|
||||
void
|
||||
put(core::string_view s) noexcept
|
||||
{
|
||||
for (char c: s)
|
||||
{
|
||||
put(c);
|
||||
}
|
||||
}
|
||||
|
||||
digest_type
|
||||
digest() const noexcept
|
||||
{
|
||||
return h_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::size_t h_;
|
||||
};
|
||||
|
||||
} // detail
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
|
||||
// Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -7,12 +8,12 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_DETAIL_IMPL_ANY_PARAMS_ITER_HPP
|
||||
#define BOOST_URL_DETAIL_IMPL_ANY_PARAMS_ITER_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/detail/any_params_iter.hpp>
|
||||
#include <boost/url/encode.hpp>
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include "../rfc/detail/charsets.hpp"
|
||||
#include <boost/url/rfc/detail/charsets.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
@@ -35,6 +36,7 @@ namespace detail {
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
any_params_iter::
|
||||
~any_params_iter() noexcept = default;
|
||||
|
||||
@@ -44,6 +46,7 @@ any_params_iter::
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
query_string_iter::
|
||||
query_string_iter(
|
||||
core::string_view s,
|
||||
@@ -54,6 +57,7 @@ query_string_iter(
|
||||
rewind();
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
query_string_iter::
|
||||
rewind() noexcept
|
||||
@@ -80,6 +84,7 @@ rewind() noexcept
|
||||
at_end_ = false;
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
query_string_iter::
|
||||
measure(
|
||||
@@ -100,6 +105,7 @@ measure(
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
query_string_iter::
|
||||
copy(
|
||||
@@ -121,6 +127,7 @@ copy(
|
||||
increment();
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
query_string_iter::
|
||||
increment() noexcept
|
||||
@@ -146,6 +153,7 @@ increment() noexcept
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
single_param_iter::
|
||||
single_param_iter(
|
||||
param_view const& p,
|
||||
@@ -159,6 +167,7 @@ single_param_iter(
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
single_param_iter::
|
||||
rewind() noexcept
|
||||
@@ -166,6 +175,7 @@ rewind() noexcept
|
||||
at_end_ = false;
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
single_param_iter::
|
||||
measure(std::size_t& n) noexcept
|
||||
@@ -190,6 +200,7 @@ measure(std::size_t& n) noexcept
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
single_param_iter::
|
||||
copy(
|
||||
@@ -223,6 +234,7 @@ copy(
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
void
|
||||
params_iter_base::
|
||||
measure_impl(
|
||||
@@ -245,6 +257,7 @@ measure_impl(
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
params_iter_base::
|
||||
copy_impl(
|
||||
@@ -278,6 +291,7 @@ copy_impl(
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
param_encoded_iter::
|
||||
param_encoded_iter(
|
||||
param_pct_view const& p) noexcept
|
||||
@@ -289,6 +303,7 @@ param_encoded_iter(
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
param_encoded_iter::
|
||||
rewind() noexcept
|
||||
@@ -296,6 +311,7 @@ rewind() noexcept
|
||||
at_end_ = false;
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
param_encoded_iter::
|
||||
measure(std::size_t& n) noexcept
|
||||
@@ -313,6 +329,7 @@ measure(std::size_t& n) noexcept
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
param_encoded_iter::
|
||||
copy(
|
||||
@@ -342,6 +359,7 @@ copy(
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
void
|
||||
params_encoded_iter_base::
|
||||
measure_impl(
|
||||
@@ -357,6 +375,7 @@ measure_impl(
|
||||
detail::param_value_chars) + 1; // for '='
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
params_encoded_iter_base::
|
||||
copy_impl(
|
||||
@@ -386,6 +405,7 @@ copy_impl(
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
void
|
||||
param_value_iter::
|
||||
rewind() noexcept
|
||||
@@ -393,6 +413,7 @@ rewind() noexcept
|
||||
at_end_ = false;
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
param_value_iter::
|
||||
measure(
|
||||
@@ -414,6 +435,7 @@ measure(
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
param_value_iter::
|
||||
copy(char*& it, char const* end) noexcept
|
||||
@@ -438,6 +460,7 @@ copy(char*& it, char const* end) noexcept
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
void
|
||||
param_encoded_value_iter::
|
||||
rewind() noexcept
|
||||
@@ -445,6 +468,7 @@ rewind() noexcept
|
||||
at_end_ = false;
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
param_encoded_value_iter::
|
||||
measure(
|
||||
@@ -463,6 +487,7 @@ measure(
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
param_encoded_value_iter::
|
||||
copy(
|
||||
@@ -484,3 +509,4 @@ copy(
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
+18
-4
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
|
||||
// Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -7,13 +8,13 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_DETAIL_IMPL_ANY_SEGMENTS_ITER_HPP
|
||||
#define BOOST_URL_DETAIL_IMPL_ANY_SEGMENTS_ITER_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include "../rfc/detail/charsets.hpp"
|
||||
#include <boost/url/detail/any_segments_iter.hpp>
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <boost/url/encode.hpp>
|
||||
#include <boost/url/rfc/pchars.hpp>
|
||||
#include <boost/url/rfc/detail/charsets.hpp>
|
||||
#include <boost/url/detail/encode.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
@@ -25,6 +26,7 @@ namespace detail {
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
segment_iter::
|
||||
segment_iter(
|
||||
core::string_view s_) noexcept
|
||||
@@ -34,6 +36,7 @@ segment_iter(
|
||||
fast_nseg = 1;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
segment_iter::
|
||||
rewind() noexcept
|
||||
@@ -41,6 +44,7 @@ rewind() noexcept
|
||||
at_end_ = false;
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
segment_iter::
|
||||
measure(
|
||||
@@ -60,6 +64,7 @@ measure(
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
segment_iter::
|
||||
copy(
|
||||
@@ -84,6 +89,7 @@ copy(
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
void
|
||||
segments_iter_base::
|
||||
measure_impl(
|
||||
@@ -101,6 +107,7 @@ measure_impl(
|
||||
opt);
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
segments_iter_base::
|
||||
copy_impl(
|
||||
@@ -127,6 +134,7 @@ copy_impl(
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
segment_encoded_iter::
|
||||
segment_encoded_iter(
|
||||
pct_string_view const& s_) noexcept
|
||||
@@ -136,6 +144,7 @@ segment_encoded_iter(
|
||||
fast_nseg = 1;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
segment_encoded_iter::
|
||||
rewind() noexcept
|
||||
@@ -143,6 +152,7 @@ rewind() noexcept
|
||||
at_end_ = false;
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
segment_encoded_iter::
|
||||
measure(
|
||||
@@ -159,6 +169,7 @@ measure(
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
segment_encoded_iter::
|
||||
copy(
|
||||
@@ -180,6 +191,7 @@ copy(
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
void
|
||||
segments_encoded_iter_base::
|
||||
measure_impl(
|
||||
@@ -194,6 +206,7 @@ measure_impl(
|
||||
pchars);
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
segments_encoded_iter_base::
|
||||
copy_impl(
|
||||
@@ -215,3 +228,4 @@ copy_impl(
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
+12
-3
@@ -7,9 +7,9 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_DETAIL_IMPL_PARAMS_ITER_IMPL_HPP
|
||||
#define BOOST_URL_DETAIL_IMPL_PARAMS_ITER_IMPL_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/detail/params_iter_impl.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -23,6 +23,7 @@ namespace detail {
|
||||
dk decoded key size no '?' or '&'
|
||||
dv decoded value size no '='
|
||||
*/
|
||||
inline
|
||||
params_iter_impl::
|
||||
params_iter_impl(
|
||||
query_ref const& ref_) noexcept
|
||||
@@ -34,6 +35,7 @@ params_iter_impl(
|
||||
setup();
|
||||
}
|
||||
|
||||
inline
|
||||
params_iter_impl::
|
||||
params_iter_impl(
|
||||
query_ref const& ref_,
|
||||
@@ -44,6 +46,7 @@ params_iter_impl(
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
params_iter_impl::
|
||||
params_iter_impl(
|
||||
query_ref const& ref_,
|
||||
@@ -60,6 +63,7 @@ params_iter_impl(
|
||||
}
|
||||
|
||||
// set up state for key/value at pos
|
||||
inline
|
||||
void
|
||||
params_iter_impl::
|
||||
setup() noexcept
|
||||
@@ -116,6 +120,7 @@ setup() noexcept
|
||||
dv = nv - dv - 1;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
params_iter_impl::
|
||||
increment() noexcept
|
||||
@@ -128,6 +133,7 @@ increment() noexcept
|
||||
setup();
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
params_iter_impl::
|
||||
decrement() noexcept
|
||||
@@ -207,6 +213,7 @@ decrement() noexcept
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
param_pct_view
|
||||
params_iter_impl::
|
||||
dereference() const noexcept
|
||||
@@ -226,6 +233,7 @@ dereference() const noexcept
|
||||
no_value};
|
||||
}
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
params_iter_impl::
|
||||
key() const noexcept
|
||||
@@ -238,6 +246,7 @@ key() const noexcept
|
||||
}
|
||||
|
||||
} // detail
|
||||
} // url
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
+12
-5
@@ -8,12 +8,11 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_DETAIL_IMPL_SEGMENTS_ITER_IMPL_HPP
|
||||
#define BOOST_URL_DETAIL_IMPL_SEGMENTS_ITER_IMPL_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include "path.hpp"
|
||||
#include <boost/url/detail/decode.hpp>
|
||||
#include <boost/url/detail/segments_iter_impl.hpp>
|
||||
#include "boost/url/rfc/detail/path_rules.hpp"
|
||||
#include <boost/url/detail/path.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -21,6 +20,7 @@ namespace urls {
|
||||
namespace detail {
|
||||
|
||||
// begin
|
||||
inline
|
||||
segments_iter_impl::
|
||||
segments_iter_impl(
|
||||
detail::path_ref const& ref_) noexcept
|
||||
@@ -33,6 +33,7 @@ segments_iter_impl(
|
||||
}
|
||||
|
||||
// end
|
||||
inline
|
||||
segments_iter_impl::
|
||||
segments_iter_impl(
|
||||
detail::path_ref const& ref_,
|
||||
@@ -46,6 +47,7 @@ segments_iter_impl(
|
||||
decoded_prefix = ref.decoded_size();
|
||||
}
|
||||
|
||||
inline
|
||||
segments_iter_impl::
|
||||
segments_iter_impl(
|
||||
url_impl const& u_,
|
||||
@@ -92,6 +94,7 @@ segments_iter_impl(
|
||||
update();
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
segments_iter_impl::
|
||||
update() noexcept
|
||||
@@ -119,6 +122,7 @@ update() noexcept
|
||||
p0, p - p0, dn);
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
segments_iter_impl::
|
||||
increment() noexcept
|
||||
@@ -162,6 +166,7 @@ increment() noexcept
|
||||
p0, p - p0, dn);
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
segments_iter_impl::
|
||||
decrement() noexcept
|
||||
@@ -213,5 +218,7 @@ decrement() noexcept
|
||||
}
|
||||
|
||||
} // detail
|
||||
} // url
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2022 Vinnie Falco (vinnie.falco@gmail.com)
|
||||
// Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -7,11 +8,14 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_DETAIL_IMPL_URL_IMPL_HPP
|
||||
#define BOOST_URL_DETAIL_IMPL_URL_IMPL_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include "path.hpp"
|
||||
#include <boost/url/detail/memcpy.hpp>
|
||||
#include <boost/url/detail/path.hpp>
|
||||
#include <boost/url/detail/url_impl.hpp>
|
||||
#include <boost/url/authority_view.hpp>
|
||||
#include <boost/url/scheme.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstring>
|
||||
|
||||
@@ -19,17 +23,13 @@ namespace boost {
|
||||
namespace urls {
|
||||
namespace detail {
|
||||
|
||||
#if defined(__GNUC__) && ! defined(__clang__) && defined(__MINGW32__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
#endif
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// url_impl
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
void
|
||||
url_impl::
|
||||
apply_scheme(
|
||||
@@ -39,6 +39,7 @@ apply_scheme(
|
||||
set_size(id_scheme, s.size() + 1);
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
void
|
||||
url_impl::
|
||||
apply_userinfo(
|
||||
@@ -69,6 +70,7 @@ apply_userinfo(
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
void
|
||||
url_impl::
|
||||
apply_host(
|
||||
@@ -86,12 +88,13 @@ apply_host(
|
||||
decoded_[id_host] =
|
||||
detail::to_size_type(
|
||||
s.decoded_size());
|
||||
std::memcpy(
|
||||
detail::memcpy(
|
||||
ip_addr_,
|
||||
addr,
|
||||
sizeof(ip_addr_));
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
void
|
||||
url_impl::
|
||||
apply_port(
|
||||
@@ -106,33 +109,35 @@ apply_port(
|
||||
set_size(id_port, 1 + s.size());
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
void
|
||||
url_impl::
|
||||
apply_authority(
|
||||
authority_view const& a) noexcept
|
||||
url_impl const& a) noexcept
|
||||
{
|
||||
BOOST_ASSERT(from_ != from::authority);
|
||||
|
||||
// userinfo
|
||||
set_size(id_user,
|
||||
a.u_.len(id_user) +
|
||||
a.len(id_user) +
|
||||
(from_ == from::authority ? 0 : 2));
|
||||
set_size(id_pass, a.u_.len(id_pass));
|
||||
decoded_[id_user] = a.u_.decoded_[id_user];
|
||||
decoded_[id_pass] = a.u_.decoded_[id_pass];
|
||||
set_size(id_pass, a.len(id_pass));
|
||||
decoded_[id_user] = a.decoded_[id_user];
|
||||
decoded_[id_pass] = a.decoded_[id_pass];
|
||||
|
||||
// host, port
|
||||
host_type_ = a.u_.host_type_;
|
||||
port_number_ = a.u_.port_number_;
|
||||
set_size(id_host, a.u_.len(id_host));
|
||||
set_size(id_port, a.u_.len(id_port));
|
||||
std::memcpy(
|
||||
host_type_ = a.host_type_;
|
||||
port_number_ = a.port_number_;
|
||||
set_size(id_host, a.len(id_host));
|
||||
set_size(id_port, a.len(id_port));
|
||||
detail::memcpy(
|
||||
ip_addr_,
|
||||
a.u_.ip_addr_,
|
||||
a.ip_addr_,
|
||||
sizeof(ip_addr_));
|
||||
decoded_[id_host] = a.u_.decoded_[id_host];
|
||||
decoded_[id_host] = a.decoded_[id_host];
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
void
|
||||
url_impl::
|
||||
apply_path(
|
||||
@@ -147,6 +152,7 @@ apply_path(
|
||||
detail::path_segments(s, nseg));
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
void
|
||||
url_impl::
|
||||
apply_query(
|
||||
@@ -160,6 +166,7 @@ apply_query(
|
||||
s.decoded_size());
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
void
|
||||
url_impl::
|
||||
apply_frag(
|
||||
@@ -172,12 +179,12 @@ apply_frag(
|
||||
}
|
||||
|
||||
// return length of [first, last)
|
||||
auto
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
std::size_t
|
||||
url_impl::
|
||||
len(
|
||||
int first,
|
||||
int last) const noexcept ->
|
||||
std::size_t
|
||||
int last) const noexcept
|
||||
{
|
||||
BOOST_ASSERT(first <= last);
|
||||
BOOST_ASSERT(last <= id_end);
|
||||
@@ -185,10 +192,10 @@ len(
|
||||
}
|
||||
|
||||
// return length of part
|
||||
auto
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
std::size_t
|
||||
url_impl::
|
||||
len(int id) const noexcept ->
|
||||
std::size_t
|
||||
len(int id) const noexcept
|
||||
{
|
||||
return id == id_end
|
||||
? zero_
|
||||
@@ -197,10 +204,10 @@ len(int id) const noexcept ->
|
||||
}
|
||||
|
||||
// return offset of id
|
||||
auto
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
std::size_t
|
||||
url_impl::
|
||||
offset(int id) const noexcept ->
|
||||
std::size_t
|
||||
offset(int id) const noexcept
|
||||
{
|
||||
return
|
||||
id == id_scheme
|
||||
@@ -209,6 +216,7 @@ offset(int id) const noexcept ->
|
||||
}
|
||||
|
||||
// return id as string
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
core::string_view
|
||||
url_impl::
|
||||
get(int id) const noexcept
|
||||
@@ -218,6 +226,7 @@ get(int id) const noexcept
|
||||
}
|
||||
|
||||
// return [first, last) as string
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
core::string_view
|
||||
url_impl::
|
||||
get(int first,
|
||||
@@ -228,6 +237,7 @@ get(int first,
|
||||
}
|
||||
|
||||
// return id as pct-string
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
pct_string_view
|
||||
url_impl::
|
||||
pct_get(
|
||||
@@ -240,6 +250,7 @@ pct_get(
|
||||
}
|
||||
|
||||
// return [first, last) as pct-string
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
pct_string_view
|
||||
url_impl::
|
||||
pct_get(
|
||||
@@ -259,6 +270,7 @@ pct_get(
|
||||
//------------------------------------------------
|
||||
|
||||
// change id to size n
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
void
|
||||
url_impl::
|
||||
set_size(
|
||||
@@ -282,6 +294,7 @@ set_size(
|
||||
|
||||
// trim id to size n,
|
||||
// moving excess into id+1
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
void
|
||||
url_impl::
|
||||
split(
|
||||
@@ -295,6 +308,7 @@ split(
|
||||
}
|
||||
|
||||
// add n to [first, last]
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
void
|
||||
url_impl::
|
||||
adjust_right(
|
||||
@@ -308,6 +322,7 @@ adjust_right(
|
||||
}
|
||||
|
||||
// remove n from [first, last]
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
void
|
||||
url_impl::
|
||||
adjust_left(
|
||||
@@ -321,6 +336,7 @@ adjust_left(
|
||||
}
|
||||
|
||||
// set [first, last) offset
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
void
|
||||
url_impl::
|
||||
collapse(
|
||||
@@ -340,6 +356,7 @@ collapse(
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
path_ref::
|
||||
path_ref(
|
||||
url_impl const& impl) noexcept
|
||||
@@ -358,6 +375,7 @@ path_ref(
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
path_ref::
|
||||
path_ref(
|
||||
core::string_view s,
|
||||
@@ -370,6 +388,7 @@ path_ref(
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
path_ref::
|
||||
buffer() const noexcept
|
||||
@@ -384,6 +403,7 @@ buffer() const noexcept
|
||||
data_, size_, dn_);
|
||||
}
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
path_ref::
|
||||
size() const noexcept
|
||||
@@ -393,6 +413,7 @@ size() const noexcept
|
||||
return size_;
|
||||
}
|
||||
|
||||
inline
|
||||
char const*
|
||||
path_ref::
|
||||
data() const noexcept
|
||||
@@ -403,6 +424,7 @@ data() const noexcept
|
||||
return data_;
|
||||
}
|
||||
|
||||
inline
|
||||
char const*
|
||||
path_ref::
|
||||
end() const noexcept
|
||||
@@ -413,6 +435,7 @@ end() const noexcept
|
||||
return data_ + size_;
|
||||
}
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
path_ref::
|
||||
nseg() const noexcept
|
||||
@@ -422,6 +445,7 @@ nseg() const noexcept
|
||||
return nseg_;
|
||||
}
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
path_ref::
|
||||
decoded_size() const noexcept
|
||||
@@ -437,6 +461,7 @@ decoded_size() const noexcept
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
query_ref::
|
||||
query_ref(
|
||||
core::string_view s,
|
||||
@@ -449,6 +474,7 @@ query_ref(
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
query_ref::
|
||||
query_ref(
|
||||
url_impl const& impl) noexcept
|
||||
@@ -472,6 +498,7 @@ query_ref(
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
query_ref::
|
||||
buffer() const noexcept
|
||||
@@ -500,6 +527,7 @@ buffer() const noexcept
|
||||
}
|
||||
|
||||
// with '?'
|
||||
inline
|
||||
std::size_t
|
||||
query_ref::
|
||||
size() const noexcept
|
||||
@@ -512,6 +540,7 @@ size() const noexcept
|
||||
}
|
||||
|
||||
// no '?'
|
||||
inline
|
||||
char const*
|
||||
query_ref::
|
||||
begin() const noexcept
|
||||
@@ -530,6 +559,7 @@ begin() const noexcept
|
||||
|
||||
}
|
||||
|
||||
inline
|
||||
char const*
|
||||
query_ref::
|
||||
end() const noexcept
|
||||
@@ -540,6 +570,7 @@ end() const noexcept
|
||||
return data_ + size_;
|
||||
}
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
query_ref::
|
||||
nparam() const noexcept
|
||||
@@ -549,10 +580,8 @@ nparam() const noexcept
|
||||
return nparam_;
|
||||
}
|
||||
|
||||
#if defined(__GNUC__) && ! defined(__clang__) && defined(__MINGW32__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
} // detail
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// Copyright (c) 2025 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_DETAIL_MEMCPY_HPP
|
||||
#define BOOST_URL_DETAIL_MEMCPY_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
namespace detail {
|
||||
|
||||
BOOST_URL_CXX14_CONSTEXPR_OR_FORCEINLINE
|
||||
void
|
||||
memcpy(
|
||||
unsigned char* dest,
|
||||
unsigned char const* src,
|
||||
std::size_t n) noexcept
|
||||
{
|
||||
#if defined(BOOST_URL_HAS_BUILTIN_IS_CONSTANT_EVALUATED)
|
||||
if (!__builtin_is_constant_evaluated())
|
||||
{
|
||||
std::memcpy(dest, src, n);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (std::size_t i = 0; i < n; ++i)
|
||||
{
|
||||
dest[i] = src[i];
|
||||
}
|
||||
}
|
||||
#elif defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
std::memcpy(dest, src, n);
|
||||
#else
|
||||
// C++14 constexpr but no way to detect constant
|
||||
// evaluation: always use the byte loop.
|
||||
for (std::size_t i = 0; i < n; ++i)
|
||||
{
|
||||
dest[i] = src[i];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
} // detail
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -11,61 +11,19 @@
|
||||
#ifndef BOOST_URL_DETAIL_NORMALIZED_HPP
|
||||
#define BOOST_URL_DETAIL_NORMALIZED_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include "boost/url/segments_encoded_view.hpp"
|
||||
#include <boost/url/detail/fnv_1a.hpp>
|
||||
#include <boost/url/segments_encoded_view.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
namespace detail {
|
||||
|
||||
class fnv_1a
|
||||
{
|
||||
public:
|
||||
using digest_type = std::size_t;
|
||||
|
||||
#if BOOST_URL_ARCH == 64
|
||||
static constexpr std::size_t const prime =
|
||||
static_cast<std::size_t>(0x100000001B3ULL);
|
||||
static constexpr std::size_t init_hash =
|
||||
static_cast<std::size_t>(0xcbf29ce484222325ULL);
|
||||
#else
|
||||
static constexpr std::size_t const prime =
|
||||
static_cast<std::size_t>(0x01000193UL);
|
||||
static constexpr std::size_t init_hash =
|
||||
static_cast<std::size_t>(0x811C9DC5UL);
|
||||
#endif
|
||||
|
||||
explicit
|
||||
fnv_1a(std::size_t salt) noexcept
|
||||
: h_(init_hash + salt)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
put(char c) noexcept
|
||||
{
|
||||
h_ ^= c;
|
||||
h_ *= prime;
|
||||
}
|
||||
|
||||
void
|
||||
put(core::string_view s) noexcept
|
||||
{
|
||||
for (char c: s)
|
||||
{
|
||||
put(c);
|
||||
}
|
||||
}
|
||||
|
||||
digest_type
|
||||
digest() const noexcept
|
||||
{
|
||||
return h_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::size_t h_;
|
||||
};
|
||||
// These functions are defined in src/detail/normalize.cpp.
|
||||
// BOOST_URL_DECL is required because they are called from
|
||||
// inline functions in public headers (url_view_base::compare,
|
||||
// url_view_base::digest, authority_view::compare, etc.).
|
||||
|
||||
void
|
||||
pop_encoded_front(
|
||||
@@ -75,6 +33,7 @@ pop_encoded_front(
|
||||
|
||||
// compare two core::string_views as if they are both
|
||||
// percent-decoded
|
||||
BOOST_URL_DECL
|
||||
int
|
||||
compare_encoded(
|
||||
core::string_view lhs,
|
||||
@@ -85,6 +44,7 @@ compare_encoded(
|
||||
// query chars ("&=+") equivalent unless they are
|
||||
// both decoded or encoded the same way, because
|
||||
// that gives them different meanings
|
||||
BOOST_URL_DECL
|
||||
int
|
||||
compare_encoded_query(
|
||||
core::string_view lhs,
|
||||
@@ -92,6 +52,7 @@ compare_encoded_query(
|
||||
|
||||
// digest a core::string_view as if it were
|
||||
// percent-decoded
|
||||
BOOST_URL_DECL
|
||||
void
|
||||
digest_encoded(
|
||||
core::string_view s,
|
||||
@@ -122,6 +83,7 @@ path_ends_with(
|
||||
|
||||
// compare two core::string_views as if they are both
|
||||
// percent-decoded and lowercase
|
||||
BOOST_URL_DECL
|
||||
int
|
||||
ci_compare_encoded(
|
||||
core::string_view lhs,
|
||||
@@ -129,12 +91,14 @@ ci_compare_encoded(
|
||||
|
||||
// digest a core::string_view as if it were decoded
|
||||
// and lowercase
|
||||
BOOST_URL_DECL
|
||||
void
|
||||
ci_digest_encoded(
|
||||
core::string_view s,
|
||||
fnv_1a& hasher) noexcept;
|
||||
|
||||
// compare two ascii core::string_views
|
||||
BOOST_URL_DECL
|
||||
int
|
||||
compare(
|
||||
core::string_view lhs,
|
||||
@@ -142,12 +106,14 @@ compare(
|
||||
|
||||
// compare two core::string_views as if they are both
|
||||
// lowercase
|
||||
BOOST_URL_DECL
|
||||
int
|
||||
ci_compare(
|
||||
core::string_view lhs,
|
||||
core::string_view rhs) noexcept;
|
||||
|
||||
// digest a core::string_view as if it were lowercase
|
||||
BOOST_URL_DECL
|
||||
void
|
||||
ci_digest(
|
||||
core::string_view s,
|
||||
@@ -170,12 +136,14 @@ pop_last_segment(
|
||||
char
|
||||
path_pop_back( core::string_view& s );
|
||||
|
||||
BOOST_URL_DECL
|
||||
void
|
||||
normalized_path_digest(
|
||||
core::string_view str,
|
||||
bool remove_unmatched,
|
||||
fnv_1a& hasher) noexcept;
|
||||
|
||||
BOOST_URL_DECL
|
||||
int
|
||||
segments_compare(
|
||||
segments_encoded_view seg0,
|
||||
@@ -19,7 +19,7 @@ namespace boost {
|
||||
namespace urls {
|
||||
namespace detail {
|
||||
|
||||
struct BOOST_URL_DECL params_iter_impl
|
||||
struct BOOST_SYMBOL_VISIBLE params_iter_impl
|
||||
: parts_base
|
||||
{
|
||||
query_ref ref;
|
||||
@@ -81,4 +81,6 @@ struct BOOST_URL_DECL params_iter_impl
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#include <boost/url/detail/impl/params_iter_impl.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#ifndef BOOST_URL_DETAIL_PATH_HPP
|
||||
#define BOOST_URL_DETAIL_PATH_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -70,7 +71,7 @@ path_prefix(
|
||||
|
||||
// returns the number of adjusted
|
||||
// segments based on the malleable prefix.
|
||||
inline
|
||||
BOOST_URL_CXX14_CONSTEXPR_OR_INLINE
|
||||
std::size_t
|
||||
path_segments(
|
||||
core::string_view s,
|
||||
@@ -10,6 +10,7 @@
|
||||
#ifndef BOOST_URL_DETAIL_PRINT_HPP
|
||||
#define BOOST_URL_DETAIL_PRINT_HPP
|
||||
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace boost {
|
||||
namespace urls {
|
||||
namespace detail {
|
||||
|
||||
struct segments_iter_impl
|
||||
struct BOOST_SYMBOL_VISIBLE segments_iter_impl
|
||||
: private parts_base
|
||||
{
|
||||
path_ref ref; // parent path data the iterator aliases
|
||||
@@ -56,11 +56,9 @@ public:
|
||||
|
||||
void update() noexcept;
|
||||
|
||||
BOOST_URL_DECL
|
||||
void
|
||||
increment() noexcept;
|
||||
|
||||
BOOST_URL_DECL
|
||||
void
|
||||
decrement() noexcept;
|
||||
|
||||
@@ -89,4 +87,6 @@ public:
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#include <boost/url/detail/impl/segments_iter_impl.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2022 Vinnie Falco (vinnie.falco@gmail.com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -35,7 +36,7 @@ constexpr char const* const empty_c_str_ = "";
|
||||
// It stores the offsets and properties of
|
||||
// a URL string stored elsewhere and pointed
|
||||
// to by cs_.
|
||||
struct BOOST_URL_DECL url_impl : parts_base
|
||||
struct BOOST_SYMBOL_VISIBLE url_impl : parts_base
|
||||
{
|
||||
using size_type = std::uint32_t;
|
||||
|
||||
@@ -64,46 +65,40 @@ struct BOOST_URL_DECL url_impl : parts_base
|
||||
|
||||
from from_ = from::string;
|
||||
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
url_impl(
|
||||
from b) noexcept
|
||||
: from_(b)
|
||||
{
|
||||
}
|
||||
|
||||
// in url_view.ipp
|
||||
url_view construct() const noexcept;
|
||||
BOOST_URL_CXX20_CONSTEXPR std::size_t len(int, int) const noexcept;
|
||||
BOOST_URL_CXX20_CONSTEXPR std::size_t len(int) const noexcept;
|
||||
BOOST_URL_CXX20_CONSTEXPR std::size_t offset(int) const noexcept;
|
||||
BOOST_URL_CXX20_CONSTEXPR core::string_view get(int) const noexcept;
|
||||
BOOST_URL_CXX20_CONSTEXPR core::string_view get(int, int) const noexcept;
|
||||
BOOST_URL_CXX20_CONSTEXPR pct_string_view pct_get(int) const noexcept;
|
||||
BOOST_URL_CXX20_CONSTEXPR pct_string_view pct_get(int, int) const noexcept;
|
||||
BOOST_URL_CXX20_CONSTEXPR void set_size(int, std::size_t) noexcept;
|
||||
BOOST_URL_CXX20_CONSTEXPR void split(int, std::size_t) noexcept;
|
||||
BOOST_URL_CXX20_CONSTEXPR void adjust_right(int first, int last, std::size_t n) noexcept;
|
||||
BOOST_URL_CXX20_CONSTEXPR void adjust_left(int first, int last, std::size_t n) noexcept;
|
||||
BOOST_URL_CXX20_CONSTEXPR void collapse(int, int, std::size_t) noexcept;
|
||||
|
||||
// in authority_view.ipp
|
||||
authority_view
|
||||
construct_authority() const noexcept;
|
||||
|
||||
std::size_t len(int, int) const noexcept;
|
||||
std::size_t len(int) const noexcept;
|
||||
std::size_t offset(int) const noexcept;
|
||||
core::string_view get(int) const noexcept;
|
||||
core::string_view get(int, int) const noexcept;
|
||||
pct_string_view pct_get(int) const noexcept;
|
||||
pct_string_view pct_get(int, int) const noexcept;
|
||||
void set_size(int, std::size_t) noexcept;
|
||||
void split(int, std::size_t) noexcept;
|
||||
void adjust_right(int first, int last, std::size_t n) noexcept;
|
||||
void adjust_left(int first, int last, std::size_t n) noexcept;
|
||||
void collapse(int, int, std::size_t) noexcept;
|
||||
|
||||
void apply_scheme(core::string_view) noexcept;
|
||||
void apply_userinfo(pct_string_view const&,
|
||||
BOOST_URL_CXX20_CONSTEXPR void apply_scheme(core::string_view) noexcept;
|
||||
BOOST_URL_CXX20_CONSTEXPR void apply_userinfo(pct_string_view const&,
|
||||
pct_string_view const*) noexcept;
|
||||
void apply_host(host_type, pct_string_view,
|
||||
BOOST_URL_CXX20_CONSTEXPR void apply_host(host_type, pct_string_view,
|
||||
unsigned char const*) noexcept;
|
||||
void apply_port(core::string_view, unsigned short) noexcept;
|
||||
void apply_authority(authority_view const&) noexcept;
|
||||
void apply_path(pct_string_view, std::size_t) noexcept;
|
||||
void apply_query(pct_string_view, std::size_t) noexcept;
|
||||
void apply_frag(pct_string_view) noexcept;
|
||||
BOOST_URL_CXX20_CONSTEXPR void apply_port(core::string_view, unsigned short) noexcept;
|
||||
BOOST_URL_CXX20_CONSTEXPR void apply_authority(url_impl const&) noexcept;
|
||||
BOOST_URL_CXX20_CONSTEXPR void apply_path(pct_string_view, std::size_t) noexcept;
|
||||
BOOST_URL_CXX20_CONSTEXPR void apply_query(pct_string_view, std::size_t) noexcept;
|
||||
BOOST_URL_CXX20_CONSTEXPR void apply_frag(pct_string_view) noexcept;
|
||||
};
|
||||
|
||||
// url_impl stores 32-bit sizes; centralize narrowing with checks.
|
||||
inline
|
||||
BOOST_URL_CXX14_CONSTEXPR_OR_INLINE
|
||||
url_impl::size_type
|
||||
to_size_type(std::size_t n) noexcept
|
||||
{
|
||||
@@ -112,7 +107,7 @@ to_size_type(std::size_t n) noexcept
|
||||
return static_cast<url_impl::size_type>(n);
|
||||
}
|
||||
|
||||
inline
|
||||
BOOST_URL_CXX14_CONSTEXPR_OR_INLINE
|
||||
url_impl::size_type
|
||||
to_size_type(std::ptrdiff_t n) noexcept
|
||||
{
|
||||
@@ -125,7 +120,11 @@ to_size_type(std::ptrdiff_t n) noexcept
|
||||
|
||||
// this allows a path to come from a
|
||||
// url_impl or a separate core::string_view
|
||||
class path_ref
|
||||
//
|
||||
// Header-only and BOOST_SYMBOL_VISIBLE since all
|
||||
// members are inline. Containing classes must also be
|
||||
// BOOST_SYMBOL_VISIBLE to avoid C4251 on MSVC.
|
||||
class BOOST_SYMBOL_VISIBLE path_ref
|
||||
: private parts_base
|
||||
{
|
||||
url_impl const* impl_ = nullptr;
|
||||
@@ -135,7 +134,7 @@ class path_ref
|
||||
std::size_t dn_ = 0;
|
||||
|
||||
public:
|
||||
path_ref() = default;
|
||||
path_ref() noexcept = default;
|
||||
path_ref(url_impl const& impl) noexcept;
|
||||
path_ref(core::string_view,
|
||||
std::size_t, std::size_t) noexcept;
|
||||
@@ -172,7 +171,7 @@ public:
|
||||
// This class represents a query string, which
|
||||
// can originate from either an url_impl object
|
||||
// or an independent core::string_view.
|
||||
class BOOST_URL_DECL query_ref
|
||||
class BOOST_SYMBOL_VISIBLE query_ref
|
||||
: private parts_base
|
||||
{
|
||||
url_impl const* impl_ = nullptr;
|
||||
@@ -222,4 +221,6 @@ public:
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#include <boost/url/detail/impl/url_impl.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2021 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -142,6 +143,7 @@ concept CharSet =
|
||||
@ref find_if_not.
|
||||
*/
|
||||
template<BOOST_URL_CONSTRAINT(CharSet) CS>
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
char const*
|
||||
find_if(
|
||||
char const* const first,
|
||||
@@ -180,6 +182,7 @@ find_if(
|
||||
@ref find_if_not.
|
||||
*/
|
||||
template<BOOST_URL_CONSTRAINT(CharSet) CS>
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
char const*
|
||||
find_if_not(
|
||||
char const* const first,
|
||||
@@ -213,6 +216,7 @@ struct charset_ref
|
||||
return cs_(ch);
|
||||
}
|
||||
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
char const*
|
||||
find_if(
|
||||
char const* first,
|
||||
@@ -222,6 +226,7 @@ struct charset_ref
|
||||
first, last, cs_);
|
||||
}
|
||||
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
char const*
|
||||
find_if_not(
|
||||
char const* first,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -21,7 +22,7 @@ struct dec_octet_rule_t
|
||||
{
|
||||
using value_type = unsigned char;
|
||||
|
||||
BOOST_URL_DECL
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
auto
|
||||
parse(
|
||||
char const*& it,
|
||||
@@ -70,4 +71,6 @@ constexpr implementation_defined::dec_octet_rule_t dec_octet_rule{};
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#include <boost/url/grammar/impl/dec_octet_rule.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -32,7 +33,7 @@ struct ch_delim_rule
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_URL_DECL
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
system::result<value_type>
|
||||
parse(
|
||||
char const*& it,
|
||||
@@ -178,4 +179,6 @@ delim_rule(
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#include <boost/url/grammar/impl/delim_rule.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -10,6 +11,7 @@
|
||||
#ifndef BOOST_URL_GRAMMAR_DETAIL_CHARSET_HPP
|
||||
#define BOOST_URL_GRAMMAR_DETAIL_CHARSET_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/core/bit.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
@@ -60,6 +62,7 @@ struct has_find_if_not<T, void_t<
|
||||
};
|
||||
|
||||
template<class Pred>
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
char const*
|
||||
find_if(
|
||||
char const* first,
|
||||
@@ -77,6 +80,7 @@ find_if(
|
||||
}
|
||||
|
||||
template<class Pred>
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
char const*
|
||||
find_if(
|
||||
char const* first,
|
||||
@@ -84,11 +88,17 @@ find_if(
|
||||
Pred const& pred,
|
||||
std::true_type) noexcept
|
||||
{
|
||||
#if defined(BOOST_URL_HAS_BUILTIN_IS_CONSTANT_EVALUATED)
|
||||
if (__builtin_is_constant_evaluated())
|
||||
return find_if(first, last, pred,
|
||||
std::false_type{});
|
||||
#endif
|
||||
return pred.find_if(
|
||||
first, last);
|
||||
}
|
||||
|
||||
template<class Pred>
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
char const*
|
||||
find_if_not(
|
||||
char const* first,
|
||||
@@ -106,6 +116,7 @@ find_if_not(
|
||||
}
|
||||
|
||||
template<class Pred>
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
char const*
|
||||
find_if_not(
|
||||
char const* first,
|
||||
@@ -113,6 +124,11 @@ find_if_not(
|
||||
Pred const& pred,
|
||||
std::true_type) noexcept
|
||||
{
|
||||
#if defined(BOOST_URL_HAS_BUILTIN_IS_CONSTANT_EVALUATED)
|
||||
if (__builtin_is_constant_evaluated())
|
||||
return find_if_not(first, last, pred,
|
||||
std::false_type{});
|
||||
#endif
|
||||
return pred.find_if_not(
|
||||
first, last);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -7,10 +8,11 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_GRAMMAR_IMPL_DEC_OCTET_RULE_HPP
|
||||
#define BOOST_URL_GRAMMAR_IMPL_DEC_OCTET_RULE_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/grammar/charset.hpp>
|
||||
#include <boost/url/grammar/dec_octet_rule.hpp>
|
||||
#include <boost/url/grammar/digit_chars.hpp>
|
||||
#include <boost/url/grammar/error.hpp>
|
||||
|
||||
@@ -18,6 +20,8 @@ namespace boost {
|
||||
namespace urls {
|
||||
namespace grammar {
|
||||
namespace implementation_defined {
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
auto
|
||||
dec_octet_rule_t::
|
||||
parse(
|
||||
@@ -29,13 +33,13 @@ parse(
|
||||
if(it == end)
|
||||
{
|
||||
// end
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::mismatch);
|
||||
}
|
||||
if(! digit_chars(*it))
|
||||
{
|
||||
// expected DIGIT
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::mismatch);
|
||||
}
|
||||
unsigned v = *it - '0';
|
||||
@@ -49,7 +53,7 @@ parse(
|
||||
if(v == 0)
|
||||
{
|
||||
// leading '0'
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::invalid);
|
||||
}
|
||||
v = (10 * v) + *it - '0';
|
||||
@@ -63,14 +67,14 @@ parse(
|
||||
if(v > 25)
|
||||
{
|
||||
// integer overflow
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::invalid);
|
||||
}
|
||||
v = (10 * v) + *it - '0';
|
||||
if(v > 255)
|
||||
{
|
||||
// integer overflow
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::invalid);
|
||||
}
|
||||
++it;
|
||||
@@ -78,14 +82,16 @@ parse(
|
||||
digit_chars(*it))
|
||||
{
|
||||
// integer overflow
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::invalid);
|
||||
}
|
||||
return static_cast<
|
||||
value_type>(v);
|
||||
}
|
||||
|
||||
} // implementation_defined
|
||||
} // grammar
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -7,15 +8,16 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_GRAMMAR_IMPL_DELIM_RULE_HPP
|
||||
#define BOOST_URL_GRAMMAR_IMPL_DELIM_RULE_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/grammar/delim_rule.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
namespace grammar {
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
auto
|
||||
implementation_defined::ch_delim_rule::
|
||||
parse(
|
||||
@@ -26,20 +28,21 @@ parse(
|
||||
if(it == end)
|
||||
{
|
||||
// end
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::need_more);
|
||||
}
|
||||
if(*it != ch_)
|
||||
{
|
||||
// wrong character
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::mismatch);
|
||||
}
|
||||
return core::string_view{
|
||||
it++, 1 };
|
||||
};
|
||||
}
|
||||
|
||||
} // grammar
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -39,23 +39,41 @@ struct BOOST_SYMBOL_VISIBLE
|
||||
error_cat_type
|
||||
: system::error_category
|
||||
{
|
||||
BOOST_URL_DECL
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
const char* name(
|
||||
) const noexcept override;
|
||||
) const noexcept override
|
||||
{
|
||||
return "boost.url.grammar";
|
||||
}
|
||||
|
||||
BOOST_URL_DECL
|
||||
std::string message(
|
||||
int) const override;
|
||||
int code) const override
|
||||
{
|
||||
return message(code, nullptr, 0);
|
||||
}
|
||||
|
||||
BOOST_URL_DECL
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
char const* message(
|
||||
int, char*, std::size_t
|
||||
) const noexcept override;
|
||||
int code,
|
||||
char*,
|
||||
std::size_t) const noexcept override
|
||||
{
|
||||
switch(static_cast<error>(code))
|
||||
{
|
||||
default:
|
||||
case error::need_more: return "need more";
|
||||
case error::mismatch: return "mismatch";
|
||||
case error::invalid: return "invalid";
|
||||
case error::end_of_range: return "end of range";
|
||||
case error::leftover: return "leftover";
|
||||
case error::out_of_range: return "out of range";
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_URL_DECL
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
system::error_condition
|
||||
default_error_condition(
|
||||
int code) const noexcept override;
|
||||
int ev) const noexcept override;
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR error_cat_type() noexcept
|
||||
: error_category(0x0536e50a30f9e9f2)
|
||||
@@ -67,18 +85,32 @@ struct BOOST_SYMBOL_VISIBLE
|
||||
condition_cat_type
|
||||
: system::error_category
|
||||
{
|
||||
BOOST_URL_DECL
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
const char* name(
|
||||
) const noexcept override;
|
||||
) const noexcept override
|
||||
{
|
||||
return "boost.url.grammar";
|
||||
}
|
||||
|
||||
BOOST_URL_DECL
|
||||
std::string message(
|
||||
int) const override;
|
||||
int code) const override
|
||||
{
|
||||
return message(code, nullptr, 0);
|
||||
}
|
||||
|
||||
BOOST_URL_DECL
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
char const* message(
|
||||
int, char*, std::size_t
|
||||
) const noexcept override;
|
||||
int code,
|
||||
char*,
|
||||
std::size_t) const noexcept override
|
||||
{
|
||||
switch(static_cast<condition>(code))
|
||||
{
|
||||
default:
|
||||
case condition::fatal:
|
||||
return "fatal condition";
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR condition_cat_type()
|
||||
: error_category(0x0536e50a30f9e9f2)
|
||||
@@ -86,15 +118,18 @@ struct BOOST_SYMBOL_VISIBLE
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_URL_DECL extern
|
||||
error_cat_type error_cat;
|
||||
|
||||
BOOST_URL_DECL extern
|
||||
condition_cat_type condition_cat;
|
||||
#if defined(BOOST_URL_HAS_CXX20_CONSTEXPR)
|
||||
inline constexpr error_cat_type error_cat{};
|
||||
inline constexpr condition_cat_type condition_cat{};
|
||||
#else
|
||||
BOOST_URL_DECL extern error_cat_type error_cat;
|
||||
BOOST_URL_DECL extern condition_cat_type condition_cat;
|
||||
#endif
|
||||
|
||||
} // detail
|
||||
|
||||
inline
|
||||
BOOST_SYSTEM_CONSTEXPR
|
||||
system::error_code
|
||||
make_error_code(
|
||||
error ev) noexcept
|
||||
@@ -106,6 +141,7 @@ make_error_code(
|
||||
}
|
||||
|
||||
inline
|
||||
BOOST_SYSTEM_CONSTEXPR
|
||||
system::error_condition
|
||||
make_error_condition(
|
||||
condition c) noexcept
|
||||
@@ -116,6 +152,22 @@ make_error_condition(
|
||||
detail::condition_cat};
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
system::error_condition
|
||||
detail::error_cat_type::
|
||||
default_error_condition(
|
||||
int ev) const noexcept
|
||||
{
|
||||
switch(static_cast<error>(ev))
|
||||
{
|
||||
case error::invalid:
|
||||
case error::out_of_range:
|
||||
return condition::fatal;
|
||||
default:
|
||||
return {ev, *this};
|
||||
}
|
||||
}
|
||||
|
||||
} // grammar
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
//
|
||||
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
|
||||
// Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -7,10 +8,11 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_GRAMMAR_IMPL_LITERAL_RULE_HPP
|
||||
#define BOOST_URL_GRAMMAR_IMPL_LITERAL_RULE_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/grammar/error.hpp>
|
||||
#include <boost/url/grammar/literal_rule.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstring>
|
||||
|
||||
@@ -18,6 +20,7 @@ namespace boost {
|
||||
namespace urls {
|
||||
namespace grammar {
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
auto
|
||||
literal_rule::
|
||||
parse(
|
||||
@@ -36,7 +39,7 @@ parse(
|
||||
it, s_, n_) != 0)
|
||||
{
|
||||
// non-match
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::mismatch);
|
||||
}
|
||||
it += n_;
|
||||
@@ -50,15 +53,15 @@ parse(
|
||||
it, s_, n) != 0)
|
||||
{
|
||||
// non-match
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::mismatch);
|
||||
}
|
||||
// prefix matches
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::need_more);
|
||||
}
|
||||
// end
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::need_more);
|
||||
}
|
||||
|
||||
@@ -66,3 +69,4 @@ parse(
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -19,6 +20,7 @@ namespace grammar {
|
||||
|
||||
namespace implementation_defined {
|
||||
template<class R>
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
auto
|
||||
not_empty_rule_t<R>::
|
||||
parse(
|
||||
@@ -29,7 +31,7 @@ parse(
|
||||
if(it == end)
|
||||
{
|
||||
// empty
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::mismatch);
|
||||
}
|
||||
auto const it0 = it;
|
||||
@@ -42,7 +44,7 @@ parse(
|
||||
if(it == it0)
|
||||
{
|
||||
// empty
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::mismatch);
|
||||
}
|
||||
// value
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -17,6 +18,7 @@ namespace urls {
|
||||
namespace grammar {
|
||||
|
||||
template<class R>
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
auto
|
||||
implementation_defined::optional_rule_t<R>::
|
||||
parse(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -18,7 +19,7 @@ namespace urls {
|
||||
namespace grammar {
|
||||
|
||||
template<BOOST_URL_CONSTRAINT(Rule) R>
|
||||
BOOST_URL_NO_INLINE
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
auto
|
||||
parse(
|
||||
char const*& it,
|
||||
@@ -37,7 +38,7 @@ parse(
|
||||
}
|
||||
|
||||
template<BOOST_URL_CONSTRAINT(Rule) R>
|
||||
BOOST_URL_NO_INLINE
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
auto
|
||||
parse(
|
||||
core::string_view s,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -741,6 +742,7 @@ range(
|
||||
//------------------------------------------------
|
||||
|
||||
template<class R>
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
auto
|
||||
implementation_defined::range_rule_t<R>::
|
||||
parse(
|
||||
@@ -765,7 +767,7 @@ parse(
|
||||
if(n < N_)
|
||||
{
|
||||
// too few
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::mismatch);
|
||||
}
|
||||
// good
|
||||
@@ -791,14 +793,14 @@ parse(
|
||||
if(n >= M_)
|
||||
{
|
||||
// too many
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::mismatch);
|
||||
}
|
||||
}
|
||||
if(n < N_)
|
||||
{
|
||||
// too few
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::mismatch);
|
||||
}
|
||||
// good
|
||||
@@ -810,6 +812,7 @@ parse(
|
||||
//------------------------------------------------
|
||||
|
||||
template<class R0, class R1>
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
auto
|
||||
implementation_defined::range_rule_t<R0, R1>::
|
||||
parse(
|
||||
@@ -833,7 +836,7 @@ parse(
|
||||
}
|
||||
if(n < N_)
|
||||
{
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::mismatch);
|
||||
}
|
||||
return range<T>(
|
||||
@@ -858,14 +861,14 @@ parse(
|
||||
if(n >= M_)
|
||||
{
|
||||
// too many
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::mismatch);
|
||||
}
|
||||
}
|
||||
if(n < N_)
|
||||
{
|
||||
// too few
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::mismatch);
|
||||
}
|
||||
// good
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -17,6 +18,7 @@ namespace urls {
|
||||
namespace grammar {
|
||||
|
||||
template<class CharSet>
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
auto
|
||||
implementation_defined::token_rule_t<CharSet>::
|
||||
parse(
|
||||
@@ -28,14 +30,14 @@ parse(
|
||||
auto const it0 = it;
|
||||
if(it == end)
|
||||
{
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::need_more);
|
||||
}
|
||||
auto const& cs = this->get();
|
||||
it = grammar::find_if_not(it, end, cs);
|
||||
if(it != it0)
|
||||
return core::string_view(it0, it - it0);
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::mismatch);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2022 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -48,6 +49,7 @@ struct parse_sequence
|
||||
R const& rn;
|
||||
V vn;
|
||||
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
explicit
|
||||
parse_sequence(
|
||||
R const& rn_) noexcept
|
||||
@@ -57,6 +59,7 @@ struct parse_sequence
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
void
|
||||
apply(
|
||||
char const*&,
|
||||
@@ -69,6 +72,7 @@ struct parse_sequence
|
||||
template<
|
||||
std::size_t Ir,
|
||||
std::size_t Iv>
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
void
|
||||
apply(
|
||||
char const*& it,
|
||||
@@ -93,6 +97,7 @@ struct parse_sequence
|
||||
template<
|
||||
std::size_t Ir,
|
||||
std::size_t Iv>
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
void
|
||||
apply(
|
||||
char const*& it,
|
||||
@@ -117,6 +122,7 @@ struct parse_sequence
|
||||
template<
|
||||
std::size_t Ir = 0,
|
||||
std::size_t Iv = 0>
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
typename std::enable_if<
|
||||
Ir < 1 + sizeof...(Rn)>::type
|
||||
apply(
|
||||
@@ -132,6 +138,7 @@ struct parse_sequence
|
||||
struct deref
|
||||
{
|
||||
template<class R>
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
auto
|
||||
operator()(R const& r) const ->
|
||||
decltype(*r)
|
||||
@@ -140,6 +147,7 @@ struct parse_sequence
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
auto
|
||||
make_result() noexcept ->
|
||||
system::result<typename implementation_defined::tuple_rule_t<
|
||||
@@ -176,6 +184,7 @@ struct parse_sequence<false, R0, Rn...>
|
||||
R const& rn;
|
||||
V v;
|
||||
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
explicit
|
||||
parse_sequence(
|
||||
R const& rn_) noexcept
|
||||
@@ -184,6 +193,7 @@ struct parse_sequence<false, R0, Rn...>
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
void
|
||||
apply(
|
||||
char const*&,
|
||||
@@ -196,7 +206,7 @@ struct parse_sequence<false, R0, Rn...>
|
||||
template<
|
||||
std::size_t Ir,
|
||||
std::size_t Iv>
|
||||
BOOST_URL_NO_INLINE
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
void
|
||||
apply(
|
||||
char const*& it,
|
||||
@@ -221,6 +231,7 @@ struct parse_sequence<false, R0, Rn...>
|
||||
template<
|
||||
std::size_t Ir,
|
||||
std::size_t Iv>
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
void
|
||||
apply(
|
||||
char const*& it,
|
||||
@@ -241,6 +252,7 @@ struct parse_sequence<false, R0, Rn...>
|
||||
template<
|
||||
std::size_t Ir = 0,
|
||||
std::size_t Iv = 0>
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
typename std::enable_if<
|
||||
Ir < 1 + sizeof...(Rn)>::type
|
||||
apply(
|
||||
@@ -253,6 +265,7 @@ struct parse_sequence<false, R0, Rn...>
|
||||
apply(it, end, ir, iv, is_void<Ir>{});
|
||||
}
|
||||
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
V
|
||||
make_result() noexcept
|
||||
{
|
||||
@@ -265,6 +278,7 @@ struct parse_sequence<false, R0, Rn...>
|
||||
template<
|
||||
class R0,
|
||||
class... Rn>
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
auto
|
||||
implementation_defined::tuple_rule_t<R0, Rn...>::
|
||||
parse(
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace urls {
|
||||
namespace grammar {
|
||||
|
||||
template<class U>
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
auto
|
||||
unsigned_rule<U>::
|
||||
parse(
|
||||
@@ -30,7 +31,7 @@ parse(
|
||||
if(it == end)
|
||||
{
|
||||
// end
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::mismatch);
|
||||
}
|
||||
if(*it == '0')
|
||||
@@ -42,20 +43,20 @@ parse(
|
||||
return U(0);
|
||||
}
|
||||
// bad leading zero
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::invalid);
|
||||
}
|
||||
if(! digit_chars(*it))
|
||||
{
|
||||
// expected digit
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::mismatch);
|
||||
}
|
||||
static constexpr U Digits10 =
|
||||
constexpr U Digits10 =
|
||||
std::numeric_limits<
|
||||
U>::digits10;
|
||||
static constexpr U ten = 10;
|
||||
char const* safe_end;
|
||||
constexpr U ten = 10;
|
||||
char const* safe_end = nullptr;
|
||||
if(static_cast<std::size_t>(
|
||||
end - it) >= Digits10)
|
||||
safe_end = it + Digits10;
|
||||
@@ -73,19 +74,19 @@ parse(
|
||||
if( it != end &&
|
||||
digit_chars(*it))
|
||||
{
|
||||
static constexpr U Max = (
|
||||
constexpr U Max = (
|
||||
std::numeric_limits<
|
||||
U>::max)();
|
||||
static constexpr
|
||||
constexpr
|
||||
auto div = (Max / ten);
|
||||
static constexpr
|
||||
constexpr
|
||||
char rem = (Max % ten);
|
||||
char const dig = *it - '0';
|
||||
if( u > div || (
|
||||
u == div && dig > rem))
|
||||
{
|
||||
// integer overflow
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::invalid);
|
||||
}
|
||||
u = u * ten + dig;
|
||||
@@ -94,7 +95,7 @@ parse(
|
||||
digit_chars(*it))
|
||||
{
|
||||
// integer overflow
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::invalid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -27,6 +28,7 @@ template<
|
||||
class R0,
|
||||
class... Rn,
|
||||
std::size_t I>
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
auto
|
||||
parse_variant(
|
||||
char const*&,
|
||||
@@ -41,7 +43,7 @@ parse_variant(
|
||||
typename Rn::value_type...>>
|
||||
{
|
||||
// no match
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
error::mismatch);
|
||||
}
|
||||
|
||||
@@ -49,6 +51,7 @@ template<
|
||||
class R0,
|
||||
class... Rn,
|
||||
std::size_t I>
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
auto
|
||||
parse_variant(
|
||||
char const*& it,
|
||||
@@ -83,6 +86,7 @@ parse_variant(
|
||||
} // detail
|
||||
|
||||
template<class R0, class... Rn>
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
auto
|
||||
implementation_defined::variant_rule_t<R0, Rn...>::
|
||||
parse(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -68,7 +69,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_URL_DECL
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
system::result<value_type>
|
||||
parse(
|
||||
char const*& it,
|
||||
@@ -79,4 +80,6 @@ public:
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#include <boost/url/grammar/impl/literal_rule.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -25,6 +26,7 @@ struct not_empty_rule_t
|
||||
using value_type =
|
||||
typename R::value_type;
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
auto
|
||||
parse(
|
||||
char const*& it,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -30,6 +31,7 @@ struct optional_rule_t
|
||||
using value_type = boost::optional<
|
||||
typename Rule::value_type>;
|
||||
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
system::result<value_type>
|
||||
parse(
|
||||
char const*& it,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -35,6 +36,7 @@ namespace grammar {
|
||||
otherwise an error.
|
||||
*/
|
||||
template<BOOST_URL_CONSTRAINT(Rule) R>
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
system::result<typename R::value_type>
|
||||
parse(
|
||||
char const*& it,
|
||||
@@ -56,6 +58,7 @@ parse(
|
||||
otherwise an error.
|
||||
*/
|
||||
template<BOOST_URL_CONSTRAINT(Rule) R>
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
system::result<typename R::value_type>
|
||||
parse(
|
||||
core::string_view s,
|
||||
|
||||
@@ -424,6 +424,7 @@ struct range_rule_t<R>
|
||||
using value_type =
|
||||
range<typename R::value_type>;
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
system::result<value_type>
|
||||
parse(
|
||||
char const*& it,
|
||||
@@ -543,6 +544,7 @@ struct range_rule_t
|
||||
using value_type =
|
||||
range<typename R0::value_type>;
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
system::result<value_type>
|
||||
parse(
|
||||
char const*& it,
|
||||
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
|
||||
@return A string view with the same contents
|
||||
*/
|
||||
operator
|
||||
constexpr operator
|
||||
core::string_view() const noexcept
|
||||
{
|
||||
return s_;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -32,6 +33,7 @@ struct token_rule_t
|
||||
is_charset<CharSet>::value,
|
||||
"CharSet requirements not met");
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
auto
|
||||
parse(
|
||||
char const*& it,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -56,6 +57,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
system::result<value_type>
|
||||
parse(
|
||||
char const*& it,
|
||||
@@ -155,6 +157,7 @@ struct squelch_rule_t
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
system::result<value_type>
|
||||
parse(
|
||||
char const*& it,
|
||||
|
||||
@@ -60,6 +60,7 @@ struct unsigned_rule
|
||||
|
||||
using value_type = Unsigned;
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
auto
|
||||
parse(
|
||||
char const*& it,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -30,6 +31,7 @@ public:
|
||||
typename R0::value_type,
|
||||
typename Rn::value_type...>;
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
auto
|
||||
parse(
|
||||
char const*& it,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
|
||||
// Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -7,15 +8,13 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_IMPL_AUTHORITY_VIEW_HPP
|
||||
#define BOOST_URL_IMPL_AUTHORITY_VIEW_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/authority_view.hpp>
|
||||
#include "detail/normalize.hpp"
|
||||
#include <boost/url/detail/memcpy.hpp>
|
||||
#include <boost/url/grammar/parse.hpp>
|
||||
#include <boost/url/rfc/authority_rule.hpp>
|
||||
#include <boost/url/rfc/pct_encoded_rule.hpp>
|
||||
#include <array>
|
||||
#include <ostream>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
@@ -24,37 +23,35 @@ namespace urls {
|
||||
|
||||
namespace detail {
|
||||
|
||||
authority_view
|
||||
url_impl::
|
||||
construct_authority() const noexcept
|
||||
{
|
||||
return authority_view(*this);
|
||||
}
|
||||
// Forward declarations for normalize functions
|
||||
// defined in src/detail/normalize.cpp
|
||||
BOOST_URL_DECL
|
||||
int
|
||||
compare_encoded(
|
||||
core::string_view lhs,
|
||||
core::string_view rhs) noexcept;
|
||||
|
||||
BOOST_URL_DECL
|
||||
int
|
||||
ci_compare_encoded(
|
||||
core::string_view lhs,
|
||||
core::string_view rhs) noexcept;
|
||||
|
||||
BOOST_URL_DECL
|
||||
int
|
||||
compare(
|
||||
core::string_view lhs,
|
||||
core::string_view rhs) noexcept;
|
||||
|
||||
} // detail
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
authority_view::
|
||||
authority_view(
|
||||
detail::url_impl const& u) noexcept
|
||||
: u_(u)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Special Members
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
authority_view::
|
||||
~authority_view()
|
||||
{
|
||||
}
|
||||
|
||||
authority_view::
|
||||
authority_view() noexcept
|
||||
: u_(from::authority)
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
authority_view::
|
||||
authority_view(
|
||||
core::string_view s)
|
||||
@@ -64,21 +61,13 @@ authority_view(
|
||||
{
|
||||
}
|
||||
|
||||
authority_view::
|
||||
authority_view(
|
||||
authority_view const&) noexcept = default;
|
||||
|
||||
authority_view&
|
||||
authority_view::
|
||||
operator=(
|
||||
authority_view const&) noexcept = default;
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// Userinfo
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
bool
|
||||
authority_view::
|
||||
has_userinfo() const noexcept
|
||||
@@ -91,6 +80,7 @@ has_userinfo() const noexcept
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
pct_string_view
|
||||
authority_view::
|
||||
encoded_userinfo() const noexcept
|
||||
@@ -110,6 +100,7 @@ encoded_userinfo() const noexcept
|
||||
has_password());
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
pct_string_view
|
||||
authority_view::
|
||||
encoded_user() const noexcept
|
||||
@@ -121,6 +112,7 @@ encoded_user() const noexcept
|
||||
u_.decoded_[id_user]);
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
bool
|
||||
authority_view::
|
||||
has_password() const noexcept
|
||||
@@ -139,6 +131,7 @@ has_password() const noexcept
|
||||
return false;
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
pct_string_view
|
||||
authority_view::
|
||||
encoded_password() const noexcept
|
||||
@@ -185,6 +178,7 @@ std::string host_name() // return decoded name or ""
|
||||
pct_string_view encoded_host_name() // return encoded host name or ""
|
||||
*/
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
pct_string_view
|
||||
authority_view::
|
||||
encoded_host() const noexcept
|
||||
@@ -192,6 +186,7 @@ encoded_host() const noexcept
|
||||
return u_.pct_get(id_host);
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
pct_string_view
|
||||
authority_view::
|
||||
encoded_host_address() const noexcept
|
||||
@@ -239,7 +234,8 @@ encoded_host_address() const noexcept
|
||||
s.data(), s.size(), n);
|
||||
}
|
||||
|
||||
urls::ipv4_address
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
ipv4_address
|
||||
authority_view::
|
||||
host_ipv4_address() const noexcept
|
||||
{
|
||||
@@ -247,12 +243,13 @@ host_ipv4_address() const noexcept
|
||||
urls::host_type::ipv4)
|
||||
return {};
|
||||
ipv4_address::bytes_type b{{}};
|
||||
std::memcpy(
|
||||
detail::memcpy(
|
||||
&b[0], &u_.ip_addr_[0], b.size());
|
||||
return urls::ipv4_address(b);
|
||||
}
|
||||
|
||||
urls::ipv6_address
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
ipv6_address
|
||||
authority_view::
|
||||
host_ipv6_address() const noexcept
|
||||
{
|
||||
@@ -260,11 +257,12 @@ host_ipv6_address() const noexcept
|
||||
urls::host_type::ipv6)
|
||||
return {};
|
||||
ipv6_address::bytes_type b{{}};
|
||||
std::memcpy(
|
||||
detail::memcpy(
|
||||
&b[0], &u_.ip_addr_[0], b.size());
|
||||
return urls::ipv6_address(b);
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
core::string_view
|
||||
authority_view::
|
||||
host_ipvfuture() const noexcept
|
||||
@@ -280,6 +278,7 @@ host_ipvfuture() const noexcept
|
||||
return s;
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
pct_string_view
|
||||
authority_view::
|
||||
encoded_host_name() const noexcept
|
||||
@@ -296,6 +295,7 @@ encoded_host_name() const noexcept
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
bool
|
||||
authority_view::
|
||||
has_port() const noexcept
|
||||
@@ -308,6 +308,7 @@ has_port() const noexcept
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
core::string_view
|
||||
authority_view::
|
||||
port() const noexcept
|
||||
@@ -319,6 +320,7 @@ port() const noexcept
|
||||
return s.substr(1);
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
std::uint16_t
|
||||
authority_view::
|
||||
port_number() const noexcept
|
||||
@@ -329,24 +331,12 @@ port_number() const noexcept
|
||||
return u_.port_number_;
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
pct_string_view
|
||||
authority_view::
|
||||
encoded_host_and_port() const noexcept
|
||||
{
|
||||
return u_.get(id_host, id_end);
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// Parsing
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
system::result<authority_view>
|
||||
parse_authority(
|
||||
core::string_view s) noexcept
|
||||
{
|
||||
return grammar::parse(s, authority_rule);
|
||||
return u_.pct_get(id_host, id_end);
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
@@ -355,6 +345,7 @@ parse_authority(
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
int
|
||||
authority_view::
|
||||
compare(const authority_view& other) const noexcept
|
||||
@@ -410,6 +401,17 @@ compare(const authority_view& other) const noexcept
|
||||
return 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
system::result<authority_view>
|
||||
parse_authority(
|
||||
core::string_view s) noexcept
|
||||
{
|
||||
return grammar::parse(s, authority_rule);
|
||||
}
|
||||
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef BOOST_URL_IMPL_ENCODE_HPP
|
||||
#define BOOST_URL_IMPL_ENCODE_HPP
|
||||
|
||||
#include "boost/url/grammar/token_rule.hpp"
|
||||
#include <boost/url/grammar/token_rule.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/core/detail/static_assert.hpp>
|
||||
#include <boost/url/detail/encode.hpp>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#ifndef BOOST_URL_IMPL_ERROR_HPP
|
||||
#define BOOST_URL_IMPL_ERROR_HPP
|
||||
|
||||
#include <boost/url/grammar/error.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost {
|
||||
@@ -32,23 +33,44 @@ struct BOOST_SYMBOL_VISIBLE
|
||||
error_cat_type
|
||||
: system::error_category
|
||||
{
|
||||
BOOST_URL_DECL
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
const char* name(
|
||||
) const noexcept override;
|
||||
) const noexcept override
|
||||
{
|
||||
return "boost.url";
|
||||
}
|
||||
|
||||
BOOST_URL_DECL
|
||||
std::string message(
|
||||
int) const override;
|
||||
int code) const override
|
||||
{
|
||||
return message(code, nullptr, 0);
|
||||
}
|
||||
|
||||
BOOST_URL_DECL
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
char const* message(
|
||||
int, char*, std::size_t
|
||||
) const noexcept override;
|
||||
int code,
|
||||
char*,
|
||||
std::size_t) const noexcept override
|
||||
{
|
||||
switch(static_cast<error>(code))
|
||||
{
|
||||
case error::success: return "success";
|
||||
case error::illegal_null: return "illegal null";
|
||||
case error::illegal_reserved_char: return "illegal reserved char";
|
||||
case error::non_canonical: return "non canonical";
|
||||
case error::bad_pct_hexdig: return "bad hexdig in pct-encoding";
|
||||
case error::incomplete_encoding: return "incomplete pct-encoding";
|
||||
case error::missing_pct_hexdig: return "missing hexdig in pct-encoding";
|
||||
case error::no_space: return "no space";
|
||||
case error::not_a_base: return "not a base";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
BOOST_URL_DECL
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
system::error_condition
|
||||
default_error_condition(
|
||||
int code) const noexcept override;
|
||||
int ev) const noexcept override;
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR error_cat_type() noexcept
|
||||
: error_category(0xbc15399d7a4ce829)
|
||||
@@ -56,8 +78,11 @@ struct BOOST_SYMBOL_VISIBLE
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_URL_DECL extern
|
||||
error_cat_type error_cat;
|
||||
#if defined(BOOST_URL_HAS_CXX20_CONSTEXPR)
|
||||
inline constexpr error_cat_type error_cat{};
|
||||
#else
|
||||
BOOST_URL_DECL extern error_cat_type error_cat;
|
||||
#endif
|
||||
|
||||
} // detail
|
||||
|
||||
@@ -73,6 +98,23 @@ make_error_code(
|
||||
detail::error_cat};
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
system::error_condition
|
||||
detail::error_cat_type::
|
||||
default_error_condition(
|
||||
int ev) const noexcept
|
||||
{
|
||||
switch(static_cast<error>(ev))
|
||||
{
|
||||
default:
|
||||
return {ev, *this};
|
||||
case error::bad_pct_hexdig:
|
||||
case error::incomplete_encoding:
|
||||
case error::missing_pct_hexdig:
|
||||
return grammar::condition::fatal;
|
||||
}
|
||||
}
|
||||
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
|
||||
@@ -12,14 +12,18 @@
|
||||
#define BOOST_URL_IMPL_PARAMS_BASE_HPP
|
||||
|
||||
#include <boost/url/detail/params_iter_impl.hpp>
|
||||
#include <boost/url/decode_view.hpp>
|
||||
#include <boost/url/grammar/ci_string.hpp>
|
||||
#include <iterator>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
class BOOST_URL_DECL params_base::iterator
|
||||
class BOOST_SYMBOL_VISIBLE params_base::iterator
|
||||
{
|
||||
detail::params_iter_impl it_;
|
||||
bool space_as_plus_ = true;
|
||||
@@ -110,6 +114,309 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
params_base::
|
||||
iterator::
|
||||
iterator(
|
||||
detail::query_ref const& ref,
|
||||
encoding_opts opt) noexcept
|
||||
: it_(ref)
|
||||
, space_as_plus_(opt.space_as_plus)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
params_base::
|
||||
iterator::
|
||||
iterator(
|
||||
detail::query_ref const& ref,
|
||||
encoding_opts opt,
|
||||
int) noexcept
|
||||
: it_(ref, 0)
|
||||
, space_as_plus_(opt.space_as_plus)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
auto
|
||||
params_base::
|
||||
iterator::
|
||||
operator*() const ->
|
||||
reference
|
||||
|
||||
{
|
||||
encoding_opts opt;
|
||||
opt.space_as_plus =
|
||||
space_as_plus_;
|
||||
param_pct_view p =
|
||||
it_.dereference();
|
||||
return reference(
|
||||
p.key.decode(opt),
|
||||
p.value.decode(opt),
|
||||
p.has_value);
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// params_base
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
params_base::
|
||||
params_base() noexcept
|
||||
// space_as_plus = true
|
||||
: opt_(true, false, false)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
params_base::
|
||||
contains(
|
||||
core::string_view key,
|
||||
ignore_case_param ic) const noexcept
|
||||
{
|
||||
return find(
|
||||
begin(),key, ic) != end();
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_base::
|
||||
find(
|
||||
core::string_view key,
|
||||
ignore_case_param ic) const noexcept ->
|
||||
iterator
|
||||
{
|
||||
return iterator(
|
||||
find_impl(
|
||||
begin().it_, key, ic),
|
||||
opt_);
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_base::
|
||||
find(
|
||||
iterator it,
|
||||
core::string_view key,
|
||||
ignore_case_param ic) const noexcept ->
|
||||
iterator
|
||||
{
|
||||
return iterator(
|
||||
find_impl(
|
||||
it.it_, key, ic),
|
||||
opt_);
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_base::
|
||||
find_last(
|
||||
core::string_view key,
|
||||
ignore_case_param ic) const noexcept ->
|
||||
iterator
|
||||
{
|
||||
return iterator(
|
||||
find_last_impl(
|
||||
end().it_, key, ic),
|
||||
opt_);
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_base::
|
||||
find_last(
|
||||
iterator it,
|
||||
core::string_view key,
|
||||
ignore_case_param ic) const noexcept ->
|
||||
iterator
|
||||
{
|
||||
return iterator(
|
||||
find_last_impl(
|
||||
it.it_, key, ic),
|
||||
opt_);
|
||||
}
|
||||
|
||||
inline
|
||||
params_base::
|
||||
params_base(
|
||||
detail::query_ref const& ref,
|
||||
encoding_opts opt) noexcept
|
||||
: ref_(ref)
|
||||
, opt_(opt)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
params_base::
|
||||
buffer() const noexcept
|
||||
{
|
||||
return ref_.buffer();
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
params_base::
|
||||
empty() const noexcept
|
||||
{
|
||||
return ref_.nparam() == 0;
|
||||
}
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
params_base::
|
||||
size() const noexcept
|
||||
{
|
||||
return ref_.nparam();
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_base::
|
||||
begin() const noexcept ->
|
||||
iterator
|
||||
{
|
||||
return iterator(ref_, opt_);
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_base::
|
||||
end() const noexcept ->
|
||||
iterator
|
||||
{
|
||||
return {ref_, opt_, 0};
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
params_base::
|
||||
count(
|
||||
core::string_view key,
|
||||
ignore_case_param ic) const noexcept
|
||||
{
|
||||
std::size_t n = 0;
|
||||
auto it = find(key, ic);
|
||||
auto const end_ = end();
|
||||
while(it != end_)
|
||||
{
|
||||
++n;
|
||||
++it;
|
||||
it = find(it, key, ic);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
inline
|
||||
std::string
|
||||
params_base::
|
||||
get_or(
|
||||
core::string_view key,
|
||||
core::string_view value,
|
||||
ignore_case_param ic) const
|
||||
{
|
||||
auto it = find_impl(
|
||||
begin().it_, key, ic);
|
||||
detail::params_iter_impl end_(ref_, 0);
|
||||
if(it.equal(end_))
|
||||
return std::string(value);
|
||||
|
||||
param_pct_view const p = it.dereference();
|
||||
if(! p.has_value)
|
||||
return std::string();
|
||||
|
||||
auto opt = opt_;
|
||||
return p.value.decode(opt);
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// (implementation)
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
detail::params_iter_impl
|
||||
params_base::
|
||||
find_impl(
|
||||
detail::params_iter_impl it,
|
||||
core::string_view key,
|
||||
ignore_case_param ic) const noexcept
|
||||
{
|
||||
detail::params_iter_impl end_(ref_, 0);
|
||||
if(! ic)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
if(it.equal(end_))
|
||||
return it;
|
||||
if(*it.key() == key)
|
||||
return it;
|
||||
it.increment();
|
||||
}
|
||||
}
|
||||
for(;;)
|
||||
{
|
||||
if(it.equal(end_))
|
||||
return it;
|
||||
if( grammar::ci_is_equal(
|
||||
*it.key(), key))
|
||||
return it;
|
||||
it.increment();
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
detail::params_iter_impl
|
||||
params_base::
|
||||
find_last_impl(
|
||||
detail::params_iter_impl it,
|
||||
core::string_view key,
|
||||
ignore_case_param ic) const noexcept
|
||||
{
|
||||
detail::params_iter_impl begin_(ref_);
|
||||
if(! ic)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
if(it.equal(begin_))
|
||||
return { ref_, 0 };
|
||||
it.decrement();
|
||||
if(*it.key() == key)
|
||||
return it;
|
||||
}
|
||||
}
|
||||
for(;;)
|
||||
{
|
||||
if(it.equal(begin_))
|
||||
return { ref_, 0 };
|
||||
it.decrement();
|
||||
if(grammar::ci_is_equal(
|
||||
*it.key(), key))
|
||||
return it;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
std::ostream&
|
||||
operator<<(
|
||||
std::ostream& os,
|
||||
params_base const& qp)
|
||||
{
|
||||
os << qp.buffer();
|
||||
return os;
|
||||
}
|
||||
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#define BOOST_URL_IMPL_PARAMS_ENCODED_BASE_HPP
|
||||
|
||||
#include <boost/url/detail/params_iter_impl.hpp>
|
||||
#include <boost/url/grammar/ci_string.hpp>
|
||||
#include <ostream>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
@@ -201,6 +203,189 @@ find_last(
|
||||
it.it_, key, ic);
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
params_encoded_base::
|
||||
iterator::
|
||||
iterator(
|
||||
detail::query_ref const& ref) noexcept
|
||||
: it_(ref)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
params_encoded_base::
|
||||
iterator::
|
||||
iterator(
|
||||
detail::query_ref const& ref, int) noexcept
|
||||
: it_(ref, 0)
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// params_encoded_base
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
params_encoded_base::
|
||||
params_encoded_base(
|
||||
detail::query_ref const& ref) noexcept
|
||||
: ref_(ref)
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// Observers
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
params_encoded_base::
|
||||
buffer() const noexcept
|
||||
{
|
||||
return ref_.buffer();
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
params_encoded_base::
|
||||
empty() const noexcept
|
||||
{
|
||||
return ref_.nparam() == 0;
|
||||
}
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
params_encoded_base::
|
||||
size() const noexcept
|
||||
{
|
||||
return ref_.nparam();
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_encoded_base::
|
||||
begin() const noexcept ->
|
||||
iterator
|
||||
{
|
||||
return { ref_ };
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_encoded_base::
|
||||
end() const noexcept ->
|
||||
iterator
|
||||
{
|
||||
return { ref_, 0 };
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
params_encoded_base::
|
||||
count(
|
||||
pct_string_view key,
|
||||
ignore_case_param ic) const noexcept
|
||||
{
|
||||
std::size_t n = 0;
|
||||
auto it = find(key, ic);
|
||||
auto const end_ = end();
|
||||
while(it != end_)
|
||||
{
|
||||
++n;
|
||||
++it;
|
||||
it = find(it, key, ic);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// (implementation)
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
detail::params_iter_impl
|
||||
params_encoded_base::
|
||||
find_impl(
|
||||
detail::params_iter_impl it,
|
||||
pct_string_view key,
|
||||
ignore_case_param ic) const noexcept
|
||||
{
|
||||
detail::params_iter_impl end_(ref_, 0);
|
||||
if(! ic)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
if(it.equal(end_))
|
||||
return it;
|
||||
if(*it.key() == *key)
|
||||
return it;
|
||||
it.increment();
|
||||
}
|
||||
}
|
||||
for(;;)
|
||||
{
|
||||
if(it.equal(end_))
|
||||
return it;
|
||||
if( grammar::ci_is_equal(
|
||||
*it.key(), *key))
|
||||
return it;
|
||||
it.increment();
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
detail::params_iter_impl
|
||||
params_encoded_base::
|
||||
find_last_impl(
|
||||
detail::params_iter_impl it,
|
||||
pct_string_view key,
|
||||
ignore_case_param ic) const noexcept
|
||||
{
|
||||
detail::params_iter_impl begin_(ref_);
|
||||
if(! ic)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
if(it.equal(begin_))
|
||||
return { ref_, 0 };
|
||||
it.decrement();
|
||||
if(*it.key() == *key)
|
||||
return it;
|
||||
}
|
||||
}
|
||||
for(;;)
|
||||
{
|
||||
if(it.equal(begin_))
|
||||
return { ref_, 0 };
|
||||
it.decrement();
|
||||
if(grammar::ci_is_equal(
|
||||
*it.key(), *key))
|
||||
return it;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
std::ostream&
|
||||
operator<<(
|
||||
std::ostream& os,
|
||||
params_encoded_base const& qp)
|
||||
{
|
||||
os << qp.buffer();
|
||||
return os;
|
||||
}
|
||||
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
|
||||
@@ -11,18 +11,76 @@
|
||||
#ifndef BOOST_URL_IMPL_PARAMS_ENCODED_REF_HPP
|
||||
#define BOOST_URL_IMPL_PARAMS_ENCODED_REF_HPP
|
||||
|
||||
#include <boost/url/params_encoded_view.hpp>
|
||||
#include <boost/url/url_base.hpp>
|
||||
#include <boost/url/detail/except.hpp>
|
||||
#include <boost/url/grammar/ci_string.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// Special Members
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
params_encoded_ref::
|
||||
params_encoded_ref(
|
||||
url_base& u) noexcept
|
||||
: params_encoded_base(u.impl_)
|
||||
, u_(&u)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
params_encoded_ref&
|
||||
params_encoded_ref::
|
||||
operator=(
|
||||
params_encoded_ref const& other)
|
||||
{
|
||||
if (!ref_.alias_of( other.ref_ ))
|
||||
assign(other.begin(), other.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
params_encoded_ref&
|
||||
params_encoded_ref::
|
||||
operator=(std::initializer_list<
|
||||
param_pct_view> init)
|
||||
{
|
||||
assign(init.begin(), init.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
params_encoded_ref::
|
||||
operator
|
||||
params_encoded_view() const noexcept
|
||||
{
|
||||
return {ref_};
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// Modifiers
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
void
|
||||
params_encoded_ref::
|
||||
assign(
|
||||
std::initializer_list<
|
||||
param_pct_view> init)
|
||||
{
|
||||
assign(init.begin(), init.end());
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
params_encoded_ref::
|
||||
@@ -190,6 +248,182 @@ insert(
|
||||
first, last));
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_encoded_ref::
|
||||
insert(
|
||||
iterator before,
|
||||
param_pct_view const& p) ->
|
||||
iterator
|
||||
{
|
||||
return u_->edit_params(
|
||||
before.it_,
|
||||
before.it_,
|
||||
detail::param_encoded_iter(p));
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_encoded_ref::
|
||||
insert(
|
||||
iterator before,
|
||||
std::initializer_list<
|
||||
param_pct_view> init) ->
|
||||
iterator
|
||||
{
|
||||
return insert(
|
||||
before,
|
||||
init.begin(),
|
||||
init.end());
|
||||
}
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
params_encoded_ref::
|
||||
erase(
|
||||
pct_string_view key,
|
||||
ignore_case_param ic) noexcept
|
||||
{
|
||||
// end() can't be fully cached,
|
||||
// since erase invalidates it.
|
||||
iterator it;
|
||||
{
|
||||
auto const end_ = end();
|
||||
it = find_last(end_, key, ic);
|
||||
if(it == end_)
|
||||
return 0;
|
||||
}
|
||||
std::size_t n = 0;
|
||||
for(;;)
|
||||
{
|
||||
++n;
|
||||
// Use it->key instead of key,
|
||||
// to handle self-intersection
|
||||
auto prev = find_last(it, it->key, ic);
|
||||
if(prev == end())
|
||||
break;
|
||||
erase(it);
|
||||
it = prev;
|
||||
}
|
||||
erase(it);
|
||||
return n;
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_encoded_ref::
|
||||
replace(
|
||||
iterator pos,
|
||||
param_pct_view const& p) ->
|
||||
iterator
|
||||
{
|
||||
return u_->edit_params(
|
||||
pos.it_,
|
||||
std::next(pos).it_,
|
||||
detail::param_encoded_iter(p));
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_encoded_ref::
|
||||
replace(
|
||||
iterator from,
|
||||
iterator to,
|
||||
std::initializer_list<
|
||||
param_pct_view> init) ->
|
||||
iterator
|
||||
{
|
||||
return replace(
|
||||
from,
|
||||
to,
|
||||
init.begin(),
|
||||
init.end());
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_encoded_ref::
|
||||
unset(
|
||||
iterator pos) noexcept ->
|
||||
iterator
|
||||
{
|
||||
BOOST_ASSERT(pos.it_.nk > 0);
|
||||
pct_string_view s;
|
||||
return u_->edit_params(
|
||||
pos.it_, pos.it_.next(),
|
||||
detail::param_encoded_value_iter(
|
||||
pos.it_.nk - 1, s, false));
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_encoded_ref::
|
||||
set(
|
||||
iterator pos,
|
||||
pct_string_view value) ->
|
||||
iterator
|
||||
{
|
||||
BOOST_ASSERT(pos.it_.nk > 0);
|
||||
return u_->edit_params(
|
||||
pos.it_,
|
||||
pos.it_.next(),
|
||||
detail::param_encoded_value_iter(
|
||||
pos.it_.nk - 1, value, true));
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_encoded_ref::
|
||||
set(
|
||||
pct_string_view key,
|
||||
pct_string_view value,
|
||||
ignore_case_param ic) ->
|
||||
iterator
|
||||
{
|
||||
// VFALCO we can't cache end() here
|
||||
// because it is invalidated
|
||||
// every time we set or erase.
|
||||
auto it0 = find(key, ic);
|
||||
if(it0 == end())
|
||||
return append({key, value});
|
||||
it0 = set(it0, value);
|
||||
auto it = end();
|
||||
for(;;)
|
||||
{
|
||||
it = find_last(it, key, ic);
|
||||
if(it == it0)
|
||||
return it0;
|
||||
it = erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_encoded_ref::
|
||||
erase(
|
||||
iterator pos) noexcept ->
|
||||
iterator
|
||||
{
|
||||
return erase(
|
||||
pos,
|
||||
std::next(pos));
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_encoded_ref::
|
||||
erase(
|
||||
iterator first,
|
||||
iterator last) noexcept ->
|
||||
iterator
|
||||
{
|
||||
core::string_view s("", 0);
|
||||
return u_->edit_params(
|
||||
first.it_,
|
||||
last.it_,
|
||||
detail::query_string_iter(s));
|
||||
}
|
||||
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
|
||||
@@ -5,17 +5,16 @@
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Official repository: https://github.com/CPPAlliance/url
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/params_encoded_view.hpp>
|
||||
#include <boost/url/parse_query.hpp>
|
||||
#ifndef BOOST_URL_IMPL_PARAMS_ENCODED_VIEW_HPP
|
||||
#define BOOST_URL_IMPL_PARAMS_ENCODED_VIEW_HPP
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
|
||||
inline
|
||||
params_encoded_view::
|
||||
params_encoded_view(
|
||||
detail::query_ref const& ref) noexcept
|
||||
@@ -23,6 +22,7 @@ params_encoded_view(
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
params_encoded_view::
|
||||
params_encoded_view(
|
||||
core::string_view s)
|
||||
@@ -32,6 +32,7 @@ params_encoded_view(
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
params_encoded_view::
|
||||
operator
|
||||
params_view() const noexcept
|
||||
@@ -42,3 +43,4 @@ params_view() const noexcept
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -12,66 +12,17 @@
|
||||
#define BOOST_URL_IMPL_PARAMS_REF_HPP
|
||||
|
||||
#include <boost/url/params_view.hpp>
|
||||
#include <boost/url/url_base.hpp>
|
||||
#include <boost/url/detail/any_params_iter.hpp>
|
||||
#include <boost/url/detail/except.hpp>
|
||||
#include <boost/url/grammar/ci_string.hpp>
|
||||
#include <boost/url/grammar/recycled.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
|
||||
inline
|
||||
params_ref::
|
||||
params_ref(
|
||||
url_base& u,
|
||||
encoding_opts opt) noexcept
|
||||
: params_base(u.impl_, opt)
|
||||
, u_(&u)
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// Special Members
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
params_ref::
|
||||
params_ref(
|
||||
params_ref const& other,
|
||||
encoding_opts opt) noexcept
|
||||
: params_ref(*other.u_, opt)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_ref::
|
||||
operator=(std::initializer_list<
|
||||
param_view> init) ->
|
||||
params_ref&
|
||||
{
|
||||
assign(init);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// Modifiers
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
void
|
||||
params_ref::
|
||||
clear() noexcept
|
||||
{
|
||||
u_->remove_query();
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
template<class FwdIt>
|
||||
void
|
||||
params_ref::
|
||||
@@ -94,27 +45,6 @@ assign(FwdIt first, FwdIt last)
|
||||
FwdIt>::iterator_category{});
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_ref::
|
||||
append(
|
||||
param_view const& p) ->
|
||||
iterator
|
||||
{
|
||||
return insert(end(), p);
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_ref::
|
||||
append(
|
||||
std::initializer_list<
|
||||
param_view> init) ->
|
||||
iterator
|
||||
{
|
||||
return insert(end(), init);
|
||||
}
|
||||
|
||||
template<class FwdIt>
|
||||
auto
|
||||
params_ref::
|
||||
@@ -234,6 +164,294 @@ insert(
|
||||
opt_);
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// Special Members
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
params_ref::
|
||||
params_ref(
|
||||
url_base& u,
|
||||
encoding_opts opt) noexcept
|
||||
: params_base(u.impl_, opt)
|
||||
, u_(&u)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
params_ref::
|
||||
params_ref(
|
||||
params_ref const& other,
|
||||
encoding_opts opt) noexcept
|
||||
: params_base(other.u_->impl_, opt)
|
||||
, u_(other.u_)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_ref::
|
||||
operator=(params_ref const& other) ->
|
||||
params_ref&
|
||||
{
|
||||
if (!ref_.alias_of(other.ref_))
|
||||
assign(other.begin(), other.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_ref::
|
||||
operator=(std::initializer_list<
|
||||
param_view> init) ->
|
||||
params_ref&
|
||||
{
|
||||
assign(init);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
params_ref::
|
||||
operator
|
||||
params_view() const noexcept
|
||||
{
|
||||
return { ref_, opt_ };
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// Modifiers
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
void
|
||||
params_ref::
|
||||
clear() noexcept
|
||||
{
|
||||
u_->remove_query();
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
params_ref::
|
||||
assign(
|
||||
std::initializer_list<
|
||||
param_view> init)
|
||||
{
|
||||
assign(init.begin(), init.end());
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_ref::
|
||||
insert(
|
||||
iterator before,
|
||||
param_view const& p) ->
|
||||
iterator
|
||||
{
|
||||
return {
|
||||
u_->edit_params(
|
||||
before.it_,
|
||||
before.it_,
|
||||
detail::single_param_iter(p, opt_.space_as_plus)),
|
||||
opt_};
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_ref::
|
||||
insert(
|
||||
iterator before,
|
||||
std::initializer_list<
|
||||
param_view> init) ->
|
||||
iterator
|
||||
{
|
||||
return insert(
|
||||
before,
|
||||
init.begin(),
|
||||
init.end());
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_ref::
|
||||
append(
|
||||
param_view const& p) ->
|
||||
iterator
|
||||
{
|
||||
return insert(end(), p);
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_ref::
|
||||
append(
|
||||
std::initializer_list<
|
||||
param_view> init) ->
|
||||
iterator
|
||||
{
|
||||
return insert(end(), init);
|
||||
}
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
params_ref::
|
||||
erase(
|
||||
core::string_view key,
|
||||
ignore_case_param ic) noexcept
|
||||
{
|
||||
// end() can't be fully cached,
|
||||
// since erase invalidates it.
|
||||
iterator it;
|
||||
{
|
||||
auto const end_ = end();
|
||||
it = find_last(end_, key, ic);
|
||||
if(it == end_)
|
||||
return 0;
|
||||
}
|
||||
std::size_t n = 0;
|
||||
for(;;)
|
||||
{
|
||||
++n;
|
||||
// Use it->key instead of key,
|
||||
// to handle self-intersection
|
||||
auto prev = find_last(it, (*it).key, ic);
|
||||
if(prev == end())
|
||||
break;
|
||||
erase(it);
|
||||
it = prev;
|
||||
}
|
||||
erase(it);
|
||||
return n;
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_ref::
|
||||
replace(
|
||||
iterator pos,
|
||||
param_view const& p) ->
|
||||
iterator
|
||||
{
|
||||
return iterator(
|
||||
u_->edit_params(
|
||||
pos.it_,
|
||||
std::next(pos).it_,
|
||||
detail::single_param_iter(p, opt_.space_as_plus)),
|
||||
opt_);
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_ref::
|
||||
replace(
|
||||
iterator from,
|
||||
iterator to,
|
||||
std::initializer_list<
|
||||
param_view> init) ->
|
||||
iterator
|
||||
{
|
||||
return replace(
|
||||
from,
|
||||
to,
|
||||
init.begin(),
|
||||
init.end());
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_ref::
|
||||
unset(
|
||||
iterator pos) noexcept ->
|
||||
iterator
|
||||
{
|
||||
BOOST_ASSERT(pos.it_.nk > 0);
|
||||
core::string_view s;
|
||||
return iterator(
|
||||
u_->edit_params(
|
||||
pos.it_,
|
||||
pos.it_.next(),
|
||||
detail::param_value_iter(
|
||||
pos.it_.nk - 1, s, false)),
|
||||
opt_);
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_ref::
|
||||
set(
|
||||
iterator pos,
|
||||
core::string_view value) ->
|
||||
iterator
|
||||
{
|
||||
BOOST_ASSERT(pos.it_.nk > 0);
|
||||
return iterator(
|
||||
u_->edit_params(
|
||||
pos.it_,
|
||||
pos.it_.next(),
|
||||
detail::param_value_iter(
|
||||
pos.it_.nk - 1, value, true)),
|
||||
opt_);
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_ref::
|
||||
set(
|
||||
core::string_view key,
|
||||
core::string_view value,
|
||||
ignore_case_param ic) ->
|
||||
iterator
|
||||
{
|
||||
// VFALCO we can't cache end() here
|
||||
// because it is invalidated
|
||||
// every time we set or erase.
|
||||
auto it0 = find(key, ic);
|
||||
if(it0 == end())
|
||||
return append({key, value});
|
||||
it0 = set(it0, value);
|
||||
auto it = end();
|
||||
for(;;)
|
||||
{
|
||||
it = find_last(it, key, ic);
|
||||
if(it == it0)
|
||||
return it0;
|
||||
it = erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_ref::
|
||||
erase(
|
||||
iterator pos) noexcept ->
|
||||
iterator
|
||||
{
|
||||
return erase(
|
||||
pos,
|
||||
std::next(pos));
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
params_ref::
|
||||
erase(
|
||||
iterator first,
|
||||
iterator last) noexcept ->
|
||||
iterator
|
||||
{
|
||||
core::string_view s("", 0);
|
||||
return iterator(
|
||||
u_->edit_params(
|
||||
first.it_,
|
||||
last.it_,
|
||||
detail::query_string_iter(s)),
|
||||
opt_);
|
||||
}
|
||||
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
|
||||
@@ -5,17 +5,16 @@
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Official repository: https://github.com/CPPAlliance/url
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/params_view.hpp>
|
||||
#include <boost/url/parse_query.hpp>
|
||||
#ifndef BOOST_URL_IMPL_PARAMS_VIEW_HPP
|
||||
#define BOOST_URL_IMPL_PARAMS_VIEW_HPP
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
|
||||
inline
|
||||
params_view::
|
||||
params_view(
|
||||
detail::query_ref const& ref,
|
||||
@@ -26,6 +25,7 @@ params_view(
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
params_view::
|
||||
params_view(
|
||||
params_view const& other,
|
||||
@@ -34,6 +34,7 @@ params_view(
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
params_view::
|
||||
params_view(
|
||||
core::string_view s)
|
||||
@@ -44,6 +45,7 @@ params_view(
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
params_view::
|
||||
params_view(
|
||||
core::string_view s,
|
||||
@@ -58,3 +60,4 @@ params_view(
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -8,19 +8,26 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_IMPL_PARSE_HPP
|
||||
#define BOOST_URL_IMPL_PARSE_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/parse.hpp>
|
||||
#include <boost/url/rfc/absolute_uri_rule.hpp>
|
||||
#include <boost/url/rfc/relative_ref_rule.hpp>
|
||||
#include <boost/url/rfc/uri_rule.hpp>
|
||||
#include <boost/url/rfc/uri_reference_rule.hpp>
|
||||
#include <boost/url/rfc/origin_form_rule.hpp>
|
||||
#include <boost/url/grammar/parse.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// parse functions
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
system::result<url_view>
|
||||
parse_absolute_uri(
|
||||
core::string_view s)
|
||||
@@ -29,6 +36,7 @@ parse_absolute_uri(
|
||||
s, absolute_uri_rule);
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
system::result<url_view>
|
||||
parse_origin_form(
|
||||
core::string_view s)
|
||||
@@ -37,6 +45,7 @@ parse_origin_form(
|
||||
s, origin_form_rule);
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
system::result<url_view>
|
||||
parse_relative_ref(
|
||||
core::string_view s)
|
||||
@@ -44,6 +53,8 @@ parse_relative_ref(
|
||||
return grammar::parse(
|
||||
s, relative_ref_rule);
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
system::result<url_view>
|
||||
parse_uri(
|
||||
core::string_view s)
|
||||
@@ -52,6 +63,7 @@ parse_uri(
|
||||
s, uri_rule);
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
system::result<url_view>
|
||||
parse_uri_reference(
|
||||
core::string_view s)
|
||||
@@ -63,3 +75,4 @@ parse_uri_reference(
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
|
||||
// Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -7,14 +8,17 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_IMPL_SCHEME_HPP
|
||||
#define BOOST_URL_IMPL_SCHEME_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/scheme.hpp>
|
||||
|
||||
#include <boost/url/grammar/ci_string.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
scheme
|
||||
string_to_scheme(
|
||||
core::string_view s) noexcept
|
||||
@@ -88,6 +92,7 @@ string_to_scheme(
|
||||
return scheme::unknown;
|
||||
}
|
||||
|
||||
inline
|
||||
core::string_view
|
||||
to_string(scheme s) noexcept
|
||||
{
|
||||
@@ -106,6 +111,7 @@ to_string(scheme s) noexcept
|
||||
return "<unknown>";
|
||||
}
|
||||
|
||||
inline
|
||||
std::uint16_t
|
||||
default_port(scheme s) noexcept
|
||||
{
|
||||
@@ -128,3 +134,4 @@ default_port(scheme s) noexcept
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -12,8 +12,10 @@
|
||||
#define BOOST_URL_IMPL_SEGMENTS_BASE_HPP
|
||||
|
||||
#include <boost/url/detail/segments_iter_impl.hpp>
|
||||
#include <boost/url/encoding_opts.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <iterator>
|
||||
#include <ostream>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
@@ -52,9 +54,13 @@ public:
|
||||
iterator& operator=(
|
||||
iterator const&) noexcept = default;
|
||||
|
||||
BOOST_URL_DECL
|
||||
reference
|
||||
operator*() const;
|
||||
operator*() const
|
||||
{
|
||||
encoding_opts opt;
|
||||
opt.space_as_plus = false;
|
||||
return it_.dereference().decode(opt);
|
||||
}
|
||||
|
||||
// the return value is too expensive
|
||||
pointer operator->() const = delete;
|
||||
@@ -106,6 +112,71 @@ public:
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
segments_base::
|
||||
iterator::
|
||||
iterator(
|
||||
detail::path_ref const& ref) noexcept
|
||||
: it_(ref)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
segments_base::
|
||||
iterator::
|
||||
iterator(
|
||||
detail::path_ref const& ref,
|
||||
int) noexcept
|
||||
: it_(ref, 0)
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// segments_base
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
segments_base::
|
||||
segments_base(
|
||||
detail::path_ref const& ref) noexcept
|
||||
: ref_(ref)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
segments_base::
|
||||
buffer() const noexcept
|
||||
{
|
||||
return ref_.buffer();
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
segments_base::
|
||||
is_absolute() const noexcept
|
||||
{
|
||||
return ref_.buffer().starts_with('/');
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
segments_base::
|
||||
empty() const noexcept
|
||||
{
|
||||
return ref_.nseg() == 0;
|
||||
}
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
segments_base::
|
||||
size() const noexcept
|
||||
{
|
||||
return ref_.nseg();
|
||||
}
|
||||
|
||||
inline
|
||||
std::string
|
||||
segments_base::
|
||||
@@ -124,6 +195,36 @@ back() const noexcept
|
||||
return *--end();
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
segments_base::
|
||||
begin() const noexcept ->
|
||||
iterator
|
||||
{
|
||||
return iterator(ref_);
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
segments_base::
|
||||
end() const noexcept ->
|
||||
iterator
|
||||
{
|
||||
return iterator(ref_, 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
std::ostream&
|
||||
operator<<(
|
||||
std::ostream& os,
|
||||
segments_base const& ps)
|
||||
{
|
||||
os << ps.buffer();
|
||||
return os;
|
||||
}
|
||||
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <boost/url/detail/segments_iter_impl.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <ostream>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
@@ -112,6 +113,77 @@ public:
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
segments_encoded_base::
|
||||
iterator::
|
||||
iterator(
|
||||
detail::path_ref const& ref) noexcept
|
||||
: it_(ref)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
segments_encoded_base::
|
||||
iterator::
|
||||
iterator(
|
||||
detail::path_ref const& ref,
|
||||
int) noexcept
|
||||
: it_(ref, 0)
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// segments_encoded_base
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
segments_encoded_base::
|
||||
segments_encoded_base(
|
||||
detail::path_ref const& ref) noexcept
|
||||
: ref_(ref)
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// Observers
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
segments_encoded_base::
|
||||
buffer() const noexcept
|
||||
{
|
||||
return ref_.buffer();
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
segments_encoded_base::
|
||||
is_absolute() const noexcept
|
||||
{
|
||||
return ref_.buffer().starts_with('/');
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
segments_encoded_base::
|
||||
empty() const noexcept
|
||||
{
|
||||
return ref_.nseg() == 0;
|
||||
}
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
segments_encoded_base::
|
||||
size() const noexcept
|
||||
{
|
||||
return ref_.nseg();
|
||||
}
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
segments_encoded_base::
|
||||
@@ -130,6 +202,36 @@ back() const noexcept
|
||||
return *--end();
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
segments_encoded_base::
|
||||
begin() const noexcept ->
|
||||
iterator
|
||||
{
|
||||
return iterator(ref_);
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
segments_encoded_base::
|
||||
end() const noexcept ->
|
||||
iterator
|
||||
{
|
||||
return iterator(ref_, 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
std::ostream&
|
||||
operator<<(
|
||||
std::ostream& os,
|
||||
segments_encoded_base const& ps)
|
||||
{
|
||||
os << ps.buffer();
|
||||
return os;
|
||||
}
|
||||
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/detail/segments_iter_impl.hpp>
|
||||
#include <boost/url/detail/any_segments_iter.hpp>
|
||||
#include <boost/url/detail/path.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost {
|
||||
@@ -25,14 +26,6 @@ namespace urls {
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
void
|
||||
segments_encoded_ref::
|
||||
clear() noexcept
|
||||
{
|
||||
erase(begin(), end());
|
||||
}
|
||||
|
||||
template<class FwdIt>
|
||||
void
|
||||
segments_encoded_ref::
|
||||
@@ -87,16 +80,6 @@ insert(
|
||||
FwdIt>::iterator_category{});
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
segments_encoded_ref::
|
||||
erase(
|
||||
iterator pos) noexcept ->
|
||||
iterator
|
||||
{
|
||||
return erase(pos, std::next(pos));
|
||||
}
|
||||
|
||||
template<class FwdIt>
|
||||
auto
|
||||
segments_encoded_ref::
|
||||
@@ -128,25 +111,6 @@ replace(
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
void
|
||||
segments_encoded_ref::
|
||||
push_back(
|
||||
pct_string_view s)
|
||||
{
|
||||
insert(end(), s);
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
segments_encoded_ref::
|
||||
pop_back() noexcept
|
||||
{
|
||||
erase(std::prev(end()));
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
template<class FwdIt>
|
||||
auto
|
||||
segments_encoded_ref::
|
||||
@@ -164,6 +128,203 @@ insert(
|
||||
first, last));
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// Special Members
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
segments_encoded_ref::
|
||||
segments_encoded_ref(
|
||||
url_base& u) noexcept
|
||||
: segments_encoded_base(
|
||||
detail::path_ref(u.impl_))
|
||||
, u_(&u)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
segments_encoded_ref::
|
||||
operator
|
||||
segments_encoded_view() const noexcept
|
||||
{
|
||||
return segments_encoded_view(ref_);
|
||||
}
|
||||
|
||||
inline
|
||||
segments_encoded_ref&
|
||||
segments_encoded_ref::
|
||||
operator=(
|
||||
segments_encoded_ref const& other)
|
||||
{
|
||||
if (!ref_.alias_of(other.ref_))
|
||||
assign(other.begin(), other.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
segments_encoded_ref&
|
||||
segments_encoded_ref::
|
||||
operator=(
|
||||
segments_encoded_view const& other)
|
||||
{
|
||||
assign(other.begin(), other.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
segments_encoded_ref&
|
||||
segments_encoded_ref::
|
||||
operator=(std::initializer_list<
|
||||
pct_string_view> init)
|
||||
{
|
||||
assign(init.begin(), init.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// Modifiers
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
void
|
||||
segments_encoded_ref::
|
||||
clear() noexcept
|
||||
{
|
||||
erase(begin(), end());
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
segments_encoded_ref::
|
||||
assign(
|
||||
std::initializer_list<
|
||||
pct_string_view> init)
|
||||
{
|
||||
assign(init.begin(), init.end());
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
segments_encoded_ref::
|
||||
insert(
|
||||
iterator before,
|
||||
pct_string_view s) ->
|
||||
iterator
|
||||
{
|
||||
return u_->edit_segments(
|
||||
before.it_,
|
||||
before.it_,
|
||||
detail::segment_encoded_iter(s));
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
segments_encoded_ref::
|
||||
insert(
|
||||
iterator before,
|
||||
std::initializer_list<
|
||||
pct_string_view> init) ->
|
||||
iterator
|
||||
{
|
||||
return insert(
|
||||
before,
|
||||
init.begin(),
|
||||
init.end());
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
segments_encoded_ref::
|
||||
erase(
|
||||
iterator first,
|
||||
iterator last) noexcept ->
|
||||
iterator
|
||||
{
|
||||
core::string_view s;
|
||||
return u_->edit_segments(
|
||||
first.it_,
|
||||
last.it_,
|
||||
detail::make_segments_encoded_iter(
|
||||
&s, &s));
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
segments_encoded_ref::
|
||||
replace(
|
||||
iterator pos,
|
||||
pct_string_view s) ->
|
||||
iterator
|
||||
{
|
||||
return u_->edit_segments(
|
||||
pos.it_,
|
||||
std::next(pos).it_,
|
||||
detail::segment_encoded_iter(s));
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
segments_encoded_ref::
|
||||
replace(
|
||||
iterator from,
|
||||
iterator to,
|
||||
pct_string_view s) ->
|
||||
iterator
|
||||
{
|
||||
return u_->edit_segments(
|
||||
from.it_,
|
||||
to.it_,
|
||||
detail::segment_encoded_iter(s));
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
segments_encoded_ref::
|
||||
replace(
|
||||
iterator from,
|
||||
iterator to,
|
||||
std::initializer_list<
|
||||
pct_string_view> init) ->
|
||||
iterator
|
||||
{
|
||||
return replace(
|
||||
from,
|
||||
to,
|
||||
init.begin(),
|
||||
init.end());
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
segments_encoded_ref::
|
||||
erase(
|
||||
iterator pos) noexcept ->
|
||||
iterator
|
||||
{
|
||||
return erase(pos, std::next(pos));
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
segments_encoded_ref::
|
||||
push_back(
|
||||
pct_string_view s)
|
||||
{
|
||||
insert(end(), s);
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
segments_encoded_ref::
|
||||
pop_back() noexcept
|
||||
{
|
||||
erase(std::prev(end()));
|
||||
}
|
||||
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
|
||||
@@ -8,15 +8,19 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_IMPL_SEGMENTS_ENCODED_VIEW_HPP
|
||||
#define BOOST_URL_IMPL_SEGMENTS_ENCODED_VIEW_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/detail/segments_range.hpp>
|
||||
#include <boost/url/segments_encoded_view.hpp>
|
||||
#include <boost/url/parse_path.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
|
||||
inline
|
||||
segments_encoded_view::
|
||||
segments_encoded_view() noexcept = default;
|
||||
|
||||
inline
|
||||
segments_encoded_view::
|
||||
segments_encoded_view(
|
||||
detail::path_ref const& ref) noexcept
|
||||
@@ -24,6 +28,7 @@ segments_encoded_view(
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
segments_encoded_view::
|
||||
segments_encoded_view(
|
||||
core::string_view s)
|
||||
@@ -33,12 +38,14 @@ segments_encoded_view(
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
segments_encoded_view::
|
||||
segments_encoded_view(iterator first, iterator last) noexcept
|
||||
: segments_encoded_base(detail::make_subref(first, last))
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
segments_encoded_view::
|
||||
operator
|
||||
segments_view() const noexcept
|
||||
@@ -49,3 +56,4 @@ segments_view() const noexcept
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/detail/any_segments_iter.hpp>
|
||||
#include <boost/url/detail/segments_iter_impl.hpp>
|
||||
#include <boost/url/detail/path.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost {
|
||||
@@ -25,14 +26,6 @@ namespace urls {
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
void
|
||||
segments_ref::
|
||||
clear() noexcept
|
||||
{
|
||||
erase(begin(), end());
|
||||
}
|
||||
|
||||
template<class FwdIt>
|
||||
void
|
||||
segments_ref::
|
||||
@@ -86,16 +79,6 @@ insert(
|
||||
FwdIt>::iterator_category{});
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
segments_ref::
|
||||
erase(
|
||||
iterator pos) noexcept ->
|
||||
iterator
|
||||
{
|
||||
return erase(pos, std::next(pos));
|
||||
}
|
||||
|
||||
template<class FwdIt>
|
||||
auto
|
||||
segments_ref::
|
||||
@@ -127,25 +110,6 @@ replace(
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
void
|
||||
segments_ref::
|
||||
push_back(
|
||||
core::string_view s)
|
||||
{
|
||||
insert(end(), s);
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
segments_ref::
|
||||
pop_back() noexcept
|
||||
{
|
||||
erase(std::prev(end()));
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
template<class FwdIt>
|
||||
auto
|
||||
segments_ref::
|
||||
@@ -163,6 +127,200 @@ insert(
|
||||
first, last));
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// Special Members
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
segments_ref::
|
||||
segments_ref(
|
||||
url_base& u) noexcept
|
||||
: segments_base(
|
||||
detail::path_ref(u.impl_))
|
||||
, u_(&u)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
segments_ref::
|
||||
operator
|
||||
segments_view() const noexcept
|
||||
{
|
||||
return segments_view(ref_);
|
||||
}
|
||||
|
||||
inline
|
||||
segments_ref&
|
||||
segments_ref::
|
||||
operator=(segments_ref const& other)
|
||||
{
|
||||
if (!ref_.alias_of(other.ref_))
|
||||
assign(other.begin(), other.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
segments_ref&
|
||||
segments_ref::
|
||||
operator=(segments_view const& other)
|
||||
{
|
||||
assign(other.begin(), other.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
segments_ref&
|
||||
segments_ref::
|
||||
operator=(std::initializer_list<
|
||||
core::string_view> init)
|
||||
{
|
||||
assign(init.begin(), init.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// Modifiers
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
void
|
||||
segments_ref::
|
||||
clear() noexcept
|
||||
{
|
||||
erase(begin(), end());
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
segments_ref::
|
||||
assign(std::initializer_list<
|
||||
core::string_view> init)
|
||||
{
|
||||
assign(init.begin(), init.end());
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
segments_ref::
|
||||
insert(
|
||||
iterator before,
|
||||
core::string_view s) ->
|
||||
iterator
|
||||
{
|
||||
return u_->edit_segments(
|
||||
before.it_,
|
||||
before.it_,
|
||||
detail::segment_iter(s));
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
segments_ref::
|
||||
insert(
|
||||
iterator before,
|
||||
std::initializer_list<
|
||||
core::string_view> init) ->
|
||||
iterator
|
||||
{
|
||||
return insert(
|
||||
before,
|
||||
init.begin(),
|
||||
init.end());
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
segments_ref::
|
||||
erase(
|
||||
iterator first,
|
||||
iterator last) noexcept ->
|
||||
iterator
|
||||
{
|
||||
core::string_view s;
|
||||
return u_->edit_segments(
|
||||
first.it_,
|
||||
last.it_,
|
||||
detail::make_segments_encoded_iter(
|
||||
&s, &s));
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
segments_ref::
|
||||
replace(
|
||||
iterator pos,
|
||||
core::string_view s) ->
|
||||
iterator
|
||||
{
|
||||
return u_->edit_segments(
|
||||
pos.it_,
|
||||
std::next(pos).it_,
|
||||
detail::segment_iter(s));
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
segments_ref::
|
||||
replace(
|
||||
iterator from,
|
||||
iterator to,
|
||||
core::string_view s) ->
|
||||
iterator
|
||||
{
|
||||
return u_->edit_segments(
|
||||
from.it_,
|
||||
to.it_,
|
||||
detail::segment_iter(s));
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
segments_ref::
|
||||
replace(
|
||||
iterator from,
|
||||
iterator to,
|
||||
std::initializer_list<
|
||||
core::string_view> init) ->
|
||||
iterator
|
||||
{
|
||||
return replace(
|
||||
from,
|
||||
to,
|
||||
init.begin(),
|
||||
init.end());
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
segments_ref::
|
||||
erase(
|
||||
iterator pos) noexcept ->
|
||||
iterator
|
||||
{
|
||||
return erase(pos, std::next(pos));
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
segments_ref::
|
||||
push_back(
|
||||
core::string_view s)
|
||||
{
|
||||
insert(end(), s);
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
segments_ref::
|
||||
pop_back() noexcept
|
||||
{
|
||||
erase(std::prev(end()));
|
||||
}
|
||||
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
|
||||
@@ -8,15 +8,19 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_IMPL_SEGMENTS_VIEW_HPP
|
||||
#define BOOST_URL_IMPL_SEGMENTS_VIEW_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/detail/segments_range.hpp>
|
||||
#include <boost/url/segments_view.hpp>
|
||||
#include <boost/url/parse_path.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
|
||||
inline
|
||||
segments_view::
|
||||
segments_view() noexcept = default;
|
||||
|
||||
inline
|
||||
segments_view::
|
||||
segments_view(
|
||||
detail::path_ref const& ref) noexcept
|
||||
@@ -24,6 +28,7 @@ segments_view(
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
segments_view::
|
||||
segments_view(
|
||||
core::string_view s)
|
||||
@@ -33,6 +38,7 @@ segments_view(
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
segments_view::
|
||||
segments_view(iterator first, iterator last) noexcept
|
||||
: segments_base(detail::make_subref(first, last))
|
||||
@@ -42,3 +48,4 @@ segments_view(iterator first, iterator last) noexcept
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -7,17 +7,16 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_IMPL_STATIC_URL_HPP
|
||||
#define BOOST_URL_IMPL_STATIC_URL_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/parse.hpp>
|
||||
#include <boost/url/static_url.hpp>
|
||||
#include <boost/url/url_view.hpp>
|
||||
#include <boost/url/detail/except.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
|
||||
inline
|
||||
static_url_base::
|
||||
static_url_base(
|
||||
char* buf,
|
||||
@@ -29,6 +28,7 @@ static_url_base(
|
||||
impl_.cs_ = s_;
|
||||
}
|
||||
|
||||
inline
|
||||
static_url_base::
|
||||
static_url_base(
|
||||
char* buf,
|
||||
@@ -40,6 +40,7 @@ static_url_base(
|
||||
).value(BOOST_URL_POS));
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
static_url_base::
|
||||
clear_impl() noexcept
|
||||
@@ -49,6 +50,7 @@ clear_impl() noexcept
|
||||
impl_.cs_ = s_;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
static_url_base::
|
||||
reserve_impl(
|
||||
@@ -63,6 +65,7 @@ reserve_impl(
|
||||
//----------------------------------------------------------
|
||||
|
||||
// LCOV_EXCL_START
|
||||
inline
|
||||
void
|
||||
static_url_base::
|
||||
cleanup(op_t&)
|
||||
@@ -88,3 +91,4 @@ cleanup(op_t&)
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -8,17 +8,19 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_IMPL_URL_HPP
|
||||
#define BOOST_URL_IMPL_URL_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/url.hpp>
|
||||
#include <boost/url/parse.hpp>
|
||||
#include <boost/url/detail/except.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstring>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
url::
|
||||
~url()
|
||||
{
|
||||
@@ -31,9 +33,11 @@ url::
|
||||
}
|
||||
|
||||
// construct empty
|
||||
inline
|
||||
url::
|
||||
url() noexcept = default;
|
||||
|
||||
inline
|
||||
url::
|
||||
url(core::string_view s)
|
||||
: url(parse_uri_reference(s
|
||||
@@ -41,6 +45,7 @@ url(core::string_view s)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
url::
|
||||
url(url&& u) noexcept
|
||||
: url_base(u.impl_)
|
||||
@@ -52,6 +57,7 @@ url(url&& u) noexcept
|
||||
u.impl_ = {from::url};
|
||||
}
|
||||
|
||||
inline
|
||||
url&
|
||||
url::
|
||||
operator=(url&& u) noexcept
|
||||
@@ -69,6 +75,7 @@ operator=(url&& u) noexcept
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
char*
|
||||
url::
|
||||
allocate(std::size_t n)
|
||||
@@ -78,6 +85,7 @@ allocate(std::size_t n)
|
||||
return s;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
url::
|
||||
deallocate(char* s)
|
||||
@@ -85,6 +93,7 @@ deallocate(char* s)
|
||||
delete[] s;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
url::
|
||||
clear_impl() noexcept
|
||||
@@ -102,6 +111,7 @@ clear_impl() noexcept
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
url::
|
||||
reserve_impl(
|
||||
@@ -138,6 +148,7 @@ reserve_impl(
|
||||
impl_.cs_ = s_;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
url::
|
||||
cleanup(
|
||||
@@ -149,6 +160,7 @@ cleanup(
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
void
|
||||
url::
|
||||
swap(url& other) noexcept
|
||||
@@ -158,13 +170,10 @@ swap(url& other) noexcept
|
||||
std::swap(s_, other.s_);
|
||||
std::swap(cap_, other.cap_);
|
||||
std::swap(impl_, other.impl_);
|
||||
std::swap(pi_, other.pi_);
|
||||
if (pi_ == &other.impl_)
|
||||
pi_ = &impl_;
|
||||
if (other.pi_ == &impl_)
|
||||
other.pi_ = &other.impl_;
|
||||
std::swap(external_impl_, other.external_impl_);
|
||||
}
|
||||
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -8,9 +8,9 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_IMPL_URL_BASE_HPP
|
||||
#define BOOST_URL_IMPL_URL_BASE_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/url_base.hpp>
|
||||
#include <boost/url/encode.hpp>
|
||||
#include <boost/url/error.hpp>
|
||||
#include <boost/url/host_type.hpp>
|
||||
@@ -21,22 +21,22 @@
|
||||
#include <boost/url/detail/decode.hpp>
|
||||
#include <boost/url/detail/encode.hpp>
|
||||
#include <boost/url/detail/except.hpp>
|
||||
#include "detail/normalize.hpp"
|
||||
#include "detail/path.hpp"
|
||||
#include "detail/print.hpp"
|
||||
#include <boost/url/detail/normalize.hpp>
|
||||
#include <boost/url/detail/path.hpp>
|
||||
#include <boost/url/detail/print.hpp>
|
||||
#include <boost/url/grammar/ci_string.hpp>
|
||||
#include <boost/url/rfc/authority_rule.hpp>
|
||||
#include <boost/url/rfc/query_rule.hpp>
|
||||
#include <boost/url/rfc/ipv6_address_rule.hpp>
|
||||
#include "rfc/detail/charsets.hpp"
|
||||
#include "rfc/detail/host_rule.hpp"
|
||||
#include "rfc/detail/ipvfuture_rule.hpp"
|
||||
#include "boost/url/rfc/detail/path_rules.hpp"
|
||||
#include "rfc/detail/port_rule.hpp"
|
||||
#include "rfc/detail/scheme_rule.hpp"
|
||||
#include "rfc/detail/userinfo_rule.hpp"
|
||||
#include <boost/url/rfc/detail/charsets.hpp>
|
||||
#include <boost/url/rfc/detail/host_rule.hpp>
|
||||
#include <boost/url/rfc/detail/ipvfuture_rule.hpp>
|
||||
#include <boost/url/rfc/detail/path_rules.hpp>
|
||||
#include <boost/url/rfc/detail/port_rule.hpp>
|
||||
#include <boost/url/rfc/detail/scheme_rule.hpp>
|
||||
#include <boost/url/rfc/detail/userinfo_rule.hpp>
|
||||
#include <boost/url/grammar/parse.hpp>
|
||||
#include "detail/move_chars.hpp"
|
||||
#include <boost/url/detail/move_chars.hpp>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
@@ -51,6 +51,7 @@ namespace urls {
|
||||
// where the user passes in strings that
|
||||
// come from inside the url buffer.
|
||||
|
||||
inline
|
||||
url_base::
|
||||
op_t::
|
||||
~op_t()
|
||||
@@ -60,6 +61,7 @@ op_t::
|
||||
u.check_invariants();
|
||||
}
|
||||
|
||||
inline
|
||||
url_base::
|
||||
op_t::
|
||||
op_t(
|
||||
@@ -73,6 +75,7 @@ op_t(
|
||||
u.check_invariants();
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
url_base::
|
||||
op_t::
|
||||
@@ -98,6 +101,7 @@ move(
|
||||
//------------------------------------------------
|
||||
|
||||
// construct reference
|
||||
inline
|
||||
url_base::
|
||||
url_base(
|
||||
detail::url_impl const& impl) noexcept
|
||||
@@ -105,6 +109,7 @@ url_base(
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
url_base::
|
||||
reserve_impl(std::size_t n)
|
||||
@@ -116,6 +121,7 @@ reserve_impl(std::size_t n)
|
||||
}
|
||||
|
||||
// make a copy of u
|
||||
inline
|
||||
void
|
||||
url_base::
|
||||
copy(url_view_base const& u)
|
||||
@@ -130,7 +136,7 @@ copy(url_view_base const& u)
|
||||
}
|
||||
reserve_impl(
|
||||
u.size(), op);
|
||||
impl_ = *u.pi_;
|
||||
impl_ = u.impl();
|
||||
impl_.cs_ = s_;
|
||||
impl_.from_ = {from::url};
|
||||
std::memcpy(s_,
|
||||
@@ -144,6 +150,7 @@ copy(url_view_base const& u)
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_scheme(core::string_view s)
|
||||
@@ -153,6 +160,7 @@ set_scheme(core::string_view s)
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_scheme_id(urls::scheme id)
|
||||
@@ -165,6 +173,7 @@ set_scheme_id(urls::scheme id)
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
remove_scheme()
|
||||
@@ -278,6 +287,7 @@ remove_scheme()
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_encoded_authority(
|
||||
@@ -301,13 +311,14 @@ set_encoded_authority(
|
||||
s.data(), s.size());
|
||||
if(need_slash)
|
||||
dest[n - 1] = '/';
|
||||
impl_.apply_authority(a);
|
||||
impl_.apply_authority(a.u_);
|
||||
if(need_slash)
|
||||
impl_.adjust_right(
|
||||
id_query, id_end, 1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
remove_authority()
|
||||
@@ -346,6 +357,7 @@ remove_authority()
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_userinfo(
|
||||
@@ -396,6 +408,7 @@ set_userinfo(
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_encoded_userinfo(
|
||||
@@ -451,6 +464,7 @@ set_encoded_userinfo(
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
remove_userinfo() noexcept
|
||||
@@ -469,6 +483,7 @@ remove_userinfo() noexcept
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_user(core::string_view s)
|
||||
@@ -489,6 +504,7 @@ set_user(core::string_view s)
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_encoded_user(
|
||||
@@ -513,6 +529,7 @@ set_encoded_user(
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_password(core::string_view s)
|
||||
@@ -533,6 +550,7 @@ set_password(core::string_view s)
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_encoded_password(
|
||||
@@ -556,6 +574,7 @@ set_encoded_password(
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
remove_password() noexcept
|
||||
@@ -607,6 +626,7 @@ set_encoded_host_name( pct_string_view ) // set name from encoded
|
||||
*/
|
||||
|
||||
// set host part from plain text
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_host(
|
||||
@@ -683,6 +703,7 @@ set_host(
|
||||
}
|
||||
|
||||
// set host part from encoded text
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_encoded_host(
|
||||
@@ -762,6 +783,7 @@ set_encoded_host(
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_host_address(
|
||||
@@ -831,6 +853,7 @@ set_host_address(
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_encoded_host_address(
|
||||
@@ -907,6 +930,7 @@ set_encoded_host_address(
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_host_ipv4(
|
||||
@@ -928,6 +952,7 @@ set_host_ipv4(
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_host_ipv6(
|
||||
@@ -937,6 +962,7 @@ set_host_ipv6(
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_zone_id(core::string_view s)
|
||||
@@ -945,6 +971,7 @@ set_zone_id(core::string_view s)
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_encoded_zone_id(pct_string_view s)
|
||||
@@ -953,6 +980,7 @@ set_encoded_zone_id(pct_string_view s)
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
url_base::
|
||||
set_host_ipv6_and_zone_id(
|
||||
@@ -991,6 +1019,7 @@ set_host_ipv6_and_zone_id(
|
||||
bytes.size());
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
url_base::
|
||||
set_host_ipv6_and_encoded_zone_id(
|
||||
@@ -1028,6 +1057,7 @@ set_host_ipv6_and_encoded_zone_id(
|
||||
bytes.size());
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_host_ipvfuture(
|
||||
@@ -1050,6 +1080,7 @@ set_host_ipvfuture(
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_host_name(
|
||||
@@ -1084,6 +1115,7 @@ set_host_name(
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_encoded_host_name(
|
||||
@@ -1120,6 +1152,7 @@ set_encoded_host_name(
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_port_number(
|
||||
@@ -1137,6 +1170,7 @@ set_port_number(
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_port(
|
||||
@@ -1157,6 +1191,7 @@ set_port(
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
remove_port() noexcept
|
||||
@@ -1173,6 +1208,7 @@ remove_port() noexcept
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
remove_origin()
|
||||
@@ -1189,6 +1225,7 @@ remove_origin()
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
bool
|
||||
url_base::
|
||||
set_path_absolute(
|
||||
@@ -1270,6 +1307,7 @@ set_path_absolute(
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_path(
|
||||
@@ -1389,6 +1427,7 @@ set_path(
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_encoded_path(
|
||||
@@ -1503,6 +1542,7 @@ set_encoded_path(
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
segments_ref
|
||||
url_base::
|
||||
segments() noexcept
|
||||
@@ -1510,6 +1550,7 @@ segments() noexcept
|
||||
return {*this};
|
||||
}
|
||||
|
||||
inline
|
||||
segments_encoded_ref
|
||||
url_base::
|
||||
encoded_segments() noexcept
|
||||
@@ -1523,6 +1564,7 @@ encoded_segments() noexcept
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_query(
|
||||
@@ -1535,6 +1577,7 @@ set_query(
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_encoded_query(
|
||||
@@ -1591,6 +1634,7 @@ set_encoded_query(
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
params_ref
|
||||
url_base::
|
||||
params() noexcept
|
||||
@@ -1601,6 +1645,7 @@ params() noexcept
|
||||
true, false, false});
|
||||
}
|
||||
|
||||
inline
|
||||
params_ref
|
||||
url_base::
|
||||
params(encoding_opts opt) noexcept
|
||||
@@ -1608,6 +1653,7 @@ params(encoding_opts opt) noexcept
|
||||
return {*this, opt};
|
||||
}
|
||||
|
||||
inline
|
||||
params_encoded_ref
|
||||
url_base::
|
||||
encoded_params() noexcept
|
||||
@@ -1615,6 +1661,7 @@ encoded_params() noexcept
|
||||
return {*this};
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_params(
|
||||
@@ -1625,6 +1672,7 @@ set_params(
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_encoded_params( std::initializer_list< param_pct_view > ps ) noexcept
|
||||
@@ -1633,6 +1681,7 @@ set_encoded_params( std::initializer_list< param_pct_view > ps ) noexcept
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
remove_query() noexcept
|
||||
@@ -1650,6 +1699,7 @@ remove_query() noexcept
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
remove_fragment() noexcept
|
||||
@@ -1660,6 +1710,7 @@ remove_fragment() noexcept
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_fragment(core::string_view s)
|
||||
@@ -1684,6 +1735,7 @@ set_fragment(core::string_view s)
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
set_encoded_fragment(
|
||||
@@ -1715,6 +1767,7 @@ set_encoded_fragment(
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
system::result<void>
|
||||
url_base::
|
||||
resolve(
|
||||
@@ -1906,6 +1959,7 @@ normalize_octets_impl(
|
||||
idx, allowed, detail::empty_chars, op);
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
normalize_scheme()
|
||||
@@ -1914,6 +1968,7 @@ normalize_scheme()
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
normalize_authority()
|
||||
@@ -1937,6 +1992,7 @@ normalize_authority()
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
normalize_path()
|
||||
@@ -2103,6 +2159,7 @@ normalize_path()
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
normalize_query()
|
||||
@@ -2116,6 +2173,7 @@ normalize_query()
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
normalize_fragment()
|
||||
@@ -2126,6 +2184,7 @@ normalize_fragment()
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
url_base&
|
||||
url_base::
|
||||
normalize()
|
||||
@@ -2144,11 +2203,11 @@ normalize()
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
void
|
||||
url_base::
|
||||
check_invariants() const noexcept
|
||||
{
|
||||
BOOST_ASSERT(pi_);
|
||||
BOOST_ASSERT(
|
||||
impl_.len(id_scheme) == 0 ||
|
||||
impl_.get(id_scheme).ends_with(':'));
|
||||
@@ -2185,6 +2244,7 @@ check_invariants() const noexcept
|
||||
BOOST_ASSERT(c_str()[size()] == '\0');
|
||||
}
|
||||
|
||||
inline
|
||||
char*
|
||||
url_base::
|
||||
resize_impl(
|
||||
@@ -2196,6 +2256,7 @@ resize_impl(
|
||||
id, id + 1, new_size, op);
|
||||
}
|
||||
|
||||
inline
|
||||
char*
|
||||
url_base::
|
||||
resize_impl(
|
||||
@@ -2231,6 +2292,7 @@ resize_impl(
|
||||
return s_ + impl_.offset(first);
|
||||
}
|
||||
|
||||
inline
|
||||
char*
|
||||
url_base::
|
||||
shrink_impl(
|
||||
@@ -2242,6 +2304,7 @@ shrink_impl(
|
||||
id, id + 1, new_size, op);
|
||||
}
|
||||
|
||||
inline
|
||||
char*
|
||||
url_base::
|
||||
shrink_impl(
|
||||
@@ -2273,6 +2336,7 @@ shrink_impl(
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
void
|
||||
url_base::
|
||||
set_scheme_impl(
|
||||
@@ -2329,6 +2393,7 @@ set_scheme_impl(
|
||||
check_invariants();
|
||||
}
|
||||
|
||||
inline
|
||||
char*
|
||||
url_base::
|
||||
set_user_impl(
|
||||
@@ -2365,6 +2430,7 @@ set_user_impl(
|
||||
return dest + 2;
|
||||
}
|
||||
|
||||
inline
|
||||
char*
|
||||
url_base::
|
||||
set_password_impl(
|
||||
@@ -2406,6 +2472,7 @@ set_password_impl(
|
||||
return dest + 3;
|
||||
}
|
||||
|
||||
inline
|
||||
char*
|
||||
url_base::
|
||||
set_userinfo_impl(
|
||||
@@ -2434,6 +2501,7 @@ set_userinfo_impl(
|
||||
return dest + 2;
|
||||
}
|
||||
|
||||
inline
|
||||
char*
|
||||
url_base::
|
||||
set_host_impl(
|
||||
@@ -2472,6 +2540,7 @@ set_host_impl(
|
||||
return dest;
|
||||
}
|
||||
|
||||
inline
|
||||
char*
|
||||
url_base::
|
||||
set_port_impl(
|
||||
@@ -2509,6 +2578,7 @@ set_port_impl(
|
||||
return dest + 3;
|
||||
}
|
||||
|
||||
inline
|
||||
char*
|
||||
url_base::
|
||||
set_path_impl(
|
||||
@@ -2526,6 +2596,7 @@ set_path_impl(
|
||||
|
||||
// return the first segment of the path.
|
||||
// this is needed for some algorithms.
|
||||
inline
|
||||
core::string_view
|
||||
url_base::
|
||||
first_segment() const noexcept
|
||||
@@ -2548,6 +2619,7 @@ first_segment() const noexcept
|
||||
return core::string_view(p0, p - p0);
|
||||
}
|
||||
|
||||
inline
|
||||
detail::segments_iter_impl
|
||||
url_base::
|
||||
edit_segments(
|
||||
@@ -2874,6 +2946,7 @@ edit_segments(
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
auto
|
||||
url_base::
|
||||
edit_params(
|
||||
@@ -3034,6 +3107,7 @@ edit_params(
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
void
|
||||
url_base::
|
||||
decoded_to_lower_impl(int id) noexcept
|
||||
@@ -3053,6 +3127,7 @@ decoded_to_lower_impl(int id) noexcept
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
url_base::
|
||||
to_lower_impl(int id) noexcept
|
||||
@@ -3069,3 +3144,5 @@ to_lower_impl(int id) noexcept
|
||||
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_IMPL_URL_VIEW_HPP
|
||||
#define BOOST_URL_IMPL_URL_VIEW_HPP
|
||||
|
||||
#include <boost/url/parse.hpp>
|
||||
#include <boost/url/detail/over_allocator.hpp>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// url_view
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
url_view::
|
||||
url_view(core::string_view s)
|
||||
: url_view(parse_uri_reference(s
|
||||
).value(BOOST_URL_POS))
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// url_view_base::persist
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
struct url_view_base::shared_impl
|
||||
: url_view
|
||||
{
|
||||
virtual
|
||||
~shared_impl()
|
||||
{
|
||||
}
|
||||
|
||||
shared_impl(
|
||||
url_view const& u) noexcept
|
||||
: url_view(u)
|
||||
{
|
||||
impl_.cs_ = reinterpret_cast<
|
||||
char const*>(this + 1);
|
||||
}
|
||||
};
|
||||
|
||||
inline
|
||||
std::shared_ptr<url_view const>
|
||||
url_view_base::
|
||||
persist() const
|
||||
{
|
||||
using T = shared_impl;
|
||||
using Alloc = std::allocator<char>;
|
||||
Alloc a;
|
||||
auto p = std::allocate_shared<T>(
|
||||
detail::over_allocator<T, Alloc>(
|
||||
size(), a), url_view(impl()));
|
||||
std::memcpy(
|
||||
reinterpret_cast<char*>(
|
||||
p.get() + 1), data(), size());
|
||||
return p;
|
||||
}
|
||||
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -8,118 +8,122 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_IMPL_URL_VIEW_BASE_HPP
|
||||
#define BOOST_URL_IMPL_URL_VIEW_BASE_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/url_view_base.hpp>
|
||||
#include <boost/url/url_view.hpp>
|
||||
#include <boost/url/detail/memcpy.hpp>
|
||||
#include <boost/url/detail/except.hpp>
|
||||
#include "detail/normalize.hpp"
|
||||
#include "detail/over_allocator.hpp"
|
||||
#include <boost/url/detail/fnv_1a.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
|
||||
// construct empty view
|
||||
url_view_base::
|
||||
url_view_base() noexcept
|
||||
: impl_(from::url)
|
||||
, pi_(&impl_)
|
||||
{
|
||||
}
|
||||
namespace detail {
|
||||
|
||||
// construct reference
|
||||
url_view_base::
|
||||
url_view_base(
|
||||
detail::url_impl const& impl) noexcept
|
||||
: impl_(impl)
|
||||
, pi_(&impl_)
|
||||
{
|
||||
}
|
||||
// Forward declarations for normalize functions
|
||||
// defined in src/detail/normalize.cpp
|
||||
BOOST_URL_DECL
|
||||
void
|
||||
ci_digest(
|
||||
core::string_view s,
|
||||
fnv_1a& hasher) noexcept;
|
||||
|
||||
BOOST_URL_DECL
|
||||
void
|
||||
digest_encoded(
|
||||
core::string_view s,
|
||||
fnv_1a& hasher) noexcept;
|
||||
|
||||
BOOST_URL_DECL
|
||||
void
|
||||
ci_digest_encoded(
|
||||
core::string_view s,
|
||||
fnv_1a& hasher) noexcept;
|
||||
|
||||
BOOST_URL_DECL
|
||||
void
|
||||
normalized_path_digest(
|
||||
core::string_view str,
|
||||
bool remove_unmatched,
|
||||
fnv_1a& hasher) noexcept;
|
||||
|
||||
BOOST_URL_DECL
|
||||
int
|
||||
ci_compare(
|
||||
core::string_view lhs,
|
||||
core::string_view rhs) noexcept;
|
||||
|
||||
BOOST_URL_DECL
|
||||
int
|
||||
compare_encoded(
|
||||
core::string_view lhs,
|
||||
core::string_view rhs) noexcept;
|
||||
|
||||
BOOST_URL_DECL
|
||||
int
|
||||
compare_encoded_query(
|
||||
core::string_view lhs,
|
||||
core::string_view rhs) noexcept;
|
||||
|
||||
BOOST_URL_DECL
|
||||
int
|
||||
segments_compare(
|
||||
segments_encoded_view seg0,
|
||||
segments_encoded_view seg1) noexcept;
|
||||
|
||||
} // detail
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
url_view_base::
|
||||
digest(std::size_t salt) const noexcept
|
||||
{
|
||||
detail::fnv_1a h(salt);
|
||||
detail::ci_digest(pi_->get(id_scheme), h);
|
||||
detail::digest_encoded(pi_->get(id_user), h);
|
||||
detail::digest_encoded(pi_->get(id_pass), h);
|
||||
detail::ci_digest_encoded(pi_->get(id_host), h);
|
||||
h.put(pi_->get(id_port));
|
||||
detail::ci_digest(impl().get(id_scheme), h);
|
||||
detail::digest_encoded(impl().get(id_user), h);
|
||||
detail::digest_encoded(impl().get(id_pass), h);
|
||||
detail::ci_digest_encoded(impl().get(id_host), h);
|
||||
h.put(impl().get(id_port));
|
||||
detail::normalized_path_digest(
|
||||
pi_->get(id_path), is_path_absolute(), h);
|
||||
detail::digest_encoded(pi_->get(id_query), h);
|
||||
detail::digest_encoded(pi_->get(id_frag), h);
|
||||
impl().get(id_path), is_path_absolute(), h);
|
||||
detail::digest_encoded(impl().get(id_query), h);
|
||||
detail::digest_encoded(impl().get(id_frag), h);
|
||||
return h.digest();
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// Observers
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
struct url_view_base::shared_impl
|
||||
: url_view
|
||||
{
|
||||
virtual
|
||||
~shared_impl()
|
||||
{
|
||||
}
|
||||
|
||||
shared_impl(
|
||||
url_view const& u) noexcept
|
||||
: url_view(u)
|
||||
{
|
||||
impl_.cs_ = reinterpret_cast<
|
||||
char const*>(this + 1);
|
||||
}
|
||||
};
|
||||
|
||||
std::shared_ptr<url_view const>
|
||||
url_view_base::
|
||||
persist() const
|
||||
{
|
||||
using T = shared_impl;
|
||||
using Alloc = std::allocator<char>;
|
||||
Alloc a;
|
||||
auto p = std::allocate_shared<T>(
|
||||
detail::over_allocator<T, Alloc>(
|
||||
size(), a), url_view(*pi_));
|
||||
std::memcpy(
|
||||
reinterpret_cast<char*>(
|
||||
p.get() + 1), data(), size());
|
||||
return p;
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// Scheme
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
bool
|
||||
url_view_base::
|
||||
has_scheme() const noexcept
|
||||
{
|
||||
auto const n = pi_->len(
|
||||
auto const n = impl().len(
|
||||
id_scheme);
|
||||
if(n == 0)
|
||||
return false;
|
||||
BOOST_ASSERT(n > 1);
|
||||
BOOST_ASSERT(
|
||||
pi_->get(id_scheme
|
||||
impl().get(id_scheme
|
||||
).ends_with(':'));
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
core::string_view
|
||||
url_view_base::
|
||||
scheme() const noexcept
|
||||
{
|
||||
auto s = pi_->get(id_scheme);
|
||||
auto s = impl().get(id_scheme);
|
||||
if(! s.empty())
|
||||
{
|
||||
BOOST_ASSERT(s.size() > 1);
|
||||
@@ -129,11 +133,12 @@ scheme() const noexcept
|
||||
return s;
|
||||
}
|
||||
|
||||
inline
|
||||
urls::scheme
|
||||
url_view_base::
|
||||
scheme_id() const noexcept
|
||||
{
|
||||
return pi_->scheme_;
|
||||
return impl().scheme_;
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
@@ -142,6 +147,7 @@ scheme_id() const noexcept
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
authority_view
|
||||
url_view_base::
|
||||
authority() const noexcept
|
||||
@@ -150,33 +156,36 @@ authority() const noexcept
|
||||
u.cs_ = encoded_authority().data();
|
||||
if(has_authority())
|
||||
{
|
||||
u.set_size(id_user, pi_->len(id_user) - 2);
|
||||
u.set_size(id_pass, pi_->len(id_pass));
|
||||
u.set_size(id_host, pi_->len(id_host));
|
||||
u.set_size(id_port, pi_->len(id_port));
|
||||
u.set_size(id_user, impl().len(id_user) - 2);
|
||||
u.set_size(id_pass, impl().len(id_pass));
|
||||
u.set_size(id_host, impl().len(id_host));
|
||||
u.set_size(id_port, impl().len(id_port));
|
||||
}
|
||||
else
|
||||
{
|
||||
u.set_size(id_user, pi_->len(id_user));
|
||||
BOOST_ASSERT(pi_->len(id_pass) == 0);
|
||||
BOOST_ASSERT(pi_->len(id_host) == 0);
|
||||
BOOST_ASSERT(pi_->len(id_port) == 0);
|
||||
u.set_size(id_user, impl().len(id_user));
|
||||
BOOST_ASSERT(impl().len(id_pass) == 0);
|
||||
BOOST_ASSERT(impl().len(id_host) == 0);
|
||||
BOOST_ASSERT(impl().len(id_port) == 0);
|
||||
}
|
||||
u.decoded_[id_user] = pi_->decoded_[id_user];
|
||||
u.decoded_[id_pass] = pi_->decoded_[id_pass];
|
||||
u.decoded_[id_host] = pi_->decoded_[id_host];
|
||||
for (int i = 0; i < 16; ++i)
|
||||
u.ip_addr_[i] = pi_->ip_addr_[i];
|
||||
u.port_number_ = pi_->port_number_;
|
||||
u.host_type_ = pi_->host_type_;
|
||||
return u.construct_authority();
|
||||
u.decoded_[id_user] = impl().decoded_[id_user];
|
||||
u.decoded_[id_pass] = impl().decoded_[id_pass];
|
||||
u.decoded_[id_host] = impl().decoded_[id_host];
|
||||
detail::memcpy(
|
||||
u.ip_addr_,
|
||||
impl().ip_addr_,
|
||||
16);
|
||||
u.port_number_ = impl().port_number_;
|
||||
u.host_type_ = impl().host_type_;
|
||||
return authority_view(u);
|
||||
}
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
url_view_base::
|
||||
encoded_authority() const noexcept
|
||||
{
|
||||
auto s = pi_->get(id_user, id_path);
|
||||
auto s = impl().get(id_user, id_path);
|
||||
if(! s.empty())
|
||||
{
|
||||
BOOST_ASSERT(has_authority());
|
||||
@@ -185,10 +194,10 @@ encoded_authority() const noexcept
|
||||
return make_pct_string_view_unsafe(
|
||||
s.data(),
|
||||
s.size(),
|
||||
pi_->decoded_[id_user] +
|
||||
pi_->decoded_[id_pass] +
|
||||
pi_->decoded_[id_host] +
|
||||
pi_->decoded_[id_port] +
|
||||
impl().decoded_[id_user] +
|
||||
impl().decoded_[id_pass] +
|
||||
impl().decoded_[id_host] +
|
||||
impl().decoded_[id_port] +
|
||||
has_password());
|
||||
}
|
||||
|
||||
@@ -198,42 +207,45 @@ encoded_authority() const noexcept
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
bool
|
||||
url_view_base::
|
||||
has_userinfo() const noexcept
|
||||
{
|
||||
auto n = pi_->len(id_pass);
|
||||
auto n = impl().len(id_pass);
|
||||
if(n == 0)
|
||||
return false;
|
||||
BOOST_ASSERT(has_authority());
|
||||
BOOST_ASSERT(pi_->get(
|
||||
BOOST_ASSERT(impl().get(
|
||||
id_pass).ends_with('@'));
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
url_view_base::
|
||||
has_password() const noexcept
|
||||
{
|
||||
auto const n = pi_->len(id_pass);
|
||||
auto const n = impl().len(id_pass);
|
||||
if(n > 1)
|
||||
{
|
||||
BOOST_ASSERT(pi_->get(id_pass
|
||||
BOOST_ASSERT(impl().get(id_pass
|
||||
).starts_with(':'));
|
||||
BOOST_ASSERT(pi_->get(id_pass
|
||||
BOOST_ASSERT(impl().get(id_pass
|
||||
).ends_with('@'));
|
||||
return true;
|
||||
}
|
||||
BOOST_ASSERT(n == 0 || pi_->get(
|
||||
BOOST_ASSERT(n == 0 || impl().get(
|
||||
id_pass).ends_with('@'));
|
||||
return false;
|
||||
}
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
url_view_base::
|
||||
encoded_userinfo() const noexcept
|
||||
{
|
||||
auto s = pi_->get(
|
||||
auto s = impl().get(
|
||||
id_user, id_host);
|
||||
if(s.empty())
|
||||
return s;
|
||||
@@ -248,16 +260,17 @@ encoded_userinfo() const noexcept
|
||||
return make_pct_string_view_unsafe(
|
||||
s.data(),
|
||||
s.size(),
|
||||
pi_->decoded_[id_user] +
|
||||
pi_->decoded_[id_pass] +
|
||||
impl().decoded_[id_user] +
|
||||
impl().decoded_[id_pass] +
|
||||
has_password());
|
||||
}
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
url_view_base::
|
||||
encoded_user() const noexcept
|
||||
{
|
||||
auto s = pi_->get(id_user);
|
||||
auto s = impl().get(id_user);
|
||||
if(! s.empty())
|
||||
{
|
||||
BOOST_ASSERT(
|
||||
@@ -267,14 +280,15 @@ encoded_user() const noexcept
|
||||
return make_pct_string_view_unsafe(
|
||||
s.data(),
|
||||
s.size(),
|
||||
pi_->decoded_[id_user]);
|
||||
impl().decoded_[id_user]);
|
||||
}
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
url_view_base::
|
||||
encoded_password() const noexcept
|
||||
{
|
||||
auto s = pi_->get(id_pass);
|
||||
auto s = impl().get(id_pass);
|
||||
switch(s.size())
|
||||
{
|
||||
case 1:
|
||||
@@ -293,7 +307,7 @@ encoded_password() const noexcept
|
||||
return make_pct_string_view_unsafe(
|
||||
s.data() + 1,
|
||||
s.size() - 2,
|
||||
pi_->decoded_[id_pass]);
|
||||
impl().decoded_[id_pass]);
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
@@ -316,20 +330,22 @@ std::string host_name() // return decoded name or ""
|
||||
pct_string_view encoded_host_name() // return encoded host name or ""
|
||||
*/
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
url_view_base::
|
||||
encoded_host() const noexcept
|
||||
{
|
||||
return pi_->pct_get(id_host);
|
||||
return impl().pct_get(id_host);
|
||||
}
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
url_view_base::
|
||||
encoded_host_address() const noexcept
|
||||
{
|
||||
core::string_view s = pi_->get(id_host);
|
||||
core::string_view s = impl().get(id_host);
|
||||
std::size_t n;
|
||||
switch(pi_->host_type_)
|
||||
switch(impl().host_type_)
|
||||
{
|
||||
default:
|
||||
case urls::host_type::none:
|
||||
@@ -339,21 +355,21 @@ encoded_host_address() const noexcept
|
||||
|
||||
case urls::host_type::name:
|
||||
case urls::host_type::ipv4:
|
||||
n = pi_->decoded_[id_host];
|
||||
n = impl().decoded_[id_host];
|
||||
break;
|
||||
|
||||
case urls::host_type::ipv6:
|
||||
case urls::host_type::ipvfuture:
|
||||
{
|
||||
BOOST_ASSERT(
|
||||
pi_->decoded_[id_host] ==
|
||||
impl().decoded_[id_host] ==
|
||||
s.size() ||
|
||||
!this->encoded_zone_id().empty());
|
||||
BOOST_ASSERT(s.size() >= 2);
|
||||
BOOST_ASSERT(s.front() == '[');
|
||||
BOOST_ASSERT(s.back() == ']');
|
||||
s = s.substr(1, s.size() - 2);
|
||||
n = pi_->decoded_[id_host] - 2;
|
||||
n = impl().decoded_[id_host] - 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -363,40 +379,43 @@ encoded_host_address() const noexcept
|
||||
n);
|
||||
}
|
||||
|
||||
inline
|
||||
urls::ipv4_address
|
||||
url_view_base::
|
||||
host_ipv4_address() const noexcept
|
||||
{
|
||||
if(pi_->host_type_ !=
|
||||
if(impl().host_type_ !=
|
||||
urls::host_type::ipv4)
|
||||
return {};
|
||||
ipv4_address::bytes_type b{{}};
|
||||
std::memcpy(
|
||||
&b[0], &pi_->ip_addr_[0], b.size());
|
||||
&b[0], &impl().ip_addr_[0], b.size());
|
||||
return urls::ipv4_address(b);
|
||||
}
|
||||
|
||||
inline
|
||||
urls::ipv6_address
|
||||
url_view_base::
|
||||
host_ipv6_address() const noexcept
|
||||
{
|
||||
if(pi_->host_type_ !=
|
||||
if(impl().host_type_ !=
|
||||
urls::host_type::ipv6)
|
||||
return {};
|
||||
ipv6_address::bytes_type b{{}};
|
||||
std::memcpy(
|
||||
&b[0], &pi_->ip_addr_[0], b.size());
|
||||
&b[0], &impl().ip_addr_[0], b.size());
|
||||
return {b};
|
||||
}
|
||||
|
||||
inline
|
||||
core::string_view
|
||||
url_view_base::
|
||||
host_ipvfuture() const noexcept
|
||||
{
|
||||
if(pi_->host_type_ !=
|
||||
if(impl().host_type_ !=
|
||||
urls::host_type::ipvfuture)
|
||||
return {};
|
||||
core::string_view s = pi_->get(id_host);
|
||||
core::string_view s = impl().get(id_host);
|
||||
BOOST_ASSERT(s.size() >= 6);
|
||||
BOOST_ASSERT(s.front() == '[');
|
||||
BOOST_ASSERT(s.back() == ']');
|
||||
@@ -404,28 +423,30 @@ host_ipvfuture() const noexcept
|
||||
return s;
|
||||
}
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
url_view_base::
|
||||
encoded_host_name() const noexcept
|
||||
{
|
||||
if(pi_->host_type_ !=
|
||||
if(impl().host_type_ !=
|
||||
urls::host_type::name)
|
||||
return {};
|
||||
core::string_view s = pi_->get(id_host);
|
||||
core::string_view s = impl().get(id_host);
|
||||
return make_pct_string_view_unsafe(
|
||||
s.data(),
|
||||
s.size(),
|
||||
pi_->decoded_[id_host]);
|
||||
impl().decoded_[id_host]);
|
||||
}
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
url_view_base::
|
||||
encoded_zone_id() const noexcept
|
||||
{
|
||||
if(pi_->host_type_ !=
|
||||
if(impl().host_type_ !=
|
||||
urls::host_type::ipv6)
|
||||
return {};
|
||||
core::string_view s = pi_->get(id_host);
|
||||
core::string_view s = impl().get(id_host);
|
||||
BOOST_ASSERT(s.front() == '[');
|
||||
BOOST_ASSERT(s.back() == ']');
|
||||
s = s.substr(1, s.size() - 2);
|
||||
@@ -438,37 +459,40 @@ encoded_zone_id() const noexcept
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
bool
|
||||
url_view_base::
|
||||
has_port() const noexcept
|
||||
{
|
||||
auto const n = pi_->len(id_port);
|
||||
auto const n = impl().len(id_port);
|
||||
if(n == 0)
|
||||
return false;
|
||||
BOOST_ASSERT(
|
||||
pi_->get(id_port).starts_with(':'));
|
||||
impl().get(id_port).starts_with(':'));
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
core::string_view
|
||||
url_view_base::
|
||||
port() const noexcept
|
||||
{
|
||||
auto s = pi_->get(id_port);
|
||||
auto s = impl().get(id_port);
|
||||
if(s.empty())
|
||||
return s;
|
||||
BOOST_ASSERT(has_port());
|
||||
return s.substr(1);
|
||||
}
|
||||
|
||||
inline
|
||||
std::uint16_t
|
||||
url_view_base::
|
||||
port_number() const noexcept
|
||||
{
|
||||
BOOST_ASSERT(
|
||||
has_port() ||
|
||||
pi_->port_number_ == 0);
|
||||
return pi_->port_number_;
|
||||
impl().port_number_ == 0);
|
||||
return impl().port_number_;
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
@@ -477,26 +501,29 @@ port_number() const noexcept
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
url_view_base::
|
||||
encoded_path() const noexcept
|
||||
{
|
||||
return pi_->pct_get(id_path);
|
||||
return impl().pct_get(id_path);
|
||||
}
|
||||
|
||||
inline
|
||||
segments_view
|
||||
url_view_base::
|
||||
segments() const noexcept
|
||||
{
|
||||
return {detail::path_ref(*pi_)};
|
||||
return {detail::path_ref(impl())};
|
||||
}
|
||||
|
||||
inline
|
||||
segments_encoded_view
|
||||
url_view_base::
|
||||
encoded_segments() const noexcept
|
||||
{
|
||||
return segments_encoded_view(
|
||||
detail::path_ref(*pi_));
|
||||
detail::path_ref(impl()));
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
@@ -505,25 +532,27 @@ encoded_segments() const noexcept
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
bool
|
||||
url_view_base::
|
||||
has_query() const noexcept
|
||||
{
|
||||
auto const n = pi_->len(
|
||||
auto const n = impl().len(
|
||||
id_query);
|
||||
if(n == 0)
|
||||
return false;
|
||||
BOOST_ASSERT(
|
||||
pi_->get(id_query).
|
||||
impl().get(id_query).
|
||||
starts_with('?'));
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
url_view_base::
|
||||
encoded_query() const noexcept
|
||||
{
|
||||
auto s = pi_->get(id_query);
|
||||
auto s = impl().get(id_query);
|
||||
if(s.empty())
|
||||
return s;
|
||||
BOOST_ASSERT(
|
||||
@@ -531,28 +560,31 @@ encoded_query() const noexcept
|
||||
return s.substr(1);
|
||||
}
|
||||
|
||||
inline
|
||||
params_encoded_view
|
||||
url_view_base::
|
||||
encoded_params() const noexcept
|
||||
{
|
||||
return params_encoded_view(*pi_);
|
||||
return params_encoded_view(impl());
|
||||
}
|
||||
|
||||
inline
|
||||
params_view
|
||||
url_view_base::
|
||||
params() const noexcept
|
||||
{
|
||||
return params_view(
|
||||
*pi_,
|
||||
impl(),
|
||||
encoding_opts{
|
||||
true,false,false});
|
||||
}
|
||||
|
||||
inline
|
||||
params_view
|
||||
url_view_base::
|
||||
params(encoding_opts opt) const noexcept
|
||||
{
|
||||
return params_view(*pi_, opt);
|
||||
return params_view(impl(), opt);
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
@@ -561,24 +593,26 @@ params(encoding_opts opt) const noexcept
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
bool
|
||||
url_view_base::
|
||||
has_fragment() const noexcept
|
||||
{
|
||||
auto const n = pi_->len(id_frag);
|
||||
auto const n = impl().len(id_frag);
|
||||
if(n == 0)
|
||||
return false;
|
||||
BOOST_ASSERT(
|
||||
pi_->get(id_frag).
|
||||
impl().get(id_frag).
|
||||
starts_with('#'));
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
url_view_base::
|
||||
encoded_fragment() const noexcept
|
||||
{
|
||||
auto s = pi_->get(id_frag);
|
||||
auto s = impl().get(id_frag);
|
||||
if(! s.empty())
|
||||
{
|
||||
BOOST_ASSERT(
|
||||
@@ -588,7 +622,7 @@ encoded_fragment() const noexcept
|
||||
return make_pct_string_view_unsafe(
|
||||
s.data(),
|
||||
s.size(),
|
||||
pi_->decoded_[id_frag]);
|
||||
impl().decoded_[id_frag]);
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
@@ -597,55 +631,59 @@ encoded_fragment() const noexcept
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
url_view_base::
|
||||
encoded_host_and_port() const noexcept
|
||||
{
|
||||
return pi_->pct_get(id_host, id_path);
|
||||
return impl().pct_get(id_host, id_path);
|
||||
}
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
url_view_base::
|
||||
encoded_origin() const noexcept
|
||||
{
|
||||
if(pi_->len(id_user) < 2)
|
||||
if(impl().len(id_user) < 2)
|
||||
return {};
|
||||
return pi_->get(id_scheme, id_path);
|
||||
return impl().get(id_scheme, id_path);
|
||||
}
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
url_view_base::
|
||||
encoded_resource() const noexcept
|
||||
{
|
||||
auto n =
|
||||
pi_->decoded_[id_path] +
|
||||
pi_->decoded_[id_query] +
|
||||
pi_->decoded_[id_frag];
|
||||
impl().decoded_[id_path] +
|
||||
impl().decoded_[id_query] +
|
||||
impl().decoded_[id_frag];
|
||||
if(has_query())
|
||||
++n;
|
||||
if(has_fragment())
|
||||
++n;
|
||||
BOOST_ASSERT(pct_string_view(
|
||||
pi_->get(id_path, id_end)
|
||||
impl().get(id_path, id_end)
|
||||
).decoded_size() == n);
|
||||
auto s = pi_->get(id_path, id_end);
|
||||
auto s = impl().get(id_path, id_end);
|
||||
return make_pct_string_view_unsafe(
|
||||
s.data(), s.size(), n);
|
||||
}
|
||||
|
||||
inline
|
||||
pct_string_view
|
||||
url_view_base::
|
||||
encoded_target() const noexcept
|
||||
{
|
||||
auto n =
|
||||
pi_->decoded_[id_path] +
|
||||
pi_->decoded_[id_query];
|
||||
impl().decoded_[id_path] +
|
||||
impl().decoded_[id_query];
|
||||
if(has_query())
|
||||
++n;
|
||||
BOOST_ASSERT(pct_string_view(
|
||||
pi_->get(id_path, id_frag)
|
||||
impl().get(id_path, id_frag)
|
||||
).decoded_size() == n);
|
||||
auto s = pi_->get(id_path, id_frag);
|
||||
auto s = impl().get(id_path, id_frag);
|
||||
return make_pct_string_view_unsafe(
|
||||
s.data(), s.size(), n);
|
||||
}
|
||||
@@ -656,6 +694,7 @@ encoded_target() const noexcept
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
inline
|
||||
int
|
||||
url_view_base::
|
||||
compare(const url_view_base& other) const noexcept
|
||||
@@ -730,3 +769,4 @@ compare(const url_view_base& other) const noexcept
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -121,9 +121,12 @@ public:
|
||||
|
||||
@param bytes The value to construct from.
|
||||
*/
|
||||
BOOST_URL_DECL
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
ipv6_address(
|
||||
bytes_type const& bytes) noexcept;
|
||||
bytes_type const& bytes) noexcept
|
||||
: addr_(bytes)
|
||||
{
|
||||
}
|
||||
|
||||
/** Construct from an IPv4 address.
|
||||
|
||||
|
||||
@@ -22,13 +22,6 @@
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(push)
|
||||
// "struct 'boost::urls::encoding_opts' needs to have dll-interface to be used by clients of class 'boost::urls::params_base'"
|
||||
// but encoding_opts should not be BOOST_URL_DECL and params_base should be BOOST_URL_DECL.
|
||||
# pragma warning(disable: 4251)
|
||||
#endif
|
||||
|
||||
/** Decoded query parameter helper base
|
||||
|
||||
This base centralizes the read-only,
|
||||
@@ -46,7 +39,7 @@ namespace urls {
|
||||
@li @ref params_encoded_ref
|
||||
@li @ref params_encoded_view
|
||||
*/
|
||||
class BOOST_URL_DECL params_base
|
||||
class BOOST_SYMBOL_VISIBLE params_base
|
||||
{
|
||||
friend class url_view_base;
|
||||
friend class params_ref;
|
||||
@@ -570,7 +563,6 @@ private:
|
||||
@param qp The parameters to write
|
||||
@return A reference to the output stream, for chaining
|
||||
*/
|
||||
BOOST_URL_DECL
|
||||
std::ostream&
|
||||
operator<<(
|
||||
std::ostream& os,
|
||||
@@ -581,8 +573,4 @@ operator<<(
|
||||
|
||||
#include <boost/url/impl/params_base.hpp>
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace urls {
|
||||
@li @ref params_encoded_ref
|
||||
@li @ref params_encoded_view
|
||||
*/
|
||||
class BOOST_URL_DECL params_encoded_base
|
||||
class BOOST_SYMBOL_VISIBLE params_encoded_base
|
||||
{
|
||||
friend class url_view_base;
|
||||
friend class params_encoded_ref;
|
||||
@@ -594,7 +594,6 @@ private:
|
||||
@param qp The params to write
|
||||
@return A reference to the output stream, for chaining
|
||||
*/
|
||||
BOOST_URL_DECL
|
||||
std::ostream&
|
||||
operator<<(
|
||||
std::ostream& os,
|
||||
|
||||
@@ -74,7 +74,7 @@ class params_encoded_view;
|
||||
current encoded query and does not perform
|
||||
any modifications.
|
||||
*/
|
||||
class BOOST_URL_DECL params_encoded_ref
|
||||
class BOOST_SYMBOL_VISIBLE params_encoded_ref
|
||||
: public params_encoded_base
|
||||
{
|
||||
friend class url_base;
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace implementation_defined {
|
||||
Changes to the underlying character buffer
|
||||
can invalidate iterators which reference it.
|
||||
*/
|
||||
class BOOST_URL_DECL params_encoded_view
|
||||
class BOOST_SYMBOL_VISIBLE params_encoded_view
|
||||
: public params_encoded_base
|
||||
{
|
||||
friend class url_view_base;
|
||||
@@ -230,15 +230,25 @@ public:
|
||||
|
||||
//--------------------------------------------
|
||||
|
||||
friend
|
||||
BOOST_URL_DECL
|
||||
friend
|
||||
system::result<params_encoded_view>
|
||||
parse_query(core::string_view s) noexcept;
|
||||
};
|
||||
|
||||
// Forward-declare for inline constructors below.
|
||||
// Full declaration in parse_query.hpp; definition in
|
||||
// src/parse_query.cpp.
|
||||
BOOST_URL_DECL
|
||||
system::result<params_encoded_view>
|
||||
parse_query(core::string_view s) noexcept;
|
||||
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#include <boost/url/impl/params_view.hpp>
|
||||
#include <boost/url/impl/params_encoded_view.hpp>
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// std::ranges::enable_borrowed_range
|
||||
|
||||
@@ -83,7 +83,7 @@ class params_view;
|
||||
current contents of the referenced URL
|
||||
without modifying it.
|
||||
*/
|
||||
class BOOST_URL_DECL params_ref
|
||||
class BOOST_SYMBOL_VISIBLE params_ref
|
||||
: public params_base
|
||||
{
|
||||
friend class url_base;
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace urls {
|
||||
Changes to the underlying character buffer
|
||||
can invalidate iterators which reference it.
|
||||
*/
|
||||
class params_view
|
||||
class BOOST_SYMBOL_VISIBLE params_view
|
||||
: public params_base
|
||||
{
|
||||
friend class url_view_base;
|
||||
@@ -183,7 +183,6 @@ public:
|
||||
@li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.4"
|
||||
>3.4. Query</a>
|
||||
*/
|
||||
BOOST_URL_DECL
|
||||
params_view(
|
||||
core::string_view s);
|
||||
|
||||
@@ -250,7 +249,6 @@ public:
|
||||
@li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.4"
|
||||
>3.4. Query</a>
|
||||
*/
|
||||
BOOST_URL_DECL
|
||||
params_view(
|
||||
core::string_view s,
|
||||
encoding_opts opt);
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace urls {
|
||||
@param s The string to parse
|
||||
@return A view to the parsed URL
|
||||
*/
|
||||
BOOST_URL_DECL
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
system::result<url_view>
|
||||
parse_absolute_uri(
|
||||
core::string_view s);
|
||||
@@ -106,7 +106,7 @@ parse_absolute_uri(
|
||||
@param s The string to parse
|
||||
@return A view to the parsed URL
|
||||
*/
|
||||
BOOST_URL_DECL
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
system::result<url_view>
|
||||
parse_origin_form(
|
||||
core::string_view s);
|
||||
@@ -158,7 +158,7 @@ parse_origin_form(
|
||||
@param s The string to parse
|
||||
@return A view to the parsed URL
|
||||
*/
|
||||
BOOST_URL_DECL
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
system::result<url_view>
|
||||
parse_relative_ref(
|
||||
core::string_view s);
|
||||
@@ -207,7 +207,7 @@ parse_relative_ref(
|
||||
@param s The string to parse
|
||||
@return A `boost::system::result` containing a value or an error
|
||||
*/
|
||||
BOOST_URL_DECL
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
system::result<url_view>
|
||||
parse_uri(
|
||||
core::string_view s);
|
||||
@@ -268,7 +268,7 @@ parse_uri(
|
||||
@param s The string to parse
|
||||
@return A view to the parsed URL
|
||||
*/
|
||||
BOOST_URL_DECL
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
system::result<url_view>
|
||||
parse_uri_reference(
|
||||
core::string_view s);
|
||||
@@ -276,4 +276,7 @@ parse_uri_reference(
|
||||
} // url
|
||||
} // boost
|
||||
|
||||
#include <boost/url/impl/url_view.hpp>
|
||||
#include <boost/url/impl/parse.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2022 Vinnie Falco (vinnie.falco@gmail.com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -31,6 +32,7 @@ namespace urls {
|
||||
class decode_view;
|
||||
class pct_string_view;
|
||||
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
pct_string_view
|
||||
make_pct_string_view_unsafe(
|
||||
char const*, std::size_t,
|
||||
@@ -63,6 +65,7 @@ class pct_string_view final
|
||||
|
||||
#ifndef BOOST_URL_DOCS
|
||||
friend
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
pct_string_view
|
||||
make_pct_string_view_unsafe(
|
||||
char const*, std::size_t,
|
||||
@@ -433,6 +436,7 @@ make_pct_string_view(
|
||||
#ifndef BOOST_URL_DOCS
|
||||
// VFALCO semi-private for now
|
||||
inline
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
pct_string_view
|
||||
make_pct_string_view_unsafe(
|
||||
char const* data,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -12,17 +13,18 @@
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/error_types.hpp>
|
||||
#include <boost/url/url_view.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
|
||||
class url_view;
|
||||
|
||||
namespace implementation_defined {
|
||||
struct absolute_uri_rule_t
|
||||
{
|
||||
using value_type = url_view;
|
||||
|
||||
BOOST_URL_DECL
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
auto
|
||||
parse(
|
||||
char const*& it,
|
||||
@@ -69,4 +71,6 @@ BOOST_INLINE_CONSTEXPR implementation_defined::absolute_uri_rule_t absolute_uri_
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#include <boost/url/rfc/impl/absolute_uri_rule.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -21,7 +22,7 @@ struct authority_rule_t
|
||||
{
|
||||
using value_type = authority_view;
|
||||
|
||||
BOOST_URL_DECL
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
auto
|
||||
parse(
|
||||
char const*& it,
|
||||
@@ -63,4 +64,11 @@ constexpr implementation_defined::authority_rule_t authority_rule{};
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
// authority_view.hpp defers its impl include when
|
||||
// this header is being processed. Include it now
|
||||
// that authority_rule is declared.
|
||||
#include <boost/url/impl/authority_view.hpp>
|
||||
|
||||
#include <boost/url/rfc/impl/authority_rule.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
#ifndef BOOST_URL_RFC_DETAIL_CHARSETS_HPP
|
||||
#define BOOST_URL_RFC_DETAIL_CHARSETS_HPP
|
||||
|
||||
#include "boost/url/rfc/pchars.hpp"
|
||||
#include "boost/url/rfc/sub_delim_chars.hpp"
|
||||
#include "boost/url/rfc/unreserved_chars.hpp"
|
||||
#include <boost/url/rfc/pchars.hpp>
|
||||
#include <boost/url/rfc/sub_delim_chars.hpp>
|
||||
#include <boost/url/rfc/unreserved_chars.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
+5
-3
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -10,9 +11,9 @@
|
||||
#ifndef BOOST_URL_RFC_DETAIL_FRAGMENT_PART_RULE_HPP
|
||||
#define BOOST_URL_RFC_DETAIL_FRAGMENT_PART_RULE_HPP
|
||||
|
||||
#include "boost/url/rfc/pct_encoded_rule.hpp"
|
||||
#include "charsets.hpp"
|
||||
#include "boost/url/grammar/parse.hpp"
|
||||
#include <boost/url/rfc/pct_encoded_rule.hpp>
|
||||
#include <boost/url/rfc/detail/charsets.hpp>
|
||||
#include <boost/url/grammar/parse.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
@@ -39,6 +40,7 @@ struct fragment_part_rule_t
|
||||
bool has_fragment = false;
|
||||
};
|
||||
|
||||
BOOST_URL_CXX14_CONSTEXPR
|
||||
system::result<value_type>
|
||||
parse(
|
||||
char const*& it,
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -10,8 +11,8 @@
|
||||
#ifndef BOOST_URL_RFC_DETAIL_H16_RULE_HPP
|
||||
#define BOOST_URL_RFC_DETAIL_H16_RULE_HPP
|
||||
|
||||
#include "boost/url/detail/config.hpp"
|
||||
#include "boost/url/error_types.hpp"
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/error_types.hpp>
|
||||
#include <cstdint>
|
||||
|
||||
namespace boost {
|
||||
@@ -41,6 +42,7 @@ struct h16_rule_t
|
||||
std::uint8_t lo;
|
||||
};
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
auto
|
||||
parse(
|
||||
char const*& it,
|
||||
@@ -55,4 +57,6 @@ constexpr h16_rule_t h16_rule{};
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#include <boost/url/rfc/detail/impl/h16_rule.hpp>
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -10,9 +11,9 @@
|
||||
#ifndef BOOST_URL_RFC_DETAIL_HIER_PART_RULE_HPP
|
||||
#define BOOST_URL_RFC_DETAIL_HIER_PART_RULE_HPP
|
||||
|
||||
#include "boost/url/detail/config.hpp"
|
||||
#include "boost/url/pct_string_view.hpp"
|
||||
#include "boost/url/rfc/authority_rule.hpp"
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/pct_string_view.hpp>
|
||||
#include <boost/url/rfc/authority_rule.hpp>
|
||||
#include <cstdlib>
|
||||
|
||||
namespace boost {
|
||||
@@ -43,7 +44,7 @@ struct hier_part_rule_t
|
||||
bool has_authority = false;
|
||||
};
|
||||
|
||||
BOOST_URL_DECL
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
auto
|
||||
parse(
|
||||
char const*& it,
|
||||
@@ -58,4 +59,6 @@ constexpr hier_part_rule_t hier_part_rule{};
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#include <boost/url/rfc/detail/impl/hier_part_rule.hpp>
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -10,11 +11,12 @@
|
||||
#ifndef BOOST_URL_RFC_DETAIL_HOST_RULE_HPP
|
||||
#define BOOST_URL_RFC_DETAIL_HOST_RULE_HPP
|
||||
|
||||
#include "boost/url/host_type.hpp"
|
||||
#include "boost/url/error_types.hpp"
|
||||
#include "boost/url/pct_string_view.hpp"
|
||||
#include "boost/url/ipv4_address.hpp"
|
||||
#include "boost/url/ipv6_address.hpp"
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/host_type.hpp>
|
||||
#include <boost/url/error_types.hpp>
|
||||
#include <boost/url/pct_string_view.hpp>
|
||||
#include <boost/url/ipv4_address.hpp>
|
||||
#include <boost/url/ipv6_address.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
@@ -42,11 +44,12 @@ struct host_rule_t
|
||||
{
|
||||
urls::host_type host_type =
|
||||
urls::host_type::none;
|
||||
core::string_view match;
|
||||
pct_string_view match;
|
||||
unsigned char addr[16] = {};
|
||||
pct_string_view name;
|
||||
};
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
auto
|
||||
parse(
|
||||
char const*& it,
|
||||
@@ -61,4 +64,6 @@ constexpr host_rule_t host_rule{};
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#include <boost/url/rfc/detail/impl/host_rule.hpp>
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2024 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -7,17 +8,18 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_RFC_DETAIL_IMPL_H16_RULE_HPP
|
||||
#define BOOST_URL_RFC_DETAIL_IMPL_H16_RULE_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include "h16_rule.hpp"
|
||||
#include <boost/url/grammar/charset.hpp>
|
||||
#include <boost/url/grammar/error.hpp>
|
||||
#include <boost/url/grammar/hexdig_chars.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
namespace detail {
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
auto
|
||||
h16_rule_t::
|
||||
parse(
|
||||
@@ -26,14 +28,15 @@ parse(
|
||||
) const noexcept ->
|
||||
system::result<value_type>
|
||||
{
|
||||
// VFALCO it might be impossible for
|
||||
// this condition to be true (coverage)
|
||||
// LCOV_EXCL_START
|
||||
// h16 is only called from ipv6_address_rule
|
||||
// which ensures at least one char is available
|
||||
if(it == end)
|
||||
{
|
||||
// end
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
grammar::error::invalid);
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
|
||||
std::uint16_t v;
|
||||
for(;;)
|
||||
@@ -42,7 +45,7 @@ parse(
|
||||
if(d < 0)
|
||||
{
|
||||
// expected HEXDIG
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
grammar::error::invalid);
|
||||
}
|
||||
v = d;
|
||||
@@ -81,3 +84,5 @@ parse(
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
|
||||
#endif
|
||||
+7
-3
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -7,17 +8,18 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_RFC_DETAIL_IMPL_HIER_PART_RULE_HPP
|
||||
#define BOOST_URL_RFC_DETAIL_IMPL_HIER_PART_RULE_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include "hier_part_rule.hpp"
|
||||
#include "boost/url/rfc/detail/path_rules.hpp"
|
||||
#include <boost/url/grammar/parse.hpp>
|
||||
#include <boost/url/rfc/detail/path_rules.hpp>
|
||||
#include <boost/url/grammar/parse.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
namespace detail {
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
auto
|
||||
hier_part_rule_t::
|
||||
parse(
|
||||
@@ -114,3 +116,5 @@ parse(
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -7,18 +8,21 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_RFC_DETAIL_IMPL_HOST_RULE_HPP
|
||||
#define BOOST_URL_RFC_DETAIL_IMPL_HOST_RULE_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/rfc/ipv4_address_rule.hpp>
|
||||
#include "host_rule.hpp"
|
||||
#include "ip_literal_rule.hpp"
|
||||
#include "reg_name_rule.hpp"
|
||||
#include <boost/url/rfc/detail/ip_literal_rule.hpp>
|
||||
#include <boost/url/rfc/detail/reg_name_rule.hpp>
|
||||
#include <boost/url/grammar/parse.hpp>
|
||||
#include <cstring>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
namespace detail {
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
auto
|
||||
host_rule_t::
|
||||
parse(
|
||||
@@ -58,16 +62,16 @@ parse(
|
||||
b.size());
|
||||
t.host_type =
|
||||
urls::host_type::ipv6;
|
||||
t.match = core::string_view(
|
||||
it0, it - it0);
|
||||
t.match = make_pct_string_view_unsafe(
|
||||
it0, it - it0, it - it0);
|
||||
return t;
|
||||
}
|
||||
|
||||
// IPvFuture
|
||||
t.host_type =
|
||||
urls::host_type::ipvfuture;
|
||||
t.match = core::string_view(
|
||||
it0, it - it0);
|
||||
t.match = make_pct_string_view_unsafe(
|
||||
it0, it - it0, it - it0);
|
||||
return t;
|
||||
}
|
||||
|
||||
@@ -84,12 +88,14 @@ parse(
|
||||
if (rv2.has_value() &&
|
||||
!rv2->empty())
|
||||
{
|
||||
t.name = core::string_view(
|
||||
it0, it - it0);
|
||||
auto dn = static_cast<
|
||||
std::size_t>(it02 - it0) +
|
||||
rv2->decoded_size();
|
||||
t.name = make_pct_string_view_unsafe(
|
||||
it0, it - it0, dn);
|
||||
t.host_type =
|
||||
urls::host_type::name;
|
||||
t.match = core::string_view(
|
||||
it0, it - it0);
|
||||
t.match = t.name;
|
||||
return t;
|
||||
}
|
||||
it = it02;
|
||||
@@ -101,8 +107,8 @@ parse(
|
||||
b.size());
|
||||
t.host_type =
|
||||
urls::host_type::ipv4;
|
||||
t.match = core::string_view(
|
||||
it0, it - it0);
|
||||
t.match = make_pct_string_view_unsafe(
|
||||
it0, it - it0, it - it0);
|
||||
return t;
|
||||
}
|
||||
|
||||
@@ -119,8 +125,7 @@ parse(
|
||||
t.name = *rv;
|
||||
t.host_type =
|
||||
urls::host_type::name;
|
||||
t.match = core::string_view(
|
||||
it0, it - it0);
|
||||
t.match = *rv;
|
||||
return t;
|
||||
}
|
||||
}
|
||||
@@ -129,3 +134,5 @@ parse(
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
|
||||
#endif
|
||||
+11
-6
@@ -1,6 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
// Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -8,20 +8,23 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_RFC_DETAIL_IMPL_IP_LITERAL_RULE_HPP
|
||||
#define BOOST_URL_RFC_DETAIL_IMPL_IP_LITERAL_RULE_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/rfc/ipv6_address_rule.hpp>
|
||||
#include "ip_literal_rule.hpp"
|
||||
#include "ipv6_addrz_rule.hpp"
|
||||
#include <boost/url/rfc/detail/ipv6_addrz_rule.hpp>
|
||||
#include <boost/url/rfc/detail/ipvfuture_rule.hpp>
|
||||
#include <boost/url/grammar/delim_rule.hpp>
|
||||
#include <boost/url/grammar/error.hpp>
|
||||
#include <boost/url/grammar/parse.hpp>
|
||||
#include <boost/url/grammar/tuple_rule.hpp>
|
||||
#include "ipvfuture_rule.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
namespace detail {
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
auto
|
||||
ip_literal_rule_t::
|
||||
parse(
|
||||
@@ -42,7 +45,7 @@ parse(
|
||||
if(it == end)
|
||||
{
|
||||
// end
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
grammar::error::invalid);
|
||||
}
|
||||
if(*it != 'v')
|
||||
@@ -78,7 +81,7 @@ parse(
|
||||
{
|
||||
// IPvFuture
|
||||
auto rv = grammar::parse(
|
||||
it, end,
|
||||
it, end,
|
||||
grammar::tuple_rule(
|
||||
ipvfuture_rule,
|
||||
grammar::squelch(
|
||||
@@ -95,3 +98,5 @@ parse(
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
|
||||
#endif
|
||||
+8
-3
@@ -7,10 +7,12 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_RFC_DETAIL_IMPL_IPV6_ADDRZ_RULE_HPP
|
||||
#define BOOST_URL_RFC_DETAIL_IMPL_IPV6_ADDRZ_RULE_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/grammar/error.hpp>
|
||||
#include <boost/url/grammar/parse.hpp>
|
||||
#include "ipv6_addrz_rule.hpp"
|
||||
#include <boost/url/rfc/ipv6_address_rule.hpp>
|
||||
#include <boost/url/rfc/unreserved_chars.hpp>
|
||||
#include <boost/url/rfc/pct_encoded_rule.hpp>
|
||||
@@ -19,6 +21,7 @@ namespace boost {
|
||||
namespace urls {
|
||||
namespace detail {
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
auto
|
||||
ipv6_addrz_rule_t::
|
||||
parse(
|
||||
@@ -41,7 +44,7 @@ parse(
|
||||
*(it + 1) != '2' ||
|
||||
*(it + 2) != '5')
|
||||
{
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
grammar::error::invalid);
|
||||
}
|
||||
it += 3;
|
||||
@@ -55,7 +58,7 @@ parse(
|
||||
if(!rv2 || rv2->empty())
|
||||
{
|
||||
it = it0;
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
grammar::error::invalid);
|
||||
}
|
||||
else
|
||||
@@ -69,3 +72,5 @@ parse(
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
|
||||
#endif
|
||||
+14
-17
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -7,13 +8,14 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_RFC_DETAIL_IMPL_IPVFUTURE_RULE_HPP
|
||||
#define BOOST_URL_RFC_DETAIL_IMPL_IPVFUTURE_RULE_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include "ipvfuture_rule.hpp"
|
||||
#include <boost/url/error.hpp>
|
||||
#include "charsets.hpp"
|
||||
#include <boost/url/rfc/detail/charsets.hpp>
|
||||
#include <boost/url/grammar/charset.hpp>
|
||||
#include <boost/url/grammar/delim_rule.hpp>
|
||||
#include <boost/url/grammar/error.hpp>
|
||||
#include <boost/url/grammar/hexdig_chars.hpp>
|
||||
#include <boost/url/grammar/parse.hpp>
|
||||
#include <boost/url/grammar/token_rule.hpp>
|
||||
@@ -23,6 +25,7 @@ namespace boost {
|
||||
namespace urls {
|
||||
namespace detail {
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
auto
|
||||
ipvfuture_rule_t::
|
||||
parse(
|
||||
@@ -31,8 +34,8 @@ parse(
|
||||
) const noexcept ->
|
||||
system::result<value_type>
|
||||
{
|
||||
static constexpr auto
|
||||
minor_chars =
|
||||
constexpr auto
|
||||
minor_chars =
|
||||
unreserved_chars +
|
||||
sub_delim_chars + ':';
|
||||
auto const it0 = it;
|
||||
@@ -49,18 +52,10 @@ parse(
|
||||
value_type t;
|
||||
t.major = std::get<0>(*rv);
|
||||
t.minor = std::get<1>(*rv);
|
||||
if(t.major.empty())
|
||||
{
|
||||
// can't be empty
|
||||
BOOST_URL_RETURN_EC(
|
||||
grammar::error::invalid);
|
||||
}
|
||||
if(t.minor.empty())
|
||||
{
|
||||
// can't be empty
|
||||
BOOST_URL_RETURN_EC(
|
||||
grammar::error::invalid);
|
||||
}
|
||||
// token_rule guarantees non-empty tokens,
|
||||
// so major/minor are always non-empty here.
|
||||
BOOST_ASSERT(!t.major.empty());
|
||||
BOOST_ASSERT(!t.minor.empty());
|
||||
t.str = core::string_view(
|
||||
it0, it - it0);
|
||||
return t;
|
||||
@@ -70,3 +65,5 @@ parse(
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -7,19 +8,19 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_RFC_DETAIL_IMPL_PORT_RULE_HPP
|
||||
#define BOOST_URL_RFC_DETAIL_IMPL_PORT_RULE_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include "port_rule.hpp"
|
||||
#include <boost/url/grammar/digit_chars.hpp>
|
||||
#include <boost/url/grammar/parse.hpp>
|
||||
#include <boost/url/grammar/token_rule.hpp>
|
||||
#include <boost/url/grammar/unsigned_rule.hpp>
|
||||
#include <boost/core/detail/static_assert.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
namespace detail {
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
auto
|
||||
port_rule::
|
||||
parse(
|
||||
@@ -72,6 +73,7 @@ parse(
|
||||
return t;
|
||||
}
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
auto
|
||||
port_part_rule_t::
|
||||
parse(
|
||||
@@ -102,3 +104,5 @@ parse(
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
|
||||
#endif
|
||||
+13
-5
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -7,18 +8,21 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_RFC_DETAIL_IMPL_RELATIVE_PART_RULE_HPP
|
||||
#define BOOST_URL_RFC_DETAIL_IMPL_RELATIVE_PART_RULE_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include "relative_part_rule.hpp"
|
||||
#include "boost/url/rfc/detail/path_rules.hpp"
|
||||
#include <boost/url/rfc/detail/path_rules.hpp>
|
||||
#include <boost/url/rfc/pct_encoded_rule.hpp>
|
||||
#include <boost/url/rfc/pchars.hpp>
|
||||
#include <boost/url/grammar/error.hpp>
|
||||
#include <boost/url/grammar/parse.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
namespace detail {
|
||||
|
||||
constexpr auto pchars_nc = pchars - ':';
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
auto
|
||||
relative_part_rule_t::
|
||||
parse(
|
||||
@@ -27,6 +31,8 @@ parse(
|
||||
) const noexcept ->
|
||||
system::result<value_type>
|
||||
{
|
||||
constexpr auto pchars_nc = pchars - ':';
|
||||
|
||||
value_type t;
|
||||
if(it == end)
|
||||
{
|
||||
@@ -94,7 +100,7 @@ parse(
|
||||
if( it != end &&
|
||||
*it == ':')
|
||||
{
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
grammar::error::mismatch);
|
||||
}
|
||||
}
|
||||
@@ -124,3 +130,5 @@ parse(
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -7,19 +8,21 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_RFC_DETAIL_IMPL_SCHEME_RULE_HPP
|
||||
#define BOOST_URL_RFC_DETAIL_IMPL_SCHEME_RULE_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include "scheme_rule.hpp"
|
||||
#include <boost/url/grammar/alpha_chars.hpp>
|
||||
#include <boost/url/grammar/delim_rule.hpp>
|
||||
#include <boost/url/grammar/charset.hpp>
|
||||
#include <boost/url/grammar/error.hpp>
|
||||
#include <boost/url/grammar/lut_chars.hpp>
|
||||
#include <boost/url/grammar/parse.hpp>
|
||||
#include <boost/url/grammar/tuple_rule.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
namespace detail {
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
auto
|
||||
scheme_rule::
|
||||
parse(
|
||||
@@ -31,17 +34,16 @@ parse(
|
||||
if(it == end)
|
||||
{
|
||||
// end
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
grammar::error::mismatch);
|
||||
}
|
||||
if(! grammar::alpha_chars(*it))
|
||||
{
|
||||
// expected alpha
|
||||
BOOST_URL_RETURN_EC(
|
||||
BOOST_URL_CONSTEXPR_RETURN_EC(
|
||||
grammar::error::mismatch);
|
||||
}
|
||||
|
||||
static
|
||||
constexpr
|
||||
grammar::lut_chars scheme_chars(
|
||||
"0123456789" "+-."
|
||||
@@ -61,3 +63,5 @@ parse(
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
|
||||
#endif
|
||||
+8
-4
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -7,10 +8,10 @@
|
||||
// Official repository: https://github.com/boostorg/url
|
||||
//
|
||||
|
||||
#ifndef BOOST_URL_RFC_DETAIL_IMPL_USERINFO_RULE_HPP
|
||||
#define BOOST_URL_RFC_DETAIL_IMPL_USERINFO_RULE_HPP
|
||||
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include "userinfo_rule.hpp"
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <boost/url/rfc/pct_encoded_rule.hpp>
|
||||
#include <boost/url/rfc/sub_delim_chars.hpp>
|
||||
#include <boost/url/rfc/unreserved_chars.hpp>
|
||||
@@ -20,6 +21,7 @@ namespace boost {
|
||||
namespace urls {
|
||||
namespace detail {
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
|
||||
auto
|
||||
userinfo_rule_t::
|
||||
parse(
|
||||
@@ -28,10 +30,10 @@ parse(
|
||||
) const noexcept ->
|
||||
system::result<value_type>
|
||||
{
|
||||
static constexpr auto uchars =
|
||||
constexpr auto uchars =
|
||||
unreserved_chars +
|
||||
sub_delim_chars;
|
||||
static constexpr auto pwchars =
|
||||
constexpr auto pwchars =
|
||||
uchars + ':';
|
||||
|
||||
value_type t;
|
||||
@@ -70,3 +72,5 @@ parse(
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
|
||||
#endif
|
||||
+7
-4
@@ -1,6 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -11,9 +11,9 @@
|
||||
#ifndef BOOST_URL_RFC_DETAIL_IP_LITERAL_RULE_HPP
|
||||
#define BOOST_URL_RFC_DETAIL_IP_LITERAL_RULE_HPP
|
||||
|
||||
#include "boost/url/detail/config.hpp"
|
||||
#include "boost/url/ipv6_address.hpp"
|
||||
#include "boost/url/error_types.hpp"
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/ipv6_address.hpp>
|
||||
#include <boost/url/error_types.hpp>
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -43,6 +43,7 @@ struct ip_literal_rule_t
|
||||
core::string_view ipvfuture;
|
||||
};
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
auto
|
||||
parse(
|
||||
char const*& it,
|
||||
@@ -57,4 +58,6 @@ constexpr ip_literal_rule_t ip_literal_rule{};
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#include <boost/url/rfc/detail/impl/ip_literal_rule.hpp>
|
||||
|
||||
#endif
|
||||
+6
-3
@@ -10,9 +10,9 @@
|
||||
#ifndef BOOST_URL_RFC_DETAIL_IPV6ADDRZ_RULE_HPP
|
||||
#define BOOST_URL_RFC_DETAIL_IPV6ADDRZ_RULE_HPP
|
||||
|
||||
#include "boost/url/error_types.hpp"
|
||||
#include "boost/url/ipv6_address.hpp"
|
||||
#include "boost/url/pct_string_view.hpp"
|
||||
#include <boost/url/error_types.hpp>
|
||||
#include <boost/url/ipv6_address.hpp>
|
||||
#include <boost/url/pct_string_view.hpp>
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -39,6 +39,7 @@ struct ipv6_addrz_rule_t
|
||||
pct_string_view zone_id;
|
||||
};
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
auto
|
||||
parse(
|
||||
char const*& it,
|
||||
@@ -53,4 +54,6 @@ constexpr ipv6_addrz_rule_t ipv6_addrz_rule{};
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#include <boost/url/rfc/detail/impl/ipv6_addrz_rule.hpp>
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -10,7 +11,7 @@
|
||||
#ifndef BOOST_URL_RFC_DETAIL_IPVFUTURE_RULE_HPP
|
||||
#define BOOST_URL_RFC_DETAIL_IPVFUTURE_RULE_HPP
|
||||
|
||||
#include "boost/url/error_types.hpp"
|
||||
#include <boost/url/error_types.hpp>
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -37,6 +38,7 @@ struct ipvfuture_rule_t
|
||||
core::string_view minor;
|
||||
};
|
||||
|
||||
BOOST_URL_CXX20_CONSTEXPR
|
||||
auto
|
||||
parse(
|
||||
char const*& it,
|
||||
@@ -51,4 +53,6 @@ constexpr ipvfuture_rule_t ipvfuture_rule{};
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
#include <boost/url/rfc/detail/impl/ipvfuture_rule.hpp>
|
||||
|
||||
#endif
|
||||
@@ -10,11 +10,11 @@
|
||||
#ifndef BOOST_URL_RFC_DETAIL_PATH_RULES_HPP
|
||||
#define BOOST_URL_RFC_DETAIL_PATH_RULES_HPP
|
||||
|
||||
#include "boost/url/rfc/pchars.hpp"
|
||||
#include "boost/url/rfc/pct_encoded_rule.hpp"
|
||||
#include "boost/url/grammar/delim_rule.hpp"
|
||||
#include "boost/url/grammar/range_rule.hpp"
|
||||
#include "boost/url/grammar/tuple_rule.hpp"
|
||||
#include <boost/url/rfc/pchars.hpp>
|
||||
#include <boost/url/rfc/pct_encoded_rule.hpp>
|
||||
#include <boost/url/grammar/delim_rule.hpp>
|
||||
#include <boost/url/grammar/range_rule.hpp>
|
||||
#include <boost/url/grammar/tuple_rule.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user