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)
23 : in_(in), depth_(depth), limit_(limit)
24 {
25 }
26
27 void
28 operator()(Env&, JTx& jt) const;
29};
30
31//------------------------------------------------------------------------------
32
37class path
38{
39private:
41
42public:
44
45 template <class T, class... Args>
46 explicit path(T const& t, Args const&... args);
47
48 void
49 operator()(Env&, JTx& jt) const;
50
51private:
53 create();
54
55 void
56 append_one(Account const& account);
57
58 void
59 append_one(AccountID const& account);
60
61 template <class T>
63 append_one(T const& t)
64 {
66 }
67
68 void
69 append_one(IOU const& iou);
70
71 void
72 append_one(BookSpec const& book);
73
74 template <class T, class... Args>
75 void
76 append(T const& t, Args const&... args);
77};
78
79template <class T, class... Args>
80path::path(T const& t, Args const&... args) : jv_(Json::arrayValue)
81{
82 append(t, args...);
83}
84
85template <class T, class... Args>
86void
87path::append(T const& t, Args const&... args)
88{
89 append_one(t);
90 if constexpr (sizeof...(args) > 0)
91 append(args...);
92}
93
94} // namespace jtx
95} // namespace test
96} // 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:122
Converts to IOU Issue or STAmount.
Add a path.
Definition paths.h:38
std::enable_if_t< std::is_constructible< Account, T >::value > append_one(T const &t)
Definition paths.h:63
Json::Value jv_
Definition paths.h:40
void append(T const &t, Args const &... args)
Definition paths.h:87
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