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 test {
31namespace jtx {
32
33// JSON generators
34
37fset(Account const& account, std::uint32_t on, std::uint32_t off = 0);
38
40inline Json::Value
41fclear(Account const& account, std::uint32_t off)
42{
43 return fset(account, 0, off);
44}
45
46namespace detail {
47
49{
50protected:
52
53private:
54 void
56 {
57 switch (flag)
58 {
59 case asfRequireDest:
61 break;
62 case asfRequireAuth:
64 break;
65 case asfDisallowXRP:
67 break;
70 break;
71 // case asfAccountTxnID: // ???
72 case asfNoFreeze:
74 break;
75 case asfGlobalFreeze:
77 break;
80 break;
81 case asfDepositAuth:
83 break;
86 break;
89 break;
92 break;
95 break;
98 break;
99 default:
100 Throw<std::runtime_error>("unknown flag");
101 }
102 }
103
104 template <class Flag, class... Args>
105 void
106 set_args(std::uint32_t flag, Args... args)
107 {
108 set_args(flag);
109 if constexpr (sizeof...(args))
110 set_args(args...);
111 }
112
113protected:
114 template <class... Args>
115 flags_helper(Args... args) : mask_(0)
116 {
117 set_args(args...);
118 }
119};
120
121} // namespace detail
122
125{
126private:
128
129public:
130 template <class... Args>
131 flags(Account const& account, Args... args)
132 : flags_helper(args...), account_(account)
133 {
134 }
135
136 void
137 operator()(Env& env) const;
138};
139
142{
143private:
145
146public:
147 template <class... Args>
148 nflags(Account const& account, Args... args)
149 : flags_helper(args...), account_(account)
150 {
151 }
152
153 void
154 operator()(Env& env) const;
155};
156
157} // namespace jtx
158} // namespace test
159} // namespace ripple
160
161#endif
Represents a JSON value.
Definition: json_value.h:150
Immutable cryptographic account descriptor.
Definition: Account.h:39
A transaction testing environment.
Definition: Env.h:121
void set_args(std::uint32_t flag)
Definition: flags.h:55
void set_args(std::uint32_t flag, Args... args)
Definition: flags.h:106
Match set account flags.
Definition: flags.h:125
flags(Account const &account, Args... args)
Definition: flags.h:131
void operator()(Env &env) const
Definition: flags.cpp:42
Match clear account flags.
Definition: flags.h:142
nflags(Account const &account, Args... args)
Definition: flags.h:148
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:41
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:26
constexpr std::uint32_t asfGlobalFreeze
Definition: TxFlags.h:82
constexpr std::uint32_t asfDepositAuth
Definition: TxFlags.h:84
constexpr std::uint32_t asfDisallowIncomingNFTokenOffer
Definition: TxFlags.h:89
constexpr std::uint32_t asfRequireDest
Definition: TxFlags.h:76
@ lsfRequireDestTag
@ lsfDefaultRipple
@ lsfRequireAuth
@ lsfDisallowIncomingCheck
@ lsfAllowTrustLineClawback
@ lsfDisableMaster
@ lsfDepositAuth
@ lsfDisallowIncomingPayChan
@ lsfDisallowIncomingTrustline
@ lsfDisallowIncomingNFTokenOffer
@ lsfGlobalFreeze
@ lsfDisallowXRP
constexpr std::uint32_t asfNoFreeze
Definition: TxFlags.h:81
constexpr std::uint32_t asfDisableMaster
Definition: TxFlags.h:79
constexpr std::uint32_t asfDisallowIncomingTrustline
Definition: TxFlags.h:92
constexpr std::uint32_t asfDefaultRipple
Definition: TxFlags.h:83
constexpr std::uint32_t asfDisallowIncomingCheck
Definition: TxFlags.h:90
constexpr std::uint32_t asfDisallowIncomingPayChan
Definition: TxFlags.h:91
constexpr std::uint32_t asfAllowTrustLineClawback
Definition: TxFlags.h:93
constexpr std::uint32_t asfRequireAuth
Definition: TxFlags.h:77
constexpr std::uint32_t asfDisallowXRP
Definition: TxFlags.h:78