/
CStr.h
48 lines (37 loc) · 1.14 KB
/
CStr.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
//
// cstr.h - Stand-alone mini-CString
//
// Copyright (c) 2004, Algin Technology LLC
// Written by Alan Klietz
// Distributed under GNU General Public License version 2.
//
// $Id: CStr.h,v 1.2 2007/11/06 00:30:04 cvsalan Exp $
//
///////////////////////////////////////////////////////////////////////////////
class EXPORT CString
{
public:
CString() { m_szBuf = NULL; };
CString(const CString& stringSrc);
CString(LPCSTR psz);
~CString();
// cast to LPCTSTR
operator LPCTSTR() const { return m_szBuf == NULL ? "" : m_szBuf; };
// assignment
CString& operator=(const CString& stringSrc);
CString& operator=(LPCSTR sz);
LPCTSTR GetData() const { return m_szBuf; };
int GetLength() const { return m_iLen; };
int Equal(LPCTSTR sz) const { return _tcscmp(m_szBuf == NULL ? "" : m_szBuf, sz); };
BOOL IsEmpty() const { return m_iLen == 0; };
private:
void _alloc(int iLen);
private:
LPTSTR m_szBuf;
int m_iLen;
};
EXPORT extern BOOL operator==(const CString& s1, const CString& s2);
EXPORT extern BOOL operator!=(const CString& s1, const CString& s2);
/*
vim:tabstop=4:shiftwidth=4:noexpandtab
*/