virthttp  0.0
libvirt http interface
Namespaces | Macros | Typedefs | Functions | Variables
flagwork.hpp File Reference
#include <optional>
#include <string_view>
#include "../../detect.hpp"
#include "urlparser.hpp"

Go to the source code of this file.

Namespaces

 subq_impl
 

Macros

#define SUBQ_LIFT(mem_fn)
 

Typedefs

template<class T , class A >
using subq_impl::ToJson = decltype(to_json(std::declval< T && >(), std::declval< A & >()))
 
template<class T , class A >
using subq_impl::GetToJson = decltype(get_to_json(std::declval< T && >(), std::declval< A & >()))
 

Functions

template<class F , class = std::enable_if_t<!std::is_same_v<F, Empty>>>
constexpr auto target_get_composable_flag (const TargetParser &target, std::string_view tag) noexcept-> std::optional< F >
 Extracts a flag from the HTTP target. More...
 
template<class... Fcns>
constexpr auto parameterized_depends_scope (Fcns &&...depends) noexcept((std::is_nothrow_move_constructible_v< Fcns > &&...))
 
template<class T , class A >
decltype(auto) constexpr subq_impl::auto_serialize (T &&v, A &al)
 
template<class TI , class F , class VC , class TJ >
auto subq_impl::subquery (std::string_view name, std::string_view opt_tag, [[maybe_unused]] TI ti, F &&lifted, VC &&valid_check, TJ &&to_json) noexcept(std::is_nothrow_move_constructible_v< F > &&std::is_nothrow_move_constructible_v< VC > &&std::is_nothrow_move_constructible_v< TJ >)
 subquery overload for functions taking a single flag and without automatically deduced JSON serialization More...
 
template<class F , class VC , class TI >
auto subq_impl::subquery (std::string_view name, std::string_view opt_tag, TI ti, F &&lifted, VC &&valid_check) noexcept(std::is_nothrow_move_constructible_v< F > &&std::is_nothrow_move_constructible_v< VC >) -> decltype(auto)
 subquery overload for functions taking no flag and with automatically deduced JSON serialization More...
 
template<class F , class VC , class TJ , class = std::enable_if_t<!std::is_same_v<F, std::string_view>>>
auto subq_impl::subquery (std::string_view name, F &&lifted, VC &&valid_check, TJ &&to_json) noexcept(std::is_nothrow_move_constructible_v< F > &&std::is_nothrow_move_constructible_v< VC > &&std::is_nothrow_move_constructible_v< TJ >)
 subquery overload for functions taking no flag and without automatically deduced JSON serialization More...
 
template<class F , class VC , class = std::enable_if_t<!std::is_same_v<F, std::string_view>>>
auto subq_impl::subquery (std::string_view name, F &&lifted, VC &&valid_check) noexcept(std::is_nothrow_move_constructible_v< F > &&std::is_nothrow_move_constructible_v< VC >) -> decltype(auto)
 subquery overload for functions taking no flag and with automatically deduced JSON serialization More...
 

Variables

constexpr auto subquery
 Perfect-forwarding lifted subq_impl::subquery. More...
 

Detailed Description

Utilities for making subqueries work and have as many parameters as possible be deduced

Macro Definition Documentation

#define SUBQ_LIFT (   mem_fn)
Value:
[&](auto&&... args) noexcept(noexcept(mem_fn(std::forward<decltype(args)>(args)...))) -> decltype( \
mem_fn(std::forward<decltype(args)>(args)...)) { \
return mem_fn(std::forward<decltype(args)>(args)...); \
}
Parameters
mem_fna reference to the function to be lifted

Function Documentation

template<class... Fcns>
constexpr auto parameterized_depends_scope ( Fcns &&...  depends)
noexcept

Creates a closure which invokes callables in order so long they return DependsOutcome::SKIPPED

Template Parameters
Fcns(deduced from depends)
Parameters
[in]dependsa parameter pack of callables which all match the same DependsOutcome(auto&&...)
Returns
(auto) a closure of signature void(auto&&...)
template<class F , class = std::enable_if_t<!std::is_same_v<F, Empty>>>
constexpr auto target_get_composable_flag ( const TargetParser target,
std::string_view  tag 
) -> std::optional<F>
noexcept

Extracts a flag from the HTTP target.

Extracts by tag a flag from a TargetParser. The flag values must be comma-separated and only the first appearance of tag within the target is considered. If the flag is not composable (i.e. F{} | F{} is ill-formed), only the first value is considered.

Template Parameters
Fthe type of flag; value Empty SFINAE'ed out
Parameters
[in]targetthe target to read the query from
[in]tagthe key of the query where the flag values are
Returns
(std::optional<F>) the flag, or std::nullopt if an error occurred when reading the flag values. Note that if F is not composable, only the first flag value will be read

Variable Documentation

constexpr auto subquery
Initial value:
= [](auto&&... args) noexcept(noexcept(subq_impl::subquery(std::forward<decltype(args)>(args)...)))
-> decltype(subq_impl::subquery(std::forward<decltype(args)>(args)...)) { return subq_impl::subquery(std::forward<decltype(args)>(args)...); }
auto subquery(std::string_view name, std::string_view opt_tag, [[maybe_unused]] TI ti, F &&lifted, VC &&valid_check, TJ &&to_json) noexcept(std::is_nothrow_move_constructible_v< F > &&std::is_nothrow_move_constructible_v< VC > &&std::is_nothrow_move_constructible_v< TJ >)
subquery overload for functions taking a single flag and without automatically deduced JSON serializa...
Definition: flagwork.hpp:136

Perfect-forwarding lifted subq_impl::subquery.

Lifts a set of closure factories, where said closures process the subquery described by args. The resulting closure upon invocation of this lifting lambda must be of the signature DependsOutcome(int sq_lev, const TargetParser& target, auto& res_val, auto& allocator, auto&& error), where:

  • [in] sq_lev is the target path part index where the subquery to look for is located
  • [in] target is the target parser object containing the currently parsed URI target
  • [out] res_val is the place where to put the JSON result to be sent back to the client
  • [in] allocator is the JSON allocator to be used when serializing
  • [in] error is a callable used for error reporting
Parameters
argsthe subquery description; see the different versions of subq_impl::subquery to know the possible description formats