Click here to Skip to main content
12,244,802 members (48,613 online)
Click here to Skip to main content

Stats

21.3K views
428 downloads
27 bookmarked
Posted

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

, 12 Apr 2016 Ms-PL
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

Shao Voon Wong
Software Developer (Senior)
Singapore Singapore
IT Certifications

  • IT Infrastructure Library Foundational (ITIL v3)
  • Scrum Alliance Certified Scrum Master (CSM)
  • EC-Council Certified Secure Programmer (ECSP) .NET
  • EC-Council Certified Ethical Hacker (CEH)
  • EC-Council Certified Security Analyst (ECSA)
  • Certified Secure Software Lifecycle Professional (CSSLP)

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.160426.1 | Last Updated 12 Apr 2016
Article Copyright 2016 by Shao Voon Wong
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid