rippled
Loading...
Searching...
No Matches
paths.h
1#ifndef XRPL_TEST_JTX_PATHS_H_INCLUDED
2#define XRPL_TEST_JTX_PATHS_H_INCLUDED
3
4#include <test/jtx/Env.h>
5
6#include <xrpl/protocol/Issue.h>
7
8#include <type_traits>
9
10namespace ripple {
11namespace test {
12namespace jtx {
13
15class paths
16{
17private:
19 int depth_;
20 unsigned int limit_;
21
22public:
23 paths(Issue const& in, int depth = 7, unsigned int limit = 4)
24 : in_(in), depth_(depth), limit_(limit)
25 {
26 }
27
28 void
29 operator()(Env&, JTx& jt) const;
30};
31
32//------------------------------------------------------------------------------
33
38class path
39{
40private:
42
43public:
45
46 template <class T, class... Args>
47 explicit path(T const& t, Args const&... args);
48
49 void
50 operator()(Env&, JTx& jt) const;
51
52private:
54 create();
55
56 void
57 append_one(Account const& account);
58
59 void
60 append_one(AccountID const& account);
61
62 template <class T>
64 append_one(T const& t)
65 {
67 }
68
69 void
70 append_one(IOU const& iou);
71
72 void
73 append_one(BookSpec const& book);
74
75 template <class T, class... Args>
76 void
77 append(T const& t, Args const&... args);
78};
79
80template <class T, class... Args>
81path::path(T const& t, Args const&... args) : jv_(Json::arrayValue)
82{
83 append(t, args...);
84}
85
86template <class T, class... Args>
87void
88path::append(T const& t, Args const&... args)
89{
90 append_one(t);
91 if constexpr (sizeof...(args) > 0)
92 append(args...);
93}
94
95} // namespace jtx
96} // namespace test
97} // namespace ripple
98
99#endif
Represents a JSON value.
Definition json_value.h:130
A currency issued by an account.
Definition Issue.h:14
Immutable cryptographic account descriptor.
Definition Account.h:20
A transaction testing environment.
Definition Env.h:102
Converts to IOU Issue or STAmount.
Add a path.
Definition paths.h:39
std::enable_if_t< std::is_constructible< Account, T >::value > append_one(T const &t)
Definition paths.h:64
Json::Value jv_
Definition paths.h:41
Json::Value & create()
Definition paths.cpp:59
void append(T const &t, Args const &... args)
Definition paths.h:88
void operator()(Env &, JTx &jt) const
Definition paths.cpp:94
void append_one(Account const &account)
Definition paths.cpp:65
Set Paths, SendMax on a JTx.
Definition paths.h:16
unsigned int limit_
Definition paths.h:20
paths(Issue const &in, int depth=7, unsigned int limit=4)
Definition paths.h:23
void operator()(Env &, JTx &jt) const
Definition paths.cpp:14
JSON (JavaScript Object Notation).
Definition json_errors.h:6
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
Execution context for applying a JSON transaction.
Definition JTx.h:26