rippled
InnerObjectFormats.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 <ripple/protocol/InnerObjectFormats.h>
21 
22 namespace ripple {
23 
25 {
28  {
29  {sfAccount, soeREQUIRED},
30  {sfSignerWeight, soeREQUIRED},
31  {sfWalletLocator, soeOPTIONAL},
32  });
33 
34  add(sfSigner.jsonName.c_str(),
35  sfSigner.getCode(),
36  {
37  {sfAccount, soeREQUIRED},
38  {sfSigningPubKey, soeREQUIRED},
39  {sfTxnSignature, soeREQUIRED},
40  });
41 
42  add(sfMajority.jsonName.c_str(),
43  sfMajority.getCode(),
44  {
45  {sfAmendment, soeREQUIRED},
46  {sfCloseTime, soeREQUIRED},
47  });
48 
51  {
52  {sfPublicKey, soeREQUIRED},
53  {sfFirstLedgerSequence, soeREQUIRED},
54  });
55 
56  add(sfNFToken.jsonName.c_str(),
58  {
59  {sfNFTokenID, soeREQUIRED},
60  {sfURI, soeOPTIONAL},
61  });
62 }
63 
64 InnerObjectFormats const&
65 InnerObjectFormats::getInstance()
66 {
67  static InnerObjectFormats instance;
68  return instance;
69 }
70 
71 SOTemplate const*
72 InnerObjectFormats::findSOTemplateBySField(SField const& sField) const
73 {
74  auto itemPtr = findByType(sField.getCode());
75  if (itemPtr)
76  return &(itemPtr->getSOTemplate());
77 
78  return nullptr;
79 }
80 
81 } // namespace ripple
ripple::InnerObjectFormats::InnerObjectFormats
InnerObjectFormats()
Create the object.
Definition: InnerObjectFormats.cpp:24
Json::StaticString::c_str
constexpr const char * c_str() const
Definition: json_value.h:73
ripple::SField::jsonName
const Json::StaticString jsonName
Definition: SField.h:136
ripple::SOTemplate
Defines the fields and their attributes within a STObject.
Definition: SOTemplate.h:82
ripple::sfSigner
const SField sfSigner
ripple::sfSignerEntry
const SField sfSignerEntry
ripple::sfNFToken
const SField sfNFToken
ripple::InnerObjectFormats
Manages the list of known inner object formats.
Definition: InnerObjectFormats.h:29
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::SField
Identifies fields.
Definition: SField.h:112
ripple::sfDisabledValidator
const SField sfDisabledValidator
ripple::SField::getCode
int getCode() const
Definition: SField.h:221
ripple::KnownFormats< int, InnerObjectFormats >::add
Item const & add(char const *name, int type, std::initializer_list< SOElement > uniqueFields, std::initializer_list< SOElement > commonFields={})
Add a new format.
Definition: KnownFormats.h:170