Mads
Multi-Agent Distributed System
Loading...
Searching...
No Matches
echo_format.hpp
Go to the documentation of this file.
1/*
2 _____ _ _____ _
3 | ____|___| |__ ___ | ___|__ _ __ _ __ ___ __ _| |_
4 | _| / __| '_ \ / _ \| |_ / _ \| '__| '_ ` _ \ / _` | __|
5 | |__| (__| | | | (_) | _| (_) | | | | | | | | (_| | |_
6 |_____\___|_| |_|\___/|_| \___/|_| |_| |_| |_|\__,_|\__|
7
8Pure, ZMQ/Agent-free rendering of one received `mads echo` message: pretty
9(optionally rang-colored) multi-line JSON or a one-line blob summary, or a
10single compact JSON line (`--jsonl`) of either. Factored out of
11src/main/echo.cpp so the exact formatting logic the executable prints is
12directly callable (and testable) without spawning a subprocess -- see
13tests/test_echo_loopback.cpp.
14
15Author(s): Paolo Bosetti
16*/
17#pragma once
18
19#include <cstddef>
20#include <string>
21
22#include <nlohmann/json.hpp>
23
24namespace Mads {
25
33 bool raw = false;
36 bool jsonl = false;
40 bool color = true;
41};
42
53std::string format_echo_json(const std::string &topic,
54 const nlohmann::json &payload, size_t wire_size,
55 const EchoRenderOptions &opts);
56
68std::string format_echo_blob(const std::string &topic,
69 const std::string &format,
70 const unsigned char *data, size_t len,
71 const EchoRenderOptions &opts);
72
79std::string base64_encode(const unsigned char *data, size_t len);
80
81} // namespace Mads
Definition agent.hpp:67
std::string format_echo_blob(const std::string &topic, const std::string &format, const unsigned char *data, size_t len, const EchoRenderOptions &opts)
Formats one received blob message for mads echo stdout.
std::string format_echo_json(const std::string &topic, const nlohmann::json &payload, size_t wire_size, const EchoRenderOptions &opts)
Formats one received JSON message for mads echo stdout.
std::string base64_encode(const unsigned char *data, size_t len)
Standard base64 encoding (RFC 4648, with = padding).
Rendering choices for format_echo_json()/format_echo_blob(), mirroring mads echo's CLI flags.