@@ -75,6 +75,10 @@ template<typename I>
75
75
const auto & to_num (const fc::safe<I>& i) { return i.value ; }
76
76
inline auto to_num (const fc::time_point_sec& t) { return t.sec_since_epoch (); }
77
77
78
+ // Shorthand to convert a typelist into a static_variant of that typelist
79
+ template <typename List>
80
+ using to_sv = typelist::apply<List, static_variant>;
81
+
78
82
namespace safenum = boost::safe_numerics::safe_compare;
79
83
80
84
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -127,7 +131,7 @@ using comparable_types_list = typelist::list<int64_t, string, time_point_sec, ac
127
131
proposal_id_type, withdraw_permission_id_type,
128
132
vesting_balance_id_type, worker_id_type, balance_id_type>;
129
133
// Valid for list functions (in, not_in, has_all, has_none)
130
- struct make_flat_set { template <typename T> struct transform { using type = flat_set<T>; } ; };
134
+ template <typename T> struct make_flat_set { using type = flat_set<T>; };
131
135
using list_types_list = typelist::transform<typelist::concat<typelist::list<bool , public_key_type, fc::sha256>,
132
136
comparable_types_list>,
133
137
make_flat_set>;
@@ -256,9 +260,15 @@ template<typename Field, typename Element>
256
260
struct predicate_in <fc::optional<Field>, flat_set<Element>, std::enable_if_t <comparable_types<Field, Element>>> {
257
261
// Check for optional value
258
262
constexpr static bool valid = true ;
263
+ template <typename F = Field, std::enable_if_t <!std::is_same<F, share_type>::value, bool > = true >
259
264
bool operator ()(const fc::optional<Field>& f, const flat_set<Element>& c) const {
260
265
if (!f.valid ()) return predicate_result::Rejection (predicate_result::null_optional);
261
- return c.count (*f) != 0 ;
266
+ return c.count (*f) != 0 ;
267
+ }
268
+ template <typename F = Field, std::enable_if_t <std::is_same<F, share_type>::value, bool > = true >
269
+ bool operator ()(const fc::optional<share_type>& f, const flat_set<Element>& c) const {
270
+ if (!f.valid ()) return predicate_result::Rejection (predicate_result::null_optional);
271
+ return c.count (Element (f->value )) != 0 ;
262
272
}
263
273
};
264
274
template <typename Container, typename Element>
@@ -470,32 +480,25 @@ object_restriction_predicate<Field> create_predicate_function(restriction_functi
470
480
try {
471
481
switch (func) {
472
482
case restriction::func_eq:
473
- return make_predicate<predicate_eq, Field>(static_variant <equality_types_list>::import_from (std::move (arg)));
483
+ return make_predicate<predicate_eq, Field>(to_sv <equality_types_list>::import_from (std::move (arg)));
474
484
case restriction::func_ne:
475
- return make_predicate<predicate_ne, Field>(static_variant <equality_types_list>::import_from (std::move (arg)));
485
+ return make_predicate<predicate_ne, Field>(to_sv <equality_types_list>::import_from (std::move (arg)));
476
486
case restriction::func_lt:
477
- return make_predicate<predicate_lt, Field>(static_variant<comparable_types_list>
478
- ::import_from (std::move(arg)));
487
+ return make_predicate<predicate_lt, Field>(to_sv<comparable_types_list>::import_from (std::move (arg)));
479
488
case restriction::func_le:
480
- return make_predicate<predicate_le, Field>(static_variant<comparable_types_list>
481
- ::import_from (std::move(arg)));
489
+ return make_predicate<predicate_le, Field>(to_sv<comparable_types_list>::import_from (std::move (arg)));
482
490
case restriction::func_gt:
483
- return make_predicate<predicate_gt, Field>(static_variant<comparable_types_list>
484
- ::import_from (std::move(arg)));
491
+ return make_predicate<predicate_gt, Field>(to_sv<comparable_types_list>::import_from (std::move (arg)));
485
492
case restriction::func_ge:
486
- return make_predicate<predicate_ge, Field>(static_variant<comparable_types_list>
487
- ::import_from (std::move(arg)));
493
+ return make_predicate<predicate_ge, Field>(to_sv<comparable_types_list>::import_from (std::move (arg)));
488
494
case restriction::func_in:
489
- return make_predicate<predicate_in, Field>(static_variant <list_types_list>::import_from (std::move (arg)));
495
+ return make_predicate<predicate_in, Field>(to_sv <list_types_list>::import_from (std::move (arg)));
490
496
case restriction::func_not_in:
491
- return make_predicate<predicate_not_in, Field>(static_variant<list_types_list>
492
- ::import_from (std::move(arg)));
497
+ return make_predicate<predicate_not_in, Field>(to_sv<list_types_list>::import_from (std::move (arg)));
493
498
case restriction::func_has_all:
494
- return make_predicate<predicate_has_all, Field>(static_variant<list_types_list>
495
- ::import_from (std::move(arg)));
499
+ return make_predicate<predicate_has_all, Field>(to_sv<list_types_list>::import_from (std::move (arg)));
496
500
case restriction::func_has_none:
497
- return make_predicate<predicate_has_none, Field>(static_variant<list_types_list>
498
- ::import_from (std::move(arg)));
501
+ return make_predicate<predicate_has_none, Field>(to_sv<list_types_list>::import_from (std::move (arg)));
499
502
case restriction::func_attr:
500
503
FC_ASSERT (arg.which () == restriction_argument::tag<vector<restriction>>::value,
501
504
" Argument type for attribute assertion must be restriction list" );
@@ -590,14 +593,14 @@ object_restriction_predicate<Object> restrictions_to_predicate(vector<restrictio
590
593
}
591
594
592
595
// To make the build gentler on RAM, break the operation list into several pieces to build over several files
593
- using operation_list_1 = static_variant <typelist::slice<operation::list, 0 , 5 >>;
594
- using operation_list_2 = static_variant <typelist::slice<operation::list, 5 , 10 >>;
595
- using operation_list_3 = static_variant <typelist::slice<operation::list, 10 , 20 >>;
596
- using operation_list_4 = static_variant <typelist::slice<operation::list, 20 , 30 >>;
597
- using operation_list_5 = static_variant <typelist::slice<operation::list, 30 , 35 >>;
598
- using operation_list_6 = static_variant <typelist::slice<operation::list, 35 , 40 >>;
599
- using operation_list_7 = static_variant <typelist::slice<operation::list, 40 , 50 >>;
600
- using operation_list_8 = static_variant <typelist::slice<operation::list, 50 >>;
596
+ using operation_list_1 = to_sv <typelist::slice<operation::list, 0 , 5 >>;
597
+ using operation_list_2 = to_sv <typelist::slice<operation::list, 5 , 10 >>;
598
+ using operation_list_3 = to_sv <typelist::slice<operation::list, 10 , 20 >>;
599
+ using operation_list_4 = to_sv <typelist::slice<operation::list, 20 , 30 >>;
600
+ using operation_list_5 = to_sv <typelist::slice<operation::list, 30 , 35 >>;
601
+ using operation_list_6 = to_sv <typelist::slice<operation::list, 35 , 40 >>;
602
+ using operation_list_7 = to_sv <typelist::slice<operation::list, 40 , 50 >>;
603
+ using operation_list_8 = to_sv <typelist::slice<operation::list, 50 >>;
601
604
602
605
object_restriction_predicate<operation> get_restriction_predicate_list_1 (size_t idx, vector<restriction> rs);
603
606
object_restriction_predicate<operation> get_restriction_predicate_list_2 (size_t idx, vector<restriction> rs);
0 commit comments