RESTinio

Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
restinio::router::impl::buffered_matcher_holder_t Class Reference

A special class that allows to hold a copy of small-size method_matchers or a pointer to dynamically allocated large-size method_matchers. More...

`#include <method_matcher.hpp>`

## Public Member Functions
| buffered_matcher_holder_t ()=default
| ~buffered_matcher_holder_t () noexcept
| buffered_matcher_holder_t (const buffered_matcher_holder_t &)=delete
buffered_matcher_holder_t & | operator= (const buffered_matcher_holder_t &)=delete
| buffered_matcher_holder_t (buffered_matcher_holder_t &&other) noexcept
buffered_matcher_holder_t & | operator= (buffered_matcher_holder_t &&other) noexcept
template<typename Target_Type , typename... Args>
void | assign (Args &&... args)
| Creates an instance of Target_Type and initializes it with arguments Args. More...
RESTINIO_NODISCARD method_matcher_t * | get () const noexcept
| Get the pointer to actual matcher inside the holder. More...
RESTINIO_NODISCARD method_matcher_t * | operator-> () const noexcept
| Get the pointer to actual matcher inside the holder. More...
RESTINIO_NODISCARD method_matcher_t & | operator* () const noexcept
| Get a reference to actual matcher inside the holder. More...

## Private Types
using | pfn_move_t = method_matcher_t *(*)(void *object, void *buffer)
| A type of free function to be used to move a value of an object to the specified buffer. More...

## Private Member Functions
void | cleanup ()
void | move_from (buffered_matcher_holder_t &other)

## Private Attributes
method_matcher_t * | m_matcher { nullptr }
| A pointer to actual matcher allocated inside the internall buffer. More...
std::array< char, buffer_size > | m_buffer
| The internal buffer. More...
pfn_move_t | m_mover { nullptr }
| An actual move-function. More...

## Static Private Attributes
static constexpr std::size_t | buffer_size
| The size of the internal buffer. More...
static constexpr std::size_t | alignment
| Alignment to be used by the internal buffer. More...

## Friends
void | assign (buffered_matcher_holder_t &holder, http_method_id_t method)
template<typename Arg >
void | assign (buffered_matcher_holder_t &holder, Arg &&method_matcher)

## Detailed Description

A special class that allows to hold a copy of small-size method_matchers or a pointer to dynamically allocated large-size method_matchers.

