This is an automated email from the ASF dual-hosted git repository.
martinzink pushed a commit to branch minifi-api-property
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
The following commit(s) were added to refs/heads/minifi-api-property by this
push:
new 690349420 review changes
690349420 is described below
commit 69034942006bc7ddf0c091b5b4c621cf6436a0b3
Author: Martin Zink <[email protected]>
AuthorDate: Mon Apr 7 15:42:07 2025 +0200
review changes
---
extensions/sftp/processors/PutSFTP.cpp | 2 +-
libminifi/test/unit/ParsingUtilsTests.cpp | 30 +++++++++++-----------
utils/include/utils/ParsingUtils.h | 2 +-
.../utils/detail/MonadicOperationWrappers.h | 8 +++---
utils/src/utils/ParsingUtils.cpp | 2 +-
5 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/extensions/sftp/processors/PutSFTP.cpp
b/extensions/sftp/processors/PutSFTP.cpp
index 348f78371..9d356d178 100644
--- a/extensions/sftp/processors/PutSFTP.cpp
+++ b/extensions/sftp/processors/PutSFTP.cpp
@@ -101,7 +101,7 @@ bool PutSFTP::processOne(core::ProcessContext& context,
core::ProcessSession& se
auto last_modified_ = utils::parseOptionalProperty(context,
LastModifiedTime, flow_file.get())
| utils::andThen(utils::timeutils::parseDateTimeStr);
- std::optional<uint32_t> permissions = context.getProperty(Permissions,
flow_file.get()) | utils::andThen(parsing::parsePermissions) |
utils::toOptional();
+ std::optional<uint32_t> permissions = context.getProperty(Permissions,
flow_file.get()) | utils::andThen(parsing::parseUnixOctalPermissions) |
utils::toOptional();
std::optional<uint64_t> remote_owner =
utils::parseOptionalU64Property(context, RemoteOwner, flow_file.get());
std::optional<uint64_t> remote_group =
utils::parseOptionalU64Property(context, RemoteGroup, flow_file.get());
diff --git a/libminifi/test/unit/ParsingUtilsTests.cpp
b/libminifi/test/unit/ParsingUtilsTests.cpp
index 85cf45795..1783ccffb 100644
--- a/libminifi/test/unit/ParsingUtilsTests.cpp
+++ b/libminifi/test/unit/ParsingUtilsTests.cpp
@@ -55,25 +55,25 @@ TEST_CASE("Test data size parsing") {
}
TEST_CASE("Test Permissions Parsing") {
- CHECK(0777U == parsePermissions("0777"));
- CHECK(0000U == parsePermissions("0000"));
- CHECK(0644U == parsePermissions("0644"));
+ CHECK(0777U == parseUnixOctalPermissions("0777"));
+ CHECK(0000U == parseUnixOctalPermissions("0000"));
+ CHECK(0644U == parseUnixOctalPermissions("0644"));
- CHECK_FALSE(parsePermissions("0999"));
- CHECK_FALSE(parsePermissions("999"));
- CHECK_FALSE(parsePermissions("0644a"));
- CHECK_FALSE(parsePermissions("07777"));
+ CHECK_FALSE(parseUnixOctalPermissions("0999"));
+ CHECK_FALSE(parseUnixOctalPermissions("999"));
+ CHECK_FALSE(parseUnixOctalPermissions("0644a"));
+ CHECK_FALSE(parseUnixOctalPermissions("07777"));
- CHECK(0777U == parsePermissions("rwxrwxrwx"));
- CHECK(0000U == parsePermissions("---------"));
- CHECK(0764U == parsePermissions("rwxrw-r--"));
- CHECK(0444U == parsePermissions("r--r--r--"));
+ CHECK(0777U == parseUnixOctalPermissions("rwxrwxrwx"));
+ CHECK(0000U == parseUnixOctalPermissions("---------"));
+ CHECK(0764U == parseUnixOctalPermissions("rwxrw-r--"));
+ CHECK(0444U == parseUnixOctalPermissions("r--r--r--"));
- CHECK_FALSE(parsePermissions("wxrwxrwxr"));
- CHECK_FALSE(parsePermissions("foobarfoo"));
- CHECK_FALSE(parsePermissions("foobar"));
+ CHECK_FALSE(parseUnixOctalPermissions("wxrwxrwxr"));
+ CHECK_FALSE(parseUnixOctalPermissions("foobarfoo"));
+ CHECK_FALSE(parseUnixOctalPermissions("foobar"));
- CHECK_FALSE(parsePermissions("0644 banana"));
+ CHECK_FALSE(parseUnixOctalPermissions("0644 banana"));
}
TEST_CASE("Test Duration Parsing") {
diff --git a/utils/include/utils/ParsingUtils.h
b/utils/include/utils/ParsingUtils.h
index 0b68a48f5..6657afa7a 100644
--- a/utils/include/utils/ParsingUtils.h
+++ b/utils/include/utils/ParsingUtils.h
@@ -40,7 +40,7 @@ nonstd::expected<TargetDuration, std::error_code>
parseDuration(std::string_view
nonstd::expected<uint64_t, std::error_code>
parseDataSizeMinMax(std::string_view input, uint64_t minimum, uint64_t maximum);
nonstd::expected<uint64_t, std::error_code> parseDataSize(std::string_view
input);
-nonstd::expected<uint32_t, std::error_code> parsePermissions(std::string_view
input);
+nonstd::expected<uint32_t, std::error_code>
parseUnixOctalPermissions(std::string_view input);
template<std::integral T>
diff --git a/utils/include/utils/detail/MonadicOperationWrappers.h
b/utils/include/utils/detail/MonadicOperationWrappers.h
index 7c491643b..2eed3a752 100644
--- a/utils/include/utils/detail/MonadicOperationWrappers.h
+++ b/utils/include/utils/detail/MonadicOperationWrappers.h
@@ -58,11 +58,11 @@ struct to_expected_wrapper {
};
struct or_throw_wrapper {
- std::string reason;
+ std::string_view reason{};
};
struct or_terminate_wrapper {
- std::string reason;
+ std::string_view reason{};
};
} // namespace detail
@@ -121,12 +121,12 @@ inline detail::to_optional_wrapper toOptional() noexcept
{ return {}; }
* For optional-like types, returns the present value or throws with the
provided message
* It is recommended that expect messages are used to describe the reason you
expect the optional-like to have value.
*/
-inline detail::or_throw_wrapper orThrow(std::string&& exception_message)
noexcept { return {std::forward<std::string>(std::move(exception_message))}; }
+inline detail::or_throw_wrapper orThrow(const std::string_view
exception_message) noexcept { return {exception_message}; }
/**
* For optional-like types, returns the present value or aborts with the
provided message
*/
-inline detail::or_terminate_wrapper orTerminate(std::string&&
exception_message) noexcept { return
{std::forward<std::string>(std::move(exception_message))}; }
+inline detail::or_terminate_wrapper orTerminate(const std::string_view
exception_message) noexcept { return {exception_message}; }
/**
diff --git a/utils/src/utils/ParsingUtils.cpp b/utils/src/utils/ParsingUtils.cpp
index e7f5beb52..cf907d0e7 100644
--- a/utils/src/utils/ParsingUtils.cpp
+++ b/utils/src/utils/ParsingUtils.cpp
@@ -87,7 +87,7 @@ nonstd::expected<uint64_t, std::error_code>
parseDataSize(const std::string_view
return parseDataSizeMinMax(input, std::numeric_limits<uint64_t>::min(),
std::numeric_limits<uint64_t>::max());
}
-nonstd::expected<uint32_t, std::error_code> parsePermissions(const
std::string_view input) {
+nonstd::expected<uint32_t, std::error_code> parseUnixOctalPermissions(const
std::string_view input) {
uint32_t result = 0U;
if (input.size() == 9U) {
/* Probably rwxrwxrwx formatted */