updated fbe for new transaction struct

This commit is contained in:
EntireTwix 2022-11-28 16:39:32 -08:00
parent 5a754a567c
commit 1f983322a1
14 changed files with 157 additions and 102 deletions

View file

@ -1,22 +1,24 @@
//------------------------------------------------------------------------------
// Automatically generated by the Fast Binary Encoding compiler, do not modify!
// https://github.com/chronoxor/FastBinaryEncoding
// Source: user_model.fbe
// Version: 1.7.0.0
// FBE version: 1.14.1.0
//------------------------------------------------------------------------------
#include "bank_dom.h"
namespace bank_dom {
Transaction::Transaction()
: from("")
, to("")
: counterparty("")
, receiving(false)
, amount((uint32_t)0ull)
, time((uint64_t)0ull)
{}
Transaction::Transaction(const std::string& arg_from, const std::string& arg_to, uint32_t arg_amount, uint64_t arg_time)
: from(arg_from)
, to(arg_to)
Transaction::Transaction(const std::string& arg_counterparty, bool arg_receiving, uint32_t arg_amount, uint64_t arg_time)
: counterparty(arg_counterparty)
, receiving(arg_receiving)
, amount(arg_amount)
, time(arg_time)
{}
@ -36,8 +38,8 @@ bool Transaction::operator<(const Transaction& other) const noexcept
void Transaction::swap(Transaction& other) noexcept
{
using std::swap;
swap(from, other.from);
swap(to, other.to);
swap(counterparty, other.counterparty);
swap(receiving, other.receiving);
swap(amount, other.amount);
swap(time, other.time);
}
@ -45,8 +47,8 @@ void Transaction::swap(Transaction& other) noexcept
std::ostream& operator<<(std::ostream& stream, const Transaction& value)
{
stream << "Transaction(";
stream << "from="; stream << "\"" << value.from << "\"";
stream << ",to="; stream << "\"" << value.to << "\"";
stream << "counterparty="; stream << "\"" << value.counterparty << "\"";
stream << ",receiving="; stream << (value.receiving ? "true" : "false");
stream << ",amount="; stream << value.amount;
stream << ",time="; stream << value.time;
stream << ")";

View file

@ -1,7 +1,9 @@
//------------------------------------------------------------------------------
// Automatically generated by the Fast Binary Encoding compiler, do not modify!
// https://github.com/chronoxor/FastBinaryEncoding
// Source: user_model.fbe
// Version: 1.7.0.0
// FBE version: 1.14.1.0
//------------------------------------------------------------------------------
#pragma once
@ -27,15 +29,15 @@ namespace bank_dom {
struct Transaction
{
std::string from;
std::string to;
std::string counterparty;
bool receiving;
uint32_t amount;
uint64_t time;
size_t fbe_type() const noexcept { return 1; }
Transaction();
Transaction(const std::string& arg_from, const std::string& arg_to, uint32_t arg_amount, uint64_t arg_time);
Transaction(const std::string& arg_counterparty, bool arg_receiving, uint32_t arg_amount, uint64_t arg_time);
Transaction(const Transaction& other) = default;
Transaction(Transaction&& other) = default;
~Transaction() = default;
@ -60,10 +62,12 @@ struct Transaction
} // namespace bank_dom
namespace std {
#if defined(FMT_VERSION) && (FMT_VERSION >= 90000)
template <> struct fmt::formatter<bank_dom::Transaction> : ostream_formatter {};
#endif
template<>
struct hash<bank_dom::Transaction>
struct std::hash<bank_dom::Transaction>
{
typedef bank_dom::Transaction argument_type;
typedef size_t result_type;
@ -75,8 +79,6 @@ struct hash<bank_dom::Transaction>
}
};
} // namespace std
namespace bank_dom {
struct Logs
@ -111,10 +113,12 @@ struct Logs
} // namespace bank_dom
namespace std {
#if defined(FMT_VERSION) && (FMT_VERSION >= 90000)
template <> struct fmt::formatter<bank_dom::Logs> : ostream_formatter {};
#endif
template<>
struct hash<bank_dom::Logs>
struct std::hash<bank_dom::Logs>
{
typedef bank_dom::Logs argument_type;
typedef size_t result_type;
@ -126,8 +130,6 @@ struct hash<bank_dom::Logs>
}
};
} // namespace std
namespace bank_dom {
struct User
@ -164,10 +166,12 @@ struct User
} // namespace bank_dom
namespace std {
#if defined(FMT_VERSION) && (FMT_VERSION >= 90000)
template <> struct fmt::formatter<bank_dom::User> : ostream_formatter {};
#endif
template<>
struct hash<bank_dom::User>
struct std::hash<bank_dom::User>
{
typedef bank_dom::User argument_type;
typedef size_t result_type;
@ -179,8 +183,6 @@ struct hash<bank_dom::User>
}
};
} // namespace std
namespace bank_dom {
struct Global
@ -216,10 +218,12 @@ struct Global
} // namespace bank_dom
namespace std {
#if defined(FMT_VERSION) && (FMT_VERSION >= 90000)
template <> struct fmt::formatter<bank_dom::Global> : ostream_formatter {};
#endif
template<>
struct hash<bank_dom::Global>
struct std::hash<bank_dom::Global>
{
typedef bank_dom::Global argument_type;
typedef size_t result_type;
@ -231,8 +235,6 @@ struct hash<bank_dom::Global>
}
};
} // namespace std
namespace bank_dom {
} // namespace bank_dom

