restinio::utils Namespace Reference

## Namespaces

namespace | base64
namespace | details
namespace | impl
namespace | metaprogramming
namespace | scope_exit_details
namespace | sha1
namespace | tuple_algorithms
namespace | uri_normalization

## Classes

struct | javascript_compatible_unescape_traits
| The traits for escaping and unexcaping symbols in JavaScript-compatible mode. More...
struct | relaxed_unescape_traits
| Traits for escaping and unescaping symbols in a query string in very relaxed mode. More...
struct | restinio_default_unescape_traits
| The default traits for escaping and unexcaping symbols in a query string. More...
class | tagged_scalar_t
| Helper template for defining tagged scalar types. More...
class | unescape_percent_encoding_failure_t
| Type that indicates a failure of unescaping of percent-encoded symbols. More...
struct | unescape_percent_encoding_success_t
| Type that indicates that unescaping of percent-encoded symbols completed successfully. More...
class | utf8_checker_t
| Helper class for checking UTF-8 byte sequence during parsing URI or incoming byte stream. More...
struct | x_www_form_urlencoded_unescape_traits
| Traits for escaping and unexcaping symbols in a query string in correspondence with application/x-www-form-urlencoded rules. More...

## Functions

template<typename L >
scope_exit_details::at_exit_t< L > | at_scope_exit (L &&l)
| Helper function for creation action to be performed at scope exit. More...
template<typename Value_Type >
Value_Type | from_string (string_view_t s)
| Get a value from string. More...
template<>
std::string | from_string< std::string > (string_view_t s)
| Get a value from string. More...
template<>
string_view_t | from_string< string_view_t > (string_view_t s)
| Get a value from string_view. More...
template<typename Logger , typename Message_Builder >
void | log_trace_noexcept (Logger &&logger, Message_Builder &&builder) noexcept
template<typename Message_Builder >
void | log_trace_noexcept (null_logger_t &, Message_Builder &&) noexcept
template<typename Logger , typename Message_Builder >
void | log_info_noexcept (Logger &&logger, Message_Builder &&builder) noexcept
template<typename Message_Builder >
void | log_info_noexcept (null_logger_t &, Message_Builder &&) noexcept
template<typename Logger , typename Message_Builder >
void | log_warn_noexcept (Logger &&logger, Message_Builder &&builder) noexcept
template<typename Message_Builder >
void | log_warn_noexcept (null_logger_t &, Message_Builder &&) noexcept
template<typename Logger , typename Message_Builder >
void | log_error_noexcept (Logger &&logger, Message_Builder &&builder) noexcept
template<typename Message_Builder >
void | log_error_noexcept (null_logger_t &, Message_Builder &&) noexcept
template<typename Logger , typename Lambda >
void | suppress_exceptions (Logger &&logger, const char *block_description, Lambda &&lambda) noexcept
| Helper function for execution a block of code with suppression of any exceptions raised inside that block. More...
template<typename Lambda >
void | suppress_exceptions_quietly (Lambda &&lambda) noexcept
| Helper function for execution a block of code with suppression of any exceptions raised inside that block. More...
void | read_value (std::int64_t &v, const char *data, std::size_t size)
| Read int values. More...
void | read_value (std::uint64_t &v, const char *data, std::size_t size)
void | read_value (std::int32_t &v, const char *data, std::size_t size)
void | read_value (std::uint32_t &v, const char *data, std::size_t size)
void | read_value (std::int16_t &v, const char *data, std::size_t size)
void | read_value (std::uint16_t &v, const char *data, std::size_t size)
void | read_value (std::int8_t &v, const char *data, std::size_t size)
void | read_value (std::uint8_t &v, const char *data, std::size_t size)
void | read_value (float &v, const char *data, std::size_t size)
| Read float values. More...
void | read_value (double &v, const char *data, std::size_t size)
template<typename Traits = restinio_default_unescape_traits>
RESTINIO_NODISCARD std::string | escape_percent_encoding (const string_view_t data)
| Percent encoding. More...
template<typename Traits = restinio_default_unescape_traits>
RESTINIO_NODISCARD std::string | unescape_percent_encoding (const string_view_t data)
template<typename Traits = restinio_default_unescape_traits>
RESTINIO_NODISCARD expected_t< std::string, unescape_percent_encoding_failure_t > | try_unescape_percent_encoding (const string_view_t data)
| Helper function for unescaping percent-encoded string. More...
template<typename Traits = restinio_default_unescape_traits>
RESTINIO_NODISCARD std::size_t | inplace_unescape_percent_encoding (char *data, std::size_t size)
template<typename Traits = restinio_default_unescape_traits>
RESTINIO_NODISCARD expected_t< std::size_t, unescape_percent_encoding_failure_t > | try_inplace_unescape_percent_encoding (char *data, std::size_t size)
| Helper function for unescaping percent-encoded string inplace. More...

