* @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>
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;
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: "
}
// 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(),
}
// Done
- return outputString.Release();
+ return outputString.release();
}
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