diff --git a/src/ripple/protocol/SField.h b/src/ripple/protocol/SField.h index 3742fc39d9..4834d402de 100644 --- a/src/ripple/protocol/SField.h +++ b/src/ripple/protocol/SField.h @@ -23,6 +23,9 @@ #include #include #include +#include +#include +#include #include namespace ripple { @@ -141,22 +144,30 @@ public: int const fieldCode; // (type<<16)|index SerializedTypeID const fieldType; // STI_* int const fieldValue; // Code number for protocol - std::string fieldName; - int fieldMeta; - int fieldNum; + std::string const fieldName; + int const fieldMeta; + int const fieldNum; IsSigning const signingField; Json::StaticString const jsonName; SField(SField const&) = delete; SField& operator=(SField const&) = delete; - SField(SField&&); + SField(SField&&) = delete; + SField& operator=(SField&&) = delete; + +public: + struct private_access_tag_t; // public, but still an implementation detail + + // These constructors can only be called from SField.cpp + SField (private_access_tag_t, SerializedTypeID tid, int fv, + const char* fn, int meta = sMD_Default, + IsSigning signing = IsSigning::yes); + explicit SField (private_access_tag_t, int fc); + SField (private_access_tag_t, SerializedTypeID tid, int fv); protected: - // These constructors can only be called from FieldNames.cpp - SField (SerializedTypeID tid, int fv, const char* fn, - int meta = sMD_Default, IsSigning signing = IsSigning::yes); - explicit SField (int fc); - SField (SerializedTypeID id, int val); + // These constructors can only be called from SField.cpp + explicit SField (SerializedTypeID tid, int fv); public: // getField will dynamically construct a new SField if necessary @@ -238,10 +249,6 @@ public: { return (fieldMeta & c) != 0; } - void setMeta (int c) - { - fieldMeta = c; - } bool shouldInclude (bool withSigningField) const { @@ -261,10 +268,12 @@ public: static int compare (const SField& f1, const SField& f2); - struct make; // public, but still an implementation detail - private: static int num; + + static std::mutex SField_mutex; + static std::map knownCodeToField; + static std::map> unknownCodeToField; }; /** A field with a type known at compile time. */ diff --git a/src/ripple/protocol/impl/SField.cpp b/src/ripple/protocol/impl/SField.cpp index a2bd61af55..58f931b40e 100644 --- a/src/ripple/protocol/impl/SField.cpp +++ b/src/ripple/protocol/impl/SField.cpp @@ -20,256 +20,232 @@ #include #include #include -#include -#include -#include #include #include namespace ripple { -// These must stay at the top of this file, and in this order -// Files-cope statics are preferred here because the SFields must be -// file-scope. The following 3 objects must have scope prior to -// the file-scope SFields. -static std::mutex SField_mutex; -static std::map knownCodeToField; -static std::map> unknownCodeToField; - -// Storage for static const member. +// Storage for static const members. SField::IsSigning const SField::notSigning; - int SField::num = 0; +std::mutex SField::SField_mutex; +std::map SField::knownCodeToField; +std::map> SField::unknownCodeToField; using StaticScopedLockType = std::lock_guard ; -// Give this translation unit only, permission to construct SFields -struct SField::make +// Give only this translation unit permission to construct SFields +struct SField::private_access_tag_t { - explicit make() = default; - - template - static SField one(SField const* p, Args&& ...args) - { - SField result(std::forward(args)...); - knownCodeToField[result.fieldCode] = p; - return result; - } - - template - static TypedField one(SField const* p, Args&& ...args) - { - TypedField result(std::forward(args)...); - knownCodeToField[result.fieldCode] = p; - return result; - } + explicit private_access_tag_t() = default; }; -using make = SField::make; +SField::private_access_tag_t access; // Construct all compile-time SFields, and register them in the knownCodeToField // database: -SField const sfInvalid = make::one(&sfInvalid, -1); -SField const sfGeneric = make::one(&sfGeneric, 0); -SField const sfLedgerEntry = make::one(&sfLedgerEntry, STI_LEDGERENTRY, 257, "LedgerEntry"); -SField const sfTransaction = make::one(&sfTransaction, STI_TRANSACTION, 257, "Transaction"); -SField const sfValidation = make::one(&sfValidation, STI_VALIDATION, 257, "Validation"); -SField const sfMetadata = make::one(&sfMetadata, STI_METADATA, 257, "Metadata"); -SField const sfHash = make::one(&sfHash, STI_HASH256, 257, "hash"); -SField const sfIndex = make::one(&sfIndex, STI_HASH256, 258, "index"); +SField const sfInvalid (access, -1); +SField const sfGeneric (access, 0); +SField const sfLedgerEntry (access, STI_LEDGERENTRY, 257, "LedgerEntry"); +SField const sfTransaction (access, STI_TRANSACTION, 257, "Transaction"); +SField const sfValidation (access, STI_VALIDATION, 257, "Validation"); +SField const sfMetadata (access, STI_METADATA, 257, "Metadata"); +SField const sfHash (access, STI_HASH256, 257, "hash"); +SField const sfIndex (access, STI_HASH256, 258, "index"); // 8-bit integers -SF_U8 const sfCloseResolution = make::one(&sfCloseResolution, STI_UINT8, 1, "CloseResolution"); -SF_U8 const sfMethod = make::one(&sfMethod, STI_UINT8, 2, "Method"); -SF_U8 const sfTransactionResult = make::one(&sfTransactionResult, STI_UINT8, 3, "TransactionResult"); +SF_U8 const sfCloseResolution (access, STI_UINT8, 1, "CloseResolution"); +SF_U8 const sfMethod (access, STI_UINT8, 2, "Method"); +SF_U8 const sfTransactionResult (access, STI_UINT8, 3, "TransactionResult"); // 8-bit integers (uncommon) -SF_U8 const sfTickSize = make::one(&sfTickSize, STI_UINT8, 16, "TickSize"); +SF_U8 const sfTickSize (access, STI_UINT8, 16, "TickSize"); // 16-bit integers -SF_U16 const sfLedgerEntryType = make::one(&sfLedgerEntryType, STI_UINT16, 1, "LedgerEntryType", SField::sMD_Never); -SF_U16 const sfTransactionType = make::one(&sfTransactionType, STI_UINT16, 2, "TransactionType"); -SF_U16 const sfSignerWeight = make::one(&sfSignerWeight, STI_UINT16, 3, "SignerWeight"); +SF_U16 const sfLedgerEntryType (access, STI_UINT16, 1, "LedgerEntryType", SField::sMD_Never); +SF_U16 const sfTransactionType (access, STI_UINT16, 2, "TransactionType"); +SF_U16 const sfSignerWeight (access, STI_UINT16, 3, "SignerWeight"); // 16-bit integers (uncommon) -SF_U16 const sfVersion = make::one(&sfVersion, STI_UINT16, 16, "Version"); +SF_U16 const sfVersion (access, STI_UINT16, 16, "Version"); // 32-bit integers (common) -SF_U32 const sfFlags = make::one(&sfFlags, STI_UINT32, 2, "Flags"); -SF_U32 const sfSourceTag = make::one(&sfSourceTag, STI_UINT32, 3, "SourceTag"); -SF_U32 const sfSequence = make::one(&sfSequence, STI_UINT32, 4, "Sequence"); -SF_U32 const sfPreviousTxnLgrSeq = make::one(&sfPreviousTxnLgrSeq, STI_UINT32, 5, "PreviousTxnLgrSeq", SField::sMD_DeleteFinal); -SF_U32 const sfLedgerSequence = make::one(&sfLedgerSequence, STI_UINT32, 6, "LedgerSequence"); -SF_U32 const sfCloseTime = make::one(&sfCloseTime, STI_UINT32, 7, "CloseTime"); -SF_U32 const sfParentCloseTime = make::one(&sfParentCloseTime, STI_UINT32, 8, "ParentCloseTime"); -SF_U32 const sfSigningTime = make::one(&sfSigningTime, STI_UINT32, 9, "SigningTime"); -SF_U32 const sfExpiration = make::one(&sfExpiration, STI_UINT32, 10, "Expiration"); -SF_U32 const sfTransferRate = make::one(&sfTransferRate, STI_UINT32, 11, "TransferRate"); -SF_U32 const sfWalletSize = make::one(&sfWalletSize, STI_UINT32, 12, "WalletSize"); -SF_U32 const sfOwnerCount = make::one(&sfOwnerCount, STI_UINT32, 13, "OwnerCount"); -SF_U32 const sfDestinationTag = make::one(&sfDestinationTag, STI_UINT32, 14, "DestinationTag"); +SF_U32 const sfFlags (access, STI_UINT32, 2, "Flags"); +SF_U32 const sfSourceTag (access, STI_UINT32, 3, "SourceTag"); +SF_U32 const sfSequence (access, STI_UINT32, 4, "Sequence"); +SF_U32 const sfPreviousTxnLgrSeq (access, STI_UINT32, 5, "PreviousTxnLgrSeq", SField::sMD_DeleteFinal); +SF_U32 const sfLedgerSequence (access, STI_UINT32, 6, "LedgerSequence"); +SF_U32 const sfCloseTime (access, STI_UINT32, 7, "CloseTime"); +SF_U32 const sfParentCloseTime (access, STI_UINT32, 8, "ParentCloseTime"); +SF_U32 const sfSigningTime (access, STI_UINT32, 9, "SigningTime"); +SF_U32 const sfExpiration (access, STI_UINT32, 10, "Expiration"); +SF_U32 const sfTransferRate (access, STI_UINT32, 11, "TransferRate"); +SF_U32 const sfWalletSize (access, STI_UINT32, 12, "WalletSize"); +SF_U32 const sfOwnerCount (access, STI_UINT32, 13, "OwnerCount"); +SF_U32 const sfDestinationTag (access, STI_UINT32, 14, "DestinationTag"); // 32-bit integers (uncommon) -SF_U32 const sfHighQualityIn = make::one(&sfHighQualityIn, STI_UINT32, 16, "HighQualityIn"); -SF_U32 const sfHighQualityOut = make::one(&sfHighQualityOut, STI_UINT32, 17, "HighQualityOut"); -SF_U32 const sfLowQualityIn = make::one(&sfLowQualityIn, STI_UINT32, 18, "LowQualityIn"); -SF_U32 const sfLowQualityOut = make::one(&sfLowQualityOut, STI_UINT32, 19, "LowQualityOut"); -SF_U32 const sfQualityIn = make::one(&sfQualityIn, STI_UINT32, 20, "QualityIn"); -SF_U32 const sfQualityOut = make::one(&sfQualityOut, STI_UINT32, 21, "QualityOut"); -SF_U32 const sfStampEscrow = make::one(&sfStampEscrow, STI_UINT32, 22, "StampEscrow"); -SF_U32 const sfBondAmount = make::one(&sfBondAmount, STI_UINT32, 23, "BondAmount"); -SF_U32 const sfLoadFee = make::one(&sfLoadFee, STI_UINT32, 24, "LoadFee"); -SF_U32 const sfOfferSequence = make::one(&sfOfferSequence, STI_UINT32, 25, "OfferSequence"); -SF_U32 const sfFirstLedgerSequence = make::one(&sfFirstLedgerSequence, STI_UINT32, 26, "FirstLedgerSequence"); // Deprecated: do not use -SF_U32 const sfLastLedgerSequence = make::one(&sfLastLedgerSequence, STI_UINT32, 27, "LastLedgerSequence"); -SF_U32 const sfTransactionIndex = make::one(&sfTransactionIndex, STI_UINT32, 28, "TransactionIndex"); -SF_U32 const sfOperationLimit = make::one(&sfOperationLimit, STI_UINT32, 29, "OperationLimit"); -SF_U32 const sfReferenceFeeUnits = make::one(&sfReferenceFeeUnits, STI_UINT32, 30, "ReferenceFeeUnits"); -SF_U32 const sfReserveBase = make::one(&sfReserveBase, STI_UINT32, 31, "ReserveBase"); -SF_U32 const sfReserveIncrement = make::one(&sfReserveIncrement, STI_UINT32, 32, "ReserveIncrement"); -SF_U32 const sfSetFlag = make::one(&sfSetFlag, STI_UINT32, 33, "SetFlag"); -SF_U32 const sfClearFlag = make::one(&sfClearFlag, STI_UINT32, 34, "ClearFlag"); -SF_U32 const sfSignerQuorum = make::one(&sfSignerQuorum, STI_UINT32, 35, "SignerQuorum"); -SF_U32 const sfCancelAfter = make::one(&sfCancelAfter, STI_UINT32, 36, "CancelAfter"); -SF_U32 const sfFinishAfter = make::one(&sfFinishAfter, STI_UINT32, 37, "FinishAfter"); -SF_U32 const sfSignerListID = make::one(&sfSignerListID, STI_UINT32, 38, "SignerListID"); -SF_U32 const sfSettleDelay = make::one(&sfSettleDelay, STI_UINT32, 39, "SettleDelay"); +SF_U32 const sfHighQualityIn (access, STI_UINT32, 16, "HighQualityIn"); +SF_U32 const sfHighQualityOut (access, STI_UINT32, 17, "HighQualityOut"); +SF_U32 const sfLowQualityIn (access, STI_UINT32, 18, "LowQualityIn"); +SF_U32 const sfLowQualityOut (access, STI_UINT32, 19, "LowQualityOut"); +SF_U32 const sfQualityIn (access, STI_UINT32, 20, "QualityIn"); +SF_U32 const sfQualityOut (access, STI_UINT32, 21, "QualityOut"); +SF_U32 const sfStampEscrow (access, STI_UINT32, 22, "StampEscrow"); +SF_U32 const sfBondAmount (access, STI_UINT32, 23, "BondAmount"); +SF_U32 const sfLoadFee (access, STI_UINT32, 24, "LoadFee"); +SF_U32 const sfOfferSequence (access, STI_UINT32, 25, "OfferSequence"); +SF_U32 const sfFirstLedgerSequence (access, STI_UINT32, 26, "FirstLedgerSequence"); // Deprecated: do not use +SF_U32 const sfLastLedgerSequence (access, STI_UINT32, 27, "LastLedgerSequence"); +SF_U32 const sfTransactionIndex (access, STI_UINT32, 28, "TransactionIndex"); +SF_U32 const sfOperationLimit (access, STI_UINT32, 29, "OperationLimit"); +SF_U32 const sfReferenceFeeUnits (access, STI_UINT32, 30, "ReferenceFeeUnits"); +SF_U32 const sfReserveBase (access, STI_UINT32, 31, "ReserveBase"); +SF_U32 const sfReserveIncrement (access, STI_UINT32, 32, "ReserveIncrement"); +SF_U32 const sfSetFlag (access, STI_UINT32, 33, "SetFlag"); +SF_U32 const sfClearFlag (access, STI_UINT32, 34, "ClearFlag"); +SF_U32 const sfSignerQuorum (access, STI_UINT32, 35, "SignerQuorum"); +SF_U32 const sfCancelAfter (access, STI_UINT32, 36, "CancelAfter"); +SF_U32 const sfFinishAfter (access, STI_UINT32, 37, "FinishAfter"); +SF_U32 const sfSignerListID (access, STI_UINT32, 38, "SignerListID"); +SF_U32 const sfSettleDelay (access, STI_UINT32, 39, "SettleDelay"); // 64-bit integers -SF_U64 const sfIndexNext = make::one(&sfIndexNext, STI_UINT64, 1, "IndexNext"); -SF_U64 const sfIndexPrevious = make::one(&sfIndexPrevious, STI_UINT64, 2, "IndexPrevious"); -SF_U64 const sfBookNode = make::one(&sfBookNode, STI_UINT64, 3, "BookNode"); -SF_U64 const sfOwnerNode = make::one(&sfOwnerNode, STI_UINT64, 4, "OwnerNode"); -SF_U64 const sfBaseFee = make::one(&sfBaseFee, STI_UINT64, 5, "BaseFee"); -SF_U64 const sfExchangeRate = make::one(&sfExchangeRate, STI_UINT64, 6, "ExchangeRate"); -SF_U64 const sfLowNode = make::one(&sfLowNode, STI_UINT64, 7, "LowNode"); -SF_U64 const sfHighNode = make::one(&sfHighNode, STI_UINT64, 8, "HighNode"); -SF_U64 const sfDestinationNode = make::one(&sfDestinationNode, STI_UINT64, 9, "DestinationNode"); -SF_U64 const sfCookie = make::one(&sfCookie, STI_UINT64, 10,"Cookie"); +SF_U64 const sfIndexNext (access, STI_UINT64, 1, "IndexNext"); +SF_U64 const sfIndexPrevious (access, STI_UINT64, 2, "IndexPrevious"); +SF_U64 const sfBookNode (access, STI_UINT64, 3, "BookNode"); +SF_U64 const sfOwnerNode (access, STI_UINT64, 4, "OwnerNode"); +SF_U64 const sfBaseFee (access, STI_UINT64, 5, "BaseFee"); +SF_U64 const sfExchangeRate (access, STI_UINT64, 6, "ExchangeRate"); +SF_U64 const sfLowNode (access, STI_UINT64, 7, "LowNode"); +SF_U64 const sfHighNode (access, STI_UINT64, 8, "HighNode"); +SF_U64 const sfDestinationNode (access, STI_UINT64, 9, "DestinationNode"); +SF_U64 const sfCookie (access, STI_UINT64, 10,"Cookie"); // 128-bit -SF_U128 const sfEmailHash = make::one(&sfEmailHash, STI_HASH128, 1, "EmailHash"); +SF_U128 const sfEmailHash (access, STI_HASH128, 1, "EmailHash"); // 160-bit (common) -SF_U160 const sfTakerPaysCurrency = make::one(&sfTakerPaysCurrency, STI_HASH160, 1, "TakerPaysCurrency"); -SF_U160 const sfTakerPaysIssuer = make::one(&sfTakerPaysIssuer, STI_HASH160, 2, "TakerPaysIssuer"); -SF_U160 const sfTakerGetsCurrency = make::one(&sfTakerGetsCurrency, STI_HASH160, 3, "TakerGetsCurrency"); -SF_U160 const sfTakerGetsIssuer = make::one(&sfTakerGetsIssuer, STI_HASH160, 4, "TakerGetsIssuer"); +SF_U160 const sfTakerPaysCurrency (access, STI_HASH160, 1, "TakerPaysCurrency"); +SF_U160 const sfTakerPaysIssuer (access, STI_HASH160, 2, "TakerPaysIssuer"); +SF_U160 const sfTakerGetsCurrency (access, STI_HASH160, 3, "TakerGetsCurrency"); +SF_U160 const sfTakerGetsIssuer (access, STI_HASH160, 4, "TakerGetsIssuer"); // 256-bit (common) -SF_U256 const sfLedgerHash = make::one(&sfLedgerHash, STI_HASH256, 1, "LedgerHash"); -SF_U256 const sfParentHash = make::one(&sfParentHash, STI_HASH256, 2, "ParentHash"); -SF_U256 const sfTransactionHash = make::one(&sfTransactionHash, STI_HASH256, 3, "TransactionHash"); -SF_U256 const sfAccountHash = make::one(&sfAccountHash, STI_HASH256, 4, "AccountHash"); -SF_U256 const sfPreviousTxnID = make::one(&sfPreviousTxnID, STI_HASH256, 5, "PreviousTxnID", SField::sMD_DeleteFinal); -SF_U256 const sfLedgerIndex = make::one(&sfLedgerIndex, STI_HASH256, 6, "LedgerIndex"); -SF_U256 const sfWalletLocator = make::one(&sfWalletLocator, STI_HASH256, 7, "WalletLocator"); -SF_U256 const sfRootIndex = make::one(&sfRootIndex, STI_HASH256, 8, "RootIndex", SField::sMD_Always); -SF_U256 const sfAccountTxnID = make::one(&sfAccountTxnID, STI_HASH256, 9, "AccountTxnID"); +SF_U256 const sfLedgerHash (access, STI_HASH256, 1, "LedgerHash"); +SF_U256 const sfParentHash (access, STI_HASH256, 2, "ParentHash"); +SF_U256 const sfTransactionHash (access, STI_HASH256, 3, "TransactionHash"); +SF_U256 const sfAccountHash (access, STI_HASH256, 4, "AccountHash"); +SF_U256 const sfPreviousTxnID (access, STI_HASH256, 5, "PreviousTxnID", SField::sMD_DeleteFinal); +SF_U256 const sfLedgerIndex (access, STI_HASH256, 6, "LedgerIndex"); +SF_U256 const sfWalletLocator (access, STI_HASH256, 7, "WalletLocator"); +SF_U256 const sfRootIndex (access, STI_HASH256, 8, "RootIndex", SField::sMD_Always); +SF_U256 const sfAccountTxnID (access, STI_HASH256, 9, "AccountTxnID"); // 256-bit (uncommon) -SF_U256 const sfBookDirectory = make::one(&sfBookDirectory, STI_HASH256, 16, "BookDirectory"); -SF_U256 const sfInvoiceID = make::one(&sfInvoiceID, STI_HASH256, 17, "InvoiceID"); -SF_U256 const sfNickname = make::one(&sfNickname, STI_HASH256, 18, "Nickname"); -SF_U256 const sfAmendment = make::one(&sfAmendment, STI_HASH256, 19, "Amendment"); -SF_U256 const sfTicketID = make::one(&sfTicketID, STI_HASH256, 20, "TicketID"); -SF_U256 const sfDigest = make::one(&sfDigest, STI_HASH256, 21, "Digest"); -SF_U256 const sfPayChannel = make::one(&sfPayChannel, STI_HASH256, 22, "Channel"); -SF_U256 const sfConsensusHash = make::one(&sfConsensusHash, STI_HASH256, 23, "ConsensusHash"); -SF_U256 const sfCheckID = make::one(&sfCheckID, STI_HASH256, 24, "CheckID"); +SF_U256 const sfBookDirectory (access, STI_HASH256, 16, "BookDirectory"); +SF_U256 const sfInvoiceID (access, STI_HASH256, 17, "InvoiceID"); +SF_U256 const sfNickname (access, STI_HASH256, 18, "Nickname"); +SF_U256 const sfAmendment (access, STI_HASH256, 19, "Amendment"); +SF_U256 const sfTicketID (access, STI_HASH256, 20, "TicketID"); +SF_U256 const sfDigest (access, STI_HASH256, 21, "Digest"); +SF_U256 const sfPayChannel (access, STI_HASH256, 22, "Channel"); +SF_U256 const sfConsensusHash (access, STI_HASH256, 23, "ConsensusHash"); +SF_U256 const sfCheckID (access, STI_HASH256, 24, "CheckID"); // currency amount (common) -SF_Amount const sfAmount = make::one(&sfAmount, STI_AMOUNT, 1, "Amount"); -SF_Amount const sfBalance = make::one(&sfBalance, STI_AMOUNT, 2, "Balance"); -SF_Amount const sfLimitAmount = make::one(&sfLimitAmount, STI_AMOUNT, 3, "LimitAmount"); -SF_Amount const sfTakerPays = make::one(&sfTakerPays, STI_AMOUNT, 4, "TakerPays"); -SF_Amount const sfTakerGets = make::one(&sfTakerGets, STI_AMOUNT, 5, "TakerGets"); -SF_Amount const sfLowLimit = make::one(&sfLowLimit, STI_AMOUNT, 6, "LowLimit"); -SF_Amount const sfHighLimit = make::one(&sfHighLimit, STI_AMOUNT, 7, "HighLimit"); -SF_Amount const sfFee = make::one(&sfFee, STI_AMOUNT, 8, "Fee"); -SF_Amount const sfSendMax = make::one(&sfSendMax, STI_AMOUNT, 9, "SendMax"); -SF_Amount const sfDeliverMin = make::one(&sfDeliverMin, STI_AMOUNT, 10, "DeliverMin"); +SF_Amount const sfAmount (access, STI_AMOUNT, 1, "Amount"); +SF_Amount const sfBalance (access, STI_AMOUNT, 2, "Balance"); +SF_Amount const sfLimitAmount (access, STI_AMOUNT, 3, "LimitAmount"); +SF_Amount const sfTakerPays (access, STI_AMOUNT, 4, "TakerPays"); +SF_Amount const sfTakerGets (access, STI_AMOUNT, 5, "TakerGets"); +SF_Amount const sfLowLimit (access, STI_AMOUNT, 6, "LowLimit"); +SF_Amount const sfHighLimit (access, STI_AMOUNT, 7, "HighLimit"); +SF_Amount const sfFee (access, STI_AMOUNT, 8, "Fee"); +SF_Amount const sfSendMax (access, STI_AMOUNT, 9, "SendMax"); +SF_Amount const sfDeliverMin (access, STI_AMOUNT, 10, "DeliverMin"); // currency amount (uncommon) -SF_Amount const sfMinimumOffer = make::one(&sfMinimumOffer, STI_AMOUNT, 16, "MinimumOffer"); -SF_Amount const sfRippleEscrow = make::one(&sfRippleEscrow, STI_AMOUNT, 17, "RippleEscrow"); -SF_Amount const sfDeliveredAmount = make::one(&sfDeliveredAmount, STI_AMOUNT, 18, "DeliveredAmount"); +SF_Amount const sfMinimumOffer (access, STI_AMOUNT, 16, "MinimumOffer"); +SF_Amount const sfRippleEscrow (access, STI_AMOUNT, 17, "RippleEscrow"); +SF_Amount const sfDeliveredAmount (access, STI_AMOUNT, 18, "DeliveredAmount"); // variable length (common) -SF_Blob const sfPublicKey = make::one(&sfPublicKey, STI_VL, 1, "PublicKey"); -SF_Blob const sfMessageKey = make::one(&sfMessageKey, STI_VL, 2, "MessageKey"); -SF_Blob const sfSigningPubKey = make::one(&sfSigningPubKey, STI_VL, 3, "SigningPubKey"); -SF_Blob const sfTxnSignature = make::one(&sfTxnSignature, STI_VL, 4, "TxnSignature", SField::sMD_Default, SField::notSigning); -SF_Blob const sfSignature = make::one(&sfSignature, STI_VL, 6, "Signature", SField::sMD_Default, SField::notSigning); -SF_Blob const sfDomain = make::one(&sfDomain, STI_VL, 7, "Domain"); -SF_Blob const sfFundCode = make::one(&sfFundCode, STI_VL, 8, "FundCode"); -SF_Blob const sfRemoveCode = make::one(&sfRemoveCode, STI_VL, 9, "RemoveCode"); -SF_Blob const sfExpireCode = make::one(&sfExpireCode, STI_VL, 10, "ExpireCode"); -SF_Blob const sfCreateCode = make::one(&sfCreateCode, STI_VL, 11, "CreateCode"); -SF_Blob const sfMemoType = make::one(&sfMemoType, STI_VL, 12, "MemoType"); -SF_Blob const sfMemoData = make::one(&sfMemoData, STI_VL, 13, "MemoData"); -SF_Blob const sfMemoFormat = make::one(&sfMemoFormat, STI_VL, 14, "MemoFormat"); +SF_Blob const sfPublicKey (access, STI_VL, 1, "PublicKey"); +SF_Blob const sfMessageKey (access, STI_VL, 2, "MessageKey"); +SF_Blob const sfSigningPubKey (access, STI_VL, 3, "SigningPubKey"); +SF_Blob const sfTxnSignature (access, STI_VL, 4, "TxnSignature", SField::sMD_Default, SField::notSigning); +SF_Blob const sfSignature (access, STI_VL, 6, "Signature", SField::sMD_Default, SField::notSigning); +SF_Blob const sfDomain (access, STI_VL, 7, "Domain"); +SF_Blob const sfFundCode (access, STI_VL, 8, "FundCode"); +SF_Blob const sfRemoveCode (access, STI_VL, 9, "RemoveCode"); +SF_Blob const sfExpireCode (access, STI_VL, 10, "ExpireCode"); +SF_Blob const sfCreateCode (access, STI_VL, 11, "CreateCode"); +SF_Blob const sfMemoType (access, STI_VL, 12, "MemoType"); +SF_Blob const sfMemoData (access, STI_VL, 13, "MemoData"); +SF_Blob const sfMemoFormat (access, STI_VL, 14, "MemoFormat"); // variable length (uncommon) -SF_Blob const sfFulfillment = make::one(&sfFulfillment, STI_VL, 16, "Fulfillment"); -SF_Blob const sfCondition = make::one(&sfCondition, STI_VL, 17, "Condition"); -SF_Blob const sfMasterSignature = make::one(&sfMasterSignature, STI_VL, 18, "MasterSignature", SField::sMD_Default, SField::notSigning); +SF_Blob const sfFulfillment (access, STI_VL, 16, "Fulfillment"); +SF_Blob const sfCondition (access, STI_VL, 17, "Condition"); +SF_Blob const sfMasterSignature (access, STI_VL, 18, "MasterSignature", SField::sMD_Default, SField::notSigning); // account -SF_Account const sfAccount = make::one(&sfAccount, STI_ACCOUNT, 1, "Account"); -SF_Account const sfOwner = make::one(&sfOwner, STI_ACCOUNT, 2, "Owner"); -SF_Account const sfDestination = make::one(&sfDestination, STI_ACCOUNT, 3, "Destination"); -SF_Account const sfIssuer = make::one(&sfIssuer, STI_ACCOUNT, 4, "Issuer"); -SF_Account const sfAuthorize = make::one(&sfAuthorize, STI_ACCOUNT, 5, "Authorize"); -SF_Account const sfUnauthorize = make::one(&sfUnauthorize, STI_ACCOUNT, 6, "Unauthorize"); -SF_Account const sfTarget = make::one(&sfTarget, STI_ACCOUNT, 7, "Target"); -SF_Account const sfRegularKey = make::one(&sfRegularKey, STI_ACCOUNT, 8, "RegularKey"); +SF_Account const sfAccount (access, STI_ACCOUNT, 1, "Account"); +SF_Account const sfOwner (access, STI_ACCOUNT, 2, "Owner"); +SF_Account const sfDestination (access, STI_ACCOUNT, 3, "Destination"); +SF_Account const sfIssuer (access, STI_ACCOUNT, 4, "Issuer"); +SF_Account const sfAuthorize (access, STI_ACCOUNT, 5, "Authorize"); +SF_Account const sfUnauthorize (access, STI_ACCOUNT, 6, "Unauthorize"); +SF_Account const sfTarget (access, STI_ACCOUNT, 7, "Target"); +SF_Account const sfRegularKey (access, STI_ACCOUNT, 8, "RegularKey"); // path set -SField const sfPaths = make::one(&sfPaths, STI_PATHSET, 1, "Paths"); +SField const sfPaths (access, STI_PATHSET, 1, "Paths"); // vector of 256-bit -SF_Vec256 const sfIndexes = make::one(&sfIndexes, STI_VECTOR256, 1, "Indexes", SField::sMD_Never); -SF_Vec256 const sfHashes = make::one(&sfHashes, STI_VECTOR256, 2, "Hashes"); -SF_Vec256 const sfAmendments = make::one(&sfAmendments, STI_VECTOR256, 3, "Amendments"); +SF_Vec256 const sfIndexes (access, STI_VECTOR256, 1, "Indexes", SField::sMD_Never); +SF_Vec256 const sfHashes (access, STI_VECTOR256, 2, "Hashes"); +SF_Vec256 const sfAmendments (access, STI_VECTOR256, 3, "Amendments"); // inner object // OBJECT/1 is reserved for end of object -SField const sfTransactionMetaData = make::one(&sfTransactionMetaData, STI_OBJECT, 2, "TransactionMetaData"); -SField const sfCreatedNode = make::one(&sfCreatedNode, STI_OBJECT, 3, "CreatedNode"); -SField const sfDeletedNode = make::one(&sfDeletedNode, STI_OBJECT, 4, "DeletedNode"); -SField const sfModifiedNode = make::one(&sfModifiedNode, STI_OBJECT, 5, "ModifiedNode"); -SField const sfPreviousFields = make::one(&sfPreviousFields, STI_OBJECT, 6, "PreviousFields"); -SField const sfFinalFields = make::one(&sfFinalFields, STI_OBJECT, 7, "FinalFields"); -SField const sfNewFields = make::one(&sfNewFields, STI_OBJECT, 8, "NewFields"); -SField const sfTemplateEntry = make::one(&sfTemplateEntry, STI_OBJECT, 9, "TemplateEntry"); -SField const sfMemo = make::one(&sfMemo, STI_OBJECT, 10, "Memo"); -SField const sfSignerEntry = make::one(&sfSignerEntry, STI_OBJECT, 11, "SignerEntry"); +SField const sfTransactionMetaData (access, STI_OBJECT, 2, "TransactionMetaData"); +SField const sfCreatedNode (access, STI_OBJECT, 3, "CreatedNode"); +SField const sfDeletedNode (access, STI_OBJECT, 4, "DeletedNode"); +SField const sfModifiedNode (access, STI_OBJECT, 5, "ModifiedNode"); +SField const sfPreviousFields (access, STI_OBJECT, 6, "PreviousFields"); +SField const sfFinalFields (access, STI_OBJECT, 7, "FinalFields"); +SField const sfNewFields (access, STI_OBJECT, 8, "NewFields"); +SField const sfTemplateEntry (access, STI_OBJECT, 9, "TemplateEntry"); +SField const sfMemo (access, STI_OBJECT, 10, "Memo"); +SField const sfSignerEntry (access, STI_OBJECT, 11, "SignerEntry"); // inner object (uncommon) -SField const sfSigner = make::one(&sfSigner, STI_OBJECT, 16, "Signer"); +SField const sfSigner (access, STI_OBJECT, 16, "Signer"); // 17 has not been used yet... -SField const sfMajority = make::one(&sfMajority, STI_OBJECT, 18, "Majority"); +SField const sfMajority (access, STI_OBJECT, 18, "Majority"); // array of objects // ARRAY/1 is reserved for end of array -// SField const sfSigningAccounts = make::one(&sfSigningAccounts, STI_ARRAY, 2, "SigningAccounts"); // Never been used. -SField const sfSigners = make::one(&sfSigners, STI_ARRAY, 3, "Signers", SField::sMD_Default, SField::notSigning); -SField const sfSignerEntries = make::one(&sfSignerEntries, STI_ARRAY, 4, "SignerEntries"); -SField const sfTemplate = make::one(&sfTemplate, STI_ARRAY, 5, "Template"); -SField const sfNecessary = make::one(&sfNecessary, STI_ARRAY, 6, "Necessary"); -SField const sfSufficient = make::one(&sfSufficient, STI_ARRAY, 7, "Sufficient"); -SField const sfAffectedNodes = make::one(&sfAffectedNodes, STI_ARRAY, 8, "AffectedNodes"); -SField const sfMemos = make::one(&sfMemos, STI_ARRAY, 9, "Memos"); +// SField const sfSigningAccounts (access, STI_ARRAY, 2, "SigningAccounts"); // Never been used. +SField const sfSigners (access, STI_ARRAY, 3, "Signers", SField::sMD_Default, SField::notSigning); +SField const sfSignerEntries (access, STI_ARRAY, 4, "SignerEntries"); +SField const sfTemplate (access, STI_ARRAY, 5, "Template"); +SField const sfNecessary (access, STI_ARRAY, 6, "Necessary"); +SField const sfSufficient (access, STI_ARRAY, 7, "Sufficient"); +SField const sfAffectedNodes (access, STI_ARRAY, 8, "AffectedNodes"); +SField const sfMemos (access, STI_ARRAY, 9, "Memos"); // array of objects (uncommon) -SField const sfMajorities = make::one(&sfMajorities, STI_ARRAY, 16, "Majorities"); +SField const sfMajorities (access, STI_ARRAY, 16, "Majorities"); -SField::SField (SerializedTypeID tid, int fv, const char* fn, - int meta, IsSigning signing) +SField::SField(private_access_tag_t, + SerializedTypeID tid, int fv, const char* fn, int meta, + IsSigning signing) : fieldCode (field_code (tid, fv)) , fieldType (tid) , fieldValue (fv) @@ -279,9 +255,10 @@ SField::SField (SerializedTypeID tid, int fv, const char* fn, , signingField (signing) , jsonName (fieldName.c_str()) { + knownCodeToField[fieldCode] = this; } -SField::SField (int fc) +SField::SField(private_access_tag_t, int fc) : fieldCode (fc) , fieldType (STI_UNKNOWN) , fieldValue (0) @@ -290,12 +267,13 @@ SField::SField (int fc) , signingField (IsSigning::yes) , jsonName (fieldName.c_str()) { + knownCodeToField[fieldCode] = this; } // call with the map mutex to protect num. // This is naturally done with no extra expense // from getField(int code). -SField::SField (SerializedTypeID tid, int fv) +SField::SField(SerializedTypeID tid, int fv) : fieldCode (field_code (tid, fv)) , fieldType (tid) , fieldValue (fv) @@ -308,17 +286,11 @@ SField::SField (SerializedTypeID tid, int fv) assert ((fv != 1) || ((tid != STI_ARRAY) && (tid != STI_OBJECT))); } -// we can't use the default move constructor because -// it could leave jsonName referencing a destroyed string -SField::SField (SField &&s) - : fieldCode (s.fieldCode) - , fieldType (s.fieldType) - , fieldValue (s.fieldValue) - , fieldMeta (s.fieldMeta) - , fieldNum (s.fieldNum) - , signingField (s.signingField) - , jsonName (fieldName.c_str()) +SField::SField(private_access_tag_t, + SerializedTypeID tid, int fv) + : SField(tid, fv) { + knownCodeToField[fieldCode] = this; } SField const&