Skip to content

Commit

Permalink
[eclipse-iceoryx#491] Use iox::into instead of error_string()
Browse files Browse the repository at this point in the history
  • Loading branch information
orecham committed Nov 19, 2024
1 parent cde6837 commit 56234ac
Show file tree
Hide file tree
Showing 18 changed files with 430 additions and 455 deletions.
1 change: 0 additions & 1 deletion iceoryx2-ffi/cxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ target_include_directories(includes-only-cxx

add_library(iceoryx2-cxx-object-lib OBJECT
src/config.cpp
src/error_string.cpp
src/event_id.cpp
src/file_descriptor.cpp
src/header_publish_subscribe.cpp
Expand Down
2 changes: 0 additions & 2 deletions iceoryx2-ffi/cxx/include/iox2/config_creation_error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ enum class ConfigCreationError : uint8_t {
UnableToDeserializeContents
};

auto error_string(const iox2::ConfigCreationError& error) -> const char*;

} // namespace iox2

#endif
3 changes: 0 additions & 3 deletions iceoryx2-ffi/cxx/include/iox2/connection_failure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ enum class ConnectionFailure : uint8_t {
UnableToMapPublishersDataSegment
};


auto error_string(const iox2::ConnectionFailure& error) -> const char*;

} // namespace iox2

#endif
150 changes: 150 additions & 0 deletions iceoryx2-ffi/cxx/include/iox2/enum_translation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ constexpr auto from<iox2::SemanticStringError, iox2_semantic_string_error_e>(
IOX_UNREACHABLE();
}

template <>
constexpr auto from<iox2::SemanticStringError, const char*>(const iox2::SemanticStringError value) noexcept -> const
char* {
return iox2_semantic_string_error_string(iox::into<iox2_semantic_string_error_e>(value));
}

template <>
constexpr auto from<int, iox2::ServiceType>(const int value) noexcept -> iox2::ServiceType {
const auto service_type = static_cast<iox2_service_type_e>(value);
Expand Down Expand Up @@ -115,6 +121,12 @@ constexpr auto from<iox2::NodeCreationFailure, iox2_node_creation_failure_e>(
IOX_UNREACHABLE();
}

template <>
constexpr auto from<iox2::NodeCreationFailure, const char*>(const iox2::NodeCreationFailure value) noexcept -> const
char* {
return iox2_node_creation_failure_string(iox::into<iox2_node_creation_failure_e>(value));
}

template <>
constexpr auto from<int, iox2::CallbackProgression>(const int value) noexcept -> iox2::CallbackProgression {
const auto error = static_cast<iox2_callback_progression_e>(value);
Expand Down Expand Up @@ -171,6 +183,11 @@ constexpr auto from<iox2::NodeListFailure, iox2_node_list_failure_e>(const iox2:
IOX_UNREACHABLE();
}

template <>
constexpr auto from<iox2::NodeListFailure, const char*>(const iox2::NodeListFailure value) noexcept -> const char* {
return iox2_node_list_failure_string(iox::into<iox2_node_list_failure_e>(value));
}

template <>
constexpr auto from<int, iox2::NodeWaitFailure>(const int value) noexcept -> iox2::NodeWaitFailure {
const auto error = static_cast<iox2_node_wait_failure_e>(value);
Expand All @@ -197,6 +214,11 @@ constexpr auto from<iox2::NodeWaitFailure, iox2_node_wait_failure_e>(const iox2:
IOX_UNREACHABLE();
}

template <>
constexpr auto from<iox2::NodeWaitFailure, const char*>(const iox2::NodeWaitFailure value) noexcept -> const char* {
return iox2_node_wait_failure_string(iox::into<iox2_node_wait_failure_e>(value));
}

template <>
constexpr auto from<iox2::MessagingPattern, iox2_messaging_pattern_e>(const iox2::MessagingPattern value) noexcept
-> iox2_messaging_pattern_e {
Expand Down Expand Up @@ -256,6 +278,12 @@ constexpr auto from<iox2::ServiceDetailsError, iox2_service_details_error_e>(
IOX_UNREACHABLE();
}

template <>
constexpr auto from<iox2::ServiceDetailsError, const char*>(const iox2::ServiceDetailsError value) noexcept -> const
char* {
return iox2_service_details_error_string(iox::into<iox2_service_details_error_e>(value));
}

template <>
constexpr auto from<int, iox2::EventOpenOrCreateError>(const int value) noexcept -> iox2::EventOpenOrCreateError {
const auto error = static_cast<iox2_event_open_or_create_error_e>(value);
Expand Down Expand Up @@ -356,6 +384,12 @@ constexpr auto from<iox2::EventOpenOrCreateError, iox2_event_open_or_create_erro
}
}

template <>
constexpr auto
from<iox2::EventOpenOrCreateError, const char*>(const iox2::EventOpenOrCreateError value) noexcept -> const char* {
return iox2_event_open_or_create_error_string(iox::into<iox2_event_open_or_create_error_e>(value));
}

template <>
constexpr auto from<int, iox2::EventOpenError>(const int value) noexcept -> iox2::EventOpenError {
const auto error = static_cast<iox2_event_open_or_create_error_e>(value);
Expand Down Expand Up @@ -426,6 +460,11 @@ constexpr auto from<iox2::EventOpenError, iox2_event_open_or_create_error_e>(con
}
}

template <>
constexpr auto from<iox2::EventOpenError, const char*>(const iox2::EventOpenError value) noexcept -> const char* {
return iox2_event_open_or_create_error_string(iox::into<iox2_event_open_or_create_error_e>(value));
}

template <>
constexpr auto from<int, iox2::EventCreateError>(const int value) noexcept -> iox2::EventCreateError {
const auto error = static_cast<iox2_event_open_or_create_error_e>(value);
Expand Down Expand Up @@ -470,6 +509,11 @@ constexpr auto from<iox2::EventCreateError, iox2_event_open_or_create_error_e>(
}
}

template <>
constexpr auto from<iox2::EventCreateError, const char*>(const iox2::EventCreateError value) noexcept -> const char* {
return iox2_event_open_or_create_error_string(iox::into<iox2_event_open_or_create_error_e>(value));
}

template <>
constexpr auto from<int, iox2::PublishSubscribeOpenOrCreateError>(const int value) noexcept
-> iox2::PublishSubscribeOpenOrCreateError {
Expand Down Expand Up @@ -617,6 +661,13 @@ constexpr auto from<iox2::PublishSubscribeOpenError, iox2_pub_sub_open_or_create
}
}

template <>
constexpr auto
from<iox2::PublishSubscribeOpenError, const char*>(const iox2::PublishSubscribeOpenError value) noexcept -> const
char* {
return iox2_pub_sub_open_or_create_error_string(iox::into<iox2_pub_sub_open_or_create_error_e>(value));
}

template <>
constexpr auto
from<int, iox2::PublishSubscribeCreateError>(const int value) noexcept -> iox2::PublishSubscribeCreateError {
Expand Down Expand Up @@ -664,6 +715,13 @@ constexpr auto from<iox2::PublishSubscribeCreateError, iox2_pub_sub_open_or_crea
}
}

template <>
constexpr auto
from<iox2::PublishSubscribeCreateError, const char*>(const iox2::PublishSubscribeCreateError value) noexcept -> const
char* {
return iox2_pub_sub_open_or_create_error_string(iox::into<iox2_pub_sub_open_or_create_error_e>(value));
}

template <>
constexpr auto from<iox2::PublishSubscribeOpenOrCreateError, iox2_pub_sub_open_or_create_error_e>(
const iox2::PublishSubscribeOpenOrCreateError value) noexcept -> iox2_pub_sub_open_or_create_error_e {
Expand Down Expand Up @@ -723,6 +781,12 @@ constexpr auto from<iox2::PublishSubscribeOpenOrCreateError, iox2_pub_sub_open_o
}
}

template <>
constexpr auto from<iox2::PublishSubscribeOpenOrCreateError, const char*>(
const iox2::PublishSubscribeOpenOrCreateError value) noexcept -> const char* {
return iox2_pub_sub_open_or_create_error_string(iox::into<iox2_pub_sub_open_or_create_error_e>(value));
}

template <>
constexpr auto from<int, iox2::NotifierCreateError>(const int value) noexcept -> iox2::NotifierCreateError {
const auto error = static_cast<iox2_notifier_create_error_e>(value);
Expand All @@ -745,6 +809,12 @@ constexpr auto from<iox2::NotifierCreateError, iox2_notifier_create_error_e>(
IOX_UNREACHABLE();
}

template <>
constexpr auto from<iox2::NotifierCreateError, const char*>(const iox2::NotifierCreateError value) noexcept -> const
char* {
return iox2_notifier_create_error_string(iox::into<iox2_notifier_create_error_e>(value));
}

template <>
constexpr auto from<int, iox2::ListenerCreateError>(const int value) noexcept -> iox2::ListenerCreateError {
const auto error = static_cast<iox2_listener_create_error_e>(value);
Expand All @@ -771,6 +841,12 @@ constexpr auto from<iox2::ListenerCreateError, iox2_listener_create_error_e>(
IOX_UNREACHABLE();
}

template <>
constexpr auto from<iox2::ListenerCreateError, const char*>(const iox2::ListenerCreateError value) noexcept -> const
char* {
return iox2_listener_create_error_string(iox::into<iox2_listener_create_error_e>(value));
}

template <>
constexpr auto from<int, iox2::NotifierNotifyError>(const int value) noexcept -> iox2::NotifierNotifyError {
const auto error = static_cast<iox2_notifier_notify_error_e>(value);
Expand All @@ -793,6 +869,12 @@ constexpr auto from<iox2::NotifierNotifyError, iox2_notifier_notify_error_e>(
IOX_UNREACHABLE();
}

template <>
constexpr auto from<iox2::NotifierNotifyError, const char*>(const iox2::NotifierNotifyError value) noexcept -> const
char* {
return iox2_notifier_notify_error_string(iox::into<iox2_notifier_notify_error_e>(value));
}

template <>
constexpr auto from<int, iox2::ListenerWaitError>(const int value) noexcept -> iox2::ListenerWaitError {
const auto error = static_cast<iox2_listener_wait_error_e>(value);
Expand Down Expand Up @@ -823,6 +905,11 @@ constexpr auto from<iox2::ListenerWaitError, iox2_listener_wait_error_e>(const i
IOX_UNREACHABLE();
}

template <>
constexpr auto from<iox2::ListenerWaitError, const char*>(const iox2::ListenerWaitError value) noexcept -> const char* {
return iox2_listener_wait_error_string(iox::into<iox2_listener_wait_error_e>(value));
}

template <>
constexpr auto from<int, iox2::PublisherCreateError>(const int value) noexcept -> iox2::PublisherCreateError {
const auto error = static_cast<iox2_publisher_create_error_e>(value);
Expand All @@ -849,6 +936,12 @@ constexpr auto from<iox2::PublisherCreateError, iox2_publisher_create_error_e>(
IOX_UNREACHABLE();
}

template <>
constexpr auto from<iox2::PublisherCreateError, const char*>(const iox2::PublisherCreateError value) noexcept -> const
char* {
return iox2_publisher_create_error_string(iox::into<iox2_publisher_create_error_e>(value));
}

template <>
constexpr auto from<int, iox2::SubscriberCreateError>(const int value) noexcept -> iox2::SubscriberCreateError {
const auto error = static_cast<iox2_subscriber_create_error_e>(value);
Expand All @@ -875,6 +968,12 @@ constexpr auto from<iox2::SubscriberCreateError, iox2_subscriber_create_error_e>
IOX_UNREACHABLE();
}

template <>
constexpr auto from<iox2::SubscriberCreateError, const char*>(const iox2::SubscriberCreateError value) noexcept -> const
char* {
return iox2_subscriber_create_error_string(iox::into<iox2_subscriber_create_error_e>(value));
}

template <>
constexpr auto from<int, iox2::PublisherSendError>(const int value) noexcept -> iox2::PublisherSendError {
const auto error = static_cast<iox2_publisher_send_error_e>(value);
Expand Down Expand Up @@ -921,6 +1020,12 @@ constexpr auto from<iox2::PublisherSendError, iox2_publisher_send_error_e>(
IOX_UNREACHABLE();
}

template <>
constexpr auto from<iox2::PublisherSendError, const char*>(const iox2::PublisherSendError value) noexcept -> const
char* {
return iox2_publisher_send_error_string(iox::into<iox2_publisher_send_error_e>(value));
}

template <>
constexpr auto from<int, iox2::SubscriberReceiveError>(const int value) noexcept -> iox2::SubscriberReceiveError {
const auto error = static_cast<iox2_subscriber_receive_error_e>(value);
Expand Down Expand Up @@ -951,6 +1056,12 @@ constexpr auto from<iox2::SubscriberReceiveError, iox2_subscriber_receive_error_
IOX_UNREACHABLE();
}

template <>
constexpr auto
from<iox2::SubscriberReceiveError, const char*>(const iox2::SubscriberReceiveError value) noexcept -> const char* {
return iox2_subscriber_receive_error_string(iox::into<iox2_subscriber_receive_error_e>(value));
}

template <>
constexpr auto from<int, iox2::PublisherLoanError>(const int value) noexcept -> iox2::PublisherLoanError {
const auto error = static_cast<iox2_publisher_loan_error_e>(value);
Expand Down Expand Up @@ -985,6 +1096,12 @@ constexpr auto from<iox2::PublisherLoanError, iox2_publisher_loan_error_e>(
IOX_UNREACHABLE();
}

template <>
constexpr auto from<iox2::PublisherLoanError, const char*>(const iox2::PublisherLoanError value) noexcept -> const
char* {
return iox2_publisher_loan_error_string(iox::into<iox2_publisher_loan_error_e>(value));
}

template <>
constexpr auto from<int, iox2::TypeVariant>(const int value) noexcept -> iox2::TypeVariant {
const auto variant = static_cast<iox2_type_variant_e>(value);
Expand Down Expand Up @@ -1024,6 +1141,11 @@ constexpr auto from<iox2::ServiceListError, iox2_service_list_error_e>(const iox
IOX_UNREACHABLE();
}

template <>
constexpr auto from<iox2::ServiceListError, const char*>(const iox2::ServiceListError value) noexcept -> const char* {
return iox2_service_list_error_string(iox::into<iox2_service_list_error_e>(value));
}

template <>
constexpr auto from<int, iox2::MessagingPattern>(const int value) noexcept -> iox2::MessagingPattern {
const auto variant = static_cast<iox2_messaging_pattern_e>(value);
Expand Down Expand Up @@ -1088,6 +1210,11 @@ constexpr auto from<iox2::ConnectionFailure, iox2_connection_failure_e>(const io
IOX_UNREACHABLE();
}

template <>
constexpr auto from<iox2::ConnectionFailure, const char*>(const iox2::ConnectionFailure value) noexcept -> const char* {
return iox2_connection_failure_string(iox::into<iox2_connection_failure_e>(value));
}

template <>
constexpr auto from<int, iox2::ConfigCreationError>(const int value) noexcept -> iox2::ConfigCreationError {
const auto variant = static_cast<iox2_config_creation_error_e>(value);
Expand Down Expand Up @@ -1121,6 +1248,12 @@ constexpr auto from<iox2::ConfigCreationError, iox2_config_creation_error_e>(
IOX_UNREACHABLE();
}

template <>
constexpr auto from<iox2::ConfigCreationError, const char*>(const iox2::ConfigCreationError value) noexcept -> const
char* {
return iox2_config_creation_error_string(iox::into<iox2_config_creation_error_e>(value));
}

template <>
constexpr auto from<iox2::LogLevel, iox2_log_level_e>(iox2::LogLevel value) noexcept -> iox2_log_level_e {
switch (value) {
Expand Down Expand Up @@ -1183,6 +1316,12 @@ constexpr auto from<iox2::WaitSetCreateError, iox2_waitset_create_error_e>(
IOX_UNREACHABLE();
}

template <>
constexpr auto from<iox2::WaitSetCreateError, const char*>(const iox2::WaitSetCreateError value) noexcept -> const
char* {
return iox2_waitset_create_error_string(iox::into<iox2_waitset_create_error_e>(value));
}

template <>
constexpr auto from<int, iox2::WaitSetRunResult>(const int value) noexcept -> iox2::WaitSetRunResult {
const auto variant = static_cast<iox2_waitset_run_result_e>(value);
Expand Down Expand Up @@ -1247,6 +1386,12 @@ constexpr auto from<iox2::WaitSetAttachmentError, iox2_waitset_attachment_error_
IOX_UNREACHABLE();
}

template <>
constexpr auto
from<iox2::WaitSetAttachmentError, const char*>(const iox2::WaitSetAttachmentError value) noexcept -> const char* {
return iox2_waitset_attachment_error_string(iox::into<iox2_waitset_attachment_error_e>(value));
}

template <>
constexpr auto from<int, iox2::WaitSetRunError>(const int value) noexcept -> iox2::WaitSetRunError {
const auto variant = static_cast<iox2_waitset_run_error_e>(value);
Expand Down Expand Up @@ -1285,6 +1430,11 @@ constexpr auto from<iox2::WaitSetRunError, iox2_waitset_run_error_e>(const iox2:
IOX_UNREACHABLE();
}

template <>
constexpr auto from<iox2::WaitSetRunError, const char*>(const iox2::WaitSetRunError value) noexcept -> const char* {
return iox2_waitset_run_error_string(iox::into<iox2_waitset_run_error_e>(value));
}

} // namespace iox

#endif
3 changes: 0 additions & 3 deletions iceoryx2-ffi/cxx/include/iox2/listener_error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ enum class ListenerWaitError : uint8_t {
InternalFailure,
};

auto error_string(const iox2::ListenerCreateError& error) -> const char*;
auto error_string(const iox2::ListenerWaitError& error) -> const char*;

} // namespace iox2

#endif
3 changes: 0 additions & 3 deletions iceoryx2-ffi/cxx/include/iox2/node_failure_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ enum class NodeCreationFailure : uint8_t {
enum class NodeCleanupFailure : uint8_t {
};

auto error_string(const iox2::NodeListFailure& error) -> const char*;
auto error_string(const iox2::NodeCreationFailure& error) -> const char*;

} // namespace iox2

#endif
3 changes: 0 additions & 3 deletions iceoryx2-ffi/cxx/include/iox2/node_wait_failure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ enum class NodeWaitFailure : uint8_t {
Interrupt,
};


auto error_string(const iox2::NodeWaitFailure& error) -> const char*;

} // namespace iox2

#endif
3 changes: 0 additions & 3 deletions iceoryx2-ffi/cxx/include/iox2/notifier_error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ enum class NotifierNotifyError : uint8_t {
EventIdOutOfBounds,
};

auto error_string(const iox2::NotifierCreateError& error) -> const char*;
auto error_string(const iox2::NotifierNotifyError& error) -> const char*;

} // namespace iox2

#endif
Loading

0 comments on commit 56234ac

Please sign in to comment.