BitShares-Core
7.0.2
BitShares blockchain node software and command-line wallet software
libraries
protocol
restriction.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2019 Contributors.
3
*
4
* The MIT License
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a copy
7
* of this software and associated documentation files (the "Software"), to deal
8
* in the Software without restriction, including without limitation the rights
9
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
* copies of the Software, and to permit persons to whom the Software is
11
* furnished to do so, subject to the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be included in
14
* all copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
* THE SOFTWARE.
23
*/
24
25
#include <
graphene/protocol/restriction.hpp
>
26
27
namespace
graphene
{
namespace
protocol {
28
29
struct
adder
{
30
size_t
sum
= 0;
31
void
operator()
(
const
restriction
& r) {
sum
+= r.
restriction_count
(); }
32
void
operator()
(
const
vector<restriction>& r) {
sum
+=
std::for_each
(r.begin(), r.end(),
adder
()).sum; }
33
};
34
35
size_t
restriction::restriction_count
(
const
vector<restriction>& restrictions) {
36
return
std::for_each
(restrictions.begin(), restrictions.end(),
adder
()).sum;
37
}
38
39
size_t
restriction::restriction_count
()
const
{
40
if
(
argument
.
is_type
<vector<restriction>>()) {
41
const
vector<restriction>& rs =
argument
.
get
<vector<restriction>>();
42
return
1 +
std::for_each
(rs.begin(), rs.end(),
adder
()).sum;
43
}
else
if
(
argument
.
is_type
<vector<vector<restriction>>>()) {
44
const
vector<vector<restriction>>& rs =
argument
.
get
<vector<vector<restriction>>>();
45
return
1 +
std::for_each
(rs.begin(), rs.end(),
adder
()).sum;
46
}
else
if
(
argument
.
is_type
<
variant_assert_argument_type
>()) {
47
const
variant_assert_argument_type
& arg =
argument
.
get
<
variant_assert_argument_type
>();
48
return
1 +
std::for_each
(arg.second.begin(), arg.second.end(),
adder
()).sum;
49
}
50
return
1;
51
}
52
53
} }
// namespace graphene::protocol
graphene::protocol::adder::operator()
void operator()(const restriction &r)
Definition:
restriction.cpp:31
graphene::protocol::restriction
Definition:
restriction.hpp:33
graphene::protocol::restriction::argument
argument_type argument
Definition:
restriction.hpp:103
graphene::protocol::restriction::restriction_count
size_t restriction_count() const
Definition:
restriction.cpp:39
restriction.hpp
graphene::protocol::adder::operator()
void operator()(const vector< restriction > &r)
Definition:
restriction.cpp:32
fc::static_variant::is_type
bool is_type() const
Definition:
static_variant.hpp:332
fc::static_variant::get
X & get()
Definition:
static_variant.hpp:236
graphene::protocol::adder
Definition:
restriction.cpp:29
graphene::protocol::restriction::restriction_count
static size_t restriction_count(const vector< restriction > &restrictions)
Definition:
restriction.cpp:35
graphene::protocol::restriction::variant_assert_argument_type
pair< int64_t, vector< restriction > > variant_assert_argument_type
Definition:
restriction.hpp:53
graphene::protocol::adder::sum
size_t sum
Definition:
restriction.cpp:30
graphene
Definition:
api.cpp:48
fc::typelist::runtime::for_each
void for_each(list< Types... >, Callable c)
Invoke the provided callable with an argument wrapper<Type>() for each type in the list.
Definition:
typelist.hpp:257
Generated on Fri Dec 15 2023 06:12:43 for BitShares-Core by
1.8.17