tizen 2.4 release
[framework/web/wrt-plugins-common.git] / src / CommonsJavaScript / Converter.cpp
similarity index 95%
rename from src_wearable/CommonsJavaScript/Converter.cpp
rename to src/CommonsJavaScript/Converter.cpp
index 0eccb60..0b03a82 100644 (file)
@@ -15,7 +15,6 @@
  */
 #include <sstream>
 #include <limits>
-#include <dpl/scoped_array.h>
 #include <dpl/scoped_free.h>
 #include "ScopedJSStringRef.h"
 #include "Converter.h"
@@ -159,13 +158,13 @@ std::string Converter::toString(const JSStringRef& arg)
     size_t jsSize = JSStringGetMaximumUTF8CStringSize(arg);
     if (jsSize > 0) {
         jsSize = jsSize + 1;
-        DPL::ScopedArray<char> buffer(new char[jsSize]);
-        size_t written = JSStringGetUTF8CString(arg, buffer.Get(), jsSize);
+        std::unique_ptr<char[]> buffer(new char[jsSize]);
+        size_t written = JSStringGetUTF8CString(arg, buffer.get(), jsSize);
         if (written > jsSize) {
             ThrowMsg(ConversionException,
                      "Conversion could not be fully performed.");
         }
-        result = buffer.Get();
+        result = buffer.get();
     }
 
     return result;
@@ -179,20 +178,22 @@ time_t Converter::toDateTimeT(const JSValueRef& arg)
 
 tm Converter::toDateTm(const JSValueRef& arg)
 {
+    using namespace std::placeholders;
+
     std::string stringDate = toDateString(arg);
     struct tm result;
     char* currentLocale = setlocale(LC_TIME, NULL);
     if (currentLocale == NULL) {
         ThrowMsg(ConversionException, "Couldn't get current locale.");
     }
-    DPL::ScopedFree<char> currentLocaleCopy(strdup(currentLocale));
+    std::unique_ptr<char, void(*)(void*)> currentLocaleCopy(strdup(currentLocale), &free);
     if (setlocale(LC_TIME, "C") == NULL) {
         ThrowMsg(ConversionException, "Couldn't set POSIX locale.");
     }
     if (strptime(stringDate.c_str(), "%a %b %d %Y %T", &result) == NULL) {
         ThrowMsg(ConversionException, "Couldn't convert supplied date.");
     }
-    if (setlocale(LC_TIME, currentLocaleCopy.Get()) == NULL) {
+    if (setlocale(LC_TIME, currentLocaleCopy.get()) == NULL) {
         ThrowMsg(ConversionException, "Couldn't set previous locale back.");
     }
     //strptime function doesn't affect tm_isdst flag.
@@ -370,9 +371,9 @@ std::string Converter::toString_(const JSValueRef& arg)
 
     size_t jsSize = JSStringGetMaximumUTF8CStringSize(str);
     if (jsSize > 0) {
-        DPL::ScopedArray<char> buffer(new char[jsSize]);
-        JSStringGetUTF8CString(str, buffer.Get(), jsSize);
-        result = buffer.Get();
+        std::unique_ptr<char[]> buffer(new char[jsSize]);
+        JSStringGetUTF8CString(str, buffer.get(), jsSize);
+        result = buffer.get();
     }
     JSStringRelease(str);
     return result;