20#ifndef RIPPLE_RPC_CTID_H_INCLUDED
21#define RIPPLE_RPC_CTID_H_INCLUDED
23#include <boost/regex.hpp>
43encodeCTID(uint32_t ledgerSeq, uint32_t txnIndex, uint32_t networkID)
noexcept
45 if (ledgerSeq > 0x0FFF'FFFF || txnIndex > 0xFFFF || networkID > 0xFFFF)
49 ((0xC000'0000ULL +
static_cast<uint64_t
>(ledgerSeq)) << 32) +
50 (
static_cast<uint64_t
>(txnIndex) << 16) + networkID;
55 return {buffer.
str()};
62 uint64_t ctidValue{0};
64 std::is_same_v<T, std::string> || std::is_same_v<T, char*> ||
65 std::is_same_v<T, const char*> || std::is_same_v<T, std::string_view>)
69 if (ctidString.
length() != 16)
72 if (!boost::regex_match(ctidString, boost::regex(
"^[0-9A-Fa-f]+$")))
77 else if constexpr (std::is_integral_v<T>)
82 if ((ctidValue & 0xF000'0000'0000'0000ULL) != 0xC000'0000'0000'0000ULL)
85 uint32_t ledger_seq = (ctidValue >> 32) & 0xFFFF'FFFUL;
86 uint16_t txn_index = (ctidValue >> 16) & 0xFFFFU;
87 uint16_t network_id = ctidValue & 0xFFFFU;
88 return {{ledger_seq, txn_index, network_id}};
std::optional< std::tuple< uint32_t, uint16_t, uint16_t > > decodeCTID(const T ctid) noexcept
std::optional< std::string > encodeCTID(uint32_t ledgerSeq, uint32_t txnIndex, uint32_t networkID) noexcept
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.