/* *** exported interfaces ****************************************************/
-namespace lldpcli {
-namespace literals {
-/**
- * @brief Operator to define std::byte literals.
- *
- * Example: auto byte{ 0x01_b };
- */
-consteval std::byte operator"" _b(unsigned long long int value)
+namespace
{
- return static_cast<std::byte>(value);
-}
-} // namespace literals
-
/**
- * @brief LLDP error category.
+ * @brief LLDP error category. Don't use this class directly, intead, use @ref lldpcli::make_error_code.
*/
class LldpErrCategory : public std::error_category {
public:
}
};
+const LldpErrCategory lldp_err_category{};
+
+} // namespace
+
+namespace lldpcli {
+
+/**
+ * Convenience function to wrap an LLDP error code in a @p std::error_code.
+ */
+inline std::error_code make_error_code( lldpctl_error_t e )
+{
+ return { static_cast<int>( e ), lldp_err_category };
+}
+
+namespace literals {
+/**
+ * @brief Operator to define std::byte literals.
+ *
+ * Example: auto byte{ 0x01_b };
+ */
+consteval std::byte operator"" _b(unsigned long long int value)
+{
+ return static_cast<std::byte>(value);
+}
+} // namespace literals
+
/**
* @brief Fallback type trait for checking against a const char array.
*/