rippled
ticket.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_TICKET_H_INCLUDED
21 #define RIPPLE_TEST_JTX_TICKET_H_INCLUDED
22 
23 #include <test/jtx/Env.h>
24 #include <test/jtx/Account.h>
25 #include <test/jtx/owners.h>
26 #include <boost/optional.hpp>
27 #include <cstdint>
28 
29 namespace ripple {
30 namespace test {
31 namespace jtx {
32 
33 /*
34  This shows how the jtx system may be extended to other
35  generators, funclets, conditions, and operations,
36  without changing the base declarations.
37 */
38 
40 namespace ticket {
41 
42 namespace detail {
43 
45 create (Account const& account,
46  boost::optional<Account> const& target,
47  boost::optional<std::uint32_t> const& expire);
48 
49 inline
50 void
51 create_arg (boost::optional<Account>& opt,
52  boost::optional<std::uint32_t>&,
53  Account const& value)
54 {
55  opt = value;
56 }
57 
58 inline
59 void
60 create_arg (boost::optional<Account>&,
61  boost::optional<std::uint32_t>& opt,
62  std::uint32_t value)
63 {
64  opt = value;
65 }
66 
67 template<class Arg, class... Args>
68 void
69 create_args(boost::optional<Account>& account_opt,
70  boost::optional<std::uint32_t>& expire_opt,
71  Arg const& arg, Args const&... args)
72 {
73  create_arg(account_opt, expire_opt, arg);
74  if constexpr (sizeof...(args))
75  create_args(account_opt, expire_opt, args...);
76 }
77 
78 } // detail
79 
81 template <class... Args>
83 create (Account const& account,
84  Args const&... args)
85 {
86  boost::optional<Account> target;
87  boost::optional<std::uint32_t> expire;
88  if constexpr (sizeof...(args) > 0)
89  detail::create_args(target, expire, args...);
90  return detail::create(
91  account, target, expire);
92 }
93 
96 cancel(Account const& account, std::string const & ticketId);
97 
98 } // ticket
99 
102 
103 } // jtx
104 
105 } // test
106 } // ripple
107 
108 #endif
std::string
STL class.
ripple::test::jtx::ticket::detail::create_arg
void create_arg(boost::optional< Account > &opt, boost::optional< std::uint32_t > &, Account const &value)
Definition: ticket.h:51
ripple::test::jtx::ticket::cancel
Json::Value cancel(Account const &account, std::string const &ticketId)
Cancel a ticket.
Definition: ticket.cpp:49
ripple::test::jtx::ticket::detail::create
Json::Value create(Account const &account, boost::optional< Account > const &target, boost::optional< std::uint32_t > const &expire)
Definition: ticket.cpp:32
cstdint
std::uint32_t
ripple::test::jtx::ticket::create
Json::Value create(Account const &account, Args const &... args)
Create a ticket.
Definition: ticket.h:83
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::test::jtx::Account
Immutable cryptographic account descriptor.
Definition: Account.h:37
ripple::test::jtx::ticket::detail::create_args
void create_args(boost::optional< Account > &account_opt, boost::optional< std::uint32_t > &expire_opt, Arg const &arg, Args const &... args)
Definition: ticket.h:69
Json::Value
Represents a JSON value.
Definition: json_value.h:141
ripple::test::jtx::owner_count
Definition: owners.h:50