Click here to Skip to main content
13,295,987 members (48,787 online)
Click here to Skip to main content

Stats

27.6K views
459 downloads
28 bookmarked
Posted 12 Apr 2016

Linq-To-XML Style of Node Creation for C++

, 12 Apr 2016
Linq-To-XML Node Creation for Native C++
BuildProcessTemplates
Elmax.vsmdi
ElmaxNet
Properties
Elmax
Elmax.vcxproj.user
StringUtils
Local.testsettings
TestNativeElmax
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax
Properties
TestNetElmax.csproj.user
TraceAndTestImpact.testsettings
TryoutNet
Properties
Tryout
res
Tryout.ico
Tryout.vcxproj.user
Elmax.vsmdi
Elmax.vcxproj.user
Local.testsettings
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax.csproj.user
TraceAndTestImpact.testsettings
Tryout.ico
Tryout.vcxproj.user
Elmax.vsmdi
Elmax.vcxproj.user
Local.testsettings
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax.csproj.user
TraceAndTestImpact.testsettings
Tryout.ico
Tryout.vcxproj.user
Elmax.vsmdi
Elmax.vcxproj.user
Local.testsettings
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax.csproj.user
TraceAndTestImpact.testsettings
Tryout.ico
Tryout.vcxproj.user
Elmax.vsmdi
Elmax.vcxproj.user
Local.testsettings
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax.csproj.user
TraceAndTestImpact.testsettings
Tryout.ico
Tryout.vcxproj.user
Elmax.vsmdi
Elmax.vcxproj.user
Local.testsettings
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax.csproj.user
TraceAndTestImpact.testsettings
Tryout.ico
Tryout.vcxproj.user
Elmax-ver089
Elmax.vsmdi
Elmax
Elmax.vcxproj.user
StringUtils
ElmaxNet
Properties
Local.testsettings
TestNativeElmax
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax
Properties
TestNetElmax.csproj.user
TraceAndTestImpact.testsettings
Tryout
res
Tryout.ico
Tryout.vcxproj.user
TryoutNet
Properties
Elmax.vsmdi
Elmax.vcxproj.user
Local.testsettings
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax.csproj.user
TraceAndTestImpact.testsettings
Tryout.ico
Tryout.vcxproj.user
#include "StdAfx.h"
#include "StringUtils.h"
#include "..\\BaseConverter.h"

using namespace Elmax;
std::wstring ToStr(bool val)
{
	std::wstring dest;

	if(val)
		dest = L"true";
	else
		dest = L"false";

	return dest;
}

std::wstring ToStr(char val)
{
	std::wstring dest;

	dest = val;

	return dest;
}

std::wstring ToStr(short val)
{
	std::wstring dest;

	const int size = 20;
	wchar_t buf[size];
	memset( buf, 0, sizeof(buf) );
	errno_t nRet = _itow_s( val, buf, size, 10 );

	dest = L"0";
	if( 0 == nRet )
		dest = buf;

	return dest;
}

std::wstring ToStr(int val)
{
	std::wstring dest;

	const int size = 20;
	wchar_t buf[size];
	memset( buf, 0, sizeof(buf) );
	errno_t nRet = _itow_s( val, buf, size, 10 );

	dest = L"0";
	if( 0 == nRet )
		dest = buf;

	return dest;
}

std::wstring ToStr(__int64 val)
{
	std::wstring dest;

	const int size = 30;
	wchar_t buf[size];
	memset( buf, 0, sizeof(buf) );
	errno_t nRet = _i64tow_s( val, buf, size, 10 );

	dest = L"0";
	if( 0 == nRet )
		dest = buf;

	return dest;
}

std::wstring ToStr(unsigned char val)
{
	std::wstring dest;

	const int size = 20;
	wchar_t buf[size];
	memset( buf, 0, sizeof(buf) );
	errno_t nRet = _ultow_s( val, buf, size, 10 );

	dest = L"0";
	if( 0 == nRet )
		dest = buf;

	return dest;
}

std::wstring ToStr(unsigned short val)
{
	std::wstring dest;

	const int size = 20;
	wchar_t buf[size];
	memset( buf, 0, sizeof(buf) );
	errno_t nRet = _ultow_s( val, buf, size, 10 );

	dest = L"0";
	if( 0 == nRet )
		dest = buf;

	return dest;
}

std::wstring ToStr(unsigned int val)
{
	std::wstring dest;

	const int size = 20;
	wchar_t buf[size];
	memset( buf, 0, sizeof(buf) );
	errno_t nRet = _ultow_s( val, buf, size, 10 );

	dest = L"0";
	if( 0 == nRet )
		dest = buf;

	return dest;
}

std::wstring ToStr(unsigned __int64 val)
{
	std::wstring dest;

	const int size = 30;
	wchar_t buf[size];
	memset( buf, 0, sizeof(buf) );
	errno_t nRet = _ui64tow_s( val, buf, size, 10 );

	dest = L"0";
	if( 0 == nRet )
		dest = buf;

	return dest;
}

std::wstring ToStr(float val)
{
	std::wstring dest;

	const int size = 60;
	wchar_t buf[size];
	memset( buf, 0, sizeof(buf) );
	int nRet = swprintf_s( buf, size, L"%f", val );

	dest = L"0.0";
	if( -1 != nRet )
		dest = buf;

	return dest;
}

std::wstring ToStr(double val)
{
	std::wstring dest;

	const int size = 60;
	wchar_t buf[size];
	memset( buf, 0, sizeof(buf) );
	int nRet = swprintf_s( buf, size, L"%lf", val );

	dest = L"0.0";
	if( -1 != nRet )
		dest = buf;

	return dest;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)

Share

About the Author

Cake Processor
Software Developer (Senior)
United States United States

C++ developer transitioning to Python


Semi-retired from writing articles but may contribute tips from time to time.



IT Certifications


  • IT Infrastructure Library Foundational (ITIL v3)
  • Scrum Alliance Certified Scrum Master (CSM)
  • Certified Secure Software Lifecycle Professional (CSSLP)

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171207.1 | Last Updated 12 Apr 2016
Article Copyright 2016 by Cake Processor
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid