Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
Loading...
Searching...
No Matches
protobuf_wire.h File Reference

Zero-dependency protobuf wire-format encoder and decoder primitives. More...

#include <cstddef>
#include <cstdint>
#include <cstring>
#include <optional>
#include <string>
#include <vector>
Include dependency graph for protobuf_wire.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  kcenon::monitoring::protobuf_wire::reader
 Minimal protobuf wire reader used for round-trip tests. More...
 

Namespaces

namespace  kcenon
 
namespace  kcenon::monitoring
 
namespace  kcenon::monitoring::protobuf_wire
 

Enumerations

enum class  kcenon::monitoring::protobuf_wire::wire_type : std::uint8_t { kcenon::monitoring::protobuf_wire::varint = 0 , kcenon::monitoring::protobuf_wire::fixed64 = 1 , kcenon::monitoring::protobuf_wire::length_delimited = 2 , kcenon::monitoring::protobuf_wire::fixed32 = 5 }
 

Functions

void kcenon::monitoring::protobuf_wire::encode_varint (std::vector< std::uint8_t > &out, std::uint64_t value)
 Encode an unsigned varint into the buffer.
 
void kcenon::monitoring::protobuf_wire::encode_tag (std::vector< std::uint8_t > &out, std::uint32_t field_number, wire_type wt)
 Encode a tag (field_number << 3 | wire_type) as a varint.
 
void kcenon::monitoring::protobuf_wire::encode_fixed64 (std::vector< std::uint8_t > &out, std::uint64_t value)
 Encode a fixed64 little-endian value (used for Zipkin timestamps).
 
void kcenon::monitoring::protobuf_wire::encode_length_delimited (std::vector< std::uint8_t > &out, const std::uint8_t *data, std::size_t size)
 Encode a length-delimited byte sequence.
 
void kcenon::monitoring::protobuf_wire::encode_string_field (std::vector< std::uint8_t > &out, std::uint32_t field_number, const std::string &value)
 Encode a string field.
 
void kcenon::monitoring::protobuf_wire::encode_bytes_field (std::vector< std::uint8_t > &out, std::uint32_t field_number, const std::vector< std::uint8_t > &value)
 Encode a bytes field.
 
void kcenon::monitoring::protobuf_wire::encode_uint64_field (std::vector< std::uint8_t > &out, std::uint32_t field_number, std::uint64_t value)
 Encode a uint32 / uint64 / int64 varint field (skips zero).
 
void kcenon::monitoring::protobuf_wire::encode_uint64_field_always (std::vector< std::uint8_t > &out, std::uint32_t field_number, std::uint64_t value)
 Encode a uint32 field that is not allowed to be skipped even if zero.
 
void kcenon::monitoring::protobuf_wire::encode_enum_field (std::vector< std::uint8_t > &out, std::uint32_t field_number, std::int32_t value)
 Encode an enum field (always written when nonzero).
 
void kcenon::monitoring::protobuf_wire::encode_bool_field (std::vector< std::uint8_t > &out, std::uint32_t field_number, bool value)
 Encode a bool field (proto3 skips false).
 
void kcenon::monitoring::protobuf_wire::encode_fixed64_field (std::vector< std::uint8_t > &out, std::uint32_t field_number, std::uint64_t value)
 Encode a fixed64 field.
 
void kcenon::monitoring::protobuf_wire::encode_message_field (std::vector< std::uint8_t > &out, std::uint32_t field_number, const std::vector< std::uint8_t > &serialized)
 Encode an embedded message field given its pre-serialized bytes.
 
bool kcenon::monitoring::protobuf_wire::decode_tag (reader &r, std::uint32_t &field_number, wire_type &wt)
 Decode a tag into (field_number, wire_type).
 
std::vector< std::uint8_t > kcenon::monitoring::protobuf_wire::hex_to_bytes (const std::string &hex)
 Decode a hexadecimal string into bytes. Odd-length strings are zero-padded on the left; non-hex characters yield an empty vector.
 
std::string kcenon::monitoring::protobuf_wire::bytes_to_hex (const std::vector< std::uint8_t > &bytes)
 Encode raw bytes as a lowercase hex string.
 
std::vector< std::uint8_t > kcenon::monitoring::protobuf_wire::left_pad (const std::vector< std::uint8_t > &in, std::size_t width)
 Left-pad bytes to a target width. Used to normalize 8-byte trace IDs to Jaeger's 16-byte on-wire width and similar cases.
 

Detailed Description

Zero-dependency protobuf wire-format encoder and decoder primitives.

Implements just enough of the protobuf3 wire format (varint, fixed64, length- delimited) to serialize and deserialize Jaeger api_v2 and Zipkin proto3 span messages without pulling in the full protobuf runtime. Only the wire types actually exercised by the Jaeger / Zipkin span schemas are implemented.

References:

Definition in file protobuf_wire.h.