(file) Return to MyString.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / WMIMapper / WMIProvider

  1 karl  1.3 //%2003////////////////////////////////////////////////////////////////////////
  2 kumpf 1.1 //
  3 karl  1.3 // Copyright (c) 2000, 2001, 2002  BMC Software, Hewlett-Packard Development
  4           // Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
  5           // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
  6           // IBM Corp.; EMC Corporation, The Open Group.
  7 kumpf 1.1 //
  8           // Permission is hereby granted, free of charge, to any person obtaining a copy
  9           // of this software and associated documentation files (the "Software"), to
 10           // deal in the Software without restriction, including without limitation the
 11           // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 12           // sell copies of the Software, and to permit persons to whom the Software is
 13           // furnished to do so, subject to the following conditions:
 14           // 
 15           // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 16           // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 17           // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 18           // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 19           // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 20           // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 21           // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 22           // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 23           //
 24           //==============================================================================
 25           //
 26           // Author: Barbara Packard (barbara_packard@hp.com)
 27           //
 28 kumpf 1.2 // Modified By: Jair Santos, Hewlett-Packard Company (jair.santos@hp.com)
 29 kumpf 1.1 //
 30           //%/////////////////////////////////////////////////////////////////////////////
 31           
 32           #ifndef __MYSTRING_H_
 33           #define __MYSTRING_H_
 34           
 35           #ifdef _UNICODE
 36           #define CHAR_FUDGE 1    // one TCHAR unused is good enough
 37           #else
 38           #define CHAR_FUDGE 2    // two BYTES unused for case of DBC last char
 39           #endif
 40           
 41           // general purpose defines - may be modified later
 42           #define BUF_MAX			256
 43           
 44           PEGASUS_NAMESPACE_BEGIN
 45           
 46           class PEGASUS_WMIPROVIDER_LINKAGE CMyString
 47           {
 48           public:
 49           
 50 kumpf 1.1 // Constructors
 51               CMyString( );
 52           	CMyString(const CMyString& strSrc);
 53               CMyString(LPCWSTR lpsz);
 54               CMyString(LPCSTR lpsz);
 55               CMyString(const unsigned char* psz);
 56 kumpf 1.2 	CMyString(String sStr);
 57 kumpf 1.1 
 58               BSTR Bstr();
 59               BOOL Compare(BSTR bStr);
 60               BOOL Compare(LPCTSTR szStr);
 61           
 62           // Attributes & Operations
 63               // as an array of characters
 64               int GetLength() const{return m_nStrLen;} 
 65               BOOL IsEmpty() const {return m_nBufLen == 0;}
 66           	int GetBufLength() const {return m_nBufLen;}
 67               void Empty(){DeallocBuffer();}		// free up the buffer
 68           	void GetPrintableHex(int len, const unsigned char* data);	//format data buffer in hex
 69           	int Find(TCHAR ch) const;
 70           	int Find(TCHAR ch, int nStart) const;
 71           
 72           
 73               LPTSTR Copy();
 74           	
 75           	operator LPCTSTR() const;
 76           
 77               // overloaded assignment
 78 kumpf 1.1     const CMyString& operator=(const CMyString& stringSrc);
 79               const CMyString& operator=(LPCWSTR lpsz);
 80               const CMyString& operator=(LPCSTR lpsz);
 81               const CMyString& operator=(const unsigned char* psz);
 82               const CMyString& operator=(BSTR bStr);
 83           	const CMyString& operator=(String sStr);
 84           
 85           	// string concatenation
 86               const CMyString& operator+=(const CMyString& stringSrc);
 87               const CMyString& operator+=(LPCTSTR lpsz);
 88 kumpf 1.2 	const CMyString& operator+=(String sStr);
 89 kumpf 1.1 
 90           // Implementation
 91           public:
 92           //	BOOL LoadString(UINT nID);
 93           	int Format(LPCTSTR lpszFormat, int iSize, ...);
 94           //	int Format(UINT nID, int iSize, ...);
 95           
 96           	~CMyString();
 97           	HRESULT ErrorStatus(){return m_nStatus;}
 98           
 99           protected:
100               void Init();
101               BOOL AllocBuffer(int nLen);
102               void AllocBeforeWrite(int nLen);
103           	void AssignCopy( int nLen, LPCTSTR lpsz);
104               void DeallocBuffer();
105           	void ConcatCopy(int nLen1, LPCTSTR lpszSrc1, int nLen2, LPCTSTR lpszSrc2);
106           	void ConcatInPlace(int nSrcLen, LPCTSTR lpszSrc);
107           	int FormatV(LPCTSTR lpszFormat, int iSize, va_list argList);
108           
109               //	lengths/sizes in characters
110 kumpf 1.1     //  (note: an extra character is always allocated)
111           	//	(note: the buffer storage is always type TCHAR)
112               LPTSTR          m_pszData;      // actual string (zero terminated)
113               int             m_nStrLen;      // does not include terminating 0
114           	int				m_nBufLen;		// length of buffer in TCHARs
115           	HRESULT			m_nStatus;
116           };
117           
118           PEGASUS_NAMESPACE_END
119           
120           #endif // __MYSTRING_H_
121           

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2