*/
#include <sstream>
#include <limits>
-#include <dpl/scoped_array.h>
#include <dpl/scoped_free.h>
#include "ScopedJSStringRef.h"
#include "Converter.h"
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;
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.
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;