Firmware  0.0.0
Loading...
Searching...
No Matches
utility.hpp File Reference

Utility functions. More...

#include <esp_heap_caps.h>
#include <bit>
#include <charconv>
#include <dcc/dcc.hpp>
#include <functional>
#include <iterator>
#include <memory>
#include <numeric>
#include <span>
#include <string_view>
Include dependency graph for utility.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  signature< std::function< R(Args...)> >
 
struct  signature< R(T::*)(Args...)>
 

Namespaces

namespace  detail
 

Typedefs

template<typename T >
using unique_caps_ptr = std::unique_ptr<T, decltype(heap_caps_free)*>
 

Functions

template<auto Unique = [] {}, typename F >
auto make_tramp (F &&f)
 
template<auto Unique = [] {}, typename Self , typename F >
auto make_tramp (Self &&self, F &&f)
 
void esp_delayed_restart ()
 
bool validate_json (std::string_view json)
 
template<typename T >
consteval std::string_view type_name ()
 
template<std::unsigned_integral T = uint32_t>
constexpr T fnv1a (uint8_t byte, T hash=::detail::offset< T >)
 
template<std::unsigned_integral T = uint32_t>
constexpr T fnv1a (std::span< char const > str)
 
std::optional< dcc::Address::value_type > uri2address (std::string_view uri)
 
std::optional< dcc::Address > uri2loco_address (std::string_view uri)
 
template<std::output_iterator< char > OutputIt>
OutputIt decode_uri (std::string_view uri, OutputIt out)
 https://rosettacode.org/wiki/URL_decoding#C
 
template<typename T >
constexpr auto make_unique_caps (size_t size, uint32_t caps)
 
uint32_t http_receive_timeout2ms ()
 
template<typename F , typename... Ts>
auto invoke_on_core (BaseType_t core_id, F &&f, Ts &&... ts)
 
template<typename... Ts>
auto httpd_ws_send_frame_async (Ts &&... ts)
 
template<typename... Ts>
auto httpd_sess_trigger_close (Ts &&... ts)
 

Variables

template<std::unsigned_integral T>
constexpr T detail::prime {sizeof(T) <= 4uz ? 16777619ull : 1099511628211ull}
 
template<std::unsigned_integral T>
constexpr T detail::offset {sizeof(T) <= 4uz ? 2166136261ull : 14695981039346656037ull}
 

Detailed Description

Author
Vincent Hamp
Date
09/02/2023

Typedef Documentation

◆ unique_caps_ptr

template<typename T >
using unique_caps_ptr = std::unique_ptr<T, decltype(heap_caps_free)*>

Function Documentation

◆ decode_uri()

template<std::output_iterator< char > OutputIt>
OutputIt decode_uri ( std::string_view uri,
OutputIt out )

◆ esp_delayed_restart()

void esp_delayed_restart ( )

◆ fnv1a() [1/2]

template<std::unsigned_integral T = uint32_t>
T fnv1a ( std::span< char const > str)
constexpr

◆ fnv1a() [2/2]

template<std::unsigned_integral T = uint32_t>
T fnv1a ( uint8_t byte,
T hash = ::detail::offset<T> )
constexpr

◆ http_receive_timeout2ms()

uint32_t http_receive_timeout2ms ( )
Warning
Do not use this function in time-critical code. Always cache the value!

◆ httpd_sess_trigger_close()

template<typename... Ts>
auto httpd_sess_trigger_close ( Ts &&... ts)

◆ httpd_ws_send_frame_async()

template<typename... Ts>
auto httpd_ws_send_frame_async ( Ts &&... ts)

◆ invoke_on_core()

template<typename F , typename... Ts>
auto invoke_on_core ( BaseType_t core_id,
F && f,
Ts &&... ts )

◆ make_tramp() [1/2]

template<auto Unique = [] {}, typename F >
auto make_tramp ( F && f)

◆ make_tramp() [2/2]

template<auto Unique = [] {}, typename Self , typename F >
auto make_tramp ( Self && self,
F && f )

◆ make_unique_caps()

template<typename T >
auto make_unique_caps ( size_t size,
uint32_t caps )
constexpr

◆ type_name()

template<typename T >
std::string_view type_name ( )
consteval

◆ uri2address()

std::optional< dcc::Address::value_type > uri2address ( std::string_view uri)

◆ uri2loco_address()

std::optional< dcc::Address > uri2loco_address ( std::string_view uri)

◆ validate_json()

bool validate_json ( std::string_view json)