etsi_its_messages v3.4.0
Loading...
Searching...
No Matches
checks.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright Institute for Automotive Engineering (ika), RWTH Aachen University
3
8
9#ifndef ETSI_ITS_MSGS_UTILS_IMPL_CHECKS_H
10#define ETSI_ITS_MSGS_UTILS_IMPL_CHECKS_H
11
22template <typename T1, typename T2>
23void throwIfOutOfRange(const T1& val, const T2& min, const T2& max, const std::string val_desc) {
24 if (val < min || val > max)
25 throw std::invalid_argument(val_desc + " value is out of range (" + std::to_string(min) + "..." +
26 std::to_string(max) + ")!");
27}
28
34inline void throwIfNotPresent(const bool is_present, const std::string val_desc) {
35 if (!is_present) throw std::invalid_argument(val_desc + " is not present!");
36}
37
38#endif // ETSI_ITS_MSGS_UTILS_IMPL_CHECKS_H
void throwIfNotPresent(const bool is_present, const std::string val_desc)
Throws an exception if the given value is not present.
Definition checks.h:34
void throwIfOutOfRange(const T1 &val, const T2 &min, const T2 &max, const std::string val_desc)
Throws an exception if a given value is out of a defined range.
Definition checks.h:23