2
3
6
7
8
9
10
14#include <restinio/http_headers.hpp>
16#include <initializer_list>
29
30
31
32
33
34
35
36
37
68
69
70
71
72
73
74
75
76
77
78
79template<
typename Matcher >
85 template<
typename... Args >
94 return m_matcher->match( method );
102
103
104
105
106
107
108
109
131
132
133
134
135
136
137
138template< std::size_t Size >
145
146
147
148
149
150
154 assert( Size == values.size() );
156 std::copy( values.begin(), values.end(),
m_methods.begin() );
175
176
177
178
179
180
181
182template< std::size_t Size >
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
241
242
243
244
249
250
251
259
260
274 m_matcher = other.m_mover( other.m_matcher, m_buffer.data() );
316
317
318
319
320
321
322
323
324
325
326
327 template<
typename Target_Type,
typename... Args >
331 static_assert(
alignof(Target_Type) <=
alignment,
332 "Target_Type should have appropriate alignment" );
338 m_matcher =
new(m_buffer.data()) Target_Type{ std::forward<Args>(args)... };
340 auto * what =
reinterpret_cast<Target_Type *>(raw_what);
341 return new(dest_storage) Target_Type{ std::move(*what) };
347 m_matcher =
new(m_buffer.data()) actual_type{ std::forward<Args>(args)... };
349 auto * what =
reinterpret_cast<actual_type *>(raw_what);
350 return new(dest_storage) actual_type{ std::move(*what) };
376 template<
typename Arg >
380 using pure_method_matcher_type = std::decay_t<Arg>;
382 static_assert( std::is_base_of<
383 method_matcher_t, pure_method_matcher_type >::value,
384 "Arg should be derived from method_matcher_t" );
386 holder.assign< pure_method_matcher_type >(
387 std::forward<Arg>(method_matcher) );
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414template<
typename... Args >
419 return { std::initializer_list<
http_method_id_t>{ std::forward<Args>(args)... } };
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446template<
typename... Args >
451 return { std::initializer_list<
http_method_id_t>{ std::forward<Args>(args)... } };
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
486 for(
const auto & m : m_methods )
496 m_methods.emplace_back( std::move(method) );
504 return m_methods.size();
511 return m_methods.empty();
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
547 for(
const auto & m : m_methods )
557 m_methods.emplace_back( std::move(method) );
565 return m_methods.size();
572 return m_methods.empty();
A type for representation of HTTP method ID.
friend constexpr bool operator==(const http_method_id_t &a, const http_method_id_t &b) noexcept
An implementation of method_matcher that allows a method if it's found in a dynamic list of allowed m...
bool empty() const noexcept
std::vector< http_method_id_t > m_methods
dynamic_any_of_methods_matcher_t & add(http_method_id_t method)
std::size_t size() const noexcept
dynamic_any_of_methods_matcher_t()=default
bool match(const http_method_id_t &method) const noexcept override
Is the specified method can be applied to a route?
An implementation of method_matcher that allows a method if it isn't found in a dynamic list of disab...
std::size_t size() const noexcept
bool match(const http_method_id_t &method) const noexcept override
Is the specified method can be applied to a route?
dynamic_none_of_methods_matcher_t()=default
std::vector< http_method_id_t > m_methods
bool empty() const noexcept
dynamic_none_of_methods_matcher_t & add(http_method_id_t method)
A proxy for actual method_matcher that will be allocated in dynamic memory.
std::unique_ptr< Matcher > m_matcher
allocated_matcher_proxy_t(Args &&...args)
bool match(const http_method_id_t &method) const noexcept override
Is the specified method can be applied to a route?
A special class that allows to hold a copy of small-size method_matchers or a pointer to dynamically ...
method_matcher_t * operator->() const noexcept
Get the pointer to actual matcher inside the holder.
std::array< char, buffer_size > m_buffer
The internal buffer.
friend void assign(buffered_matcher_holder_t &holder, Arg &&method_matcher)
pfn_move_t m_mover
An actual move-function.
friend void assign(buffered_matcher_holder_t &holder, http_method_id_t method)
void move_from(buffered_matcher_holder_t &other)
buffered_matcher_holder_t & operator=(buffered_matcher_holder_t &&other) noexcept
buffered_matcher_holder_t & operator=(const buffered_matcher_holder_t &)=delete
method_matcher_t *(*)(void *object, void *buffer) pfn_move_t
A type of free function to be used to move a value of an object to the specified buffer.
method_matcher_t & operator*() const noexcept
Get a reference to actual matcher inside the holder.
void assign(Args &&... args)
Creates an instance of Target_Type and initializes it with arguments Args.
buffered_matcher_holder_t()=default
buffered_matcher_holder_t(buffered_matcher_holder_t &&other) noexcept
static constexpr std::size_t alignment
Alignment to be used by the internal buffer.
method_matcher_t * get() const noexcept
Get the pointer to actual matcher inside the holder.
static constexpr std::size_t buffer_size
The size of the internal buffer.
~buffered_matcher_holder_t() noexcept
method_matcher_t * m_matcher
A pointer to actual matcher allocated inside the internall buffer.
buffered_matcher_holder_t(const buffered_matcher_holder_t &)=delete
A matcher that finds a value in the vector of allowed values of fixed size.
fixed_size_any_of_matcher_t(std::initializer_list< http_method_id_t > values)
Initializing constructor.
bool match(const http_method_id_t &method) const noexcept override
Is the specified method can be applied to a route?
std::array< http_method_id_t, Size > m_methods
A matcher that finds a value in the vector of disabled values of fixed size.
fixed_size_any_of_matcher_t< Size > base_type_t
bool match(const http_method_id_t &method) const noexcept override
Is the specified method can be applied to a route?
A simple method_matcher that compares just one user-specified value.
simple_matcher_t(http_method_id_t method)
bool match(const http_method_id_t &method) const noexcept override
Is the specified method can be applied to a route?
http_method_id_t m_method
impl::fixed_size_none_of_matcher_t< sizeof...(Args) > none_of_methods(Args &&...args)
A factory function that creates a method_matcher that allows a method if it isn't found in the list o...
impl::fixed_size_any_of_matcher_t< sizeof...(Args) > any_of_methods(Args &&...args)
A factory function that creates a method_matcher that allows a method if it's found in the list of al...
An interface of method_matcher.
virtual bool match(const http_method_id_t &method) const noexcept=0
Is the specified method can be applied to a route?
method_matcher_t(method_matcher_t &&)=default
virtual ~method_matcher_t()=default
method_matcher_t & operator=(const method_matcher_t &)=default
method_matcher_t()=default
method_matcher_t & operator=(method_matcher_t &&)=default
method_matcher_t(const method_matcher_t &)=default