rippled
Loading...
Searching...
No Matches
paths.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_TEST_JTX_PATHS_H_INCLUDED
21#define RIPPLE_TEST_JTX_PATHS_H_INCLUDED
22
23#include <test/jtx/Env.h>
24
25#include <xrpl/protocol/Issue.h>
26
27#include <type_traits>
28
29namespace ripple {
30namespace test {
31namespace jtx {
32
34class paths
35{
36private:
38 int depth_;
39 unsigned int limit_;
40
41public:
42 paths(Issue const& in, int depth = 7, unsigned int limit = 4)
43 : in_(in), depth_(depth), limit_(limit)
44 {
45 }
46
47 void
48 operator()(Env&, JTx& jt) const;
49};
50
51//------------------------------------------------------------------------------
52
57class path
58{
59private:
61
62public:
64
65 template <class T, class... Args>
66 explicit path(T const& t, Args const&... args);
67
68 void
69 operator()(Env&, JTx& jt) const;
70
71private:
73 create();
74
75 void
76 append_one(Account const& account);
77
78 void
79 append_one(AccountID const& account);
80
81 template <class T>
83 append_one(T const& t)
84 {
86 }
87
88 void
89 append_one(IOU const& iou);
90
91 void
92 append_one(BookSpec const& book);
93
94 template <class T, class... Args>
95 void
96 append(T const& t, Args const&... args);
97};
98
99template <class T, class... Args>
100path::path(T const& t, Args const&... args) : jv_(Json::arrayValue)
101{
102 append(t, args...);
103}
104
105template <class T, class... Args>
106void
107path::append(T const& t, Args const&... args)
108{
109 append_one(t);
110 if constexpr (sizeof...(args) > 0)
111 append(args...);
112}
113
114} // namespace jtx
115} // namespace test
116} // namespace ripple
117
118#endif
Represents a JSON value.
Definition json_value.h:149
A currency issued by an account.
Definition Issue.h:33
Immutable cryptographic account descriptor.
Definition Account.h:39
A transaction testing environment.
Definition Env.h:121
Converts to IOU Issue or STAmount.
Add a path.
Definition paths.h:58
std::enable_if_t< std::is_constructible< Account, T >::value > append_one(T const &t)
Definition paths.h:83
Json::Value jv_
Definition paths.h:60
Json::Value & create()
Definition paths.cpp:78
void append(T const &t, Args const &... args)
Definition paths.h:107
void operator()(Env &, JTx &jt) const
Definition paths.cpp:113
void append_one(Account const &account)
Definition paths.cpp:84
Set Paths, SendMax on a JTx.
Definition paths.h:35
unsigned int limit_
Definition paths.h:39
paths(Issue const &in, int depth=7, unsigned int limit=4)
Definition paths.h:42
void operator()(Env &, JTx &jt) const
Definition paths.cpp:33
JSON (JavaScript Object Notation).
Definition json_errors.h:25
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
Execution context for applying a JSON transaction.
Definition JTx.h:45