31encodeCTID(uint32_t ledgerSeq, uint32_t txnIndex, uint32_t networkID)
noexcept
33 static constexpr uint32_t kMaxLedgerSeq = 0x0FFF'FFFF;
34 static constexpr uint32_t kMaxTxnIndex = 0xFFFF;
35 static constexpr uint32_t kMaxNetworkId = 0xFFFF;
37 if (ledgerSeq > kMaxLedgerSeq || txnIndex > kMaxTxnIndex || networkID > kMaxNetworkId)
40 uint64_t
const ctidValue = ((0xC000'0000ULL +
static_cast<uint64_t
>(ledgerSeq)) << 32) |
41 ((
static_cast<uint64_t
>(txnIndex) << 16) | networkID);
60 uint64_t ctidValue = 0;
68 if (ctidString.
size() != 16)
71 static boost::regex
const kHexRegex(
"^[0-9A-Fa-f]{16}$");
72 if (!boost::regex_match(ctidString, kHexRegex))
89 ctidValue =
static_cast<uint64_t
>(ctid);
97 static constexpr uint64_t kCtidPrefixMask = 0xF000'0000'0000'0000ULL;
98 static constexpr uint64_t kCtidPrefix = 0xC000'0000'0000'0000ULL;
99 if ((ctidValue & kCtidPrefixMask) != kCtidPrefix)
102 uint32_t
const ledgerSeq =
static_cast<uint32_t
>((ctidValue >> 32) & 0x0FFF'FFFF);
103 uint16_t
const txnIndex =
static_cast<uint16_t
>((ctidValue >> 16) & 0xFFFF);
104 uint16_t
const networkID =
static_cast<uint16_t
>(ctidValue & 0xFFFF);
std::optional< std::string > encodeCTID(uint32_t ledgerSeq, uint32_t txnIndex, uint32_t networkID) noexcept
Encodes ledger sequence, transaction index, and network ID into a CTID string.
std::optional< std::tuple< uint32_t, uint16_t, uint16_t > > decodeCTID(T const ctid) noexcept
Decodes a CTID string or integer into its component parts.