20 #ifndef RIPPLE_PROTOCOL_STEXCHANGE_H_INCLUDED
21 #define RIPPLE_PROTOCOL_STEXCHANGE_H_INCLUDED
23 #include <ripple/basics/Blob.h>
24 #include <ripple/basics/Buffer.h>
25 #include <ripple/basics/Slice.h>
26 #include <ripple/basics/contract.h>
27 #include <ripple/protocol/SField.h>
28 #include <ripple/protocol/STBlob.h>
29 #include <ripple/protocol/STInteger.h>
30 #include <ripple/protocol/STObject.h>
40 template <
class U,
class T>
43 template <
class U,
class T>
59 return std::make_unique<STInteger<U>>(f, t);
79 return std::make_unique<STBlob>(f, t.
data(), t.
size());
99 return std::make_unique<STBlob>(f, t.
data(), t.
size());
105 return std::make_unique<STBlob>(f, std::move(t));
113 template <
class T,
class U>
124 auto const u =
dynamic_cast<U const*
>(b);
127 Throw<std::runtime_error>(
"Wrong field type");
136 return get<typename U::value_type>(st, f);
141 template <
class U,
class T>
146 f, std::forward<T>(t)));
150 template <
class Init>
154 st.
set(std::make_unique<STBlob>(f, size, init));
158 template <
class =
void>
165 st.
set(std::make_unique<STBlob>(f, data, size));
std::size_t size() const noexcept
Returns the number of bytes in the storage.
virtual SerializedTypeID getSType() const
void makeFieldAbsent(SField const &field)
A field with a type known at compile time.
An immutable linear range of bytes.
static void get(std::optional< value_type > &t, STBlob const &u)
static std::unique_ptr< STBlob > set(TypedField< STBlob > const &f, Slice const &t)
std::uint8_t const * data() const noexcept
Return a pointer to beginning of the storage.
static std::unique_ptr< STBlob > set(TypedField< STBlob > const &f, Buffer const &t)
static void get(std::optional< Buffer > &t, STBlob const &u)
Like std::vector<char> but better.
void erase(STObject &st, TypedField< U > const &f)
Remove a field in an STObject.
value_type value() const noexcept
bool set(T &target, std::string const &name, Section const §ion)
Set a value from a configuration Section If the named value is not found or doesn't parse as a T,...
std::size_t size() const noexcept
Returns the number of bytes in the buffer.
Convert between serialized type U and C++ type T.
std::uint8_t const * data() const noexcept
Return a pointer to beginning of the storage.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
const STBase * peekAtPField(SField const &field) const
A type which can be exported to a well known binary format.
static std::unique_ptr< STBlob > set(TypedField< STBlob > const &f, Buffer &&t)
static std::unique_ptr< STInteger< U > > set(SField const &f, T const &t)
void set(const SOTemplate &)
T & get(EitherAmount &amt)
static void get(std::optional< T > &t, STInteger< U > const &u)
std::uint8_t const * data() const