17template <
typename Set>
24 const bool on = command.
flag != 0;
27 changed = ids.emplace(
id).second;
29 auto it = ids.find(
id);
30 changed = it != ids.end();
35 out = std::format(
"{} {} {}{}",
to_string(command.
command), on ?
"on" :
"off",
id, changed ?
"" :
" (unchanged)");
40template <
typename Set>
41void list_ids(
const Set &ids, std::string_view name, std::string &out) {
42 std::vector<std::string_view> sorted(ids.begin(), ids.end());
43 std::sort(sorted.begin(), sorted.end());
49 for (
auto id : sorted) {
59template <
typename Set,
typename OnNewOrders>
60bool serve_rejects(
const Command &command, Set &reject_logon, Set &reject_new_orders, OnNewOrders &&on_new_orders,
64 return toggle_id(reject_logon, command, out);
66 if (!
toggle_id(reject_new_orders, command, out)) {
The CLI commands that switch a gateway's business rejects per ID: REJECT_LOGON, REJECT_NEW_ORDERS and...
void list_ids(const Set &ids, std::string_view name, std::string &out)
"<name>: a b c", sorted, or "<name>: (none)".
bool refuse_unserved(const Command &command, std::string &out)
A handler's answer to a command it doesn't serve: says so in out, false.
bool serve_rejects(const Command &command, Set &reject_logon, Set &reject_new_orders, OnNewOrders &&on_new_orders, std::string &out)
Serves the reject commands against a gateway's two lists.
bool toggle_id(Set &ids, const Command &command, std::string &out)
Adds the command's ID to ids (flag 1) or removes it (flag 0), and says so in out.
@ REJECT_LOGON
A venue. flag 1 refuses the logons of ID arg from now on, 0 stops.
@ LIST_REJECTS
A venue. The IDs both of the above apply to.
@ REJECT_NEW_ORDERS
A venue. flag 1 rejects every new order of ID arg, 0 stops.
constexpr const char * to_string(FeedState state) noexcept
One command, as the CLI server hands it to the thread that runs it.
std::string_view arg_view() const noexcept