You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2021/10/29 11:14:17 UTC
[GitHub] [nifi-minifi-cpp] martinzink commented on a change in pull request #1168: MINIFICPP-1632 - Implement RouteText processor
martinzink commented on a change in pull request #1168:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1168#discussion_r739138508
##########
File path: libminifi/include/utils/StringUtils.h
##########
@@ -146,22 +160,28 @@ class StringUtils {
static std::string& replaceAll(std::string& source_string, const std::string &from_string, const std::string &to_string);
- inline static bool endsWithIgnoreCase(const std::string &value, const std::string & endString) {
- if (endString.size() > value.size())
+ inline static bool startsWith(const std::string_view& value, const std::string_view& start, bool case_sensitive = true) {
+ if (start.length() > value.length()) {
return false;
- return std::equal(endString.rbegin(), endString.rend(), value.rbegin(), [](unsigned char lc, unsigned char rc) {return tolower(lc) == tolower(rc);});
+ }
+ if (case_sensitive) {
+ return std::equal(start.begin(), start.end(), value.begin());
+ }
+ return std::equal(start.begin(), start.end(), value.begin(), [](unsigned char lc, unsigned char rc) {return tolower(lc) == tolower(rc);});
}
- inline static bool startsWith(const std::string& value, const std::string& start_string) {
- if (start_string.size() > value.size())
+ inline static bool endsWith(const std::string_view& value, const std::string_view& end, bool case_sensitive = true) {
+ if (end.length() > value.length()) {
return false;
- return std::equal(start_string.begin(), start_string.end(), value.begin());
+ }
+ if (case_sensitive) {
+ return std::equal(end.rbegin(), end.rend(), value.rbegin());
+ }
+ return std::equal(end.rbegin(), end.rend(), value.rbegin(), [](unsigned char lc, unsigned char rc) {return tolower(lc) == tolower(rc);});
}
- inline static bool endsWith(const std::string& value, const std::string& end_string) {
- if (end_string.size() > value.size())
- return false;
- return std::equal(end_string.rbegin(), end_string.rend(), value.rbegin());
+ inline static bool endsWithIgnoreCase(const std::string_view& value, const std::string_view& endString) {
Review comment:
I find it strange that we have this, but dont have startsWithIgnoreCase
##########
File path: libminifi/include/utils/ProcessorConfigUtils.h
##########
@@ -38,6 +38,19 @@ std::chrono::milliseconds parseTimePropertyMSOrThrow(core::ProcessContext* conte
std::optional<uint64_t> getOptionalUintProperty(const core::ProcessContext& context, const std::string& property_name);
std::string parsePropertyWithAllowableValuesOrThrow(const core::ProcessContext& context, const std::string& property_name, const std::set<std::string>& allowable_values);
+template<typename T>
+T parseEnumProperty(const core::ProcessContext& context, const core::Property& prop) {
Review comment:
I really like this :+1:
Could you please add some tests to verify its behaviour?
##########
File path: libminifi/include/utils/StringUtils.h
##########
@@ -146,22 +160,28 @@ class StringUtils {
static std::string& replaceAll(std::string& source_string, const std::string &from_string, const std::string &to_string);
- inline static bool endsWithIgnoreCase(const std::string &value, const std::string & endString) {
- if (endString.size() > value.size())
+ inline static bool startsWith(const std::string_view& value, const std::string_view& start, bool case_sensitive = true) {
Review comment:
I think we should also add a couple of case insensitive tests to TestStringUtils::startsWith and TestStringUtils::endsWith now that this is a feature.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org