rippled
Loading...
Searching...
No Matches
flags.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_TEST_JTX_FLAGS_H_INCLUDED
21#define RIPPLE_TEST_JTX_FLAGS_H_INCLUDED
22
23#include <test/jtx/Env.h>
24
25#include <xrpl/basics/contract.h>
26#include <xrpl/protocol/LedgerFormats.h>
27#include <xrpl/protocol/TxFlags.h>
28
29namespace ripple {
30namespace detail {
31
33{
34protected:
36
37private:
38 void
40 {
41 switch (flag)
42 {
43 case asfRequireDest:
45 break;
46 case asfRequireAuth:
48 break;
49 case asfDisallowXRP:
51 break;
54 break;
55 // case asfAccountTxnID: // ???
56 case asfNoFreeze:
58 break;
59 case asfGlobalFreeze:
61 break;
64 break;
65 case asfDepositAuth:
67 break;
70 break;
73 break;
76 break;
79 break;
82 break;
85 break;
86 default:
87 Throw<std::runtime_error>("unknown flag");
88 }
89 }
90
91 template <class Flag, class... Args>
92 void
93 set_args(std::uint32_t flag, Args... args)
94 {
95 set_args(flag);
96 if constexpr (sizeof...(args))
97 set_args(args...);
98 }
99
100protected:
101 template <class... Args>
102 flags_helper(Args... args) : mask_(0)
103 {
104 set_args(args...);
105 }
106};
107
108} // namespace detail
109
110namespace test {
111namespace jtx {
112
113// JSON generators
114
117fset(Account const& account, std::uint32_t on, std::uint32_t off = 0);
118
120inline Json::Value
121fclear(Account const& account, std::uint32_t off)
122{
123 return fset(account, 0, off);
124}
125
128{
129private:
131
132public:
133 template <class... Args>
134 flags(Account const& account, Args... args)
135 : flags_helper(args...), account_(account)
136 {
137 }
138
139 void
140 operator()(Env& env) const;
141};
142
145{
146private:
148
149public:
150 template <class... Args>
151 nflags(Account const& account, Args... args)
152 : flags_helper(args...), account_(account)
153 {
154 }
155
156 void
157 operator()(Env& env) const;
158};
159
160} // namespace jtx
161} // namespace test
162} // namespace ripple
163
164#endif
Represents a JSON value.
Definition json_value.h:149
void set_args(std::uint32_t flag, Args... args)
Definition flags.h:93
std::uint32_t mask_
Definition flags.h:35
flags_helper(Args... args)
Definition flags.h:102
void set_args(std::uint32_t flag)
Definition flags.h:39
Immutable cryptographic account descriptor.
Definition Account.h:39
A transaction testing environment.
Definition Env.h:121
Match set account flags.
Definition flags.h:128
flags(Account const &account, Args... args)
Definition flags.h:134
void operator()(Env &env) const
Definition flags.cpp:42
Match clear account flags.
Definition flags.h:145
nflags(Account const &account, Args... args)
Definition flags.h:151
void operator()(Env &env) const
Definition flags.cpp:54
Json::Value fclear(Account const &account, std::uint32_t off)
Remove account flag.
Definition flags.h:121
Json::Value fset(Account const &account, std::uint32_t on, std::uint32_t off=0)
Add and/or remove flag.
Definition flags.cpp:29
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
constexpr std::uint32_t asfGlobalFreeze
Definition TxFlags.h:83
constexpr std::uint32_t asfDepositAuth
Definition TxFlags.h:85
constexpr std::uint32_t asfDisallowIncomingNFTokenOffer
Definition TxFlags.h:90
constexpr std::uint32_t asfAllowTrustLineLocking
Definition TxFlags.h:95
constexpr std::uint32_t asfRequireDest
Definition TxFlags.h:77
@ lsfRequireDestTag
@ lsfDefaultRipple
@ lsfDisallowIncomingCheck
@ lsfAllowTrustLineClawback
@ lsfDisableMaster
@ lsfDisallowIncomingPayChan
@ lsfDisallowIncomingTrustline
@ lsfAllowTrustLineLocking
@ lsfDisallowIncomingNFTokenOffer
@ lsfGlobalFreeze
constexpr std::uint32_t asfNoFreeze
Definition TxFlags.h:82
constexpr std::uint32_t asfDisableMaster
Definition TxFlags.h:80
constexpr std::uint32_t asfDisallowIncomingTrustline
Definition TxFlags.h:93
constexpr std::uint32_t asfDefaultRipple
Definition TxFlags.h:84
constexpr std::uint32_t asfDisallowIncomingCheck
Definition TxFlags.h:91
constexpr std::uint32_t asfDisallowIncomingPayChan
Definition TxFlags.h:92
constexpr std::uint32_t asfAllowTrustLineClawback
Definition TxFlags.h:94
constexpr std::uint32_t asfRequireAuth
Definition TxFlags.h:78
constexpr std::uint32_t asfDisallowXRP
Definition TxFlags.h:79