View file

@ -1,15 +1,17 @@
//------------------------------------------------------------------------------
// Automatically generated by the Fast Binary Encoding compiler, do not modify!
// https://github.com/chronoxor/FastBinaryEncoding
// Source: user_model.fbe
// Version: 1.7.0.0
// FBE version: 1.14.1.0
//------------------------------------------------------------------------------
#include "bank_dom_final_models.h"
namespace FBE {
FinalModel<::bank_dom::Transaction>::FinalModel(FBEBuffer& buffer, size_t offset) noexcept : _buffer(buffer), _offset(offset)
, from(buffer, 0)
, to(buffer, 0)
, counterparty(buffer, 0)
, receiving(buffer, 0)
, amount(buffer, 0)
, time(buffer, 0)
{}
@ -17,8 +19,8 @@ FinalModel<::bank_dom::Transaction>::FinalModel(FBEBuffer& buffer, size_t offset
size_t FinalModel<::bank_dom::Transaction>::fbe_allocation_size(const ::bank_dom::Transaction& fbe_value) const noexcept
{
size_t fbe_result = 0
+ from.fbe_allocation_size(fbe_value.from)
+ to.fbe_allocation_size(fbe_value.to)
+ counterparty.fbe_allocation_size(fbe_value.counterparty)
+ receiving.fbe_allocation_size(fbe_value.receiving)
+ amount.fbe_allocation_size(fbe_value.amount)
+ time.fbe_allocation_size(fbe_value.time)
;
@ -38,14 +40,14 @@ size_t FinalModel<::bank_dom::Transaction>::verify_fields() const noexcept
size_t fbe_current_offset = 0;
size_t fbe_field_size;
from.fbe_offset(fbe_current_offset);
fbe_field_size = from.verify();
counterparty.fbe_offset(fbe_current_offset);
fbe_field_size = counterparty.verify();
if (fbe_field_size == std::numeric_limits<std::size_t>::max())
return std::numeric_limits<std::size_t>::max();
fbe_current_offset += fbe_field_size;
to.fbe_offset(fbe_current_offset);
fbe_field_size = to.verify();
receiving.fbe_offset(fbe_current_offset);
fbe_field_size = receiving.verify();
if (fbe_field_size == std::numeric_limits<std::size_t>::max())
return std::numeric_limits<std::size_t>::max();
fbe_current_offset += fbe_field_size;
@ -79,13 +81,13 @@ size_t FinalModel<::bank_dom::Transaction>::get_fields(::bank_dom::Transaction&
size_t fbe_current_size = 0;
size_t fbe_field_size;
from.fbe_offset(fbe_current_offset);
fbe_field_size = from.get(fbe_value.from);
counterparty.fbe_offset(fbe_current_offset);
fbe_field_size = counterparty.get(fbe_value.counterparty);
fbe_current_offset += fbe_field_size;
fbe_current_size += fbe_field_size;
to.fbe_offset(fbe_current_offset);
fbe_field_size = to.get(fbe_value.to);
receiving.fbe_offset(fbe_current_offset);
fbe_field_size = receiving.get(fbe_value.receiving);
fbe_current_offset += fbe_field_size;
fbe_current_size += fbe_field_size;
@ -116,13 +118,13 @@ size_t FinalModel<::bank_dom::Transaction>::set_fields(const ::bank_dom::Transac
size_t fbe_current_size = 0;
size_t fbe_field_size;
from.fbe_offset(fbe_current_offset);
fbe_field_size = from.set(fbe_value.from);
counterparty.fbe_offset(fbe_current_offset);
fbe_field_size = counterparty.set(fbe_value.counterparty);
fbe_current_offset += fbe_field_size;
fbe_current_size += fbe_field_size;
to.fbe_offset(fbe_current_offset);
fbe_field_size = to.set(fbe_value.to);
receiving.fbe_offset(fbe_current_offset);
fbe_field_size = receiving.set(fbe_value.receiving);
fbe_current_offset += fbe_field_size;
fbe_current_size += fbe_field_size;

View file

@ -1,7 +1,9 @@
//------------------------------------------------------------------------------
// Automatically generated by the Fast Binary Encoding compiler, do not modify!
// https://github.com/chronoxor/FastBinaryEncoding
// Source: user_model.fbe
// Version: 1.7.0.0
// FBE version: 1.14.1.0
//------------------------------------------------------------------------------
#pragma once
@ -60,8 +62,8 @@ private:
mutable size_t _offset;
public:
FinalModel<std::string> from;
FinalModel<std::string> to;
FinalModel<std::string> counterparty;
FinalModel<bool> receiving;
FinalModel<uint32_t> amount;
FinalModel<uint64_t> time;
};

View file

@ -1,24 +1,26 @@
//------------------------------------------------------------------------------
// Automatically generated by the Fast Binary Encoding compiler, do not modify!
// https://github.com/chronoxor/FastBinaryEncoding
// Source: user_model.fbe
// Version: 1.7.0.0
// FBE version: 1.14.1.0
//------------------------------------------------------------------------------
#include "bank_dom_models.h"
namespace FBE {
FieldModel<::bank_dom::Transaction>::FieldModel(FBEBuffer& buffer, size_t offset) noexcept : _buffer(buffer), _offset(offset)
, from(buffer, 4 + 4)
, to(buffer, from.fbe_offset() + from.fbe_size())
, amount(buffer, to.fbe_offset() + to.fbe_size())
, counterparty(buffer, 4 + 4)
, receiving(buffer, counterparty.fbe_offset() + counterparty.fbe_size())
, amount(buffer, receiving.fbe_offset() + receiving.fbe_size())
, time(buffer, amount.fbe_offset() + amount.fbe_size())
{}
size_t FieldModel<::bank_dom::Transaction>::fbe_body() const noexcept
{
size_t fbe_result = 4 + 4
+ from.fbe_size()
+ to.fbe_size()
+ counterparty.fbe_size()
+ receiving.fbe_size()
+ amount.fbe_size()
+ time.fbe_size()
;
@ -37,8 +39,8 @@ size_t FieldModel<::bank_dom::Transaction>::fbe_extra() const noexcept
_buffer.shift(fbe_struct_offset);
size_t fbe_result = fbe_body()
+ from.fbe_extra()
+ to.fbe_extra()
+ counterparty.fbe_extra()
+ receiving.fbe_extra()
+ amount.fbe_extra()
+ time.fbe_extra()
;
@ -75,17 +77,17 @@ bool FieldModel<::bank_dom::Transaction>::verify_fields(size_t fbe_struct_size)
{
size_t fbe_current_size = 4 + 4;
if ((fbe_current_size + from.fbe_size()) > fbe_struct_size)
if ((fbe_current_size + counterparty.fbe_size()) > fbe_struct_size)
return true;
if (!from.verify())
if (!counterparty.verify())
return false;
fbe_current_size += from.fbe_size();
fbe_current_size += counterparty.fbe_size();
if ((fbe_current_size + to.fbe_size()) > fbe_struct_size)
if ((fbe_current_size + receiving.fbe_size()) > fbe_struct_size)
return true;
if (!to.verify())
if (!receiving.verify())
return false;
fbe_current_size += to.fbe_size();
fbe_current_size += receiving.fbe_size();
if ((fbe_current_size + amount.fbe_size()) > fbe_struct_size)
return true;
@ -141,17 +143,17 @@ void FieldModel<::bank_dom::Transaction>::get_fields(::bank_dom::Transaction& fb
{
size_t fbe_current_size = 4 + 4;
if ((fbe_current_size + from.fbe_size()) <= fbe_struct_size)
from.get(fbe_value.from, "");
if ((fbe_current_size + counterparty.fbe_size()) <= fbe_struct_size)
counterparty.get(fbe_value.counterparty, "");
else
fbe_value.from = "";
fbe_current_size += from.fbe_size();
fbe_value.counterparty = "";
fbe_current_size += counterparty.fbe_size();
if ((fbe_current_size + to.fbe_size()) <= fbe_struct_size)
to.get(fbe_value.to, "");
if ((fbe_current_size + receiving.fbe_size()) <= fbe_struct_size)
receiving.get(fbe_value.receiving, false);
else
fbe_value.to = "";
fbe_current_size += to.fbe_size();
fbe_value.receiving = false;
fbe_current_size += receiving.fbe_size();
if ((fbe_current_size + amount.fbe_size()) <= fbe_struct_size)
amount.get(fbe_value.amount, (uint32_t)0ull);
@ -203,8 +205,8 @@ void FieldModel<::bank_dom::Transaction>::set(const ::bank_dom::Transaction& fbe
void FieldModel<::bank_dom::Transaction>::set_fields(const ::bank_dom::Transaction& fbe_value) noexcept
{
from.set(fbe_value.from);
to.set(fbe_value.to);
counterparty.set(fbe_value.counterparty);
receiving.set(fbe_value.receiving);
amount.set(fbe_value.amount);
time.set(fbe_value.time);
}

View file

@ -1,7 +1,9 @@
//------------------------------------------------------------------------------
// Automatically generated by the Fast Binary Encoding compiler, do not modify!
// https://github.com/chronoxor/FastBinaryEncoding
// Source: user_model.fbe
// Version: 1.7.0.0
// FBE version: 1.14.1.0
//------------------------------------------------------------------------------
#pragma once
@ -72,8 +74,8 @@ private:
size_t _offset;
public:
FieldModel<std::string> from;
FieldModel<std::string> to;
FieldModel<std::string> counterparty;
FieldModel<bool> receiving;
FieldModel<uint32_t> amount;
FieldModel<uint64_t> time;
};

View file

@ -1,10 +1,24 @@
//------------------------------------------------------------------------------
// Automatically generated by the Fast Binary Encoding compiler, do not modify!
// https://github.com/chronoxor/FastBinaryEncoding
// Source: FBE
// Version: 1.7.0.0
// FBE version: 1.14.1.0
//------------------------------------------------------------------------------
#include "fbe.h"
#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#include <rpc.h>
#undef DELETE
#undef ERROR
#undef HOST_NOT_FOUND
#undef Yield
#undef min
#undef max
#undef uuid_t
#endif
namespace FBE {
std::string buffer_t::base64encode() const

View file

@ -1,7 +1,9 @@
//------------------------------------------------------------------------------
// Automatically generated by the Fast Binary Encoding compiler, do not modify!
// https://github.com/chronoxor/FastBinaryEncoding
// Source: FBE
// Version: 1.7.0.0
// FBE version: 1.14.1.0
//------------------------------------------------------------------------------
#pragma once
@ -41,7 +43,6 @@
#include <uuid/uuid.h>
#undef HOST_NOT_FOUND
#elif defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#undef DELETE
#undef ERROR
#undef HOST_NOT_FOUND
@ -321,10 +322,20 @@ private:
} // namespace FBE
namespace std {
#if defined(FMT_VERSION) && (FMT_VERSION >= 90000)
template <>
struct fmt::formatter<FBE::decimal_t> : formatter<std::string_view>
{
template <typename FormatContext>
auto format(const FBE::decimal_t& value, FormatContext& ctx) const
{
return formatter<string_view>::format((double)value, ctx);
}
};
#endif
template <>
struct hash<FBE::decimal_t>
struct std::hash<FBE::decimal_t>
{
typedef FBE::decimal_t argument_type;
typedef size_t result_type;
@ -337,8 +348,6 @@ struct hash<FBE::decimal_t>
}
};
} // namespace std
namespace FBE {
// Register a new enum-based flags macro
@ -530,10 +539,20 @@ private:
} // namespace FBE
namespace std {
#if defined(FMT_VERSION) && (FMT_VERSION >= 90000)
template <>
struct fmt::formatter<FBE::uuid_t> : formatter<std::string_view>
{
template <typename FormatContext>
auto format(const FBE::uuid_t& value, FormatContext& ctx) const
{
return formatter<string_view>::format(value.string(), ctx);
}
};
#endif
template <>
struct hash<FBE::uuid_t>
struct std::hash<FBE::uuid_t>
{
typedef FBE::uuid_t argument_type;
typedef size_t result_type;
@ -548,8 +567,6 @@ struct hash<FBE::uuid_t>
}
};
} // namespace std
namespace FBE {
// Fast Binary Encoding buffer based on the dynamic byte buffer

View file

@ -1,7 +1,9 @@
//------------------------------------------------------------------------------
// Automatically generated by the Fast Binary Encoding compiler, do not modify!
// https://github.com/chronoxor/FastBinaryEncoding
// Source: FBE
// Version: 1.7.0.0
// FBE version: 1.14.1.0
//------------------------------------------------------------------------------
#include "fbe_final_models.h"

View file

@ -1,7 +1,9 @@
//------------------------------------------------------------------------------
// Automatically generated by the Fast Binary Encoding compiler, do not modify!
// https://github.com/chronoxor/FastBinaryEncoding
// Source: FBE
// Version: 1.7.0.0
// FBE version: 1.14.1.0
//------------------------------------------------------------------------------
#pragma once

View file

@ -1,7 +1,9 @@
//------------------------------------------------------------------------------
// Automatically generated by the Fast Binary Encoding compiler, do not modify!
// https://github.com/chronoxor/FastBinaryEncoding
// Source: FBE
// Version: 1.7.0.0
// FBE version: 1.14.1.0
//------------------------------------------------------------------------------
namespace FBE {
@ -536,8 +538,8 @@ inline size_t FinalModelMap<TKey, TValue>::get(std::map<TKey, TValue>& values) c
FinalModel<TValue> fbe_model_value(_buffer, fbe_offset() + 4);
for (size_t i = fbe_map_size; i-- > 0;)
{
TKey key;
TValue value;
TKey key = TKey();
TValue value = TValue();
size_t offset_key = fbe_model_key.get(key);
fbe_model_key.fbe_shift(offset_key);
fbe_model_value.fbe_shift(offset_key);
@ -568,8 +570,8 @@ inline size_t FinalModelMap<TKey, TValue>::get(std::unordered_map<TKey, TValue>&
FinalModel<TValue> fbe_model_value(_buffer, fbe_offset() + 4);
for (size_t i = fbe_map_size; i-- > 0;)
{
TKey key;
TValue value;
TKey key = TKey();
TValue value = TValue();
size_t offset_key = fbe_model_key.get(key);
fbe_model_key.fbe_shift(offset_key);
fbe_model_value.fbe_shift(offset_key);

View file

@ -1,7 +1,9 @@
//------------------------------------------------------------------------------
// Automatically generated by the Fast Binary Encoding compiler, do not modify!
// https://github.com/chronoxor/FastBinaryEncoding
// Source: FBE
// Version: 1.7.0.0
// FBE version: 1.14.1.0
//------------------------------------------------------------------------------
#include "fbe_models.h"

View file

@ -1,7 +1,9 @@
//------------------------------------------------------------------------------
// Automatically generated by the Fast Binary Encoding compiler, do not modify!
// https://github.com/chronoxor/FastBinaryEncoding
// Source: FBE
// Version: 1.7.0.0
// FBE version: 1.14.1.0
//------------------------------------------------------------------------------
#pragma once

View file

@ -1,7 +1,9 @@
//------------------------------------------------------------------------------
// Automatically generated by the Fast Binary Encoding compiler, do not modify!
// https://github.com/chronoxor/FastBinaryEncoding
// Source: FBE
// Version: 1.7.0.0
// FBE version: 1.14.1.0
//------------------------------------------------------------------------------
namespace FBE {
@ -618,8 +620,8 @@ inline void FieldModelMap<TKey, TValue>::get(std::map<TKey, TValue>& values) con
auto fbe_model = (*this)[0];
for (size_t i = fbe_map_size; i-- > 0;)
{
TKey key;
TValue value;
TKey key = TKey();
TValue value = TValue();
fbe_model.first.get(key);
fbe_model.second.get(value);
values.emplace(key, value);
@ -640,8 +642,8 @@ inline void FieldModelMap<TKey, TValue>::get(std::unordered_map<TKey, TValue>& v
auto fbe_model = (*this)[0];
for (size_t i = fbe_map_size; i-- > 0;)
{
TKey key;
TValue value;
TKey key = TKey();
TValue value = TValue();
fbe_model.first.get(key);
fbe_model.second.get(value);
values.emplace(key, value);