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

CStringArray Class Reference

#include <stringar.h>

List of all members.

Public Member Functions

 CStringArray ()
 ~CStringArray ()
unsigned Count () const
void Add (LPCTSTR lpstrNew)
CStringoperator[] (unsigned u) const
void Remove (unsigned u)
void Empty ()
unsigned Map (LPCTSTR lpstrRef)

Private Member Functions

const unsigned ChunkSize () const
LPCTSTR Borrow ()

Private Attributes

CString m_aStore [20]
CStringArraym_pcsaNext
unsigned m_ucUsed


Constructor & Destructor Documentation

CStringArray::CStringArray  ) 
 

Definition at line 285 of file stringar.cpp.

References m_pcsaNext, m_ucUsed, and NULL.

00285 { 00286 m_ucUsed = 0; 00287 m_pcsaNext = NULL; 00288 }

CStringArray::~CStringArray  ) 
 

Definition at line 292 of file stringar.cpp.

References Empty().

00292 { 00293 Empty(); 00294 }


Member Function Documentation

void CStringArray::Add LPCTSTR  lpstrNew  ) 
 

Definition at line 320 of file stringar.cpp.

References Add(), ChunkSize(), m_aStore, m_pcsaNext, and m_ucUsed.

Referenced by Add(), CAddProfileDialog::AddProfile(), CProfile::Enumerate(), CAllDeviceList::Enumerate(), CScannerList::Enumerate(), CMonitorList::Enumerate(), and CPrinterList::Enumerate().

00320 { 00321 00322 if (m_ucUsed < ChunkSize()) { 00323 m_aStore[m_ucUsed++] = lpstrNew; 00324 return; 00325 } 00326 00327 // Not enough space! Add another record, if there isn't one 00328 00329 if (!m_pcsaNext) 00330 m_pcsaNext = new CStringArray; 00331 00332 // Add the string to the next array (recursive call!) 00333 00334 if (m_pcsaNext) { 00335 m_pcsaNext -> Add(lpstrNew); 00336 m_ucUsed++; 00337 } 00338 }

LPCTSTR CStringArray::Borrow  )  [private]
 

Definition at line 261 of file stringar.cpp.

References ChunkSize(), m_aStore, m_pcsaNext, m_ucUsed, and NULL.

Referenced by Remove().

00261 { 00262 00263 LPCTSTR lpstrReturn = m_aStore[0]; 00264 00265 memcpy((LPSTR) m_aStore, (LPSTR) (m_aStore + 1), 00266 (ChunkSize() - 1) * sizeof m_aStore[0]); 00267 00268 if (m_ucUsed > ChunkSize()) 00269 m_aStore[ChunkSize() - 1] = m_pcsaNext -> Borrow(); 00270 else 00271 m_aStore[ChunkSize() - 1] = (LPCTSTR) NULL; 00272 00273 m_ucUsed--; 00274 00275 if (m_ucUsed <= ChunkSize() && m_pcsaNext) { 00276 delete m_pcsaNext; 00277 m_pcsaNext = NULL; 00278 } 00279 00280 return lpstrReturn; 00281 }

const unsigned CStringArray::ChunkSize  )  const [inline, private]
 

Definition at line 92 of file stringar.h.

Referenced by Add(), Borrow(), operator[](), and Remove().

00092 { 00093 return sizeof m_aStore / sizeof m_aStore[0]; 00094 }

unsigned CStringArray::Count  )  const [inline]
 

Definition at line 103 of file stringar.h.

Referenced by CProfile::AssociationCheck(), CColorMatchDialog::CompleteInitialization(), CAllDeviceList::Count(), CScannerList::Count(), CMonitorList::Count(), CPrinterList::Count(), CProfile::InstallCheck(), CGlobals::IsInstalled(), CColorMatchDialog::OnCommand(), CColorMatchDialog::OnInit(), and CAddProfileDialog::ProfileCount().

00103 { return m_ucUsed; }

void CStringArray::Empty  ) 
 

Definition at line 298 of file stringar.cpp.

References m_pcsaNext, m_ucUsed, and NULL.

Referenced by CAddProfileDialog::CAddProfileDialog(), CColorMatchDialog::CompleteInitialization(), CProfile::Enumerate(), CAddProfileDialog::~CAddProfileDialog(), CColorMatchDialog::~CColorMatchDialog(), and ~CStringArray().

00298 { 00299 00300 if (!m_ucUsed) return; 00301 00302 if (m_pcsaNext) { 00303 delete m_pcsaNext; 00304 m_pcsaNext = NULL; 00305 } 00306 m_ucUsed = 0; 00307 }

unsigned CStringArray::Map LPCTSTR  lpstrRef  ) 
 

Definition at line 309 of file stringar.cpp.

References m_ucUsed, and Map().

Referenced by CColorMatchDialog::CompleteInitialization(), and Map().

00309 { 00310 00311 for (unsigned u = 0; u < m_ucUsed; u++) 00312 if (!lstrcmpi(operator[](u), lpstrRef)) 00313 break; 00314 00315 return u; 00316 }

CString & CStringArray::operator[] unsigned  u  )  const
 

Definition at line 342 of file stringar.cpp.

References ChunkSize(), m_aStore, m_pcsaNext, m_ucUsed, and operator[]().

Referenced by operator[]().

00342 { 00343 _ASSERTE(u < m_ucUsed); 00344 00345 return u < ChunkSize() ? 00346 (CString&)m_aStore[u] : m_pcsaNext -> operator[](u - ChunkSize()); 00347 }

void CStringArray::Remove unsigned  u  ) 
 

Definition at line 351 of file stringar.cpp.

References Borrow(), ChunkSize(), m_aStore, m_pcsaNext, m_ucUsed, NULL, and Remove().

Referenced by Remove().

00351 { 00352 00353 if (u > m_ucUsed) 00354 return; 00355 00356 if (u >= ChunkSize()) { 00357 m_pcsaNext -> Remove(u - ChunkSize()); 00358 return; 00359 } 00360 00361 memmove((LPSTR) (m_aStore + u), (LPSTR) (m_aStore + u + 1), 00362 (ChunkSize() - (u + 1)) * sizeof m_aStore[0]); 00363 00364 if (m_ucUsed > ChunkSize()) 00365 m_aStore[ChunkSize() - 1] = m_pcsaNext -> Borrow(); 00366 else 00367 m_aStore[ChunkSize() - 1] = (LPCTSTR) NULL; 00368 00369 m_ucUsed--; 00370 00371 if (m_ucUsed <= ChunkSize() && m_pcsaNext) { 00372 delete m_pcsaNext; 00373 m_pcsaNext = NULL; 00374 } 00375 }


Member Data Documentation

CString CStringArray::m_aStore[20] [private]
 

Definition at line 88 of file stringar.h.

Referenced by Add(), Borrow(), operator[](), and Remove().

CStringArray* CStringArray::m_pcsaNext [private]
 

Definition at line 89 of file stringar.h.

Referenced by Add(), Borrow(), CStringArray(), Empty(), operator[](), and Remove().

unsigned CStringArray::m_ucUsed [private]
 

Definition at line 90 of file stringar.h.

Referenced by Add(), Borrow(), CStringArray(), Empty(), Map(), operator[](), and Remove().


The documentation for this class was generated from the following files:
Generated on Sat May 15 19:46:28 2004 for test by doxygen 1.3.7