[PSDK] Add missing CreateRestrictedToken() declaration. CORE-13762
[reactos.git] / sdk / include / psdk / chstring.h
1 #pragma once
2
3 #ifndef _CHSTRING_H
4 #define _CHSTRING_H
5
6 #include <windows.h>
7 #include <provexce.h>
8
9 struct CHStringData
10 {
11 long nRefs;
12 int nDataLength;
13 int nAllocLength;
14
15 WCHAR* data()
16 {
17 return (WCHAR*)(this+1);
18 }
19 };
20
21 class CHString
22 {
23 public:
24 CHString();
25 CHString(WCHAR ch, int nRepeat = 1) throw (CHeap_Exception);
26 CHString(LPCWSTR lpsz) throw (CHeap_Exception);
27 CHString(LPCWSTR lpch, int nLength) throw (CHeap_Exception);
28 CHString(LPCSTR lpsz) throw (CHeap_Exception);
29 CHString(const CHString& stringSrc);
30 CHString(const unsigned char* lpsz);
31 ~CHString();
32
33 BSTR AllocSysString() const throw (CHeap_Exception);
34 int Collate(LPCWSTR lpsz) const;
35 int Compare(LPCWSTR lpsz) const;
36 int CompareNoCase(LPCWSTR lpsz) const;
37 void Empty();
38 int Find(WCHAR ch) const;
39 int Find(LPCWSTR lpszSub) const;
40 int FindOneOf(LPCWSTR lpszCharSet) const;
41 void Format(UINT nFormatID, ...) throw (CHeap_Exception);
42 void Format(LPCWSTR lpszFormat, ...) throw (CHeap_Exception);
43 void FormatMessageW(UINT nFormatID, ...) throw (CHeap_Exception);
44 void FormatMessageW(LPCWSTR lpszFormat, ...) throw (CHeap_Exception);
45 void FormatV(LPCWSTR lpszFormat, va_list argList);
46 void FreeExtra() throw (CHeap_Exception);
47 int GetAllocLength() const;
48 WCHAR GetAt(int nIndex) const;
49 LPWSTR GetBuffer(int nMinBufLength) throw (CHeap_Exception);
50 LPWSTR GetBufferSetLength(int nNewLength) throw (CHeap_Exception);
51 int GetLength() const;
52 BOOL IsEmpty() const;
53 CHString Left(int nCount) const throw (CHeap_Exception);
54 int LoadStringW(UINT nID) throw (CHeap_Exception);
55 LPWSTR LockBuffer();
56 void MakeLower() throw (CHeap_Exception);
57 void MakeReverse() throw (CHeap_Exception);
58 void MakeUpper() throw (CHeap_Exception);
59 CHString Mid(int nFirst) const throw (CHeap_Exception);
60 CHString Mid(int nFirst, int nCount) const throw (CHeap_Exception);
61 void ReleaseBuffer(int nNewLength = -1) throw (CHeap_Exception);
62 int ReverseFind(WCHAR ch) const;
63 CHString Right(int nCount) const throw (CHeap_Exception);
64 void SetAt(int nIndex, WCHAR ch) throw (CHeap_Exception);
65 CHString SpanExcluding(LPCWSTR lpszCharSet) const throw (CHeap_Exception);
66 CHString SpanIncluding(LPCWSTR lpszCharSet) const throw (CHeap_Exception);
67 void TrimLeft() throw (CHeap_Exception);
68 void TrimRight() throw (CHeap_Exception);
69 void UnlockBuffer();
70
71 const CHString& operator=(char ch) throw (CHeap_Exception);
72 const CHString& operator=(WCHAR ch) throw (CHeap_Exception);
73 const CHString& operator=(CHString *p) throw (CHeap_Exception);
74 const CHString& operator=(LPCSTR lpsz) throw (CHeap_Exception);
75 const CHString& operator=(LPCWSTR lpsz) throw (CHeap_Exception);
76 const CHString& operator=(const CHString& stringSrc) throw (CHeap_Exception);
77 const CHString& operator=(const unsigned char* lpsz) throw (CHeap_Exception);
78
79 const CHString& operator+=(char ch) throw (CHeap_Exception);
80 const CHString& operator+=(WCHAR ch) throw (CHeap_Exception);
81 const CHString& operator+=(LPCWSTR lpsz) throw (CHeap_Exception);
82 const CHString& operator+=(const CHString& string) throw (CHeap_Exception);
83
84 WCHAR operator[](int nIndex) const;
85
86 operator LPCWSTR() const;
87
88 friend CHString WINAPI operator+(WCHAR ch, const CHString& string) throw (CHeap_Exception);
89 friend CHString WINAPI operator+(const CHString& string, WCHAR ch) throw (CHeap_Exception);
90 friend CHString WINAPI operator+(const CHString& string, LPCWSTR lpsz) throw (CHeap_Exception);
91 friend CHString WINAPI operator+(LPCWSTR lpsz, const CHString& string) throw (CHeap_Exception);
92 friend CHString WINAPI operator+(const CHString& string1, const CHString& string2) throw (CHeap_Exception);
93
94 protected:
95 LPWSTR m_pchData;
96
97 void AllocBeforeWrite(int nLen) throw (CHeap_Exception);
98 void AllocBuffer(int nLen) throw (CHeap_Exception);
99 void AllocCopy(CHString& dest, int nCopyLen, int nCopyIndex, int nExtraLen) const throw (CHeap_Exception);
100 void AssignCopy(int nSrcLen, LPCWSTR lpszSrcData) throw (CHeap_Exception);
101 void ConcatCopy(int nSrc1Len, LPCWSTR lpszSrc1Data, int nSrc2Len, LPCWSTR lpszSrc2Data) throw (CHeap_Exception);
102 void ConcatInPlace(int nSrcLen, LPCWSTR lpszSrcData);
103 void CopyBeforeWrite() throw (CHeap_Exception);
104 CHStringData* GetData() const;
105 void Init();
106 int LoadStringW(UINT nID, LPWSTR lpszBuf, UINT nMaxBuf) throw (CHeap_Exception);
107 void Release();
108 static void WINAPI Release(CHStringData* pData);
109 static int WINAPI SafeStrlen(LPCWSTR lpsz);
110 };
111
112 inline BOOL operator==(const CHString& s1, LPCWSTR s2) { return s1.Compare(s2) == 0; }
113 inline BOOL operator==(const CHString& s1, const CHString& s2) { return s1.Compare(s2) == 0; }
114
115 inline BOOL operator!=(const CHString& s1, LPCWSTR s2) { return s1.Compare(s2) != 0; }
116 inline BOOL operator!=(const CHString& s1, const CHString& s2) { return s1.Compare(s2) != 0; }
117
118 inline BOOL operator<(const CHString& s1, LPCWSTR s2) { return s1.Compare(s2) < 0; }
119 inline BOOL operator<(const CHString& s1, const CHString& s2) { return s1.Compare(s2) < 0; }
120
121 inline BOOL operator>(const CHString& s1, LPCWSTR s2) { return s1.Compare(s2) > 0; }
122 inline BOOL operator>(const CHString& s1, const CHString& s2) { return s1.Compare(s2) > 0; }
123
124 inline BOOL operator<=(const CHString& s1, LPCWSTR s2) { return s1.Compare(s2) <= 0; }
125 inline BOOL operator<=(const CHString& s1, const CHString& s2) { return s1.Compare(s2) <= 0; }
126
127 inline BOOL operator>=(const CHString& s1, LPCWSTR s2) { return s1.Compare(s2) >= 0; }
128 inline BOOL operator>=(const CHString& s1, const CHString& s2) { return s1.Compare(s2) >= 0; }
129
130 #endif