## Function Documentation

## at_scope_exit()

template<typename L >

scope_exit_details::at_exit_t< L > restinio::utils::at_scope_exit | ( | L && | l | ) |

Helper function for creation action to be performed at scope exit.

Usage example:

if( needs_wait )
{
m_threads_to_wakeup += 1;
auto decrement_threads = at_scope_exit( [&m_threads_to_wakeup] {
--m_threads_to_wakeup;
} );
m_sleep_cond.wait_for( some_time, some_predicate );
}
restinio::utils::at_scope_exit
scope_exit_details::at_exit_t< L > at_scope_exit(L &&l)
Helper function for creation action to be performed at scope exit.
Definition: at_scope_exit.hpp:60

Definition at line 60 of file at_scope_exit.hpp.

## escape_percent_encoding()

template<typename Traits = restinio_default_unescape_traits>

RESTINIO_NODISCARD std::string restinio::utils::escape_percent_encoding | ( | const string_view_t | data | ) |

Percent encoding.

Definition at line 328 of file percent_encoding.hpp.

## from_string()

template<typename Value_Type >

Value_Type restinio::utils::from_string | ( | string_view_t | s | ) |

Get a value from string.

Definition at line 105 of file from_string.hpp.

## from_string< std::string >()

template<>

std::string restinio::utils::from_string< std::string > | ( | string_view_t | s | ) |

inline

Get a value from string.

Definition at line 116 of file from_string.hpp.

## from_string< string_view_t >()

template<>

string_view_t restinio::utils::from_string< string_view_t > | ( | string_view_t | s | ) |

inline

Get a value from string_view.

Definition at line 124 of file from_string.hpp.

## inplace_unescape_percent_encoding()

template<typename Traits = restinio_default_unescape_traits>

RESTINIO_NODISCARD std::size_t restinio::utils::inplace_unescape_percent_encoding | ( | char * | data,
|  | std::size_t | size
| ) |  |

Definition at line 409 of file percent_encoding.hpp.

## log_error_noexcept() [1/2]

template<typename Logger , typename Message_Builder >

void restinio::utils::log_error_noexcept | ( | Logger && | logger,
|  | Message_Builder && | builder
| ) |  |

noexcept

Definition at line 71 of file suppress_exceptions.hpp.

## log_error_noexcept() [2/2]

template<typename Message_Builder >

void restinio::utils::log_error_noexcept | ( | null_logger_t & | ,
|  | Message_Builder && |
| ) |  |

noexcept

Definition at line 79 of file suppress_exceptions.hpp.

## log_info_noexcept() [1/2]

template<typename Logger , typename Message_Builder >

void restinio::utils::log_info_noexcept | ( | Logger && | logger,
|  | Message_Builder && | builder
| ) |  |

noexcept

Definition at line 45 of file suppress_exceptions.hpp.

## log_info_noexcept() [2/2]

template<typename Message_Builder >

void restinio::utils::log_info_noexcept | ( | null_logger_t & | ,
|  | Message_Builder && |
| ) |  |

noexcept

Definition at line 53 of file suppress_exceptions.hpp.

## log_trace_noexcept() [1/2]

template<typename Logger , typename Message_Builder >

void restinio::utils::log_trace_noexcept | ( | Logger && | logger,
|  | Message_Builder && | builder
| ) |  |

noexcept

Definition at line 32 of file suppress_exceptions.hpp.

## log_trace_noexcept() [2/2]

template<typename Message_Builder >

void restinio::utils::log_trace_noexcept | ( | null_logger_t & | ,
|  | Message_Builder && |
| ) |  |

noexcept

Definition at line 40 of file suppress_exceptions.hpp.

## log_warn_noexcept() [1/2]

template<typename Logger , typename Message_Builder >

void restinio::utils::log_warn_noexcept | ( | Logger && | logger,
|  | Message_Builder && | builder
| ) |  |

noexcept

Definition at line 58 of file suppress_exceptions.hpp.

## log_warn_noexcept() [2/2]

template<typename Message_Builder >

void restinio::utils::log_warn_noexcept | ( | null_logger_t & | ,
|  | Message_Builder && |
| ) |  |

noexcept

Definition at line 66 of file suppress_exceptions.hpp.

## read_value() [1/10]

void restinio::utils::read_value | ( | double & | v,
|  | const char * | data,
|  | std::size_t | size
| ) |  |

