Blame view

3rdparty/boost_1_81_0/boost/url/params_view.hpp 6.75 KB
0b6a182c   Hu Chunming   添加无鉴权注册和注销
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
  //
  // 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_PARAMS_VIEW_HPP
  #define BOOST_URL_PARAMS_VIEW_HPP
  
  #include <boost/url/detail/config.hpp>
  #include <boost/url/params_base.hpp>
  
  namespace boost {
  namespace urls {
  
  /** A view representing query parameters in a URL
  
      Objects of this type are used to interpret
      the query parameters as a bidirectional view
      of key/value pairs.
  
      The view does not retain ownership of the
      elements and instead references the original
      character buffer. The caller is responsible
      for ensuring that the lifetime of the buffer
      extends until it is no longer referenced.
  
      @par Example
      @code
      url_view u( "?first=John&last=Doe" );
  
      params_view p = u.params();
      @endcode
  
      Percent escapes in strings returned when
      dereferencing iterators are automatically
      decoded.
  
      @par Iterator Invalidation
      Changes to the underlying character buffer
      can invalidate iterators which reference it.
  */
  class params_view
      : public params_base
  {
      friend class url_view_base;
      friend class params_encoded_view;
      friend class params_ref;
  
      params_view(
          detail::query_ref const& ref,
          encoding_opts opt) noexcept;
  
  public:
      /** Constructor
  
          Default-constructed params have
          zero elements.
  
          @par Example
          @code
          params_view qp;
          @endcode
  
          @par Effects
          @code
          return params_view( "" );
          @endcode
  
          @par Complexity
          Constant.
  
          @par Exception Safety
          Throws nothing.
      */
      params_view() = default;
  
      /** Constructor
  
          After construction both views reference
          the same character buffer.
  
          Ownership is not transferred; the caller
          is responsible for ensuring the lifetime
          of the buffer extends until it is no
          longer referenced.
  
          @par Postconditions
          @code
          this->buffer().data() == other.buffer().data()
          @endcode
  
          @par Complexity
          Constant.
  
          @par Exception Safety
          Throws nothing
      */
      params_view(
          params_view const& other) = default;
  
      /** Constructor
  
          After construction both views will
          reference the same character buffer
          but this instance will use the specified
          @ref encoding_opts when the values
          are decoded.
  
          Ownership is not transferred; the caller
          is responsible for ensuring the lifetime
          of the buffer extends until it is no
          longer referenced.
  
          @par Postconditions
          @code
          this->buffer().data() == other.buffer().data()
          @endcode
  
          @par Complexity
          Constant.
  
          @par Exception Safety
          Throws nothing
      */
      params_view(
          params_view const& other,
          encoding_opts opt) noexcept;
  
      /** Constructor
  
          This function constructs params from
          a valid query parameter string, which
          can contain percent escapes. Unlike
          the parameters in URLs, the string
          passed here should not start with "?".
          Upon construction, the view references
          the character buffer pointed to by `s`.
          The caller is responsible for ensuring
          that the lifetime of the buffer extends
          until it is no longer referenced.
  
          @par Example
          @code
          params_view qp( "first=John&last=Doe" );
          @endcode
  
          @par Effects
          @code
          return parse_query( s ).value();
          @endcode
  
          @par Postconditions
          @code
          this->buffer().data() == s.data()
          @endcode
  
          @par Complexity
          Linear in `s`.
  
          @par Exception Safety
          Exceptions thrown on invalid input.
  
          @throw system_error
          `s` contains an invalid query parameter
          string.
  
          @param s The string to parse.
  
          @par BNF
          @code
          query-params    = [ query-param ] *( "&" query-param )
  
          query-param     = key [ "=" value ]
          @endcode
  
          @par Specification
          @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.4"
              >3.4.  Query</a>
      */
      BOOST_URL_DECL
      params_view(
          string_view s);
  
      /** Constructor
  
          This function constructs params from
          a valid query parameter string, which
          can contain percent escapes.
  
          This instance will use the specified
          @ref encoding_opts when the values
          are decoded.
  
          Unlike the parameters in URLs, the string
          passed here should not start with "?".
          Upon construction, the view will
          reference the character buffer pointed
          to by `s`. The caller is responsible
          for ensuring that the lifetime of the
          buffer extends until it is no longer
          referenced.
  
          @par Example
          @code
          encoding_opts opt;
          opt.space_as_plus = true;
          params_view qp( "name=John+Doe", opt );
          @endcode
  
          @par Effects
          @code
          return params_view(parse_query( s ).value(), opt);
          @endcode
  
          @par Postconditions
          @code
          this->buffer().data() == s.data()
          @endcode
  
          @par Complexity
          Linear in `s`.
  
          @par Exception Safety
          Exceptions thrown on invalid input.
  
          @throw system_error
          `s` contains an invalid query parameter
          string.
  
          @param s The string to parse.
  
          @param opt The options for decoding. If
          this parameter is omitted, `space_as_plus`
          is used.
  
          @par BNF
          @code
          query-params    = [ query-param ] *( "&" query-param )
  
          query-param     = key [ "=" value ]
          @endcode
  
          @par Specification
          @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.4"
              >3.4.  Query</a>
      */
      BOOST_URL_DECL
      params_view(
          string_view s,
          encoding_opts opt);
  
      /** Assignment
  
          After assignment, both views reference
          the same underlying character buffer.
  
          Ownership is not transferred; the caller
          is responsible for ensuring the lifetime
          of the buffer extends until it is no
          longer referenced.
  
          @par Postconditions
          @code
          this->buffer().data() == other.buffer().data()
          @endcode
  
          @par Complexity
          Constant
  
          @par Exception Safety
          Throws nothing
      */
      params_view&
      operator=(
          params_view const&) = default;
  };
  
  } // urls
  } // boost
  
  #endif