An instance of this class looks like a smart pointer to method_matcher_t. This smart pointer is moveable, but not copyable (it's like unique_ptr).

A value is set by assign() method:

buffered_matcher_holder_t matcher;
matcher.assign<fixed_size_any_of_matcher_t<10>>(
std::initializer_list<http_method_id_t>{
http_method_get(),
http_method_head(),
...
});
restinio::router::impl::buffered_matcher_holder_t::buffered_matcher_holder_t
buffered_matcher_holder_t()=default

Since
  v.0.6.6

Definition at line 224 of file method_matcher.hpp.

## Member Typedef Documentation

## ◆ pfn_move_t

using restinio::router::impl::buffered_matcher_holder_t::pfn_move_t = method_matcher_t* (*)(void* object, void* buffer)
| private

A type of free function to be used to move a value of an object to the specified buffer.

This function should allocate a new instance in buffer and move the content of object into it. The pointer to the allocated instance should be returned.

Definition at line 245 of file method_matcher.hpp.

## Constructor & Destructor Documentation

## ◆ buffered_matcher_holder_t() [1/3]

restinio::router::impl::buffered_matcher_holder_t::buffered_matcher_holder_t | ( |  | ) |
| default

## ◆ ~buffered_matcher_holder_t()

restinio::router::impl::buffered_matcher_holder_t::~buffered_matcher_holder_t | ( |  | ) |
| inline noexcept

Definition at line 285 of file method_matcher.hpp.

## ◆ buffered_matcher_holder_t() [2/3]

restinio::router::impl::buffered_matcher_holder_t::buffered_matcher_holder_t | ( | const buffered_matcher_holder_t & |  | ) |
| delete

## ◆ buffered_matcher_holder_t() [3/3]

restinio::router::impl::buffered_matcher_holder_t::buffered_matcher_holder_t | ( | buffered_matcher_holder_t && | other | ) |
| inline noexcept

Definition at line 297 of file method_matcher.hpp.

## Member Function Documentation

## ◆ assign()

template<typename Target_Type , typename... Args>

void restinio::router::impl::buffered_matcher_holder_t::assign | ( | Args &&... | args | ) |
| inline

Creates an instance of Target_Type and initializes it with arguments Args.

Previous value of buffered_matcher_holder_t will be destroyed.

A new object is created in the internal buffer if its size is not greater than buffer_size. Otherwise a new object is created in dynamic memory and allocated_matcher_proxy_t for it is placed into the internal buffer.

Definition at line 329 of file method_matcher.hpp.

## ◆ cleanup()

void restinio::router::impl::buffered_matcher_holder_t::cleanup | ( |  | ) |
| inline private

Definition at line 264 of file method_matcher.hpp.

## ◆ get()

RESTINIO_NODISCARD method_matcher_t * restinio::router::impl::buffered_matcher_holder_t::get | ( |  | ) | const
| inline noexcept

Get the pointer to actual matcher inside the holder.

Definition at line 358 of file method_matcher.hpp.

## ◆ move_from()

void restinio::router::impl::buffered_matcher_holder_t::move_from | ( | buffered_matcher_holder_t & | other | ) |
| inline private

Definition at line 270 of file method_matcher.hpp.

## ◆ operator*()

RESTINIO_NODISCARD method_matcher_t & restinio::router::impl::buffered_matcher_holder_t::operator* | ( |  | ) | const
| inline noexcept

Get a reference to actual matcher inside the holder.

Definition at line 368 of file method_matcher.hpp.

## ◆ operator->()

RESTINIO_NODISCARD method_matcher_t * restinio::router::impl::buffered_matcher_holder_t::operator-> | ( |  | ) | const
| inline noexcept

Get the pointer to actual matcher inside the holder.

Definition at line 363 of file method_matcher.hpp.

## ◆ operator=() [1/2]

buffered_matcher_holder_t & restinio::router::impl::buffered_matcher_holder_t::operator= | ( | buffered_matcher_holder_t && | other | ) |
| inline noexcept

Definition at line 304 of file method_matcher.hpp.

## ◆ operator=() [2/2]

buffered_matcher_holder_t & restinio::router::impl::buffered_matcher_holder_t::operator= | ( | const buffered_matcher_holder_t & |  | ) |
| delete

## Friends And Related Function Documentation

## ◆ assign [1/2]

template<typename Arg >

void assign | ( | buffered_matcher_holder_t & | holder,
|  | Arg && | method_matcher
| ) |  |
| friend

Definition at line 378 of file method_matcher.hpp.

## ◆ assign [2/2]

void assign | ( | buffered_matcher_holder_t & | holder,
|  | http_method_id_t | method
| ) |  |
| friend

Definition at line 371 of file method_matcher.hpp.

## Member Data Documentation

## ◆ alignment

constexpr std::size_t restinio::router::impl::buffered_matcher_holder_t::alignment
| static constexpr private

Initial value:
=
std::max( {
alignof(simple_matcher_t),
alignof(fixed_size_any_of_matcher_t<4>),
alignof(allocated_matcher_proxy_t<
fixed_size_any_of_matcher_t<20>>) } )

Alignment to be used by the internal buffer.

Definition at line 231 of file method_matcher.hpp.

## ◆ buffer_size

constexpr std::size_t restinio::router::impl::buffered_matcher_holder_t::buffer_size
| static constexpr private

Initial value:
=
sizeof(fixed_size_any_of_matcher_t<4>)

The size of the internal buffer.

Definition at line 227 of file method_matcher.hpp.

## ◆ m_buffer

std::array<char, buffer_size> restinio::router::impl::buffered_matcher_holder_t::m_buffer
| private

The internal buffer.

Definition at line 255 of file method_matcher.hpp.

## ◆ m_matcher

method_matcher_t* restinio::router::impl::buffered_matcher_holder_t::m_matcher { nullptr }
| private

A pointer to actual matcher allocated inside the internall buffer.

Can be nullptr. For example: just after the creation and before the call to assign(). Or after a move-constructor or move-operator.

Definition at line 252 of file method_matcher.hpp.

## ◆ m_mover

pfn_move_t restinio::router::impl::buffered_matcher_holder_t::m_mover { nullptr }
| private

An actual move-function.

Can be nullptr if assign() is not called yet.

Definition at line 261 of file method_matcher.hpp.

The documentation for this class was generated from the following file:

- restinio/router/method_matcher.hpp