inline

Definition at line 94 of file from_string.hpp.

## read_value() [2/10]

void restinio::utils::read_value | ( | float & | v,
|  | const char * | data,
|  | std::size_t | size
| ) |  |

inline

Read float values.

Definition at line 86 of file from_string.hpp.

## read_value() [3/10]

void restinio::utils::read_value | ( | std::int16_t & | v,
|  | const char * | data,
|  | std::size_t | size
| ) |  |

inline

Definition at line 58 of file from_string.hpp.

## read_value() [4/10]

void restinio::utils::read_value | ( | std::int32_t & | v,
|  | const char * | data,
|  | std::size_t | size
| ) |  |

inline

Definition at line 46 of file from_string.hpp.

## read_value() [5/10]

void restinio::utils::read_value | ( | std::int64_t & | v,
|  | const char * | data,
|  | std::size_t | size
| ) |  |

inline

Read int values.

Definition at line 34 of file from_string.hpp.

## read_value() [6/10]

void restinio::utils::read_value | ( | std::int8_t & | v,
|  | const char * | data,
|  | std::size_t | size
| ) |  |

inline

Definition at line 70 of file from_string.hpp.

## read_value() [7/10]

void restinio::utils::read_value | ( | std::uint16_t & | v,
|  | const char * | data,
|  | std::size_t | size
| ) |  |

inline

Definition at line 64 of file from_string.hpp.

## read_value() [8/10]

void restinio::utils::read_value | ( | std::uint32_t & | v,
|  | const char * | data,
|  | std::size_t | size
| ) |  |

inline

Definition at line 52 of file from_string.hpp.

## read_value() [9/10]

void restinio::utils::read_value | ( | std::uint64_t & | v,
|  | const char * | data,
|  | std::size_t | size
| ) |  |

inline

Definition at line 40 of file from_string.hpp.

## read_value() [10/10]

void restinio::utils::read_value | ( | std::uint8_t & | v,
|  | const char * | data,
|  | std::size_t | size
| ) |  |

inline

Definition at line 76 of file from_string.hpp.

## suppress_exceptions()

template<typename Logger , typename Lambda >

void restinio::utils::suppress_exceptions | ( | Logger && | logger,
|  | const char * | block_description,
|  | Lambda && | lambda
| ) |  |

noexcept

Helper function for execution a block of code with suppression of any exceptions raised inside that block.

Exceptions caught are logged via logger. Exceptions thrown during this logging are suppressed.

Since
  v.0.6.0

Parameters

  logger | Logger to be used.
  block_description | Description of the block of code. Will be used for logging about exceptions caught.
  lambda | Block of code for execution.

Definition at line 94 of file suppress_exceptions.hpp.

## suppress_exceptions_quietly()

template<typename Lambda >

void restinio::utils::suppress_exceptions_quietly | ( | Lambda && | lambda | ) |

noexcept

Helper function for execution a block of code with suppression of any exceptions raised inside that block.

All exceptions are simply intercepted. Nothing is logged in the case of an exception thrown.

Since
  v.0.6.0

Definition at line 133 of file suppress_exceptions.hpp.

## try_inplace_unescape_percent_encoding()

template<typename Traits = restinio_default_unescape_traits>

RESTINIO_NODISCARD expected_t< std::size_t, unescape_percent_encoding_failure_t > restinio::utils::try_inplace_unescape_percent_encoding | ( | char * | data,
|  | std::size_t | size
| ) |  |

Helper function for unescaping percent-encoded string inplace.

This function doesn't throw if some character can't be unescaped or some ill-formed sequence is found.

Note
  This function is not noexcept and can throw on other types of failures.

Since
  v.0.6.5

Definition at line 441 of file percent_encoding.hpp.

## try_unescape_percent_encoding()

template<typename Traits = restinio_default_unescape_traits>

RESTINIO_NODISCARD expected_t< std::string, unescape_percent_encoding_failure_t > restinio::utils::try_unescape_percent_encoding | ( | const string_view_t | data | ) |

Helper function for unescaping percent-encoded string.

This function doesn't throw if some character can't be unescaped or some ill-formed sequence is found.

Note
  This function is not noexcept and can throw on other types of failures (like unability to allocate a memory).

Since
  v.0.6.5

Definition at line 392 of file percent_encoding.hpp.

## unescape_percent_encoding()

template<typename Traits = restinio_default_unescape_traits>

RESTINIO_NODISCARD std::string restinio::utils::unescape_percent_encoding | ( | const string_view_t | data | ) |

Examples
  sample/express_router/main.cpp.

Definition at line 363 of file percent_encoding.hpp.