Radix Relay
Hybrid mesh communications with Signal Protocol encryption
Loading...
Searching...
No Matches
radix_relay::core::command_parser< Bridge > Struct Template Reference

Chain of Responsibility command parser. More...

#include <command_parser.hpp>

Public Types

using command_variant_t = std::variant< events::help, events::peers, events::status, events::sessions, events::identities, events::scan, events::version, events::mode, events::send, events::broadcast, events::connect, events::disconnect, events::publish_identity, events::unpublish_identity, events::trust, events::verify, events::chat, events::leave, events::unknown_command >
 
using parse_result_t = std::optional< command_variant_t >
 
using handler_t = std::function< parse_result_t(const std::string &)>
 

Public Member Functions

 command_parser (std::shared_ptr< Bridge > bridge)
 
auto parse (const std::string &input) const -> command_variant_t
 Parses a raw command string into a typed command event.
 
auto enter_chat_mode (const std::string &rdx_fingerprint) const -> void
 Enters chat mode with the specified contact.
 
auto exit_chat_mode () const -> void
 Exits chat mode.
 
auto in_chat_mode () const -> bool
 Checks if currently in chat mode.
 

Detailed Description

template<concepts::signal_bridge Bridge>
struct radix_relay::core::command_parser< Bridge >

Chain of Responsibility command parser.

Parses raw command strings into strongly-typed command events. Defines its own variant type as a type trait so types and parsing always match. Uses unknown_command as fallback when no command matches. Manages chat mode state for preprocessing plain text as send commands.

Template Parameters
BridgeType satisfying the signal_bridge concept (for contact lookup)

Definition at line 25 of file command_parser.hpp.

Member Typedef Documentation

◆ command_variant_t

◆ handler_t

template<concepts::signal_bridge Bridge>
using radix_relay::core::command_parser< Bridge >::handler_t = std::function<parse_result_t(const std::string &)>

Definition at line 48 of file command_parser.hpp.

◆ parse_result_t

template<concepts::signal_bridge Bridge>
using radix_relay::core::command_parser< Bridge >::parse_result_t = std::optional<command_variant_t>

Definition at line 47 of file command_parser.hpp.

Constructor & Destructor Documentation

◆ command_parser()

template<concepts::signal_bridge Bridge>
radix_relay::core::command_parser< Bridge >::command_parser ( std::shared_ptr< Bridge >  bridge)
inlineexplicit

Definition at line 50 of file command_parser.hpp.

Member Function Documentation

◆ enter_chat_mode()

template<concepts::signal_bridge Bridge>
auto radix_relay::core::command_parser< Bridge >::enter_chat_mode ( const std::string &  rdx_fingerprint) const -> void
inline

Enters chat mode with the specified contact.

Parameters
rdx_fingerprintThe RDX fingerprint of the contact to chat with

Definition at line 82 of file command_parser.hpp.

◆ exit_chat_mode()

template<concepts::signal_bridge Bridge>
auto radix_relay::core::command_parser< Bridge >::exit_chat_mode ( ) const -> void
inline

Exits chat mode.

Definition at line 87 of file command_parser.hpp.

◆ in_chat_mode()

template<concepts::signal_bridge Bridge>
auto radix_relay::core::command_parser< Bridge >::in_chat_mode ( ) const -> bool
inline

Checks if currently in chat mode.

Returns
true if in chat mode, false otherwise

Definition at line 94 of file command_parser.hpp.

◆ parse()

template<concepts::signal_bridge Bridge>
auto radix_relay::core::command_parser< Bridge >::parse ( const std::string &  input) const -> command_variant_t
inline

Parses a raw command string into a typed command event.

When in chat mode, plain text (not starting with /) is converted to a send command. The /leave command exits chat mode.

Parameters
inputRaw command string
Returns
Strongly-typed command variant

Definition at line 61 of file command_parser.hpp.

References radix_relay::core::events::unknown_command::input.


The documentation for this struct was generated from the following file: