xrpld
Loading...
Searching...
No Matches
paths.h
1#pragma once
2
3#include <test/jtx/Account.h>
4#include <test/jtx/Env.h>
5#include <test/jtx/JTx.h>
6#include <test/jtx/amount.h>
7
8#include <xrpl/json/json_value.h>
9#include <xrpl/protocol/AccountID.h>
10#include <xrpl/protocol/Asset.h>
11
12#include <type_traits>
13
14namespace xrpl {
15class STPath;
16
17namespace test::jtx {
18
22class Paths
23{
24private:
26 int depth_;
27 unsigned int limit_;
28
29public:
30 Paths(Asset const& in, int depth = 7, unsigned int limit = 4)
31 : in_(in), depth_(depth), limit_(limit)
32 {
33 }
34
35 void
36 operator()(Env&, JTx& jt) const;
37};
38
39//------------------------------------------------------------------------------
40
46class Path
47{
48private:
50
51public:
53
54 template <class T, class... Args>
55 explicit Path(T const& t, Args const&... args);
56
57 Path(STPath const& p);
58
59 void
60 operator()(Env&, JTx& jt) const;
61
62private:
64 create();
65
66 void
67 appendOne(Account const& account);
68
69 void
70 appendOne(AccountID const& account);
71
72 template <class T>
73 void
74 appendOne(T const& t)
76 {
78 }
79
80 void
81 appendOne(IOU const& iou);
82
83 void
84 appendOne(BookSpec const& book);
85
86 template <class T, class... Args>
87 void
88 append(T const& t, Args const&... args);
89};
90
91template <class T, class... Args>
92Path::Path(T const& t, Args const&... args) : jv_(json::ValueType::Array)
93{
94 append(t, args...);
95}
96
97template <class T, class... Args>
98void
99Path::append(T const& t, Args const&... args)
100{
101 appendOne(t);
102 if constexpr (sizeof...(args) > 0)
103 append(args...);
104}
105
106} // namespace test::jtx
107
108} // namespace xrpl
Represents a JSON value.
Definition json_value.h:117
Immutable cryptographic account descriptor.
Definition jtx/Account.h:21
A transaction testing environment.
Definition Env.h:161
Converts to IOU Issue or STAmount.
void append(T const &t, Args const &... args)
Definition paths.h:99
json::Value jv_
Definition paths.h:49
void appendOne(T const &t)
Definition paths.h:74
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:30
unsigned int limit_
Definition paths.h:27
void operator()(Env &, JTx &jt) const
Definition paths.cpp:26
T is_constructible_v
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:34
Execution context for applying a JSON transaction.
Definition JTx.h:27