tizen 2.4 release
[framework/web/wrt-commons.git] / modules / core / src / string.cpp
similarity index 91%
rename from modules_mobile/core/src/string.cpp
rename to modules/core/src/string.cpp
index e81ae22..26acbce 100644 (file)
  * @version     1.0
  */
 #include <stddef.h>
+#include <memory>
 #include <dpl/string.h>
 #include <dpl/char_traits.h>
 #include <dpl/errno_string.h>
 #include <dpl/exception.h>
-#include <dpl/scoped_array.h>
-#include <dpl/log/log.h>
+#include <dpl/log/wrt_log.h>
 #include <string>
 #include <vector>
 #include <algorithm>
@@ -181,7 +181,7 @@ String FromUTF32String(const std::wstring& aString)
 
 static UChar *ConvertToICU(const String &inputString)
 {
-    ScopedArray<UChar> outputString;
+    std::unique_ptr<UChar[]> outputString;
     int32_t size = 0;
     int32_t convertedSize = 0;
     UErrorCode error = U_ZERO_ERROR;
@@ -198,7 +198,7 @@ static UChar *ConvertToICU(const String &inputString)
         error == U_BUFFER_OVERFLOW_ERROR)
     {
         // What buffer size is ok ?
-        LogPedantic("ICU: Output buffer size: " << size);
+        WrtLogD("ICU: Output buffer size: %i", size);
     } else {
         ThrowMsg(StringException::ICUInvalidCharacterFound,
                  "ICU: Failed to retrieve output string size. Error: "
@@ -206,13 +206,13 @@ static UChar *ConvertToICU(const String &inputString)
     }
 
     // Allocate proper buffer
-    outputString.Reset(new UChar[size + 1]);
-    ::memset(outputString.Get(), 0, sizeof(UChar) * (size + 1));
+    outputString.reset(new UChar[size + 1]);
+    ::memset(outputString.get(), 0, sizeof(UChar) * (size + 1));
 
     error = U_ZERO_ERROR;
 
     // Do conversion
-    ::u_strFromWCS(outputString.Get(),
+    ::u_strFromWCS(outputString.get(),
                    size + 1,
                    &convertedSize,
                    inputString.c_str(),
@@ -225,7 +225,7 @@ static UChar *ConvertToICU(const String &inputString)
     }
 
     // Done
-    return outputString.Release();
+    return outputString.release();
 }
 
 int StringCompare(const String &left,
@@ -233,13 +233,13 @@ int StringCompare(const String &left,
                   bool caseInsensitive)
 {
     // Convert input strings
-    ScopedArray<UChar> leftICU(ConvertToICU(left));
-    ScopedArray<UChar> rightICU(ConvertToICU(right));
+    std::unique_ptr<UChar[]> leftICU(ConvertToICU(left));
+    std::unique_ptr<UChar[]> rightICU(ConvertToICU(right));
 
     if (caseInsensitive) {
-        return static_cast<int>(u_strcasecmp(leftICU.Get(), rightICU.Get(), 0));
+        return static_cast<int>(u_strcasecmp(leftICU.get(), rightICU.get(), 0));
     } else {
-        return static_cast<int>(u_strcmp(leftICU.Get(), rightICU.Get()));
+        return static_cast<int>(u_strcmp(leftICU.get(), rightICU.get()));
     }
 }
 } //namespace DPL