12#define PROGRAM_NAME "message-protocols-demo"
38 tryParse(
"floatValNegative=-3.1415");
65 IRSOL_LOG_INFO(
"Success(Command): {}", serializedCommand.toString());
71 IRSOL_LOG_INFO(
"Success(Assignment): {}", serializedAssignment.toString());
78 IRSOL_LOG_INFO(
"Success(Inquiry): {}", serializedInquiry.toString());
83 IRSOL_LOG_INFO(
"Error(Command): {}", serializedErrorCommand.toString());
88 auto serializedErrorAssignment =
90 IRSOL_LOG_INFO(
"Error(Assignment): {}", serializedErrorAssignment.toString());
95 IRSOL_LOG_INFO(
"Error(Inquiry): {}", serializedErrorInquiry.toString());
static std::optional< InMessage > parse(const std::string &line)
Attempts to parse a single protocol input line into a structured InMessage.
static internal::SerializedMessage serialize(OutMessage &&msg)
Serialize an irsol::protocol::OutMessage variant into a serialized protocol message.
const std::string getProgramName()
Returns the program name, typically used for logging. If PROGRAM_NAME is not defined at compile time,...
void tryParse(const std::string &raw)
Tries to parse a message string and logs the result or error.
void demoParsing()
Demonstrates parsing raw protocol strings into structured InMessages.
void demoSerializing()
Demonstrates serializing protocol OutMessages into SerializedMessages.
void demoProtocol()
Demonstrates protocol message creation and serialization.
void initAssertHandler()
Initializes the assertion handler system.
#define IRSOL_LOG_INFO(...)
Logs an info-level message using the default logger.
#define IRSOL_LOG_ERROR(...)
Logs an error-level message using the default logger.
void initLogging(const char *fileSinkFilename="logs/irsol.log", std::optional< spdlog::level::level_enum > minLogLevel=std::nullopt)
Initializes the irsol logging system.
std::string toString(const InMessage &msg)
Converts an incoming message variant to a human-readable string.
std::variant< int, double, std::string > protocol_value_t
Variant type representing protocol values that can be one of several types.
Represents an assignment operation in the protocol.
Represents a command invocation in the protocol.
Represents an error response message from the server.
static Error from(const T &msg, const std::string &description)
Creates an error from a specific incoming message type.
Represents a value inquiry in the protocol.
Represents a success response message from the server.
static Success from(const Assignment &msg, std::optional< irsol::types::protocol_value_t > overrideValue=std::nullopt)
Creates a success message from an Assignment.
irsol::protocol::Assignment assignment