24 #include <string_view>
43 static void validate_host(
const std::string& host);
44 static void validate_port(uint16_t port);
45 static void validate_ipv4_address(
const std::string& address);
46 static void validate_ipv6_address(
const std::string& address);
49 static void validate_device_path(
const std::string& device);
50 static void validate_baud_rate(uint32_t baud_rate);
51 static void validate_data_bits(uint8_t data_bits);
52 static void validate_stop_bits(uint8_t stop_bits);
53 static void validate_parity(
const std::string& parity);
56 static void validate_buffer_size(
size_t size);
57 static void validate_memory_alignment(
const void* ptr,
size_t alignment);
60 static void validate_timeout(
unsigned timeout_ms);
61 static void validate_retry_interval(
unsigned interval_ms);
62 static void validate_retry_count(
int retry_count);
65 static void validate_non_empty_string(
const std::string& str,
const std::string& field_name);
66 static void validate_string_length(
const std::string& str,
size_t max_length,
const std::string& field_name);
69 static void validate_positive_number(int64_t value,
const std::string& field_name);
70 static void validate_range(int64_t value, int64_t min, int64_t max,
const std::string& field_name);
71 static void validate_range(
size_t value,
size_t min,
size_t max,
const std::string& field_name);
74 static bool is_valid_host(
const std::string& host);
75 static bool is_valid_ipv4(std::string_view address);
76 static bool is_valid_ipv6(
const std::string& address);
77 static bool is_valid_hostname(std::string_view hostname);
81 static bool is_valid_device_path(
const std::string& device);
84 static constexpr
int FINITE_MIN_RETRY_COUNT = 0;
96 const std::string& field_name) {
97 if (str.length() > max_length) {
110 if (value < min || value > max) {
117 if (value < min || value > max) {
142 if (retry_count < FINITE_MIN_RETRY_COUNT || retry_count > FINITE_MAX_RETRY_COUNT) {
172 if (ptr ==
nullptr) {
176 uintptr_t address =
reinterpret_cast<uintptr_t
>(ptr);
177 if (address % alignment != 0) {
constexpr uint8_t MIN_STOP_BITS
constexpr int MAX_RETRIES_LIMIT
constexpr size_t MAX_BUFFER_SIZE
constexpr uint8_t MIN_DATA_BITS
constexpr unsigned MIN_RETRY_INTERVAL_MS
constexpr unsigned MAX_RETRY_INTERVAL_MS
constexpr size_t MIN_BUFFER_SIZE
constexpr uint8_t MAX_STOP_BITS
constexpr uint32_t MAX_BAUD_RATE
constexpr unsigned MAX_CONNECTION_TIMEOUT_MS
constexpr uint8_t MAX_DATA_BITS
constexpr int DEFAULT_MAX_RETRIES
constexpr unsigned MIN_CONNECTION_TIMEOUT_MS
constexpr uint32_t MIN_BAUD_RATE
diagnostics::ValidationException ValidationException
std::string to_string(ErrorCode code)
Convert ErrorCode to human-readable string.