RESTinio

Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
restinio::router::route_params_t Class Referencefinal

Parameters extracted from route. More...

`#include <express.hpp>`

## Public Types
using | named_parameters_container_t = std::vector< std::pair< string_view_t, string_view_t > >
using | indexed_parameters_container_t = std::vector< string_view_t >

## Public Member Functions
| route_params_t ()=default
| route_params_t (route_params_t &&)=default
route_params_t & | operator= (route_params_t &&)=default
| route_params_t (const route_params_t &)=delete
route_params_t & | operator= (const route_params_t &)=delete
string_view_t | match () const noexcept
| Matched route. More...
string_view_t | operator[] (string_view_t key) const
| Get named parameter. More...
bool | has (string_view_t key) const noexcept
| Check parameter. More...
optional_t< string_view_t > | get_param (string_view_t key) const noexcept
| Get the value of a parameter if it exists. More...
string_view_t | operator[] (std::size_t i) const
| Get indexed parameter. More...
auto | named_parameters_size () const noexcept
| Get number of parameters. More...
auto | indexed_parameters_size () const noexcept

## Private Member Functions
void | match (std::unique_ptr< char[] > request_target, std::shared_ptr< std::string > key_names_buffer, string_view_t match, named_parameters_container_t named_parameters, indexed_parameters_container_t indexed_parameters)
named_parameters_container_t::const_iterator | find_named_parameter (string_view_t key) const noexcept
named_parameters_container_t::const_reference | find_named_parameter_with_check (string_view_t key) const

## Private Attributes
std::unique_ptr< char[] > | m_request_target
| A raw request target. More...
std::shared_ptr< std::string > | m_key_names_buffer
| Shared buffer for string_view of named parameterts names. More...
string_view_t | m_match
| Matched pattern. More...
named_parameters_container_t | m_named_parameters
| Named params. More...
indexed_parameters_container_t | m_indexed_parameters
| Indexed params. More...

## Friends
struct | impl::route_params_accessor_t

## Detailed Description

Parameters extracted from route.

Holds values of parameters extracted from route.

All values are stored as string views, route_params_t instance owns bufers used by these views. And that leads to following limittions: once a copy of a string view is created it is important to use it with respect to life time of route_params_t instance to which this parameter bind belongs. String view is valid during route_params_t instance life time.

Definition at line 57 of file express.hpp.

## Member Typedef Documentation

## ◆ indexed_parameters_container_t

using restinio::router::route_params_t::indexed_parameters_container_t = std::vector< string_view_t >

Definition at line 62 of file express.hpp.

## ◆ named_parameters_container_t

using restinio::router::route_params_t::named_parameters_container_t = std::vector< std::pair< string_view_t, string_view_t > >

Definition at line 60 of file express.hpp.

## Constructor & Destructor Documentation

## ◆ route_params_t() [1/3]

restinio::router::route_params_t::route_params_t | ( |  | ) |
| default

## ◆ route_params_t() [2/3]

restinio::router::route_params_t::route_params_t | ( | route_params_t && |  | ) |
| default

## ◆ route_params_t() [3/3]

restinio::router::route_params_t::route_params_t | ( | const route_params_t & |  | ) |
| delete

## Member Function Documentation

## ◆ find_named_parameter()

named_parameters_container_t::const_iterator restinio::router::route_params_t::find_named_parameter | ( | string_view_t | key | ) | const
| inline private noexcept

Definition at line 139 of file express.hpp.

## ◆ find_named_parameter_with_check()

named_parameters_container_t::const_reference restinio::router::route_params_t::find_named_parameter_with_check | ( | string_view_t | key | ) | const
| inline private

Definition at line 151 of file express.hpp.

## ◆ get_param()

optional_t< string_view_t > restinio::router::route_params_t::get_param | ( | string_view_t | key | ) | const
| inline noexcept

Get the value of a parameter if it exists.

Since
  v.0.4.4

Definition at line 112 of file express.hpp.

## ◆ has()

bool restinio::router::route_params_t::has | ( | string_view_t | key | ) | const
| inline noexcept

Check parameter.

Definition at line 104 of file express.hpp.

## ◆ indexed_parameters_size()

auto restinio::router::route_params_t::indexed_parameters_size | ( |  | ) | const
| inline noexcept

Definition at line 134 of file express.hpp.

## ◆ match() [1/2]

string_view_t restinio::router::route_params_t::match | ( |  | ) | const
| inline noexcept

Matched route.

Definition at line 93 of file express.hpp.

## ◆ match() [2/2]

void restinio::router::route_params_t::match | ( | std::unique_ptr< char[] > | request_target,
|  | std::shared_ptr< std::string > | key_names_buffer,
|  | string_view_t | match,
|  | named_parameters_container_t | named_parameters,
|  | indexed_parameters_container_t | indexed_parameters
| ) |  |
| inline private

Definition at line 69 of file express.hpp.

## ◆ named_parameters_size()

auto restinio::router::route_params_t::named_parameters_size | ( |  | ) | const
| inline noexcept

Get number of parameters.

Definition at line 133 of file express.hpp.

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

route_params_t & restinio::router::route_params_t::operator= | ( | const route_params_t & |  | ) |
| delete

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

route_params_t & restinio::router::route_params_t::operator= | ( | route_params_t && |  | ) |
| default

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

string_view_t restinio::router::route_params_t::operator[] | ( | std::size_t | i | ) | const
| inline

Get indexed parameter.

Definition at line 123 of file express.hpp.

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

string_view_t restinio::router::route_params_t::operator[] | ( | string_view_t | key | ) | const
| inline

Get named parameter.

Definition at line 97 of file express.hpp.

## Friends And Related Function Documentation

## ◆ impl::route_params_accessor_t

friend struct impl::route_params_accessor_t
| friend

Definition at line 66 of file express.hpp.

## Member Data Documentation

## ◆ m_indexed_parameters

indexed_parameters_container_t restinio::router::route_params_t::m_indexed_parameters
| private

Indexed params.

Definition at line 188 of file express.hpp.

## ◆ m_key_names_buffer

std::shared_ptr< std::string > restinio::router::route_params_t::m_key_names_buffer
| private

Shared buffer for string_view of named parameterts names.

Definition at line 179 of file express.hpp.

## ◆ m_match

string_view_t restinio::router::route_params_t::m_match
| private

Matched pattern.

Definition at line 182 of file express.hpp.

## ◆ m_named_parameters

named_parameters_container_t restinio::router::route_params_t::m_named_parameters
| private

Named params.

Definition at line 185 of file express.hpp.

## ◆ m_request_target

std::unique_ptr< char[] > restinio::router::route_params_t::m_request_target
| private

A raw request target.

All parameters values are defined as string views refering parts of this beffer.

Note
  `std::unique_ptr< char[] >` is used here on purpose, because if we consider std::string, then it has an issue when SSO is applied. It is important that parameters that refering buffer are valid after move operations with the buffer. And std::strings with SSO applied cannot guarantee this. Vector on the other hand gives this guarantee.

Definition at line 176 of file express.hpp.

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

- restinio/router/express.hpp