Added webhook tx-confirmation support (#66)

This commit is contained in:
Lee *!* Clagett
2023-05-11 13:13:10 -04:00
committed by Lee *!* Clagett
parent 990e86f701
commit 3e0555e07d
32 changed files with 2051 additions and 122 deletions

View File

@@ -46,8 +46,12 @@
::wire::field( #name , self . name )
//! The optional field has the same key name and C/C++ name
#define WIRE_OPTIONAL_FIELD(name) \
::wire::optional_field( #name , std::ref( self . name ))
#define WIRE_OPTIONAL_FIELD_ID(id, name) \
::wire::optional_field< id >( #name , std::ref( self . name ))
//! The optional field has the same key name and C/C++ name
#define WIRE_OPTIONAL_FIELD(name) \
WIRE_OPTIONAL_FIELD_ID(0, name)
namespace wire
{
@@ -73,6 +77,10 @@ namespace wire
static constexpr std::size_t count() noexcept { return 1; }
static constexpr unsigned id() noexcept { return I; }
//! \return True if field is forced optional when `get_value().empty()`.
static constexpr bool optional_on_empty() noexcept
{ return is_optional_on_empty<value_type>::value; }
const char* name;
T value;
@@ -250,9 +258,9 @@ namespace wire
template<typename T, unsigned I>
inline constexpr bool available(const field_<T, true, I>&) noexcept
inline constexpr bool available(const field_<T, true, I>& elem) noexcept
{
return true;
return elem.is_required() || (elem.optional_on_empty() && !wire::empty(elem.get_value()));
}
template<typename T, unsigned I>
inline bool available(const field_<T, false, I>& elem)
@@ -269,18 +277,5 @@ namespace wire
{
return elem != nullptr;
}
// example usage : `wire::sum(std::size_t(wire::available(fields))...)`
inline constexpr int sum() noexcept
{
return 0;
}
template<typename T, typename... U>
inline constexpr T sum(const T head, const U... tail) noexcept
{
return head + sum(tail...);
}
}