ORE Studio 0.0.4
Loading...
Searching...
No Matches
writer.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_COMMS_MESSAGING_WRITE_HPP
21#define ORES_COMMS_MESSAGING_WRITE_HPP
22
23#include <vector>
24#include <string>
25#include <cstdint>
26#include <expected>
27#include <boost/uuid/uuid_io.hpp>
28
29
30namespace ores::comms::messaging {
31
35class writer {
36public:
40 static void write_uint16(std::vector<std::byte>& buffer,
41 std::uint16_t value);
42
46 static void write_uint32(std::vector<std::byte>& buffer,
47 std::uint32_t value);
48
52 static void write_int64(std::vector<std::byte>& buffer,
53 std::int64_t value);
54
58 static void write_string(std::vector<std::byte>& buffer,
59 const std::string& str);
60
64 static void write_bool(std::vector<std::byte>& buffer, bool value);
65
69 static void write_uuid(std::vector<std::byte>& buffer,
70 const boost::uuids::uuid& uuid);
71};
72
73}
74
75#endif
Contains messaging related infrastructure in the comms library.
Definition compression.hpp:29
Helper to write network data.
Definition writer.hpp:35
static void write_string(std::vector< std::byte > &buffer, const std::string &str)
Helper to write a string with 16-bit length prefix.
Definition writer.cpp:51
static void write_uint32(std::vector< std::byte > &buffer, std::uint32_t value)
Helper to write a 32-bit integer in network byte order.
Definition writer.cpp:33
static void write_uuid(std::vector< std::byte > &buffer, const boost::uuids::uuid &uuid)
Helper to write a UUID (16 bytes).
Definition writer.cpp:60
static void write_bool(std::vector< std::byte > &buffer, bool value)
Helper to write a boolean (1 byte).
Definition writer.cpp:66
static void write_int64(std::vector< std::byte > &buffer, std::int64_t value)
Helper to write a 64-bit integer in network byte order.
Definition writer.cpp:40
static void write_uint16(std::vector< std::byte > &buffer, std::uint16_t value)
Helper to write a 16-bit integer in network byte order.
Definition writer.cpp:28