// This file is auto-generated. Do not edit. #pragma once #include #include #include #include #include #include #include #include namespace xrpl::ledger_entries { class DirectoryNodeBuilder; /** * @brief Ledger Entry: DirectoryNode * * Type: ltDIR_NODE (0x0064) * RPC Name: directory * * Immutable wrapper around SLE providing type-safe field access. * Use DirectoryNodeBuilder to construct new ledger entries. */ class DirectoryNode : public LedgerEntryBase { public: static constexpr LedgerEntryType entryType = ltDIR_NODE; /** * @brief Construct a DirectoryNode ledger entry wrapper from an existing SLE object. * @throws std::runtime_error if the ledger entry type doesn't match. */ explicit DirectoryNode(std::shared_ptr sle) : LedgerEntryBase(std::move(sle)) { // Verify ledger entry type if (sle_->getType() != entryType) { throw std::runtime_error("Invalid ledger entry type for DirectoryNode"); } } // Ledger entry-specific field getters /** * @brief Get sfOwner (soeOPTIONAL) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] protocol_autogen::Optional getOwner() const { if (hasOwner()) return this->sle_->at(sfOwner); return std::nullopt; } /** * @brief Check if sfOwner is present. * @return True if the field is present, false otherwise. */ [[nodiscard]] bool hasOwner() const { return this->sle_->isFieldPresent(sfOwner); } /** * @brief Get sfTakerPaysCurrency (soeOPTIONAL) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] protocol_autogen::Optional getTakerPaysCurrency() const { if (hasTakerPaysCurrency()) return this->sle_->at(sfTakerPaysCurrency); return std::nullopt; } /** * @brief Check if sfTakerPaysCurrency is present. * @return True if the field is present, false otherwise. */ [[nodiscard]] bool hasTakerPaysCurrency() const { return this->sle_->isFieldPresent(sfTakerPaysCurrency); } /** * @brief Get sfTakerPaysIssuer (soeOPTIONAL) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] protocol_autogen::Optional getTakerPaysIssuer() const { if (hasTakerPaysIssuer()) return this->sle_->at(sfTakerPaysIssuer); return std::nullopt; } /** * @brief Check if sfTakerPaysIssuer is present. * @return True if the field is present, false otherwise. */ [[nodiscard]] bool hasTakerPaysIssuer() const { return this->sle_->isFieldPresent(sfTakerPaysIssuer); } /** * @brief Get sfTakerPaysMPT (soeOPTIONAL) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] protocol_autogen::Optional getTakerPaysMPT() const { if (hasTakerPaysMPT()) return this->sle_->at(sfTakerPaysMPT); return std::nullopt; } /** * @brief Check if sfTakerPaysMPT is present. * @return True if the field is present, false otherwise. */ [[nodiscard]] bool hasTakerPaysMPT() const { return this->sle_->isFieldPresent(sfTakerPaysMPT); } /** * @brief Get sfTakerGetsCurrency (soeOPTIONAL) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] protocol_autogen::Optional getTakerGetsCurrency() const { if (hasTakerGetsCurrency()) return this->sle_->at(sfTakerGetsCurrency); return std::nullopt; } /** * @brief Check if sfTakerGetsCurrency is present. * @return True if the field is present, false otherwise. */ [[nodiscard]] bool hasTakerGetsCurrency() const { return this->sle_->isFieldPresent(sfTakerGetsCurrency); } /** * @brief Get sfTakerGetsIssuer (soeOPTIONAL) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] protocol_autogen::Optional getTakerGetsIssuer() const { if (hasTakerGetsIssuer()) return this->sle_->at(sfTakerGetsIssuer); return std::nullopt; } /** * @brief Check if sfTakerGetsIssuer is present. * @return True if the field is present, false otherwise. */ [[nodiscard]] bool hasTakerGetsIssuer() const { return this->sle_->isFieldPresent(sfTakerGetsIssuer); } /** * @brief Get sfTakerGetsMPT (soeOPTIONAL) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] protocol_autogen::Optional getTakerGetsMPT() const { if (hasTakerGetsMPT()) return this->sle_->at(sfTakerGetsMPT); return std::nullopt; } /** * @brief Check if sfTakerGetsMPT is present. * @return True if the field is present, false otherwise. */ [[nodiscard]] bool hasTakerGetsMPT() const { return this->sle_->isFieldPresent(sfTakerGetsMPT); } /** * @brief Get sfExchangeRate (soeOPTIONAL) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] protocol_autogen::Optional getExchangeRate() const { if (hasExchangeRate()) return this->sle_->at(sfExchangeRate); return std::nullopt; } /** * @brief Check if sfExchangeRate is present. * @return True if the field is present, false otherwise. */ [[nodiscard]] bool hasExchangeRate() const { return this->sle_->isFieldPresent(sfExchangeRate); } /** * @brief Get sfIndexes (soeREQUIRED) * @return The field value. */ [[nodiscard]] SF_VECTOR256::type::value_type getIndexes() const { return this->sle_->at(sfIndexes); } /** * @brief Get sfRootIndex (soeREQUIRED) * @return The field value. */ [[nodiscard]] SF_UINT256::type::value_type getRootIndex() const { return this->sle_->at(sfRootIndex); } /** * @brief Get sfIndexNext (soeOPTIONAL) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] protocol_autogen::Optional getIndexNext() const { if (hasIndexNext()) return this->sle_->at(sfIndexNext); return std::nullopt; } /** * @brief Check if sfIndexNext is present. * @return True if the field is present, false otherwise. */ [[nodiscard]] bool hasIndexNext() const { return this->sle_->isFieldPresent(sfIndexNext); } /** * @brief Get sfIndexPrevious (soeOPTIONAL) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] protocol_autogen::Optional getIndexPrevious() const { if (hasIndexPrevious()) return this->sle_->at(sfIndexPrevious); return std::nullopt; } /** * @brief Check if sfIndexPrevious is present. * @return True if the field is present, false otherwise. */ [[nodiscard]] bool hasIndexPrevious() const { return this->sle_->isFieldPresent(sfIndexPrevious); } /** * @brief Get sfNFTokenID (soeOPTIONAL) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] protocol_autogen::Optional getNFTokenID() const { if (hasNFTokenID()) return this->sle_->at(sfNFTokenID); return std::nullopt; } /** * @brief Check if sfNFTokenID is present. * @return True if the field is present, false otherwise. */ [[nodiscard]] bool hasNFTokenID() const { return this->sle_->isFieldPresent(sfNFTokenID); } /** * @brief Get sfPreviousTxnID (soeOPTIONAL) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] protocol_autogen::Optional getPreviousTxnID() const { if (hasPreviousTxnID()) return this->sle_->at(sfPreviousTxnID); return std::nullopt; } /** * @brief Check if sfPreviousTxnID is present. * @return True if the field is present, false otherwise. */ [[nodiscard]] bool hasPreviousTxnID() const { return this->sle_->isFieldPresent(sfPreviousTxnID); } /** * @brief Get sfPreviousTxnLgrSeq (soeOPTIONAL) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] protocol_autogen::Optional getPreviousTxnLgrSeq() const { if (hasPreviousTxnLgrSeq()) return this->sle_->at(sfPreviousTxnLgrSeq); return std::nullopt; } /** * @brief Check if sfPreviousTxnLgrSeq is present. * @return True if the field is present, false otherwise. */ [[nodiscard]] bool hasPreviousTxnLgrSeq() const { return this->sle_->isFieldPresent(sfPreviousTxnLgrSeq); } /** * @brief Get sfDomainID (soeOPTIONAL) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] protocol_autogen::Optional getDomainID() const { if (hasDomainID()) return this->sle_->at(sfDomainID); return std::nullopt; } /** * @brief Check if sfDomainID is present. * @return True if the field is present, false otherwise. */ [[nodiscard]] bool hasDomainID() const { return this->sle_->isFieldPresent(sfDomainID); } }; /** * @brief Builder for DirectoryNode ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. * Uses Json::Value internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class DirectoryNodeBuilder : public LedgerEntryBuilderBase { public: /** * @brief Construct a new DirectoryNodeBuilder with required fields. * @param indexes The sfIndexes field value. * @param rootIndex The sfRootIndex field value. */ DirectoryNodeBuilder(std::decay_t const& indexes,std::decay_t const& rootIndex) : LedgerEntryBuilderBase(ltDIR_NODE) { setIndexes(indexes); setRootIndex(rootIndex); } /** * @brief Construct a DirectoryNodeBuilder from an existing SLE object. * @param sle The existing ledger entry to copy from. * @throws std::runtime_error if the ledger entry type doesn't match. */ DirectoryNodeBuilder(std::shared_ptr sle) { if (sle->at(sfLedgerEntryType) != ltDIR_NODE) { throw std::runtime_error("Invalid ledger entry type for DirectoryNode"); } object_ = *sle; } /** @brief Ledger entry-specific field setters */ /** * @brief Set sfOwner (soeOPTIONAL) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& setOwner(std::decay_t const& value) { object_[sfOwner] = value; return *this; } /** * @brief Set sfTakerPaysCurrency (soeOPTIONAL) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& setTakerPaysCurrency(std::decay_t const& value) { object_[sfTakerPaysCurrency] = value; return *this; } /** * @brief Set sfTakerPaysIssuer (soeOPTIONAL) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& setTakerPaysIssuer(std::decay_t const& value) { object_[sfTakerPaysIssuer] = value; return *this; } /** * @brief Set sfTakerPaysMPT (soeOPTIONAL) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& setTakerPaysMPT(std::decay_t const& value) { object_[sfTakerPaysMPT] = value; return *this; } /** * @brief Set sfTakerGetsCurrency (soeOPTIONAL) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& setTakerGetsCurrency(std::decay_t const& value) { object_[sfTakerGetsCurrency] = value; return *this; } /** * @brief Set sfTakerGetsIssuer (soeOPTIONAL) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& setTakerGetsIssuer(std::decay_t const& value) { object_[sfTakerGetsIssuer] = value; return *this; } /** * @brief Set sfTakerGetsMPT (soeOPTIONAL) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& setTakerGetsMPT(std::decay_t const& value) { object_[sfTakerGetsMPT] = value; return *this; } /** * @brief Set sfExchangeRate (soeOPTIONAL) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& setExchangeRate(std::decay_t const& value) { object_[sfExchangeRate] = value; return *this; } /** * @brief Set sfIndexes (soeREQUIRED) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& setIndexes(std::decay_t const& value) { object_[sfIndexes] = value; return *this; } /** * @brief Set sfRootIndex (soeREQUIRED) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& setRootIndex(std::decay_t const& value) { object_[sfRootIndex] = value; return *this; } /** * @brief Set sfIndexNext (soeOPTIONAL) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& setIndexNext(std::decay_t const& value) { object_[sfIndexNext] = value; return *this; } /** * @brief Set sfIndexPrevious (soeOPTIONAL) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& setIndexPrevious(std::decay_t const& value) { object_[sfIndexPrevious] = value; return *this; } /** * @brief Set sfNFTokenID (soeOPTIONAL) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& setNFTokenID(std::decay_t const& value) { object_[sfNFTokenID] = value; return *this; } /** * @brief Set sfPreviousTxnID (soeOPTIONAL) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& setPreviousTxnID(std::decay_t const& value) { object_[sfPreviousTxnID] = value; return *this; } /** * @brief Set sfPreviousTxnLgrSeq (soeOPTIONAL) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& setPreviousTxnLgrSeq(std::decay_t const& value) { object_[sfPreviousTxnLgrSeq] = value; return *this; } /** * @brief Set sfDomainID (soeOPTIONAL) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& setDomainID(std::decay_t const& value) { object_[sfDomainID] = value; return *this; } /** * @brief Build and return the completed DirectoryNode wrapper. * @param index The ledger entry index. * @return The constructed ledger entry wrapper. */ DirectoryNode build(uint256 const& index) { return DirectoryNode{std::make_shared(std::move(object_), index)}; } }; } // namespace xrpl::ledger_entries