-
Notifications
You must be signed in to change notification settings - Fork 2
/
MFCString.h
88 lines (69 loc) · 2.46 KB
/
MFCString.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
// MFCString.h
//
//////////////////////////////////////////////////////////////////////////////
#if !defined(MFCSTRING_H__CE71ED37_972C_11D0_9733_46963F000000__INCLUDED_)
#define MFCSTRING__CE71ED37_972C_11D0_9733_46963F000000__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
//////////////////////////////////////////////////////////////////////////////
#include <string>
#pragma warning(disable:4786) // Disable warning for names > 256
//////////////////////////////////////////////////////////////////////////////
namespace NotMFC
{
template<typename T>
class CStringT : public std::basic_string<T> // T should be either char or wchar_t
{
public:
// Constructors
CStringT();
CStringT(const CStringT& strInput);
CStringT(const std::basic_string<T>& strInput);
CStringT(const T* strInput);
CStringT(T ch, int nRepeat = 1);
// The string as an array
int GetLength() const;
bool IsEmpty() const;
void Empty();
T GetAt(int nIndex) const;
void SetAt(int nIndex, T ch);
// Comparison
int Compare(const T* psz) const;
int Compare(const CStringT& str) const;
int CompareNoCase(const T* psz) const;
int CompareNoCase(const CStringT& str) const;
int Collate(const T* psz) const;
int Collate(const CStringT& str) const;
// Extraction
CStringT Mid(int nFirst) const;
CStringT Mid(int nFirst, int nCount) const;
CStringT Left(int nCount) const;
CStringT Right(int nCount) const;
CStringT SpanIncluding(const T* pszCharSet) const;
CStringT SpanExcluding(const T* pszCharSet) const;
// Other Conversions
void MakeUpper();
void MakeLower();
void MakeReverse();
void TrimLeft();
void TrimRight();
void Format(const T* pszFormat, ... );
// Searching
int Find(const T& ch) const;
int Find(const T* psz) const;
int ReverseFind(const T& ch) const;
int FindOneOf(const T* pszCharSet) const;
// Operators
operator const T*() const;
T operator[](int nIndex) const;
};
#if defined UNICODE
typedef CStringT<wchar_t> CString;
#else
typedef CStringT<char> CString;
#endif
}; // namespace NotMFC
//////////////////////////////////////////////////////////////////////////////
#pragma warning(default:4786) // Enable warning for names > 256
#endif // !defined(MFCSTRING_H__CE71ED37_972C_11D0_9733_46963F000000__INCLUDED_)