From 765cdec81f31fa3829f42dc4899d1db51cff9f85 Mon Sep 17 00:00:00 2001 From: Dennis Liu Date: Mon, 11 Dec 2023 20:06:52 +0800 Subject: [PATCH] iox-#2055 Rename `fromString` to `from_string` Rename `fromString` to `from_string`. Note that the name of test cases are not included. Signed-off-by: Dennis Liu --- .../cli/include/iox/cli/arguments.inl | 2 +- .../include/iox/detail/serialization.inl | 6 +- iceoryx_examples/iceperf/main_follower.cpp | 2 +- iceoryx_examples/iceperf/main_leader.cpp | 2 +- .../test/moduletests/test_utility_convert.cpp | 88 +++++++++---------- .../utility/include/iox/detail/convert.hpp | 8 +- .../utility/include/iox/detail/convert.inl | 38 ++++---- iceoryx_posh/source/roudi/port_manager.cpp | 2 +- iceoryx_posh/source/roudi/roudi.cpp | 6 +- .../source/roudi/roudi_cmd_line_parser.cpp | 6 +- .../source/runtime/ipc_interface_base.cpp | 4 +- .../source/runtime/ipc_runtime_interface.cpp | 10 +-- .../source/runtime/posh_runtime_impl.cpp | 28 +++--- .../source/introspection_app.cpp | 2 +- 14 files changed, 102 insertions(+), 102 deletions(-) diff --git a/iceoryx_dust/cli/include/iox/cli/arguments.inl b/iceoryx_dust/cli/include/iox/cli/arguments.inl index 54802ce4515..cf6f9d3f533 100644 --- a/iceoryx_dust/cli/include/iox/cli/arguments.inl +++ b/iceoryx_dust/cli/include/iox/cli/arguments.inl @@ -27,7 +27,7 @@ template inline expected Arguments::convertFromString(const Argument_t& stringValue) const noexcept { T value; - if (!convert::fromString(stringValue.c_str(), value)) + if (!convert::from_string(stringValue.c_str(), value)) { std::cout << "\"" << stringValue.c_str() << "\" could not be converted to the requested type" << std::endl; return err(Error::UNABLE_TO_CONVERT_VALUE); diff --git a/iceoryx_dust/utility/include/iox/detail/serialization.inl b/iceoryx_dust/utility/include/iox/detail/serialization.inl index e1380f7c0f9..c31cc4129d3 100644 --- a/iceoryx_dust/utility/include/iox/detail/serialization.inl +++ b/iceoryx_dust/utility/include/iox/detail/serialization.inl @@ -94,7 +94,7 @@ inline bool Serialization::deserialize(const std::string& serializedString, T& t return false; } - if (!convert::fromString(entry.c_str(), t)) + if (!convert::from_string(entry.c_str(), t)) { return false; } @@ -111,7 +111,7 @@ inline bool Serialization::removeFirstEntry(std::string& firstEntry, std::string } uint64_t length{0}; - if (!convert::fromString(remainder.substr(0, pos).c_str(), length)) + if (!convert::from_string(remainder.substr(0, pos).c_str(), length)) { return false; } @@ -140,7 +140,7 @@ inline bool Serialization::getNth(const unsigned int index, T& t) const noexcept } } - return convert::fromString(entry.c_str(), t); + return convert::from_string(entry.c_str(), t); } } // namespace iox diff --git a/iceoryx_examples/iceperf/main_follower.cpp b/iceoryx_examples/iceperf/main_follower.cpp index b810beea531..f9b5a1e0d99 100644 --- a/iceoryx_examples/iceperf/main_follower.cpp +++ b/iceoryx_examples/iceperf/main_follower.cpp @@ -48,7 +48,7 @@ int main(int argc, char* argv[]) constexpr decltype(EXIT_SUCCESS) MOO{EXIT_SUCCESS}; uint64_t intensity{0U}; - if (!iox::convert::fromString(optarg, intensity)) + if (!iox::convert::from_string(optarg, intensity)) { std::cerr << "Could not parse 'intensity' paramater!" << std::endl; return EXIT_FAILURE; diff --git a/iceoryx_examples/iceperf/main_leader.cpp b/iceoryx_examples/iceperf/main_leader.cpp index 30b01bbb829..6e72b008330 100644 --- a/iceoryx_examples/iceperf/main_leader.cpp +++ b/iceoryx_examples/iceperf/main_leader.cpp @@ -116,7 +116,7 @@ int main(int argc, char* argv[]) } break; case 'n': - if (!iox::convert::fromString(optarg, settings.numberOfSamples)) + if (!iox::convert::from_string(optarg, settings.numberOfSamples)) { std::cerr << "Could not parse 'number-of-samples' paramater!" << std::endl; return EXIT_FAILURE; diff --git a/iceoryx_hoofs/test/moduletests/test_utility_convert.cpp b/iceoryx_hoofs/test/moduletests/test_utility_convert.cpp index a3badda763e..dd783877c65 100644 --- a/iceoryx_hoofs/test/moduletests/test_utility_convert.cpp +++ b/iceoryx_hoofs/test/moduletests/test_utility_convert.cpp @@ -109,7 +109,7 @@ TEST_F(convert_test, FromString_String) ::testing::Test::RecordProperty("TEST_ID", "22463da5-0fcb-4aa2-a7e5-68b863278a81"); std::string source = "hello"; std::string destination; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); EXPECT_THAT(source, Eq(destination)); } @@ -118,7 +118,7 @@ TEST_F(convert_test, fromString_Char_Success) ::testing::Test::RecordProperty("TEST_ID", "a15825c9-536a-4671-a502-6973490022e7"); std::string source = "h"; char destination = '\0'; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); EXPECT_THAT(source[0], Eq(destination)); } @@ -127,7 +127,7 @@ TEST_F(convert_test, fromString_Char_Fail) ::testing::Test::RecordProperty("TEST_ID", "656e87ad-6fdb-42d7-bf49-23f81a4f5a31"); std::string source = "hasd"; char destination = '\0'; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(false)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(false)); } TEST_F(convert_test, stringIsNumber_IsINTEGER) @@ -189,7 +189,7 @@ TEST_F(convert_test, fromString_FLOAT_Success) ::testing::Test::RecordProperty("TEST_ID", "d6255c3e-369e-43a0-a1ab-03f7b13d03c2"); std::string source = "123.01"; float destination = 0.0F; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); EXPECT_FLOAT_EQ(destination, 123.01F); } @@ -198,7 +198,7 @@ TEST_F(convert_test, fromString_FLOAT_Fail) ::testing::Test::RecordProperty("TEST_ID", "e2b94d50-664c-4f9e-be4f-99212c6fa165"); std::string source = "hasd"; float destination = 0.0F; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(false)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(false)); } TEST_F(convert_test, fromString_Double_Success) @@ -206,7 +206,7 @@ TEST_F(convert_test, fromString_Double_Success) ::testing::Test::RecordProperty("TEST_ID", "95ba379e-120e-4b80-a829-33fe54f1bfed"); std::string source = "123.04"; double destination = 0.0; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); EXPECT_THAT(destination, Eq(123.04)); } @@ -215,7 +215,7 @@ TEST_F(convert_test, fromString_Double_Fail) ::testing::Test::RecordProperty("TEST_ID", "f4ace11b-a056-47b1-b6c5-6fb2c58e1a06"); std::string source = "hasd"; double destination = 0.0; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(false)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(false)); } TEST_F(convert_test, fromString_LongDouble_Success) @@ -224,7 +224,7 @@ TEST_F(convert_test, fromString_LongDouble_Success) std::string source = "121.01"; long double destination = 0.0; constexpr long double VERIFY = 121.01; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); EXPECT_THAT(static_cast(destination), DoubleEq(static_cast(VERIFY))); } @@ -233,7 +233,7 @@ TEST_F(convert_test, fromString_LongDouble_Fail) ::testing::Test::RecordProperty("TEST_ID", "519f2ac5-8836-419e-8034-377230a88a09"); std::string source = "hasd"; double destination = 0.0; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(false)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(false)); } TEST_F(convert_test, fromString_UNSIGNED_Int_Success) @@ -241,7 +241,7 @@ TEST_F(convert_test, fromString_UNSIGNED_Int_Success) ::testing::Test::RecordProperty("TEST_ID", "1edb8d5f-c42d-4d02-bc31-477f48898bbb"); std::string source = "100"; unsigned int destination = 0.0; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); EXPECT_THAT(destination, Eq(100U)); } @@ -250,7 +250,7 @@ TEST_F(convert_test, fromString_UNSIGNED_Int_Fail) ::testing::Test::RecordProperty("TEST_ID", "6ce6de82-a6c0-4562-9c5c-663b93d768b3"); std::string source = "-331"; unsigned int destination = 0U; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(false)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(false)); } TEST_F(convert_test, fromString_UNSIGNED_LongInt_Success) @@ -258,7 +258,7 @@ TEST_F(convert_test, fromString_UNSIGNED_LongInt_Success) ::testing::Test::RecordProperty("TEST_ID", "054b08b2-54e1-4191-91b6-e6bec415612f"); std::string source = "999"; uint64_t destination = 0U; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); EXPECT_THAT(destination, Eq(999LU)); } @@ -267,7 +267,7 @@ TEST_F(convert_test, fromString_UNSIGNED_LongInt_Fail) ::testing::Test::RecordProperty("TEST_ID", "4b215747-90b2-4ca2-97ee-517c07597b1b"); std::string source = "-a123"; uint64_t destination = 0U; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(false)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(false)); } TEST_F(convert_test, fromString_Int_Success) @@ -275,7 +275,7 @@ TEST_F(convert_test, fromString_Int_Success) ::testing::Test::RecordProperty("TEST_ID", "9318ee60-f2e0-445a-b32d-c718cf918b18"); std::string source = "3331"; int destination = 0; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); EXPECT_THAT(destination, Eq(3331)); } @@ -284,7 +284,7 @@ TEST_F(convert_test, fromString_Int_Fail) ::testing::Test::RecordProperty("TEST_ID", "f8e698a9-054d-4441-b196-bcd58a72b1d9"); std::string source = "-+321"; int destination = 0; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(false)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(false)); } TEST_F(convert_test, fromString_ShortInt_Success) @@ -292,7 +292,7 @@ TEST_F(convert_test, fromString_ShortInt_Success) ::testing::Test::RecordProperty("TEST_ID", "e804f821-157d-4c52-81a7-75fce5a43805"); std::string source = "12345"; short destination = 0; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); EXPECT_THAT(destination, Eq(12345)); } @@ -301,7 +301,7 @@ TEST_F(convert_test, fromString_ShortInt_Fail) ::testing::Test::RecordProperty("TEST_ID", "1150066b-cb42-4055-9927-2f20fb40bc87"); std::string source = "-+123321"; short destination = 0; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(false)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(false)); } TEST_F(convert_test, fromString_Bool_Success) @@ -309,7 +309,7 @@ TEST_F(convert_test, fromString_Bool_Success) ::testing::Test::RecordProperty("TEST_ID", "893723fc-dfb8-46a4-b446-badaf8bad25a"); std::string source = "1"; bool destination = false; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); EXPECT_THAT(destination, Eq(true)); } @@ -318,7 +318,7 @@ TEST_F(convert_test, fromString_Bool_Fail) ::testing::Test::RecordProperty("TEST_ID", "1c937da6-29ea-49cf-a7d0-4c46f564c16e"); std::string source = "-+222"; bool destination = false; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(false)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(false)); } TEST_F(convert_test, fromString_UShortInt_Success) @@ -326,7 +326,7 @@ TEST_F(convert_test, fromString_UShortInt_Success) ::testing::Test::RecordProperty("TEST_ID", "99d22d80-3860-47fa-9f98-f11ff9629815"); std::string source = "333"; unsigned short destination = 0U; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); EXPECT_THAT(destination, Eq(333)); } @@ -335,7 +335,7 @@ TEST_F(convert_test, fromString_UShortInt_Fail) ::testing::Test::RecordProperty("TEST_ID", "6ab6ded6-dff3-401a-8a7f-98326da7cca6"); std::string source = "-+111"; unsigned short destination = 0U; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(false)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(false)); } TEST_F(convert_test, fromString_LongInt_Success) @@ -343,7 +343,7 @@ TEST_F(convert_test, fromString_LongInt_Success) ::testing::Test::RecordProperty("TEST_ID", "37133256-ae79-45c7-8c86-56bd33fa7bd8"); std::string source = "-1123"; int64_t destination = 0; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); EXPECT_THAT(destination, Eq(-1123L)); } @@ -352,7 +352,7 @@ TEST_F(convert_test, fromString_LongInt_Fail) ::testing::Test::RecordProperty("TEST_ID", "0e368bf3-cb16-4829-a4cc-dc56e0bde958"); std::string source = "-a121"; int64_t destination = 0; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(false)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(false)); } TEST_F(convert_test, fromString_MinMaxShort) @@ -360,13 +360,13 @@ TEST_F(convert_test, fromString_MinMaxShort) ::testing::Test::RecordProperty("TEST_ID", "98e33efd-ba39-4b88-8307-358be30e4e73"); std::string source = "32767"; int16_t destination = 0; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); source = "32768"; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(false)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(false)); source = "-32768"; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); source = "-32769"; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(false)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(false)); } TEST_F(convert_test, fromString_MinMaxUNSIGNED_Short) @@ -374,13 +374,13 @@ TEST_F(convert_test, fromString_MinMaxUNSIGNED_Short) ::testing::Test::RecordProperty("TEST_ID", "f9196939-ae5d-4c27-85bf-b3b084343261"); std::string source = "65535"; uint16_t destination = 0U; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); source = "65536"; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(false)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(false)); source = "0"; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); source = "-1"; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(false)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(false)); } TEST_F(convert_test, fromString_MinMaxInt) @@ -388,13 +388,13 @@ TEST_F(convert_test, fromString_MinMaxInt) ::testing::Test::RecordProperty("TEST_ID", "abf0fda5-044e-4f1b-bb1e-31b701578a3d"); std::string source = "2147483647"; int32_t destination = 0; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); source = "2147483648"; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(false)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(false)); source = "-2147483648"; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); source = "-2147483649"; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(false)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(false)); } TEST_F(convert_test, fromString_MinMaxUNSIGNED_Int) @@ -402,13 +402,13 @@ TEST_F(convert_test, fromString_MinMaxUNSIGNED_Int) ::testing::Test::RecordProperty("TEST_ID", "c2a832ef-3e86-4303-a98c-63c7b11ea789"); std::string source = "4294967295"; uint32_t destination = 0U; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); source = "4294967296"; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(false)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(false)); source = "0"; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); source = "-1"; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(false)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(false)); } TEST_F(convert_test, fromString_cxxString) @@ -416,15 +416,15 @@ TEST_F(convert_test, fromString_cxxString) ::testing::Test::RecordProperty("TEST_ID", "dbf015bb-5f51-47e1-9d0e-0525f65e7803"); std::string source = "hello"; iox::string<8> destination; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); source = ""; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); source = "12345678"; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(true)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(true)); source = "123456789"; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(false)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(false)); source = "this_is_a_very_long_string"; - EXPECT_THAT(iox::convert::fromString(source.c_str(), destination), Eq(false)); + EXPECT_THAT(iox::convert::from_string(source.c_str(), destination), Eq(false)); } } // namespace diff --git a/iceoryx_hoofs/utility/include/iox/detail/convert.hpp b/iceoryx_hoofs/utility/include/iox/detail/convert.hpp index faf2053b819..66e3204ae5d 100644 --- a/iceoryx_hoofs/utility/include/iox/detail/convert.hpp +++ b/iceoryx_hoofs/utility/include/iox/detail/convert.hpp @@ -40,8 +40,8 @@ namespace iox /// /// int i; /// unsigned int a; -/// if ( iox::convert::fromString("123", i) ) {} // will succeed -/// if ( iox::convert::fromString("-123", a) ) {} // will fail since -123 is not unsigned +/// if ( iox::convert::from_string("123", i) ) {} // will succeed +/// if ( iox::convert::from_string("-123", a) ) {} // will fail since -123 is not unsigned /// @endcode /// @todo iox-#260 Refactor 'convert' so that one can use 'into' to directly to convert numbers to strings: /// 'ClassExpectingAnIoxString(iox::into>(42)' @@ -81,7 +81,7 @@ class convert /// @param[in] dest destination to which the value should be written /// @return false = if the conversion fails otherwise true template - static bool fromString(const char* v, Destination& dest) noexcept; + static bool from_string(const char* v, Destination& dest) noexcept; /// @brief Sets dest from a given string. If the conversion fails false is /// returned and the value of dest is undefined. @@ -89,7 +89,7 @@ class convert /// @param[in] dest destination to which the value should be written /// @return false = if the conversion fails otherwise true template - static bool fromString(const char* v, string& dest) noexcept; + static bool from_string(const char* v, string& dest) noexcept; /// @brief checks if a given string v is a number /// @param[in] v string which contains the number diff --git a/iceoryx_hoofs/utility/include/iox/detail/convert.inl b/iceoryx_hoofs/utility/include/iox/detail/convert.inl index f2463f5ccad..86ee73aa5ee 100644 --- a/iceoryx_hoofs/utility/include/iox/detail/convert.inl +++ b/iceoryx_hoofs/utility/include/iox/detail/convert.inl @@ -58,14 +58,14 @@ convert::toString(const Source& t) noexcept } template -inline bool convert::fromString(const char* v, Destination& dest) noexcept +inline bool convert::from_string(const char* v, Destination& dest) noexcept { dest = Destination(v); return true; } template <> -inline bool convert::fromString(const char* v, char& dest) noexcept +inline bool convert::from_string(const char* v, char& dest) noexcept { if (strlen(v) != 1U) { @@ -80,7 +80,7 @@ inline bool convert::fromString(const char* v, char& dest) noexcept } template -inline bool convert::fromString(const char* v, string& dest) noexcept +inline bool convert::from_string(const char* v, string& dest) noexcept { if (strlen(v) > Capacity) { @@ -157,7 +157,7 @@ inline bool convert::stringIsNumberWithErrorMessage(const char* v, const NumberT } template <> -inline bool convert::fromString(const char* v, float& dest) noexcept +inline bool convert::from_string(const char* v, float& dest) noexcept { if (!stringIsNumberWithErrorMessage(v, NumberType::FLOAT)) { @@ -172,7 +172,7 @@ inline bool convert::fromString(const char* v, float& dest) noexcept } template <> -inline bool convert::fromString(const char* v, double& dest) noexcept +inline bool convert::from_string(const char* v, double& dest) noexcept { if (!stringIsNumberWithErrorMessage(v, NumberType::FLOAT)) { @@ -187,7 +187,7 @@ inline bool convert::fromString(const char* v, double& dest) noexcept } template <> -inline bool convert::fromString(const char* v, long double& dest) noexcept +inline bool convert::from_string(const char* v, long double& dest) noexcept { if (!stringIsNumberWithErrorMessage(v, NumberType::FLOAT)) { @@ -202,7 +202,7 @@ inline bool convert::fromString(const char* v, long double& dest) n } template <> -inline bool convert::fromString(const char* v, uint64_t& dest) noexcept +inline bool convert::from_string(const char* v, uint64_t& dest) noexcept { if (!stringIsNumberWithErrorMessage(v, NumberType::UNSIGNED_INTEGER)) { @@ -230,10 +230,10 @@ inline bool convert::fromString(const char* v, uint64_t& dest) noexcep /// introduced for mac os since unsigned long is not uint64_t despite it has the same size /// who knows why ¯\_(ツ)_/¯ template <> -inline bool convert::fromString(const char* v, unsigned long& dest) noexcept +inline bool convert::from_string(const char* v, unsigned long& dest) noexcept { uint64_t temp{0}; - bool retVal = fromString(v, temp); + bool retVal = from_string(v, temp); dest = temp; return retVal; } @@ -243,17 +243,17 @@ inline bool convert::fromString(const char* v, unsigned long& des /// introduced for 32-bit arm-none-eabi-gcc since uintptr_t is not uint32_t despite it has the same size /// who knows why ¯\_(ツ)_/¯ template <> -inline bool convert::fromString(const char* v, uintptr_t& dest) noexcept +inline bool convert::from_string(const char* v, uintptr_t& dest) noexcept { uint64_t temp{0}; - bool retVal = fromString(v, temp); + bool retVal = from_string(v, temp); dest = temp; return retVal; } #endif template <> -inline bool convert::fromString(const char* v, uint32_t& dest) noexcept +inline bool convert::from_string(const char* v, uint32_t& dest) noexcept { if (!stringIsNumberWithErrorMessage(v, NumberType::UNSIGNED_INTEGER)) { @@ -278,7 +278,7 @@ inline bool convert::fromString(const char* v, uint32_t& dest) noexcep } template <> -inline bool convert::fromString(const char* v, uint16_t& dest) noexcept +inline bool convert::from_string(const char* v, uint16_t& dest) noexcept { if (!stringIsNumberWithErrorMessage(v, NumberType::UNSIGNED_INTEGER)) { @@ -303,7 +303,7 @@ inline bool convert::fromString(const char* v, uint16_t& dest) noexcep } template <> -inline bool convert::fromString(const char* v, uint8_t& dest) noexcept +inline bool convert::from_string(const char* v, uint8_t& dest) noexcept { if (!stringIsNumberWithErrorMessage(v, NumberType::UNSIGNED_INTEGER)) { @@ -328,7 +328,7 @@ inline bool convert::fromString(const char* v, uint8_t& dest) noexcept } template <> -inline bool convert::fromString(const char* v, int64_t& dest) noexcept +inline bool convert::from_string(const char* v, int64_t& dest) noexcept { if (!stringIsNumberWithErrorMessage(v, NumberType::INTEGER)) { @@ -352,7 +352,7 @@ inline bool convert::fromString(const char* v, int64_t& dest) noexcept } template <> -inline bool convert::fromString(const char* v, int32_t& dest) noexcept +inline bool convert::from_string(const char* v, int32_t& dest) noexcept { if (!stringIsNumberWithErrorMessage(v, NumberType::INTEGER)) { @@ -376,7 +376,7 @@ inline bool convert::fromString(const char* v, int32_t& dest) noexcept } template <> -inline bool convert::fromString(const char* v, int16_t& dest) noexcept +inline bool convert::from_string(const char* v, int16_t& dest) noexcept { if (!stringIsNumberWithErrorMessage(v, NumberType::INTEGER)) { @@ -400,7 +400,7 @@ inline bool convert::fromString(const char* v, int16_t& dest) noexcept } template <> -inline bool convert::fromString(const char* v, int8_t& dest) noexcept +inline bool convert::from_string(const char* v, int8_t& dest) noexcept { if (!stringIsNumberWithErrorMessage(v, NumberType::INTEGER)) { @@ -424,7 +424,7 @@ inline bool convert::fromString(const char* v, int8_t& dest) noexcept } template <> -inline bool convert::fromString(const char* v, bool& dest) noexcept +inline bool convert::from_string(const char* v, bool& dest) noexcept { if (!stringIsNumberWithErrorMessage(v, NumberType::UNSIGNED_INTEGER)) { diff --git a/iceoryx_posh/source/roudi/port_manager.cpp b/iceoryx_posh/source/roudi/port_manager.cpp index 315c66d2317..87d64a83ab6 100644 --- a/iceoryx_posh/source/roudi/port_manager.cpp +++ b/iceoryx_posh/source/roudi/port_manager.cpp @@ -32,7 +32,7 @@ namespace roudi capro::Interfaces StringToCaProInterface(const capro::IdString_t& str) noexcept { int32_t i{0}; - convert::fromString(str.c_str(), i); + convert::from_string(str.c_str(), i); if (i >= static_cast(capro::Interfaces::INTERFACE_END)) { IOX_LOG(WARN, "invalid enum (out of range: " << i << ")"); diff --git a/iceoryx_posh/source/roudi/roudi.cpp b/iceoryx_posh/source/roudi/roudi.cpp index 5d88904dd97..c88244a5cc9 100644 --- a/iceoryx_posh/source/roudi/roudi.cpp +++ b/iceoryx_posh/source/roudi/roudi.cpp @@ -270,9 +270,9 @@ version::VersionInfo RouDi::parseRegisterMessage(const runtime::IpcMessage& mess uid_t& userId, int64_t& transmissionTimestamp) noexcept { - convert::fromString(message.getElementAtIndex(2).c_str(), pid); - convert::fromString(message.getElementAtIndex(3).c_str(), userId); - convert::fromString(message.getElementAtIndex(4).c_str(), transmissionTimestamp); + convert::from_string(message.getElementAtIndex(2).c_str(), pid); + convert::from_string(message.getElementAtIndex(3).c_str(), userId); + convert::from_string(message.getElementAtIndex(4).c_str(), transmissionTimestamp); Serialization serializationVersionInfo(message.getElementAtIndex(5)); return serializationVersionInfo; } diff --git a/iceoryx_posh/source/roudi/roudi_cmd_line_parser.cpp b/iceoryx_posh/source/roudi/roudi_cmd_line_parser.cpp index 355bbb8e2f1..5645e839f8b 100644 --- a/iceoryx_posh/source/roudi/roudi_cmd_line_parser.cpp +++ b/iceoryx_posh/source/roudi/roudi_cmd_line_parser.cpp @@ -100,7 +100,7 @@ CmdLineParser::parse(int argc, char* argv[], const CmdLineArgumentParsingMode cm { uint16_t roudiId{0u}; constexpr uint64_t MAX_ROUDI_ID = ((1 << 16) - 1); - if (!convert::fromString(optarg, roudiId)) + if (!convert::from_string(optarg, roudiId)) { IOX_LOG(ERROR, "The RouDi id must be in the range of [0, " << MAX_ROUDI_ID << "]"); m_cmdLineArgs.run = false; @@ -168,7 +168,7 @@ CmdLineParser::parse(int argc, char* argv[], const CmdLineArgumentParsingMode cm { uint32_t processTerminationDelayInSeconds{0u}; constexpr uint64_t MAX_PROCESS_TERMINATION_DELAY = std::numeric_limits::max(); - if (!convert::fromString(optarg, processTerminationDelayInSeconds)) + if (!convert::from_string(optarg, processTerminationDelayInSeconds)) { IOX_LOG(ERROR, "The process termination delay must be in the range of [0, " << MAX_PROCESS_TERMINATION_DELAY @@ -185,7 +185,7 @@ CmdLineParser::parse(int argc, char* argv[], const CmdLineArgumentParsingMode cm { uint32_t processKillDelayInSeconds{0u}; constexpr uint64_t MAX_PROCESS_KILL_DELAY = std::numeric_limits::max(); - if (!convert::fromString(optarg, processKillDelayInSeconds)) + if (!convert::from_string(optarg, processKillDelayInSeconds)) { IOX_LOG(ERROR, "The process kill delay must be in the range of [0, " << MAX_PROCESS_KILL_DELAY << "]"); m_cmdLineArgs.run = false; diff --git a/iceoryx_posh/source/runtime/ipc_interface_base.cpp b/iceoryx_posh/source/runtime/ipc_interface_base.cpp index c553d322583..8cf98ea33ac 100644 --- a/iceoryx_posh/source/runtime/ipc_interface_base.cpp +++ b/iceoryx_posh/source/runtime/ipc_interface_base.cpp @@ -30,7 +30,7 @@ IpcMessageType stringToIpcMessageType(const char* str) noexcept { std::underlying_type::type msg; bool noError = convert::stringIsNumber(str, convert::NumberType::INTEGER); - noError &= noError ? (convert::fromString(str, msg)) : false; + noError &= noError ? (convert::from_string(str, msg)) : false; noError &= noError ? !(static_cast::type>(IpcMessageType::BEGIN) >= msg || static_cast::type>(IpcMessageType::END) <= msg) : false; @@ -46,7 +46,7 @@ IpcMessageErrorType stringToIpcMessageErrorType(const char* str) noexcept { std::underlying_type::type msg; bool noError = convert::stringIsNumber(str, convert::NumberType::INTEGER); - noError &= noError ? (convert::fromString(str, msg)) : false; + noError &= noError ? (convert::from_string(str, msg)) : false; noError &= noError ? !(static_cast::type>(IpcMessageErrorType::BEGIN) >= msg || static_cast::type>(IpcMessageErrorType::END) <= msg) diff --git a/iceoryx_posh/source/runtime/ipc_runtime_interface.cpp b/iceoryx_posh/source/runtime/ipc_runtime_interface.cpp index e3e54773873..028dafd62b0 100644 --- a/iceoryx_posh/source/runtime/ipc_runtime_interface.cpp +++ b/iceoryx_posh/source/runtime/ipc_runtime_interface.cpp @@ -235,16 +235,16 @@ IpcRuntimeInterface::RegAckResult IpcRuntimeInterface::waitForRegAck(int64_t tra } // read out the shared memory base address and save it - iox::convert::fromString(receiveBuffer.getElementAtIndex(1U).c_str(), m_shmTopicSize); + iox::convert::from_string(receiveBuffer.getElementAtIndex(1U).c_str(), m_shmTopicSize); UntypedRelativePointer::offset_t segmentManagerOffset{UntypedRelativePointer::NULL_POINTER_OFFSET}; - iox::convert::fromString(receiveBuffer.getElementAtIndex(2U).c_str(), segmentManagerOffset); + iox::convert::from_string(receiveBuffer.getElementAtIndex(2U).c_str(), segmentManagerOffset); m_segmentManagerAddressOffset.emplace(segmentManagerOffset); int64_t receivedTimestamp{0U}; - iox::convert::fromString(receiveBuffer.getElementAtIndex(3U).c_str(), receivedTimestamp); - iox::convert::fromString(receiveBuffer.getElementAtIndex(4U).c_str(), m_segmentId); + iox::convert::from_string(receiveBuffer.getElementAtIndex(3U).c_str(), receivedTimestamp); + iox::convert::from_string(receiveBuffer.getElementAtIndex(4U).c_str(), m_segmentId); UntypedRelativePointer::offset_t heartbeatOffset{UntypedRelativePointer::NULL_POINTER_OFFSET}; - iox::convert::fromString(receiveBuffer.getElementAtIndex(5U).c_str(), heartbeatOffset); + iox::convert::from_string(receiveBuffer.getElementAtIndex(5U).c_str(), heartbeatOffset); /// @todo iox-#2055 this workaround is required sind the conversion of edge cases is broken constexpr uint8_t IOX_2055_WORKAROUND{1}; if (heartbeatOffset != (UntypedRelativePointer::NULL_POINTER_OFFSET - IOX_2055_WORKAROUND)) diff --git a/iceoryx_posh/source/runtime/posh_runtime_impl.cpp b/iceoryx_posh/source/runtime/posh_runtime_impl.cpp index b029657c792..e8a4e7dc514 100644 --- a/iceoryx_posh/source/runtime/posh_runtime_impl.cpp +++ b/iceoryx_posh/source/runtime/posh_runtime_impl.cpp @@ -188,9 +188,9 @@ PoshRuntimeImpl::requestPublisherFromRoudi(const IpcMessage& sendBuffer) noexcep { segment_id_underlying_t segmentId{0U}; - convert::fromString(receiveBuffer.getElementAtIndex(2U).c_str(), segmentId); + convert::from_string(receiveBuffer.getElementAtIndex(2U).c_str(), segmentId); UntypedRelativePointer::offset_t offset{0U}; - convert::fromString(receiveBuffer.getElementAtIndex(1U).c_str(), offset); + convert::from_string(receiveBuffer.getElementAtIndex(1U).c_str(), offset); auto ptr = UntypedRelativePointer::getPtr(segment_id_t{segmentId}, offset); return ok(reinterpret_cast(ptr)); } @@ -300,9 +300,9 @@ PoshRuntimeImpl::requestSubscriberFromRoudi(const IpcMessage& sendBuffer) noexce if (stringToIpcMessageType(IpcMessage.c_str()) == IpcMessageType::CREATE_SUBSCRIBER_ACK) { segment_id_underlying_t segmentId{0U}; - convert::fromString(receiveBuffer.getElementAtIndex(2U).c_str(), segmentId); + convert::from_string(receiveBuffer.getElementAtIndex(2U).c_str(), segmentId); UntypedRelativePointer::offset_t offset{0U}; - convert::fromString(receiveBuffer.getElementAtIndex(1U).c_str(), offset); + convert::from_string(receiveBuffer.getElementAtIndex(1U).c_str(), offset); auto ptr = UntypedRelativePointer::getPtr(segment_id_t{segmentId}, offset); return ok(reinterpret_cast(ptr)); } @@ -408,9 +408,9 @@ PoshRuntimeImpl::requestClientFromRoudi(const IpcMessage& sendBuffer) noexcept if (stringToIpcMessageType(IpcMessage.c_str()) == IpcMessageType::CREATE_CLIENT_ACK) { segment_id_underlying_t segmentId{0U}; - convert::fromString(receiveBuffer.getElementAtIndex(2U).c_str(), segmentId); + convert::from_string(receiveBuffer.getElementAtIndex(2U).c_str(), segmentId); UntypedRelativePointer::offset_t offset{0U}; - convert::fromString(receiveBuffer.getElementAtIndex(1U).c_str(), offset); + convert::from_string(receiveBuffer.getElementAtIndex(1U).c_str(), offset); auto ptr = UntypedRelativePointer::getPtr(segment_id_t{segmentId}, offset); return ok(reinterpret_cast(ptr)); } @@ -516,9 +516,9 @@ PoshRuntimeImpl::requestServerFromRoudi(const IpcMessage& sendBuffer) noexcept if (stringToIpcMessageType(IpcMessage.c_str()) == IpcMessageType::CREATE_SERVER_ACK) { segment_id_underlying_t segmentId{0U}; - convert::fromString(receiveBuffer.getElementAtIndex(2U).c_str(), segmentId); + convert::from_string(receiveBuffer.getElementAtIndex(2U).c_str(), segmentId); UntypedRelativePointer::offset_t offset{0U}; - convert::fromString(receiveBuffer.getElementAtIndex(1U).c_str(), offset); + convert::from_string(receiveBuffer.getElementAtIndex(1U).c_str(), offset); auto ptr = UntypedRelativePointer::getPtr(segment_id_t{segmentId}, offset); return ok(reinterpret_cast(ptr)); } @@ -560,9 +560,9 @@ popo::InterfacePortData* PoshRuntimeImpl::getMiddlewareInterface(const capro::In if (stringToIpcMessageType(IpcMessage.c_str()) == IpcMessageType::CREATE_INTERFACE_ACK) { segment_id_underlying_t segmentId{0U}; - convert::fromString(receiveBuffer.getElementAtIndex(2U).c_str(), segmentId); + convert::from_string(receiveBuffer.getElementAtIndex(2U).c_str(), segmentId); UntypedRelativePointer::offset_t offset{0U}; - convert::fromString(receiveBuffer.getElementAtIndex(1U).c_str(), offset); + convert::from_string(receiveBuffer.getElementAtIndex(1U).c_str(), offset); auto ptr = UntypedRelativePointer::getPtr(segment_id_t{segmentId}, offset); return reinterpret_cast(ptr); } @@ -594,9 +594,9 @@ NodeData* PoshRuntimeImpl::createNode(const NodeProperty& nodeProperty) noexcept if (stringToIpcMessageType(IpcMessage.c_str()) == IpcMessageType::CREATE_NODE_ACK) { segment_id_underlying_t segmentId{0U}; - convert::fromString(receiveBuffer.getElementAtIndex(2U).c_str(), segmentId); + convert::from_string(receiveBuffer.getElementAtIndex(2U).c_str(), segmentId); UntypedRelativePointer::offset_t offset{0U}; - convert::fromString(receiveBuffer.getElementAtIndex(1U).c_str(), offset); + convert::from_string(receiveBuffer.getElementAtIndex(1U).c_str(), offset); auto ptr = UntypedRelativePointer::getPtr(segment_id_t{segmentId}, offset); return reinterpret_cast(ptr); } @@ -623,9 +623,9 @@ PoshRuntimeImpl::requestConditionVariableFromRoudi(const IpcMessage& sendBuffer) if (stringToIpcMessageType(IpcMessage.c_str()) == IpcMessageType::CREATE_CONDITION_VARIABLE_ACK) { segment_id_underlying_t segmentId{0U}; - convert::fromString(receiveBuffer.getElementAtIndex(2U).c_str(), segmentId); + convert::from_string(receiveBuffer.getElementAtIndex(2U).c_str(), segmentId); UntypedRelativePointer::offset_t offset{0U}; - convert::fromString(receiveBuffer.getElementAtIndex(1U).c_str(), offset); + convert::from_string(receiveBuffer.getElementAtIndex(1U).c_str(), offset); auto ptr = UntypedRelativePointer::getPtr(segment_id_t{segmentId}, offset); return ok(reinterpret_cast(ptr)); } diff --git a/tools/introspection/source/introspection_app.cpp b/tools/introspection/source/introspection_app.cpp index a3ea91f5f5c..4ceb70ca553 100644 --- a/tools/introspection/source/introspection_app.cpp +++ b/tools/introspection/source/introspection_app.cpp @@ -102,7 +102,7 @@ void IntrospectionApp::parseCmdLineArguments(int argc, case 't': { uint64_t newUpdatePeriodMs; - if (convert::fromString(optarg, newUpdatePeriodMs)) + if (convert::from_string(optarg, newUpdatePeriodMs)) { iox::units::Duration rate = iox::units::Duration::fromMilliseconds(newUpdatePeriodMs); updatePeriodMs = bounded(rate, MIN_UPDATE_PERIOD, MAX_UPDATE_PERIOD);