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