From: Pawel Wasowski Date: Wed, 5 Feb 2020 13:00:47 +0000 (+0100) Subject: [common][messaging] Move toLowerCase from messaging to common module X-Git-Tag: accepted/tizen/unified/20200213.121556~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F26%2F224026%2F1;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [common][messaging] Move toLowerCase from messaging to common module The function is generic and may be used in modules other than messaging. Function name was changed to comply with Google C++ coding style. Change-Id: I52053780fb6f860fe7fcc1e0c7c1d912ecdd85f9 Verification: auto tct-messaging-{email,sms,mms}-tizen-tests pass rate: 100% Signed-off-by: Pawel Wasowski --- diff --git a/src/common/tools.cc b/src/common/tools.cc index d23347c..6e79ee6 100644 --- a/src/common/tools.cc +++ b/src/common/tools.cc @@ -590,5 +590,11 @@ void PrintDeprecationWarningFor(const char* className, const char* replacement) } } +std::string ConvertToLowerCase(const std::string& input_string) { + std::string output_string = input_string; + std::transform(output_string.begin(), output_string.end(), output_string.begin(), ::tolower); + return output_string; +} + } // namespace tools } // namespace common diff --git a/src/common/tools.h b/src/common/tools.h index 73acde6..17e1e98 100644 --- a/src/common/tools.h +++ b/src/common/tools.h @@ -119,6 +119,8 @@ PlatformResult CheckFileAvailability(const std::string& path); void PrintDeprecationWarningFor(const char* className, const char* replacement = nullptr); +std::string ConvertToLowerCase(const std::string& input_string); + } // namespace tools } // namespace common diff --git a/src/messaging/MsgCommon/AbstractFilter.cpp b/src/messaging/MsgCommon/AbstractFilter.cpp index 217a96e..d66ff96 100644 --- a/src/messaging/MsgCommon/AbstractFilter.cpp +++ b/src/messaging/MsgCommon/AbstractFilter.cpp @@ -25,6 +25,7 @@ namespace extension { namespace tizen { using namespace common; +using namespace common::tools; AbstractFilter::AbstractFilter(FilterType filter_type) : m_filter_type(filter_type) { ScopeLogger(); @@ -50,12 +51,6 @@ bool AbstractFilter::isMatching(const picojson::value& json) const { namespace { -std::string convertToLowerCase(const std::string& input_string) { - std::string output_string = input_string; - std::transform(output_string.begin(), output_string.end(), output_string.begin(), ::tolower); - return output_string; -} - // This function assumes, that the flag is not "EXISTS" bool isMatchingString(const std::string& match_value, const std::string& value, AttributeMatchFlag flag) { @@ -73,8 +68,8 @@ bool isMatchingString(const std::string& match_value, const std::string& value, if (match_value.size() > value.size()) { return false; } - std::string lvalue = convertToLowerCase(value); - std::string lmatch_value = convertToLowerCase(match_value); + std::string lvalue = ConvertToLowerCase(value); + std::string lmatch_value = ConvertToLowerCase(match_value); return lvalue.substr(lvalue.size() - lmatch_value.size(), lmatch_value.size()) == lmatch_value; } @@ -90,8 +85,8 @@ bool isMatchingString(const std::string& match_value, const std::string& value, if (match_value.size() > value.size()) { return false; } - std::string lvalue = convertToLowerCase(value); - std::string lmatch_value = convertToLowerCase(match_value); + std::string lvalue = ConvertToLowerCase(value); + std::string lmatch_value = ConvertToLowerCase(match_value); return lvalue.substr(0, lmatch_value.size()) == lmatch_value; } @@ -102,13 +97,13 @@ bool isMatchingString(const std::string& match_value, const std::string& value, if (match_value.size() > value.size()) { return false; } - std::string lvalue = convertToLowerCase(value); - std::string lmatch_value = convertToLowerCase(match_value); + std::string lvalue = ConvertToLowerCase(value); + std::string lmatch_value = ConvertToLowerCase(match_value); return lvalue.find(lmatch_value) != std::string::npos; } case AttributeMatchFlag::kFullString: { - return convertToLowerCase(match_value) == convertToLowerCase(value); + return ConvertToLowerCase(match_value) == ConvertToLowerCase(value); } default: {