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  });
32 
33  add(sfSigner.jsonName.c_str(),
34  sfSigner.getCode(),
35  {
36  {sfAccount, soeREQUIRED},
37  {sfSigningPubKey, soeREQUIRED},
38  {sfTxnSignature, soeREQUIRED},
39  });
40 }
41 
42 InnerObjectFormats const&
43 InnerObjectFormats::getInstance()
44 {
45  static InnerObjectFormats instance;
46  return instance;
47 }
48 
49 SOTemplate const*
50 InnerObjectFormats::findSOTemplateBySField(SField const& sField) const
51 {
52  auto itemPtr = findByType(sField.getCode());
53  if (itemPtr)
54  return &(itemPtr->getSOTemplate());
55 
56  return nullptr;
57 }
58 
59 } // namespace ripple
ripple::KnownFormats< int >::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:155
ripple::InnerObjectFormats::InnerObjectFormats
InnerObjectFormats()
Create the object.
Definition: InnerObjectFormats.cpp:24
ripple::sfSigner
const SField sfSigner(access, STI_OBJECT, 16, "Signer")
Definition: SField.h:510
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:133
ripple::SOTemplate
Defines the fields and their attributes within a STObject.
Definition: SOTemplate.h:81
ripple::sfSignerEntry
const SField sfSignerEntry(access, STI_OBJECT, 11, "SignerEntry")
Definition: SField.h:509
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:109
ripple::SField::getCode
int getCode() const
Definition: SField.h:226