From dd724bbd3ccf9abb89c91db13c2fcab40d3e88af Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sun, 1 Sep 2013 14:30:28 +0000 Subject: [PATCH] [PDSK] Add two headers: chstring.h and provexce.h They are used for framedyn.dll stuff, for instance So far, the CHString class is not fully populated. It is only populated with exported stuff from framedyn.dll svn path=/trunk/; revision=59939 --- reactos/include/psdk/chstring.h | 112 ++++++++++++++++++++++++++++++++ reactos/include/psdk/provexce.h | 23 +++++++ 2 files changed, 135 insertions(+) create mode 100644 reactos/include/psdk/chstring.h create mode 100644 reactos/include/psdk/provexce.h diff --git a/reactos/include/psdk/chstring.h b/reactos/include/psdk/chstring.h new file mode 100644 index 00000000000..81adecb4e99 --- /dev/null +++ b/reactos/include/psdk/chstring.h @@ -0,0 +1,112 @@ +#pragma once + +#ifndef _CHSTRING_H +#define _CHSTRING_H + +#include +#include + +struct CHStringData +{ + long nRefs; + int nDataLength; + int nAllocLength; + + WCHAR* data() + { + return (WCHAR*)(this+1); + } +}; + +class CHString +{ +public: + CHString(); + CHString(WCHAR ch, int nRepeat = 1) throw (CHeap_Exception); + CHString(LPCWSTR lpsz) throw (CHeap_Exception); + CHString(LPCWSTR lpch, int nLength) throw (CHeap_Exception); + CHString(LPCSTR lpsz) throw (CHeap_Exception); + CHString(const CHString& stringSrc); + CHString(const unsigned char* lpsz); + ~CHString(); + + BSTR AllocSysString() const throw (CHeap_Exception); + int Collate(LPCWSTR lpsz) const; + int Compare(LPCWSTR lpsz) const; + int CompareNoCase(LPCWSTR lpsz) const; + void Empty(); + int Find(WCHAR ch) const; + int Find(LPCWSTR lpszSub) const; + int FindOneOf(LPCWSTR lpszCharSet) const; + void Format(UINT nFormatID, ...) throw (CHeap_Exception); + void Format(LPCWSTR lpszFormat, ...) throw (CHeap_Exception); + void FormatMessageW(UINT nFormatID, ...) throw (CHeap_Exception); + void FormatMessageW(LPCWSTR lpszFormat, ...) throw (CHeap_Exception); + void FormatV(LPCWSTR lpszFormat, va_list argList); + void FreeExtra() throw (CHeap_Exception); + int GetAllocLength() const; + WCHAR GetAt(int nIndex) const; + LPWSTR GetBuffer(int nMinBufLength) throw (CHeap_Exception); + LPWSTR GetBufferSetLength(int nNewLength) throw (CHeap_Exception); + int GetLength() const; + BOOL IsEmpty() const; + CHString Left(int nCount) const throw (CHeap_Exception); + LPWSTR LockBuffer(); + void MakeLower() throw (CHeap_Exception); + void MakeReverse() throw (CHeap_Exception); + void MakeUpper() throw (CHeap_Exception); + CHString Mid(int nFirst) const throw (CHeap_Exception); + CHString Mid(int nFirst, int nCount) const throw (CHeap_Exception); + void Release(); + void Release(CHStringData* pData); + void ReleaseBuffer(int nNewLength = -1) throw (CHeap_Exception); + int ReverseFind(WCHAR ch) const; + CHString Right(int nCount) const throw (CHeap_Exception); + void SetAt(int nIndex, WCHAR ch) throw (CHeap_Exception); + CHString SpanExcluding(LPCWSTR lpszCharSet) const throw (CHeap_Exception); + CHString SpanIncluding(LPCWSTR lpszCharSet) const throw (CHeap_Exception); + void TrimLeft() throw (CHeap_Exception); + void TrimRight() throw (CHeap_Exception); + void UnlockBuffer(); + + const CHString& operator=(char ch) throw (CHeap_Exception); + const CHString& operator=(WCHAR ch) throw (CHeap_Exception); + const CHString& operator=(CHString *p) throw (CHeap_Exception); + const CHString& operator=(LPCSTR lpsz) throw (CHeap_Exception); + const CHString& operator=(LPCWSTR lpsz) throw (CHeap_Exception); + const CHString& operator=(const CHString& stringSrc) throw (CHeap_Exception); + const CHString& operator=(const unsigned char* lpsz) throw (CHeap_Exception); + + const CHString& operator+=(char ch) throw (CHeap_Exception); + const CHString& operator+=(WCHAR ch) throw (CHeap_Exception); + const CHString& operator+=(LPCWSTR lpsz) throw (CHeap_Exception); + const CHString& operator+=(const CHString& string) throw (CHeap_Exception); + + WCHAR operator[](int nIndex) const; + + operator LPWSTR(); + + friend CHString WINAPI operator+(WCHAR ch, const CHString& string) throw (CHeap_Exception); + friend CHString WINAPI operator+(const CHString& string, WCHAR ch) throw (CHeap_Exception); + friend CHString WINAPI operator+(const CHString& string, LPCWSTR lpsz) throw (CHeap_Exception); + friend CHString WINAPI operator+(LPCWSTR lpsz, const CHString& string) throw (CHeap_Exception); + friend CHString WINAPI operator+(const CHString& string1, const CHString& string2) throw (CHeap_Exception); + +protected: + LPWSTR m_pchData; + + void AllocBeforeWrite(int nLen) throw (CHeap_Exception); + void AllocBuffer(int nLen) throw (CHeap_Exception); + void AllocCopy(CHString& dest, int nCopyLen, int nCopyIndex, int nExtraLen) const throw (CHeap_Exception); + void AssignCopy(int nSrcLen, LPCWSTR lpszSrcData) throw (CHeap_Exception); + void ConcatCopy(int nSrc1Len, LPCWSTR lpszSrc1Data, int nSrc2Len, LPCWSTR lpszSrc2Data) throw (CHeap_Exception); + void ConcatInPlace(int nSrcLen, LPCWSTR lpszSrcData); + void CopyBeforeWrite() throw (CHeap_Exception); + CHStringData* GetData() const; + void Init(); + int LoadStringW(UINT nID) throw (CHeap_Exception); + int LoadStringW(UINT nID, LPWSTR lpszBuf, UINT nMaxBuf) throw (CHeap_Exception); + static int WINAPI SafeStrlen(LPCWSTR lpsz); +}; + +#endif diff --git a/reactos/include/psdk/provexce.h b/reactos/include/psdk/provexce.h new file mode 100644 index 00000000000..2de6631f9d6 --- /dev/null +++ b/reactos/include/psdk/provexce.h @@ -0,0 +1,23 @@ +#pragma once + +#ifndef _PROVIDER_EXCEPT_H +#define _PROVIDER_EXCEPT_H + +class CHeap_Exception +{ +public: + enum HEAP_ERROR + { + E_ALLOCATION_ERROR = 0 , + E_FREE_ERROR + }; + + CHeap_Exception(HEAP_ERROR e) : m_Error(e) {} + ~CHeap_Exception() {} + + HEAP_ERROR GetError() { return m_Error ; } +private: + HEAP_ERROR m_Error; +}; + +#endif