xrpld
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 {
10class STPath;
11
12namespace test::jtx {
13
15class Paths
16{
17private:
19 int depth_;
20 unsigned int limit_;
21
22public:
23 Paths(Asset 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 Path(STPath const& p);
50
51 void
52 operator()(Env&, JTx& jt) const;
53
54private:
56 create();
57
58 void
59 appendOne(Account const& account);
60
61 void
62 appendOne(AccountID const& account);
63
64 template <class T>
66 appendOne(T const& t)
67 {
69 }
70
71 void
72 appendOne(IOU const& iou);
73
74 void
75 appendOne(BookSpec const& book);
76
77 template <class T, class... Args>
78 void
79 append(T const& t, Args const&... args);
80};
81
82template <class T, class... Args>
83Path::Path(T const& t, Args const&... args) : jv_(json::ValueType::Array)
84{
85 append(t, args...);
86}
87
88template <class T, class... Args>
89void
90Path::append(T const& t, Args const&... args)
91{
92 appendOne(t);
93 if constexpr (sizeof...(args) > 0)
94 append(args...);
95}
96
97} // namespace test::jtx
98
99} // namespace xrpl
Represents a JSON value.
Definition json_value.h:130
Immutable cryptographic account descriptor.
Definition jtx/Account.h:17
A transaction testing environment.
Definition Env.h:143
Converts to IOU Issue or STAmount.
void append(T const &t, Args const &... args)
Definition paths.h:90
std::enable_if_t< std::is_constructible_v< Account, T > > appendOne(T const &t)
Definition paths.h:66
json::Value jv_
Definition paths.h:41
void operator()(Env &, JTx &jt) const
Definition paths.cpp:114
json::Value & create()
Definition paths.cpp:75
void appendOne(Account const &account)
Definition paths.cpp:81
Paths(Asset const &in, int depth=7, unsigned int limit=4)
Definition paths.h:23
unsigned int limit_
Definition paths.h:20
void operator()(Env &, JTx &jt) const
Definition paths.cpp:26
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
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:28
Execution context for applying a JSON transaction.
Definition JTx.h:23