[common][messaging] Move toLowerCase from messaging to common module 26/224026/1
authorPawel Wasowski <p.wasowski2@samsung.com>
Wed, 5 Feb 2020 13:00:47 +0000 (14:00 +0100)
committerPawel Wasowski <p.wasowski2@samsung.com>
Wed, 5 Feb 2020 15:54:57 +0000 (16:54 +0100)
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 <p.wasowski2@samsung.com>
src/common/tools.cc
src/common/tools.h
src/messaging/MsgCommon/AbstractFilter.cpp

index d23347c..6e79ee6 100644 (file)
@@ -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
index 73acde6..17e1e98 100644 (file)
@@ -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
 
index 217a96e..d66ff96 100644 (file)
@@ -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: {