From 271826ee4a7c3bea267fa8011193c33ae898be36 Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Fri, 18 Sep 2026 12:11:42 +0300 Subject: [PATCH] changes according to new naming scheme of the snippets-library new naming scheme (delete "adclib_" prefixes) --- examples/device_exam.cpp | 22 ++--- examples/netmsg_exam.cpp | 2 +- include/adclib/adclib_common.h | 6 +- include/adclib/adclib_device.h | 76 ++++++++--------- include/adclib/adclib_device1.h | 144 ++++++++++++++++---------------- include/adclib/adclib_netmsg.h | 14 ++-- 6 files changed, 130 insertions(+), 134 deletions(-) diff --git a/examples/device_exam.cpp b/examples/device_exam.cpp index 8917180..238d87d 100644 --- a/examples/device_exam.cpp +++ b/examples/device_exam.cpp @@ -9,7 +9,7 @@ using namespace adc; template void add_attr_mark(ID_T id, VT const& val, std::string_view acc = "RW") { - auto tp = snplib::snplib_get_type_name(); + auto tp = snplib::type_name_as_string(); std::println("add {}-attr with ID='{}' of type '{}'", acc, id, tp); } @@ -17,7 +17,7 @@ void add_attr_mark(ID_T id, VT const& val, std::string_view acc = "RW") template void set_attr(DEV_T& dev, typename DEV_T::attr_id_t id, VT const& val) { - auto tp = snplib::snplib_get_type_name(); + auto tp = snplib::type_name_as_string(); std::print("set '{}'-attr value to {} of type '{}':\t", id, val, tp); @@ -30,11 +30,11 @@ void set_attr(DEV_T& dev, typename DEV_T::attr_id_t id, VT const& val) } template -void get_attr(DEV_T& dev, typename DEV_T::attr_id_t id, adc_result_t& val) +void get_attr(DEV_T& dev, typename DEV_T::attr_id_t id, ret_result_t& val) { std::string tp; - [&tp](T v) { tp = snplib::snplib_get_type_name(); }(val.value()); + [&tp](T v) { tp = snplib::type_name_as_string(); }(val.value()); std::print("get '{}'-attr value as one of type '{}':\t", id, tp); @@ -59,7 +59,7 @@ int main() std::println("add arith RW-attr with id='{}' (val={})", id1, i); dev.addArithAttr( - id1, [&i]() -> adc_result_t { return i; }, + id1, [&i]() -> ret_result_t { return i; }, [&i](int const& ii) -> adc_error_t { i = ii; return AdcDeviceErrorCode::ERROR_OK; @@ -74,7 +74,7 @@ int main() // std::tuple{}); std::println("add RO-attr with id='{}' (val={})", id2, d); - dev.addAttr(id2, [&d]() -> adc_result_t { return d; }, nullptr); + dev.addAttr(id2, [&d]() -> ret_result_t { return d; }, nullptr); // std::println("add RW-attr with id='{}' (val={})", id3, s); // dev.addAttr( @@ -95,7 +95,7 @@ int main() std::println("add RW-attr with id='{}' (val={})", id3, s); dev.addCharRangeAttr( - id3, [&s]() -> adc_result_t { return s; }, + id3, [&s]() -> ret_result_t { return s; }, [&s](std::string const& sv) -> adc_error_t { s = sv; return {}; @@ -104,14 +104,14 @@ int main() // std::println("add RW-attr with id='{}' (val={})", id4, pt.native()); add_attr_mark(id4, pt); dev.addFSPathAttr( - id4, [&pt]() -> adc_result_t { return pt; }, + id4, [&pt]() -> ret_result_t { return pt; }, [&pt](std::filesystem::path const& p) -> adc_error_t { pt = p; return {}; }); std::print("get '{}'-attr value as native int:\t", id1); - adc_result_t ri = dev[id1]; + ret_result_t ri = dev[id1]; if (ri) { std::println("dev[{}] = {}", id1, ri.value()); } else { @@ -128,7 +128,7 @@ int main() } std::print("get '{}'-attr value as double:\t", id1); - adc_result_t rd = dev[id1]; + ret_result_t rd = dev[id1]; if (rd) { std::println("dev[{}] = {}", id1, rd.value()); } else { @@ -160,7 +160,7 @@ int main() std::println("\n"); std::print("get '{}'-attr value as native string:\t", id3); - adc_result_t rs = dev[id3]; + ret_result_t rs = dev[id3]; if (rs) { std::println("dev[{}] = {}", id3, rs.value()); } else { diff --git a/examples/netmsg_exam.cpp b/examples/netmsg_exam.cpp index 0f2451c..b07ef73 100644 --- a/examples/netmsg_exam.cpp +++ b/examples/netmsg_exam.cpp @@ -8,7 +8,7 @@ int main() std::println("is ACK: {}", msg.isACK()); - msg.createSET("ATTR1", snplib::snplib_serialization_params_t{}, 10, std::vector{'V', 'A', 'L'}); + msg.createSET("ATTR1", snplib::serialization_params_t{}, 10, std::vector{'V', 'A', 'L'}); std::println("KEY: <{}>", msg.key()); diff --git a/include/adclib/adclib_common.h b/include/adclib/adclib_common.h index e580750..e65119d 100644 --- a/include/adclib/adclib_common.h +++ b/include/adclib/adclib_common.h @@ -12,11 +12,11 @@ namespace adc typedef std::error_code adc_error_t; template -using adc_result_t = std::expected; +using ret_result_t = std::expected; template -concept adc_result_c = requires { - [](std::type_identity>) {}(std::type_identity>()); +concept ret_result_c = requires { + [](std::type_identity>) {}(std::type_identity>()); }; } // namespace adc \ No newline at end of file diff --git a/include/adclib/adclib_device.h b/include/adclib/adclib_device.h index 23314a3..ca423f9 100644 --- a/include/adclib/adclib_device.h +++ b/include/adclib/adclib_device.h @@ -103,29 +103,29 @@ inline std::error_code make_error_code(AdcDeviceErrorCode ec) template -concept adclib_command_exec_t = snplib::snplib_callable_c && (snplib::snplib_func_traits_t::arity == 0) && - std::same_as::ret_t>; +concept device_command_exec_t = snplib::callable_c && (snplib::func_traits_t::arity == 0) && + std::same_as::ret_t>; template -concept adclib_attr_getter_c = std::same_as || requires(T t) { +concept device_attr_getter_c = std::same_as || requires(T t) { { t() } -> adc_result_c; }; template -concept adclib_attr_setter_c = - std::same_as || (snplib::snplib_callable_c && (snplib::snplib_func_traits_t::arity >= 1) && - std::same_as::ret_t>); +concept device_attr_setter_c = + std::same_as || (snplib::callable_c && (snplib::func_traits_t::arity >= 1) && + std::same_as::ret_t>); // deduce value type from getter and setter template using adclib_attr_value_deduced_t = std::conditional_t< std::is_null_pointer_v, - std::conditional_t, void, std::remove_cvref_t>>, + std::conditional_t, void, std::remove_cvref_t>>, typename std::invoke_result_t::value_type>; -template +template struct adclib_is_deduced_void_t { static constexpr bool value = std::is_void_v>; }; @@ -134,22 +134,20 @@ struct adclib_is_deduced_void_t { // "from": adc_result_t func(const adc_result_t&) // "to": adc_result_t func(const adc_result_t&) template -concept adclib_attr_conv_from_func_c = +concept device_attr_conv_from_func_c = std::same_as || - (std::invocable&> && !std::is_void_v&>>); + (std::invocable&> && !std::is_void_v&>>); template -concept adclib_attr_conv_to_func_c = std::same_as || - (snplib::snplib_callable_c && (snplib::snplib_func_traits_t::arity == 1) && - std::same_as, typename snplib::snplib_func_traits_t::ret_t>); +concept device_attr_conv_to_func_c = + std::same_as || (snplib::callable_c && (snplib::func_traits_t::arity == 1) && + std::same_as, typename snplib::func_traits_t::ret_t>); -template CONV_FROM_T, adclib_attr_conv_to_func_c CONV_TO_T> -using adclib_attr_user_deduced_t = - std::conditional_t, - std::conditional_t, - void, - std::remove_cvref_t>>, - typename snplib::snplib_func_traits_t::ret_t>; +template CONV_FROM_T, device_attr_conv_to_func_c CONV_TO_T> +using device_attr_user_deduced_t = std::conditional_t< + std::is_null_pointer_v, + std::conditional_t, void, std::remove_cvref_t>>, + typename snplib::func_traits_t::ret_t>; @@ -161,7 +159,7 @@ class AdcGenericDevice protected: template struct attr_t { - std::function()> getter{}; + std::function()> getter{}; std::function setter{}; // template @@ -195,7 +193,7 @@ protected: requires requires(VT v, UT u) { v = u; } operator attr_t() const { - return attr_t{.getter = [this]() -> adc_result_t { + return attr_t{.getter = [this]() -> ret_result_t { auto val = getter(); if (val) { return static_cast(val.value()); @@ -206,8 +204,8 @@ protected: .setter = [this](UT const& u) { return setter(static_cast(u)); }}; } - adc_error_t serialize(snplib::snplib_output_char_range_c auto& output, - snplib::snplib_serialization_params_c auto const& params) + adc_error_t serialize(snplib::output_char_range_c auto& output, + snplib::serialization_params_c auto const& params) { if (!getter) { return AdcDeviceErrorCode::ERROR_WO_ATTR; @@ -215,9 +213,9 @@ protected: auto val = getter(); if (val) { - auto ret = snplib::snplib_serializer_t{}(output, val.value(), params); + auto ret = snplib::serializer_t{}(output, val.value(), params); if (ret) { - return snplib::snplib_deduced_error(ret, AdcDeviceErrorCode::ERROR_SERIALIZATION); + return snplib::deduced_ret_error(ret, AdcDeviceErrorCode::ERROR_SERIALIZATION); } return AdcDeviceErrorCode::ERROR_OK; @@ -226,17 +224,17 @@ protected: return val.error(); } - adc_error_t deserialize(snplib::snplib_input_char_range_c auto const& input, - snplib::snplib_serialization_params_c auto const& params) + adc_error_t deserialize(snplib::input_char_range_c auto const& input, + snplib::serialization_params_c auto const& params) { if (!setter) { return AdcDeviceErrorCode::ERROR_RO_ATTR; } VT value; // WARNING: must be default-constructible!!! - auto ret = snplib::snplib_deserializer_t{}(input, value, params); + auto ret = snplib::deserializer_t{}(input, value, params); if (ret) { - return snplib::snplib_deduced_error(ret, AdcDeviceErrorCode::ERROR_DESERIALIZATION); + return snplib::deduced_ret_error(ret, AdcDeviceErrorCode::ERROR_DESERIALIZATION); } return setter(value); @@ -248,7 +246,7 @@ protected: attr_proxy_t(AdcGenericDevice& dev, ATTR_ID_T id) : _dev(dev), _id(std::move(id)) {} template - operator adc_result_t() const + operator ret_result_t() const { auto attr = _dev._attrs.template get>(_id); if (attr) { @@ -329,13 +327,13 @@ public: return _devId; } - // template + // template // void addCommand(CMD_ID_T id, ET&& exec_func) // { // _commands.emplace(std::move(id), std::forward(exec_func)); // } - template + template void addCommand(CMD_ID_T id, ET&& exec_func) { _commands.emplace(std::move(id), std::forward(exec_func)); @@ -355,7 +353,7 @@ public: std::tuple...>{}); } - template + template requires(sizeof...(FuncTs) > 1) void addAttr(ATTR_ID_T id, GT&& getter, ST&& setter, FuncTs&&... cnv_pairs) { @@ -380,7 +378,7 @@ public: // 1, decltype(tp)>>...>, // "Getter and setter cannot be nullptr_t at the same time!"); - auto from_cnv_func = [](TpT const& func_tp) { + auto from_cnv_func = [](TpT const& func_tp) { using from_fn_t = std::decay_t>; using to_fn_t = std::decay_t>; @@ -388,7 +386,7 @@ public: return [&func_tp](attr_t const& attr) mutable -> attr_t { return attr_t{ - .getter = [&attr, &func_tp]() mutable -> adc_result_t { + .getter = [&attr, &func_tp]() mutable -> ret_result_t { return std::forward>(std::get(func_tp))(attr.getter()); }, .setter = [&attr, &func_tp](u_t const& uv) mutable -> adc_error_t { @@ -402,7 +400,7 @@ public: }}; }; }; - // auto from_cnv_func = [](TpT&& func_tp) { + // auto from_cnv_func = [](TpT&& func_tp) { // using tp_t = std::remove_cvref_t; // using from_fn_t = std::decay_t>; @@ -434,7 +432,7 @@ public: // }; // }; - auto to_cnv_func = [id, this](TpT const& func_tp) { + auto to_cnv_func = [id, this](TpT const& func_tp) { using from_fn_t = std::decay_t>; using to_fn_t = std::decay_t>; @@ -481,7 +479,7 @@ public: // function-like access to attributes template - adc_result_t attr(ATTR_ID_T id) + ret_result_t attr(ATTR_ID_T id) { return attr_proxy_t{*this, std::move(id)}; } diff --git a/include/adclib/adclib_device1.h b/include/adclib/adclib_device1.h index 106cf0f..14779ab 100644 --- a/include/adclib/adclib_device1.h +++ b/include/adclib/adclib_device1.h @@ -106,53 +106,51 @@ inline std::error_code make_error_code(AdcDeviceErrorCode ec) template -concept adclib_command_exec_t = snplib::snplib_callable_c && (snplib::snplib_func_traits_t::arity == 0) && - std::same_as::ret_t>; +concept device_command_exec_t = snplib::callable_c && (snplib::func_traits_t::arity == 0) && + std::same_as::ret_t>; template -concept adclib_attr_getter_c = std::same_as || requires(T t) { - { t() } -> adc_result_c; +concept device_attr_getter_c = std::same_as || requires(T t) { + { t() } -> ret_result_c; }; template -concept adclib_attr_setter_c = - std::same_as || (snplib::snplib_callable_c && (snplib::snplib_func_traits_t::arity >= 1) && - std::same_as::ret_t>); +concept device_attr_setter_c = + std::same_as || (snplib::callable_c && (snplib::func_traits_t::arity >= 1) && + std::same_as::ret_t>); // deduce value type from getter and setter -template -using adclib_attr_value_deduced_t = std::conditional_t< +template +using device_attr_value_deduced_t = std::conditional_t< std::is_null_pointer_v, - std::conditional_t, void, std::remove_cvref_t>>, + std::conditional_t, void, std::remove_cvref_t>>, typename std::invoke_result_t::value_type>; -template -struct adclib_is_deduced_void_t { - static constexpr bool value = std::is_void_v>; +template +struct is_deduced_void_t { + static constexpr bool value = std::is_void_v>; }; // conversional function signature: // "from": adc_result_t func(const VT&) // "to": adc_result_t func(const UT&) template -concept adclib_attr_conv_from_func_c = +concept device_attr_conv_from_func_c = std::same_as || (std::invocable && !std::is_void_v>); template -concept adclib_attr_conv_to_func_c = std::same_as || - (snplib::snplib_callable_c && (snplib::snplib_func_traits_t::arity == 1) && - std::same_as, typename snplib::snplib_func_traits_t::ret_t>); +concept device_attr_conv_to_func_c = + std::same_as || (snplib::callable_c && (snplib::func_traits_t::arity == 1) && + std::same_as, typename snplib::func_traits_t::ret_t>); -template CONV_FROM_T, adclib_attr_conv_to_func_c CONV_TO_T> -using adclib_attr_user_deduced_t = - std::conditional_t, - std::conditional_t, - void, - std::remove_cvref_t>>, - typename snplib::snplib_func_traits_t::ret_t::value_type>; +template CONV_FROM_T, device_attr_conv_to_func_c CONV_TO_T> +using device_attr_user_deduced_t = std::conditional_t< + std::is_null_pointer_v, + std::conditional_t, void, std::remove_cvref_t>>, + typename snplib::func_traits_t::ret_t::value_type>; @@ -163,7 +161,7 @@ class AdcGenericDevice { protected: template - using attr_getter_t = std::function()>; + using attr_getter_t = std::function()>; template using attr_setter_t = std::function; @@ -176,7 +174,7 @@ protected: attr_t(AdcGenericDevice& dev, ATTR_ID_T id) : _dev(dev), _id(std::move(id)) {} template - operator adc_result_t() const + operator ret_result_t() const { auto getter = _dev._attrGetter.template get>(_id); if (getter) { @@ -231,10 +229,10 @@ protected: // default convert functions for char-range types template - requires((snplib::snplib_char_range_c || snplib::snplib_pointer_to_char_c) && - (snplib::snplib_char_range_c || snplib::snplib_pointer_to_char_c)) - static inline std::function(VR const&)> default_char_range_conv_from = [](VR const& val) - -> adc_result_t { + requires((snplib::char_range_c || snplib::pointer_to_char_c) && + (snplib::char_range_c || snplib::pointer_to_char_c)) + static inline std::function(VR const&)> default_char_range_conv_from = [](VR const& val) + -> ret_result_t { if constexpr (std::same_as) { return val; } else if constexpr (std::constructible_from) { @@ -255,13 +253,13 @@ protected: template - static inline std::function(UR const&)> default_char_range_conv_to = + static inline std::function(UR const&)> default_char_range_conv_to = default_char_range_conv_from; // default convert functions for std::filesystem::path type template - static inline std::function(std::filesystem::path const&)> default_fspath_conv_from = - [](std::filesystem::path const& val) -> adc_result_t { + static inline std::function(std::filesystem::path const&)> default_fspath_conv_from = + [](std::filesystem::path const& val) -> ret_result_t { if constexpr (std::same_as) { return val; } else if constexpr (std::constructible_from) { @@ -271,7 +269,7 @@ protected: std::same_as)) { // char*/wchar_t* return val.c_str(); - } else if constexpr (snplib::snplib_char_range_c) { + } else if constexpr (snplib::char_range_c) { using iter_t = std::filesystem::path::value_type*; auto sz = val.native().size(); if constexpr (std::constructible_from) { @@ -287,13 +285,13 @@ protected: }; template - static inline std::function(UT const&)> default_fspath_conv_to = - [](UT const& uval) -> adc_result_t { + static inline std::function(UT const&)> default_fspath_conv_to = + [](UT const& uval) -> ret_result_t { if constexpr (std::same_as) { return uval; } else if constexpr (std::constructible_from) { return std::filesystem::path(uval); - } else if constexpr (snplib::snplib_char_range_c) { + } else if constexpr (snplib::char_range_c) { return std::filesystem::path(uval.begin(), uval.end()); } else { static_assert(false, "UNSUPPORTED TYPE!"); @@ -356,13 +354,13 @@ public: return _devId; } - // template + // template // void addCommand(CMD_ID_T id, ET&& exec_func) // { // _commands.emplace(std::move(id), std::forward(exec_func)); // } - template + template void addCommand(CMD_ID_T id, ET&& exec_func) { _commands.emplace(std::move(id), std::forward(exec_func)); @@ -371,7 +369,7 @@ public: template void addAttr(ATTR_ID_T id, GT&& getter, ST&& setter) { - using v_t = adclib_attr_value_deduced_t; + using v_t = device_attr_value_deduced_t; static_assert(!std::is_void_v, "Getter and setter cannot be nullptr_t at the same time!"); if constexpr (!std::is_null_pointer_v && !std::is_null_pointer_v) { @@ -386,7 +384,7 @@ public: requires(sizeof...(UTs) > 0) void addAttr(ATTR_ID_T id, GT&& getter, ST&& setter, std::tuple) { - using v_t = adclib_attr_value_deduced_t; + using v_t = device_attr_value_deduced_t; static_assert(!std::is_void_v, "Getter and setter cannot be nullptr_t at the same time!"); if constexpr (!std::is_null_pointer_v && !std::is_null_pointer_v) { @@ -411,7 +409,7 @@ public: // // conversional functions are the same as defined in the snplib::hmap class // (it must convert attribute values instead of getters or setters itself!) - template + template requires(sizeof...(FuncTs) > 1) void addAttr(ATTR_ID_T id, GT&& getter, ST&& setter, FuncTs&&... cnv_pairs) { @@ -419,7 +417,7 @@ public: static_assert(NFUNCS % 2 == 0, "Number of conversional functions must be an even!"); - using v_t = adclib_attr_value_deduced_t; + using v_t = device_attr_value_deduced_t; static_assert(!std::is_void_v, "Getter and setter cannot be nullptr_t at the same time!"); @@ -433,10 +431,10 @@ public: using from_fn_t = std::decay_t>; using to_fn_t = std::decay_t>; - using u_t = adclib_attr_user_deduced_t; + using u_t = device_attr_user_deduced_t; - return [tp = std::move(tp)](attr_getter_t const& gt) -> adc_result_t> { - return [tp = std::move(tp), >]() -> adc_result_t { + return [tp = std::move(tp)](attr_getter_t const& gt) -> ret_result_t> { + return [tp = std::move(tp), >]() -> ret_result_t { auto v = gt(); if (v) { // convert from inner type to user's ("convert-from" function) @@ -455,9 +453,9 @@ public: using from_fn_t = std::decay_t>; using to_fn_t = std::decay_t>; - using u_t = adclib_attr_user_deduced_t; + using u_t = device_attr_user_deduced_t; - return [tp = std::move(tp)](attr_setter_t const& st) -> adc_result_t> { + return [tp = std::move(tp)](attr_setter_t const& st) -> ret_result_t> { return [tp = std::move(tp), &st](u_t const& uval) -> adc_error_t { // convert from user type to inner ("convert-to" function)! auto val = std::forward>(std::get(tp))(uval); @@ -476,10 +474,10 @@ public: using from_fn_t = std::decay_t>; using to_fn_t = std::decay_t>; - using u_t = adclib_attr_user_deduced_t; + using u_t = device_attr_user_deduced_t; - return [tp = std::move(tp)](attr_getter_t const& gt) -> adc_result_t> { - return [tp = std::move(tp), >]() -> adc_result_t { + return [tp = std::move(tp)](attr_getter_t const& gt) -> ret_result_t> { + return [tp = std::move(tp), >]() -> ret_result_t { auto uv = gt(); if (uv) { // convert to inner type from user's ("convert-to" function) @@ -498,9 +496,9 @@ public: using from_fn_t = std::decay_t>; using to_fn_t = std::decay_t>; - using u_t = adclib_attr_user_deduced_t; + using u_t = device_attr_user_deduced_t; - return [tp = std::move(tp)](attr_setter_t const& st) -> adc_result_t> { + return [tp = std::move(tp)](attr_setter_t const& st) -> ret_result_t> { return [tp = std::move(tp), &st](v_t const& val) -> adc_error_t { // convert to user type from inner ("convert-from" function)! auto uval = std::forward>(std::get(tp))(val); @@ -535,17 +533,17 @@ public: setter_cap = std::forward(setter), this](std::index_sequence) mutable { auto tp = std::forward_as_tuple(std::forward(cnv_pairs_cap)...); - auto gt_cnv_from_func = [](TpT const& tpl) { + auto gt_cnv_from_func = [](TpT const& tpl) { using from_fn_t = std::decay_t>; using to_fn_t = std::decay_t>; - using u_t = adclib_attr_user_deduced_t; + using u_t = device_attr_user_deduced_t; // using u_t = std::invoke_result_t::value_type; // static_assert(requires(v_t v, u_t u) { u = v; }, "Invalid deduced user type!"); - return [&tpl](attr_getter_t const& gt) -> adc_result_t> { - return [&tpl, >]() -> adc_result_t { + return [&tpl](attr_getter_t const& gt) -> ret_result_t> { + return [&tpl, >]() -> ret_result_t { auto v = gt(); if (v) { // convert from inner type to user's ("convert-from" function) @@ -558,16 +556,16 @@ public: }; }; - auto st_cnv_from_func = [](TpT const& tpl) { + auto st_cnv_from_func = [](TpT const& tpl) { using from_fn_t = std::decay_t>; using to_fn_t = std::decay_t>; - using u_t = adclib_attr_user_deduced_t; + using u_t = device_attr_user_deduced_t; // using u_t = std::invoke_result_t::value_type; // static_assert(requires(v_t v, u_t u) { u = v; }, "Invalid deduced user type!"); - return [&tpl](attr_setter_t const& st) -> adc_result_t> { + return [&tpl](attr_setter_t const& st) -> ret_result_t> { return [&tpl, &st](u_t const& uval) -> adc_error_t { // convert from user type to inner ("convert-to" function)! auto val = std::forward>(std::get(tpl))(uval); @@ -580,18 +578,18 @@ public: }; }; - auto gt_cnv_to_func = [](TpT const& tpl) { + auto gt_cnv_to_func = [](TpT const& tpl) { using from_fn_t = std::decay_t>; using to_fn_t = std::decay_t>; - using u_t = adclib_attr_user_deduced_t; + using u_t = device_attr_user_deduced_t; // using u_t = std::invoke_result_t::value_type; // static_assert(requires(v_t v, u_t u) { v = u; }, "Invalid deduced user type!"); - return [&tpl](attr_getter_t const& gt) -> adc_result_t> { - return [&tpl, >]() -> adc_result_t { + return [&tpl](attr_getter_t const& gt) -> ret_result_t> { + return [&tpl, >]() -> ret_result_t { auto uv = gt(); if (uv) { // convert to inner type from user's ("convert-to" function) @@ -604,17 +602,17 @@ public: }; }; - auto st_cnv_to_func = [](TpT const& tpl) { + auto st_cnv_to_func = [](TpT const& tpl) { using from_fn_t = std::decay_t>; using to_fn_t = std::decay_t>; - using u_t = adclib_attr_user_deduced_t; + using u_t = device_attr_user_deduced_t; // using u_t = std::invoke_result_t::value_type; // static_assert(requires(v_t v, u_t u) { v = u; }, "Invalid deduced user type!"); - return [&tpl](attr_setter_t const& st) -> adc_result_t> { + return [&tpl](attr_setter_t const& st) -> ret_result_t> { return [&tpl, &st](v_t const& val) -> adc_error_t { // convert to user type from inner ("convert-from" function)! auto uval = std::forward>(std::get(tpl))(val); @@ -645,7 +643,7 @@ public: // add attribute of one of arithmetic type template - requires std::is_arithmetic_v> + requires std::is_arithmetic_v> void addArithAttr(ATTR_ID_T id, GT&& getter, ST&& setter) { // addAttr(std::move(id), std::forward(getter), std::forward(setter), @@ -655,10 +653,10 @@ public: // add attribute of char-range type template - requires snplib::snplib_char_range_c> + requires snplib::char_range_c> void addCharRangeAttr(ATTR_ID_T id, GT&& getter, ST&& setter) { - using v_t = adclib_attr_value_deduced_t; + using v_t = device_attr_value_deduced_t; static_assert(!std::is_void_v, "Getter and setter cannot be nullptr_t at the same time!"); if constexpr (!std::is_null_pointer_v && !std::is_null_pointer_v) { @@ -681,10 +679,10 @@ public: // add attribute of std::filesystem::path type template - requires std::same_as, std::filesystem::path> + requires std::same_as, std::filesystem::path> void addFSPathAttr(ATTR_ID_T id, GT&& getter, ST&& setter) { - using v_t = adclib_attr_value_deduced_t; + using v_t = device_attr_value_deduced_t; static_assert(!std::is_void_v, "Getter and setter cannot be nullptr_t at the same time!"); if constexpr (!std::is_null_pointer_v && !std::is_null_pointer_v) { @@ -722,7 +720,7 @@ public: // function-like access to attributes template - adc_result_t attr(ATTR_ID_T id) + ret_result_t attr(ATTR_ID_T id) { return attr_t{*this, std::move(id)}; } diff --git a/include/adclib/adclib_netmsg.h b/include/adclib/adclib_netmsg.h index 81430c4..f6bd54a 100644 --- a/include/adclib/adclib_netmsg.h +++ b/include/adclib/adclib_netmsg.h @@ -32,10 +32,10 @@ static constexpr std::array ADCLIB_NETMSG_VALID_KEYWORDS{ADCLIB_NETMSG_KEYWORD_A ADCLIB_NETMSG_KEYWORD_CMD}; -template > -class AdcNetworkMessage final : protected snplib::snplib_keyvalue_expr_t +template > +class AdcNetworkMessage final : protected snplib::keyvalue_expr_t { - typedef snplib::snplib_keyvalue_expr_t base_t; + typedef snplib::keyvalue_expr_t base_t; public: using typename base_t::error_t; @@ -72,7 +72,7 @@ public: return std::ranges::equal(this->_key, ADCLIB_NETMSG_KEYWORD_GET); } - error_t fromCharRange(snplib::snplib_input_char_range_c auto&& bytes) + error_t fromCharRange(snplib::input_char_range_c auto&& bytes) requires(!std::same_as>) { // auto err = fromCharRange( @@ -118,7 +118,7 @@ public: return this->setKeyValue(ADCLIB_NETMSG_KEYWORD_ERR, err.value()); } - template + template requires(sizeof...(ArgTs) > 0) error_t createSET(ATTR_NAME_T&& attr_name, ArgTs&&... args) { @@ -139,7 +139,7 @@ public: return err; } - template + template error_t createGET(ATTR_NAME_T&& attr_name, ArgTs&&... args) { this->_isValid = false; @@ -161,7 +161,7 @@ public: return err; } - template + template error_t createCMD(CMD_NAME_T&& cmd_name) { this->_isValid = false;