Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

stringar.h

Go to the documentation of this file.
00001 /****************************************************************************** 00002 00003 Header File: String Array.H 00004 00005 This provides a relatively simple C++ class for manipulating an array of 00006 character strings. In this project, we use it for lists of associated 00007 devices, or potential associated devices, etc. I'm not currently sorting 00008 this list. 00009 00010 The class declaration may look a bit bizarre. Since most of the arrays 00011 will in fact be rather small, I picked a decent size. When they get bigger, 00012 I'll chain them internally and use recursion to perform any needed function. 00013 00014 Copyright (c) 1996 by Microsoft Corporation 00015 00016 A Pretty Penny Enterprises Production 00017 00018 Change History: 00019 00020 11-01-96 [email protected] original version 00021 12-04-96 [email protected] Added LoadString and IsEmpty to CString 00022 00023 ******************************************************************************/ 00024 00025 #if !defined(STRING_ARRAY) 00026 00027 #if defined(UNICODE) 00028 00029 #define LPCOSTR LPCSTR 00030 #define LPOSTR LPSTR 00031 #define OCHAR CHAR 00032 00033 #if !defined(_UNICODE) 00034 #define _UNICODE 00035 #endif 00036 00037 #else 00038 00039 #define LPCOSTR LPCWSTR 00040 #define LPOSTR LPWSTR 00041 #define OCHAR WCHAR 00042 00043 #endif 00044 #include <tchar.h> 00045 00046 #define STRING_ARRAY 00047 00048 class CString { 00049 LPTSTR m_acContents; 00050 LPOSTR m_acConverted; 00051 BOOL m_bConverted; 00052 void Flip(LPCWSTR lpstrIn, LPSTR& lpstrOut); 00053 void Flip(LPCSTR lpstrIn, LPWSTR& lpstrOut); 00054 00055 public: 00056 CString(); 00057 CString(const CString& csRef); 00058 CString(LPCTSTR lpstrRef); 00059 CString(LPCOSTR lpstrRef); 00060 00061 ~CString(); 00062 00063 BOOL IsEmpty() const { return !m_acContents || !m_acContents[0]; } 00064 void Empty(); 00065 00066 operator LPCTSTR() const { return m_acContents; } 00067 operator LPTSTR() const { return m_acContents; } 00068 operator LPARAM() const { return (LPARAM) m_acContents; } 00069 operator LPCOSTR(); 00070 const CString& operator = (const CString& csSrc); 00071 const CString& operator = (LPCTSTR lpstrSrc); 00072 const CString& operator = (LPCOSTR lpstrSrc); 00073 CString NameOnly() const; 00074 CString NameAndExtension() const; 00075 void Load(int id, HINSTANCE hiWhere = NULL); 00076 void Load(HWND hwnd); 00077 void LoadAndFormat(int id, 00078 HINSTANCE hiWhere, 00079 BOOL bSystemMessage, 00080 DWORD dwNumMsg, 00081 va_list *argList); 00082 BOOL IsEqualString(CString& csRef1); 00083 00084 friend CString operator + (const CString& csRef1, LPCTSTR lpstrRef2); 00085 }; 00086 00087 class CStringArray { 00088 CString m_aStore[20]; 00089 CStringArray *m_pcsaNext; 00090 unsigned m_ucUsed; 00091 00092 const unsigned ChunkSize() const { 00093 return sizeof m_aStore / sizeof m_aStore[0]; 00094 } 00095 00096 LPCTSTR Borrow(); 00097 00098 public: 00099 00100 CStringArray(); 00101 ~CStringArray(); 00102 00103 unsigned Count() const { return m_ucUsed; } 00104 00105 // Add an item 00106 void Add(LPCTSTR lpstrNew); 00107 00108 CString& operator [](unsigned u) const; 00109 00110 void Remove(unsigned u); 00111 void Empty(); 00112 00113 // Return index of string in array- array count if not present 00114 00115 unsigned Map(LPCTSTR lpstrRef); 00116 }; 00117 00118 class CUintArray { 00119 unsigned m_aStore[20]; 00120 CUintArray *m_pcuaNext; 00121 unsigned m_ucUsed; 00122 00123 const unsigned ChunkSize() const { 00124 return sizeof m_aStore / sizeof m_aStore[0]; 00125 } 00126 00127 unsigned Borrow(); 00128 00129 public: 00130 00131 CUintArray(); 00132 ~CUintArray(); 00133 00134 unsigned Count() const { return m_ucUsed; } 00135 00136 // Add an item 00137 void Add(unsigned u); 00138 00139 unsigned operator [](unsigned u) const; 00140 00141 void Remove(unsigned u); 00142 void Empty(); 00143 }; 00144 00145 #endif

Generated on Sat May 15 19:41:53 2004 for test by doxygen 1.3.7