From f8440aa0e59925fdfcfd4d9708ac23f3562404c3 Mon Sep 17 00:00:00 2001 From: jbeder Date: Wed, 15 Jul 2009 20:47:51 +0000 Subject: [PATCH] Patched to read into std::wstring --- include/conversion.h | 3 +++ src/conversion.cpp | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/conversion.h b/include/conversion.h index 208a1ef..8c06191 100644 --- a/include/conversion.h +++ b/include/conversion.h @@ -32,4 +32,7 @@ namespace YAML template <> bool Converter::Convert(const std::string& input, bool& output); + + template <> + bool Converter::Convert(const std::string& input, std::wstring& output); } diff --git a/src/conversion.cpp b/src/conversion.cpp index 0b34501..7a55e1c 100644 --- a/src/conversion.cpp +++ b/src/conversion.cpp @@ -1,6 +1,6 @@ #include "conversion.h" #include - +#include //////////////////////////////////////////////////////////////// // Specializations for converting a string to specific types @@ -82,5 +82,19 @@ namespace YAML return false; } + + template <> + bool Converter::Convert(const std::string& input, std::wstring& output) + { + output.clear(); + output.resize(std::mbstowcs(NULL, input.data(), input.size())); + std::mbstowcs( + (wchar_t *) output.data(), + input.data(), + input.size() + ); + + return true; + } }