LCOV - code coverage report
Current view: top level - libs/url/example/router - router.hpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 100.0 % 3 3
Test Date: 2026-01-20 17:25:04 Functions: 100.0 % 2 2

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
       3              : //
       4              : // Distributed under the Boost Software License, Version 1.0. (See accompanying
       5              : // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       6              : //
       7              : // Official repository: https://github.com/boostorg/url
       8              : //
       9              : 
      10              : #ifndef BOOST_URL_ROUTER_HPP
      11              : #define BOOST_URL_ROUTER_HPP
      12              : 
      13              : #include <boost/url/detail/config.hpp>
      14              : #include <boost/url/parse_path.hpp>
      15              : #include "detail/router.hpp"
      16              : #include "matches.hpp"
      17              : 
      18              : namespace boost {
      19              : namespace urls {
      20              : 
      21              : /** A URL router.
      22              : 
      23              :     This container matches static and dynamic
      24              :     URL requests to an object which represents
      25              :     how the it should be handled. These
      26              :     values are usually callback functions.
      27              : 
      28              :     @tparam T type of resource associated with
      29              :     each path template
      30              : 
      31              :     @tparam N maximum number of replacement fields
      32              :     in a path template
      33              : 
      34              :     @par Exception Safety
      35              : 
      36              :     @li Functions marked `noexcept` provide the
      37              :     no-throw guarantee, otherwise:
      38              : 
      39              :     @li Functions which throw offer the strong
      40              :     exception safety guarantee.
      41              : 
      42              :     @see
      43              :         @ref parse_absolute_uri,
      44              :         @ref parse_relative_ref,
      45              :         @ref parse_uri,
      46              :         @ref parse_uri_reference,
      47              :         @ref resolve.
      48              : */
      49              : template <class T>
      50              : class router
      51              :     : private detail::router_base
      52              : {
      53              : public:
      54              :     /// Constructor
      55           95 :     router() = default;
      56              : 
      57              :     router(router const&) = delete;
      58              :     router& operator=(router const&) = delete;
      59              :     router(router&&) noexcept = default;
      60              :     router& operator=(router&&) noexcept = default;
      61              : 
      62              :     /** Route the specified URL path to a resource
      63              : 
      64              :         @param path A url path with dynamic segments
      65              :         @param resource A resource the path corresponds to
      66              : 
      67              :         @see
      68              :             https://fmt.dev/latest/syntax.html
      69              :      */
      70              :     template <class U>
      71              :     void
      72              :     insert(core::string_view pattern, U&& v);
      73              : 
      74              :     /** Match URL path to the corresponding resource
      75              : 
      76              :         @param request Request path
      77              :         @return The match results
      78              :      */
      79              :     T const*
      80           93 :     find(segments_encoded_view path, matches& m) const noexcept
      81              :     {
      82           93 :         return find_impl(path, m);
      83              :     }
      84              : 
      85              : private:
      86              :     T const*
      87              :     find_impl(segments_encoded_view path, matches_base& m) const noexcept;
      88              : };
      89              : 
      90              : } // urls
      91              : } // boost
      92              : 
      93              : #include "impl/router.hpp"
      94              : 
      95              : #endif
        

Generated by: LCOV version 2.3