-
Notifications
You must be signed in to change notification settings - Fork 0
/
StringConversion.h
executable file
·97 lines (91 loc) · 3.54 KB
/
StringConversion.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef STRINGCONVERSION_H
#define STRINGCONVERSION_H
///////////////////////////////////////////////////////////////////////
// StringConversion.h - Win32 API-based helper functions //
// ver 1.0 //
// Language: Visual C++, ver 8.0 //
// Platform: Dell Precision T7400, Vista Ultimate, SP1 //
// Application: CSE775 Project #1, Spring 2009 //
// Author: Jim Fawcett, Syracuse University CST 4-187, //
// (315) 443-3948, jfawcett@twcny.rr.com //
///////////////////////////////////////////////////////////////////////
/*
Module StringConversion Operations:
-----------------------------------
This module defines:
typedefs: stdStr, stdChar, stdOstream, stdOstringstream
macros: stdOut, compare, AM, PM, and a few message strings
This module also defines the class Convert with static members:
std::wstring ToWstring(const std::string& src);
std::wstring ToWstring(const std::wstring& src);
std::string ToString(const std::string& src);
std::string ToString(const std::wstring& src);
stdStr ToStdStr(const std::string& src);
stdStr ToStdStr(const std::wstring& src);
The idea is to accept either ascii or unicode strings and convert
them to one of three specific types: std::string, std::wstring, or
stdStr.
*/
///////////////////////////////////////////////////////////////
// maintenance page //
///////////////////////////////////////////////////////////////
// Build Process //
// //
// Files Required: //
// StringConversion.h, StringConversion.cpp //
// //
// Building with Visual C++ , 8.0, from command line: //
// cl -EHsc -DTEST_STRINGCONVERSION StringConversion.cpp //
// //
///////////////////////////////////////////////////////////////
/*
Maintenance History
===================
ver 1.0 : 13 Jan 09
- first release
*/
#include <string>
#include <iostream>
#include <sstream>
#include <Windows.h>
#ifdef UNICODE
typedef std::wstring stdStr;
typedef wchar_t stdChar;
typedef std::wostream stdOstream;
typedef std::wostringstream stdOstringstream;
#define stdOut std::wcout
#define compare wcscmp
#define AM L"am"
#define PM L"pm"
#define SP L" "
#define SP2 L" "
#define MSG1 L" - path not found"
#else
typedef std::string stdStr;
typedef char stdChar;
typedef std::ostream stdOstream;
typedef std::ostringstream stdOstringstream;
#define stdOut std::cout
#define compare strcmp
#define AM "am"
#define PM "pm"
#define SP " "
#define SP2 " "
#define MSG1 " - path not found"
#endif
///////////////////////////////////////////////////////////////
// class Convert - convert between basic types
namespace Win32Tools
{
class Convert
{
public:
static std::wstring ToWstring(const std::string& src);
static std::wstring ToWstring(const std::wstring& src);
static std::string ToString(const std::string& src);
static std::string ToString(const std::wstring& src);
static stdStr ToStdStr(const std::string& src);
static stdStr ToStdStr(const std::wstring& src);
};
}
#endif