RESTinio
string_algo.hpp
Go to the documentation of this file.
1 /*
2  * RESTinio
3  */
4 
5 /*!
6  * @file
7  * @brief Various string-related algorithms.
8  *
9  * @since v.0.6.1
10  */
11 
12 #pragma once
13 
14 #include <restinio/string_view.hpp>
15 #include <restinio/compiler_features.hpp>
16 
17 namespace restinio
18 {
19 
20 namespace string_algo
21 {
22 
25  const string_view_t & where,
26  const string_view_t & what ) noexcept
27 {
28  return where.size() >= what.size() &&
29  0 == where.compare(0u, what.size(), what);
30 }
31 
33 bool ends_with(
34  const string_view_t & where,
35  const string_view_t & what ) noexcept
36 {
37  return where.size() >= what.size() && 0 == where.compare(
38  where.size() - what.size(), what.size(), what);
39 }
40 
41 } /* namespace string_algo */
42 
43 } /* namespace restinio */
RESTINIO_NODISCARD bool ends_with(const string_view_t &where, const string_view_t &what) noexcept
Definition: string_algo.hpp:33
std::enable_if< std::is_same< Parameter_Container, query_string_params_t >::value||std::is_same< Parameter_Container, router::route_params_t >::value, optional_t< Value_Type > >::type opt_value(const Parameter_Container &params, string_view_t key)
Gets the value of a parameter specified by key wrapped in optional_t<Value_Type> if parameter exists ...
Definition: value_or.hpp:64