IRSOL
C++ code implementing socket server for interacting with Baumer camera.
irsol::protocol::BinaryDataAttribute Struct Reference

Represents a single binary data attribute within the protocol. More...

#include <binary.hpp>

Public Member Functions

 BinaryDataAttribute (const std::string &identifier, irsol::types::protocol_value_t value)
 Constructs a BinaryDataAttribute.
 
std::string toString () const
 Returns a string representation of the binary data attribute.
 
bool hasInt () const
 
bool hasDouble () const
 
bool hasString () const
 

Public Attributes

std::string identifier
 Identifier of the binary data attribute.
 
irsol::types::protocol_value_t value
 Value associated with the attribute.
 

Detailed Description

Represents a single binary data attribute within the protocol.

This struct encapsulates a key-value pair where the key is an identifier and the value is a protocol-specific typed value irsol::types::protocol_value_t.

Definition at line 34 of file binary.hpp.

Constructor & Destructor Documentation

◆ BinaryDataAttribute()

irsol::protocol::BinaryDataAttribute::BinaryDataAttribute ( const std::string &  identifier,
irsol::types::protocol_value_t  value 
)

Constructs a BinaryDataAttribute.

Parameters
identifierThe identifier string.
valueThe associated protocol value.

Definition at line 10 of file binary.cpp.

14{}
std::string validateIdentifier(const std::string &identifier)
Validate that a string is a valid protocol identifier.
Definition utils.hpp:55
std::string identifier
Identifier of the binary data attribute.
Definition binary.hpp:44
irsol::types::protocol_value_t value
Value associated with the attribute.
Definition binary.hpp:47

Member Function Documentation

◆ hasDouble()

bool irsol::protocol::BinaryDataAttribute::hasDouble ( ) const
Returns
True if the value holds a double type.

Definition at line 43 of file binary.cpp.

44{
45 return std::holds_alternative<double>(value);
46}

◆ hasInt()

bool irsol::protocol::BinaryDataAttribute::hasInt ( ) const
Returns
True if the value holds an integer type.

Definition at line 37 of file binary.cpp.

38{
39 return std::holds_alternative<int>(value);
40}

◆ hasString()

bool irsol::protocol::BinaryDataAttribute::hasString ( ) const
Returns
True if the value holds a string type.

Definition at line 49 of file binary.cpp.

50{
51 return std::holds_alternative<std::string>(value);
52}

◆ toString()

std::string irsol::protocol::BinaryDataAttribute::toString ( ) const

Returns a string representation of the binary data attribute.

Returns
A string representation of the binary data attribute".

Definition at line 17 of file binary.cpp.

18{
19 std::ostringstream oss;
20 oss << "BinaryDataAttribute{"
21 << "identifier: '" << identifier << "', value: ";
22 if(hasInt()) {
23 oss << "<int> " << std::get<int>(value);
24 } else if(hasDouble()) {
25 oss << "<double> " << std::get<double>(value);
26 } else if(hasString()) {
27 oss << "<string> \"" << std::get<std::string>(value) << "\"";
28 } else {
29 IRSOL_ASSERT_ERROR(false, "Invalid binary data attribute value type");
30 throw std::runtime_error("Invalid binary data attribute value type");
31 }
32 oss << '}';
33 return oss.str();
34}
#define IRSOL_ASSERT_ERROR
Error-level assertion macro.
Definition assert.hpp:134

Member Data Documentation

◆ identifier

std::string irsol::protocol::BinaryDataAttribute::identifier

Identifier of the binary data attribute.

Definition at line 44 of file binary.hpp.

◆ value

irsol::types::protocol_value_t irsol::protocol::BinaryDataAttribute::value

Value associated with the attribute.

Definition at line 47 of file binary.hpp.


The documentation for this struct was generated from the following files: