11#include <initializer_list>
24 enum class Shape : std::uint8_t {
32 inline static constexpr std::array<Spelling, 11>
spellings{{
33 {
"__margin_call__",
false},
34 {
"__pine_close_all",
false},
35 {
"__tv_money_margin_path__",
false},
36 {
"__margin_follow_up__",
false},
37 {
"__margin_priced_opening__",
false},
38 {
"__margin_waypoint__",
false},
39 {
"__intraday_loss_close__",
false},
40 {
"__intraday_cap_close__",
false},
41 {
"__pine_close_site__",
true},
42 {
"__pine_close_flush__",
true},
43 {
"__margin_revival__",
true},
51 static bool consume(std::string_view& key, std::string_view part)
noexcept {
52 if (key.size() < part.size() || key.substr(0, part.size()) != part)
return false;
53 key.remove_prefix(part.size());
56 static bool consume_number(std::string_view& key, std::uint64_t value)
noexcept {
58 char bytes[std::numeric_limits<std::uint64_t>::digits10 + 1];
59 const auto result = std::to_chars(bytes, bytes +
sizeof(bytes), value);
60 return result.ec == std::errc{}
61 &&
consume(key, {bytes,
static_cast<std::size_t
>(result.ptr - bytes)});
63 static bool read_number(std::string_view key, std::uint64_t& value)
noexcept {
64 if (key.empty())
return false;
65 const auto result = std::from_chars(key.data(), key.data() + key.size(), value);
66 return result.ec == std::errc{} && result.ptr == key.data() + key.size();
69 std::string_view from)
noexcept {
74 std::string_view from)
const noexcept {
114 matched =
consume(key, text.prefix)
119 return matched && key.empty();
123 std::string_view from) {
140 &&
family <= std::numeric_limits<std::uint8_t>::max()) {
145 const auto separator = suffix.find(
'\x1f');
146 if (separator != std::string_view::npos
148 &&
family <= std::numeric_limits<std::uint8_t>::max()
163 for (std::size_t index = 0; index <
spellings.size(); ++index) {
166 if (!
consume(suffix, text.prefix)
168 identity.
spelling =
static_cast<std::uint8_t
>(index);
183 std::string_view
source, std::string_view from)
190static_assert(std::is_trivially_copyable<LiveSourceIdentity>::value,
191 "live source identity must remain non-owning verification data");
LiveSourceIdentity identity
LiveSourceHandle(const native_order::RequestHandle &handle, std::string_view key, std::string_view source, std::string_view from)
LiveSourceHandle()=default
static LiveSourceIdentity capture(std::string_view key, std::string_view source, std::string_view from)
static bool consume_number(std::string_view &key, std::uint64_t value) noexcept
static constexpr std::array< Spelling, 11 > spellings
bool matches(std::string_view key, std::string_view source, std::string_view from) const noexcept
static bool consume(std::string_view &key, std::string_view part) noexcept
static bool consume_pair(std::string_view &key, std::string_view source, std::string_view from) noexcept
static bool read_number(std::string_view key, std::uint64_t &value) noexcept