rippled
Loading...
Searching...
No Matches
Book.cpp
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#include <xrpl/protocol/Book.h>
21#include <xrpl/protocol/Issue.h>
22
23#include <ostream>
24#include <string>
25
26namespace ripple {
27
28bool
29isConsistent(Book const& book)
30{
31 return isConsistent(book.in) && isConsistent(book.out) &&
32 book.in != book.out;
33}
34
36to_string(Book const& book)
37{
38 return to_string(book.in) + "->" + to_string(book.out);
39}
40
42operator<<(std::ostream& os, Book const& x)
43{
44 os << to_string(x);
45 return os;
46}
47
48Book
49reversed(Book const& book)
50{
51 return Book(book.out, book.in, book.domain);
52}
53
54} // namespace ripple
Specifies an order book.
Definition: Book.h:36
Issue in
Definition: Book.h:38
Issue out
Definition: Book.h:39
std::optional< uint256 > domain
Definition: Book.h:40
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
bool isConsistent(Book const &book)
Definition: Book.cpp:29
Book reversed(Book const &book)
Definition: Book.cpp:49
std::ostream & operator<<(std::ostream &out, base_uint< Bits, Tag > const &u)
Definition: base_uint.h:637
std::string to_string(base_uint< Bits, Tag > const &a)
Definition: base_uint.h:630