secureswitools/swisistools/source/interpretsislib/utils_win32.cpp
branchRCL_3
changeset 81 42552535c1ac
parent 66 8b7f4e561641
--- a/secureswitools/swisistools/source/interpretsislib/utils_win32.cpp	Wed Sep 15 12:20:42 2010 +0300
+++ b/secureswitools/swisistools/source/interpretsislib/utils_win32.cpp	Wed Oct 13 14:40:19 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -273,3 +273,71 @@
 
 	return 0;
 }
+std::string Utils::wstring2string (const std::wstring& aWide)
+	{
+	int max = WideCharToMultiByte(CP_OEMCP,0,aWide.c_str(),aWide.length(),0,0,0,0);
+	std::string reply;
+	if (max > 0 )
+		{
+		char* buffer = new char [max];
+		try
+			{
+			WideCharToMultiByte(CP_OEMCP,0,aWide.c_str(),aWide.length(),buffer,max,0,0);
+			reply = std::string (buffer, max);
+			}
+		catch (...)
+			{
+			}
+		delete [] buffer;
+		}
+	return reply;
+	}
+
+std::wstring Utils::string2wstring (const std::string& aNarrow)
+	{
+	int max = MultiByteToWideChar(CP_OEMCP,0,aNarrow.c_str(),aNarrow.length(),0,0);
+	std::wstring reply;
+	if (max > 0 )
+		{
+		wchar_t* buffer = new wchar_t [max];
+		try
+			{
+			MultiByteToWideChar(CP_OEMCP,0,aNarrow.c_str(),aNarrow.length(),buffer,max);
+			reply = std::wstring (buffer, max);
+			}
+		catch (...)
+			{
+			}
+		delete [] buffer;
+		}
+	return reply;
+	}
+
+const std::wstring Utils::IntegerToWideString(int aInt)
+	{
+	std::wstringstream wstream;
+	wstream << aInt;
+	return wstream.str();
+	}
+
+std::wstring Utils::Int64ToWideString(TInt64 aInt)
+	{
+	wchar_t wint[20];
+	
+#ifdef _MSC_VER
+	swprintf(wint, L"%I64u", aInt);
+#else
+	swprintf(wint, 20, L"%I64u", aInt);
+#endif // _MSC_VER
+	
+	std::wstring strInt64(wint);
+	return strInt64;
+	}
+
+int Utils::WideStringToInteger(const std::wstring& aWideString)
+	{
+	unsigned long int value=0;
+	std::wstringstream str(aWideString);
+	str >> value;
+	return value;
+	}