File indexing completed on 2025-01-18 09:53:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_URL_DETAIL_NORMALIZED_HPP
0012 #define BOOST_URL_DETAIL_NORMALIZED_HPP
0013
0014 #include <boost/core/detail/string_view.hpp>
0015 #include <boost/url/segments_encoded_view.hpp>
0016 #include <boost/url/detail/normalize.hpp>
0017
0018 namespace boost {
0019 namespace urls {
0020 namespace detail {
0021
0022 class fnv_1a
0023 {
0024 public:
0025 using digest_type = std::size_t;
0026
0027 #if BOOST_URL_ARCH == 64
0028 static constexpr std::size_t const prime =
0029 static_cast<std::size_t>(0x100000001B3ULL);
0030 static constexpr std::size_t init_hash =
0031 static_cast<std::size_t>(0xcbf29ce484222325ULL);
0032 #else
0033 static constexpr std::size_t const prime =
0034 static_cast<std::size_t>(0x01000193UL);
0035 static constexpr std::size_t init_hash =
0036 static_cast<std::size_t>(0x811C9DC5UL);
0037 #endif
0038
0039 explicit
0040 fnv_1a(std::size_t salt) noexcept
0041 : h_(init_hash + salt)
0042 {
0043 }
0044
0045 void
0046 put(char c) noexcept
0047 {
0048 h_ ^= c;
0049 h_ *= prime;
0050 }
0051
0052 void
0053 put(core::string_view s) noexcept
0054 {
0055 for (char c: s)
0056 {
0057 put(c);
0058 }
0059 }
0060
0061 digest_type
0062 digest() const noexcept
0063 {
0064 return h_;
0065 }
0066
0067 private:
0068 std::size_t h_;
0069 };
0070
0071 void
0072 pop_encoded_front(
0073 core::string_view& s,
0074 char& c,
0075 std::size_t& n) noexcept;
0076
0077
0078
0079 int
0080 compare_encoded(
0081 core::string_view lhs,
0082 core::string_view rhs) noexcept;
0083
0084
0085
0086 void
0087 digest_encoded(
0088 core::string_view s,
0089 fnv_1a& hasher) noexcept;
0090
0091 void
0092 digest(
0093 core::string_view s,
0094 fnv_1a& hasher) noexcept;
0095
0096
0097
0098
0099
0100 std::size_t
0101 path_starts_with(
0102 core::string_view lhs,
0103 core::string_view rhs) noexcept;
0104
0105
0106
0107
0108
0109 std::size_t
0110 path_ends_with(
0111 core::string_view lhs,
0112 core::string_view rhs) noexcept;
0113
0114
0115
0116 int
0117 ci_compare_encoded(
0118 core::string_view lhs,
0119 core::string_view rhs) noexcept;
0120
0121
0122
0123 void
0124 ci_digest_encoded(
0125 core::string_view s,
0126 fnv_1a& hasher) noexcept;
0127
0128
0129 int
0130 compare(
0131 core::string_view lhs,
0132 core::string_view rhs) noexcept;
0133
0134
0135
0136 int
0137 ci_compare(
0138 core::string_view lhs,
0139 core::string_view rhs) noexcept;
0140
0141
0142 void
0143 ci_digest(
0144 core::string_view s,
0145 fnv_1a& hasher) noexcept;
0146
0147 BOOST_URL_DECL
0148 std::size_t
0149 remove_dot_segments(
0150 char* dest,
0151 char const* end,
0152 core::string_view s) noexcept;
0153
0154 void
0155 pop_last_segment(
0156 core::string_view& s,
0157 core::string_view& c,
0158 std::size_t& level,
0159 bool r) noexcept;
0160
0161 char
0162 path_pop_back( core::string_view& s );
0163
0164 void
0165 normalized_path_digest(
0166 core::string_view s,
0167 bool remove_unmatched,
0168 fnv_1a& hasher) noexcept;
0169
0170 int
0171 segments_compare(
0172 segments_encoded_view seg0,
0173 segments_encoded_view seg1) noexcept;
0174
0175 }
0176 }
0177 }
0178
0179 #endif