20#ifndef RIPPLE_RPC_CTID_H_INCLUDED
21#define RIPPLE_RPC_CTID_H_INCLUDED
23#include <boost/regex.hpp>
37 uint16_t network_id)
noexcept
39 if (ledger_seq > 0x0FFF'FFFF)
43 ((0xC000'0000ULL +
static_cast<uint64_t
>(ledger_seq)) << 32) +
44 (
static_cast<uint64_t
>(txn_index) << 16) + network_id;
49 return {buffer.
str()};
56 uint64_t ctidValue{0};
58 std::is_same_v<T, std::string> || std::is_same_v<T, char*> ||
59 std::is_same_v<T, const char*> || std::is_same_v<T, std::string_view>)
63 if (ctidString.
length() != 16)
66 if (!boost::regex_match(ctidString, boost::regex(
"^[0-9A-Fa-f]+$")))
71 else if constexpr (std::is_integral_v<T>)
76 if ((ctidValue & 0xF000'0000'0000'0000ULL) != 0xC000'0000'0000'0000ULL)
79 uint32_t ledger_seq = (ctidValue >> 32) & 0xFFFF'FFFUL;
80 uint16_t txn_index = (ctidValue >> 16) & 0xFFFFU;
81 uint16_t network_id = ctidValue & 0xFFFFU;
82 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 ledger_seq, uint16_t txn_index, uint16_t network_id) noexcept
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.