include/ControlDataAddress.h
include/ControlDataAddress.h File Reference
Namespaces
| Name |
|---|
| Acl |
Classes
| Name | |
|---|---|
| class | Acl::ControlDataAddress A class representing an address within the control protocol. The address consists of an internal list of UUIDs, which all represent a component that needs to be passed to reach the final address. An address might end with a wildcard, which is represented by the omni UUID (i.e. all digits set to 0xF) and will then match all addresses with the same UUID sequence in the start. |
| struct | fmt::formatter< Acl::ControlDataAddress > |
Source code
// Copyright (c) 2024, Ateliere. All rights reserved.
#pragma once
#include <cstdint>
#include <sstream>
#include <string>
#include <vector>
#include <fmt/format.h>
#include "UUID.h"
namespace Acl {
class ControlDataAddress final {
public:
ControlDataAddress() = default;
explicit ControlDataAddress(const UUID& destinationUUID);
[[nodiscard]] size_t size() const;
[[nodiscard]] bool empty() const;
bool extend(const UUID& uuid);
bool extend(const ControlDataAddress& address);
[[nodiscard]] bool hasWildcard() const;
[[nodiscard]] bool currentUuidIsWildcard() const;
[[nodiscard]] bool currentUuidMatch(const UUID& uuid) const;
[[nodiscard]] bool fullAddressMatch(const ControlDataAddress& other) const;
[[nodiscard]] std::optional<UUID> getCurrentUuid() const;
std::optional<UUID> moveToAndGetNextUuid();
[[nodiscard]] std::vector<uint8_t> pack() const;
static std::optional<ControlDataAddress> unpack(const std::vector<uint8_t>::const_iterator& packedBegin,
const std::vector<uint8_t>::const_iterator& packedEnd);
static std::optional<ControlDataAddress> unpack(const uint8_t* packedBegin, const uint8_t* packedEnd);
[[nodiscard]] std::string toString() const;
bool operator==(const ControlDataAddress& other) const;
bool operator!=(const ControlDataAddress& other) const;
friend std::ostream& operator<<(std::ostream& stream, const ControlDataAddress& address);
private:
std::vector<UUID> mAddress;
};
std::ostream& operator<<(std::ostream& stream, const ControlDataAddress& address);
} // namespace Acl
template <> struct fmt::formatter<Acl::ControlDataAddress> : formatter<std::string> {
template <typename FormatContext> auto format(const Acl::ControlDataAddress& address, FormatContext& ctx) {
return formatter<std::string>::format(address.toString(), ctx);
}
};