ReactOS  0.4.15-dev-1070-ge1a01de
CCompletionList Class Reference
Collaboration diagram for CCompletionList:

Public Member Functions

 CCompletionList ()
 
 ~CCompletionList ()
 
BOOL IsNewCompletion (const TCHAR *pszContext, const TCHAR *pszBegin, BOOL &rblnNew)
 
BOOL Add (const TCHAR *pszText, BOOL blnIsKey)
 
const TCHARGet (unsigned __int64 nIndex, BOOL &rblnIsKey)
 
unsigned __int64 GetCount ()
 
const TCHARGetContext ()
 
const TCHARGetBegin ()
 
void DeleteList ()
 
void Invalidate ()
 

Private Attributes

CCompletionMatchm_pHead
 
CCompletionMatchm_pTail
 
CCompletionMatchm_pLastSearched
 
unsigned int m_nLastSearched
 
TCHARm_pszContext
 
TCHARm_pszBegin
 
TCHARm_pszCurrentKey
 
unsigned __int64 m_nCount
 

Detailed Description

Definition at line 88 of file Completion.cpp.

Constructor & Destructor Documentation

◆ CCompletionList()

CCompletionList::CCompletionList ( )

Definition at line 115 of file Completion.cpp.

116 {
117  m_pHead = NULL;
118  m_pTail = NULL;
119  m_nCount = 0;
121  m_pszContext = NULL;
122  m_pszBegin = NULL;
124 }
TCHAR * m_pszContext
Definition: Completion.cpp:108
smooth NULL
Definition: ftsmooth.c:416
TCHAR * m_pszCurrentKey
Definition: Completion.cpp:110
TCHAR * m_pszBegin
Definition: Completion.cpp:109
unsigned __int64 m_nCount
Definition: Completion.cpp:111
CCompletionMatch * m_pHead
Definition: Completion.cpp:104
CCompletionMatch * m_pLastSearched
Definition: Completion.cpp:106
CCompletionMatch * m_pTail
Definition: Completion.cpp:105

◆ ~CCompletionList()

CCompletionList::~CCompletionList ( )

Definition at line 126 of file Completion.cpp.

127 {
128  DeleteList();
129 
130  if (m_pszContext)
131  delete[] m_pszContext;
132 
133  if (m_pszBegin)
134  delete[] m_pszBegin;
135 
136  if (m_pszCurrentKey)
137  delete[] m_pszCurrentKey;
138 }
TCHAR * m_pszContext
Definition: Completion.cpp:108
TCHAR * m_pszCurrentKey
Definition: Completion.cpp:110
TCHAR * m_pszBegin
Definition: Completion.cpp:109

Member Function Documentation

◆ Add()

BOOL CCompletionList::Add ( const TCHAR pszText,
BOOL  blnIsKey 
)

Definition at line 214 of file Completion.cpp.

215 {
216  if (_tcsnicmp(pszText,m_pszBegin,_tcslen(m_pszBegin)) != 0)
217  return TRUE;
218  CCompletionMatch *pNode = new (std::nothrow) CCompletionMatch;
219  if (!pNode)
220  return FALSE;
221  if (!pNode->Init(pszText))
222  return FALSE;
223 
224  ASSERT(pNode->m_pszText);
225  ASSERT(pNode->m_pNext == NULL);
226 
227  // add new node to tail
228  pNode->m_blnIsKey = blnIsKey;
229  if (m_pTail)
230  {
231  pNode->m_pPrev = m_pTail;
232  ASSERT(m_pTail->m_pNext == NULL);
233  m_pTail->m_pNext = pNode;
234  m_pTail = pNode;
235  }
236  else
237  {
238  ASSERT(m_pHead == NULL);
239  m_pHead = m_pTail = pNode;
240  }
241 
242  m_nCount++;
243 
245 
246  return TRUE;
247 }
CCompletionMatch * m_pNext
Definition: Completion.cpp:83
BOOL Init(const TCHAR *pszText)
Definition: Completion.cpp:42
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define _tcsnicmp
Definition: xmlstorage.h:207
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
TCHAR * m_pszBegin
Definition: Completion.cpp:109
unsigned __int64 m_nCount
Definition: Completion.cpp:111
CCompletionMatch * m_pPrev
Definition: Completion.cpp:84
CCompletionMatch * m_pHead
Definition: Completion.cpp:104
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CCompletionMatch * m_pLastSearched
Definition: Completion.cpp:106
CCompletionMatch * m_pTail
Definition: Completion.cpp:105

Referenced by FillCompletion().

◆ DeleteList()

void CCompletionList::DeleteList ( )

Definition at line 316 of file Completion.cpp.

317 {
318  CCompletionMatch *pNode;
319  while(m_pHead)
320  {
321  pNode = m_pHead;
323  delete pNode;
324  }
325  m_pTail = NULL;
326  ASSERT(m_pHead == NULL);
327  m_nCount = 0;
328 }
CCompletionMatch * m_pNext
Definition: Completion.cpp:83
smooth NULL
Definition: ftsmooth.c:416
unsigned __int64 m_nCount
Definition: Completion.cpp:111
CCompletionMatch * m_pHead
Definition: Completion.cpp:104
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CCompletionMatch * m_pTail
Definition: Completion.cpp:105

Referenced by FillCompletion(), IsNewCompletion(), and ~CCompletionList().

◆ Get()

const TCHAR * CCompletionList::Get ( unsigned __int64  nIndex,
BOOL rblnIsKey 
)

Definition at line 249 of file Completion.cpp.

250 {
251  ASSERT(nIndex < m_nCount);
252  BOOL blnForward = FALSE;
253  CCompletionMatch *pNode = NULL;
254 
255  unsigned __int64 nRelativeIndex = 0;
256 
257  if (m_pLastSearched)
258  {
259  pNode = m_pLastSearched;
260  blnForward = nIndex > m_nLastSearched;
261  nRelativeIndex = blnForward?(nIndex-m_nLastSearched):(m_nLastSearched-nIndex);
262  if ((nRelativeIndex > nIndex)||(nRelativeIndex > m_nCount-nIndex-1))
263  pNode = NULL; // seraching from tail or from head is more effective
264  }
265 
266  if (!pNode && (nIndex <= m_nCount/2))
267  { // search from head
268  pNode = m_pHead;
269  blnForward = TRUE;
270  nRelativeIndex = nIndex;
271  }
272 
273  if (!pNode)
274  { // search from tail
275  pNode = m_pTail;
276  blnForward = FALSE;
277  nRelativeIndex = m_nCount-nIndex-1;
278  }
279 
280  while(pNode)
281  {
282  if (nRelativeIndex == 0)
283  {
284  m_nLastSearched = nIndex;
285  m_pLastSearched = pNode;
286  rblnIsKey = pNode->m_blnIsKey;
287  if (!pNode->m_pszText)
288  ASSERT(FALSE);
289  return pNode->m_pszText;
290  }
291 
292  nRelativeIndex--;
293 
294  pNode = blnForward?(pNode->m_pNext):(pNode->m_pPrev);
295  }
296 
297  ASSERT(FALSE);
298  return NULL;
299 }
CCompletionMatch * m_pNext
Definition: Completion.cpp:83
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
unsigned __int64 m_nCount
Definition: Completion.cpp:111
CCompletionMatch * m_pPrev
Definition: Completion.cpp:84
CCompletionMatch * m_pHead
Definition: Completion.cpp:104
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CCompletionMatch * m_pLastSearched
Definition: Completion.cpp:106
CCompletionMatch * m_pTail
Definition: Completion.cpp:105
unsigned int m_nLastSearched
Definition: Completion.cpp:107
#define __int64
Definition: basetyps.h:16

Referenced by CompletionCallback().

◆ GetBegin()

const TCHAR * CCompletionList::GetBegin ( )

Definition at line 311 of file Completion.cpp.

312 {
313  return m_pszBegin;
314 }
TCHAR * m_pszBegin
Definition: Completion.cpp:109

◆ GetContext()

const TCHAR * CCompletionList::GetContext ( )

Definition at line 306 of file Completion.cpp.

307 {
308  return m_pszContext;
309 }
TCHAR * m_pszContext
Definition: Completion.cpp:108

◆ GetCount()

unsigned __int64 CCompletionList::GetCount ( )

Definition at line 301 of file Completion.cpp.

302 {
303  return m_nCount;
304 }
unsigned __int64 m_nCount
Definition: Completion.cpp:111

Referenced by CompletionCallback().

◆ Invalidate()

void CCompletionList::Invalidate ( )

Definition at line 140 of file Completion.cpp.

141 {
142  if (m_pszCurrentKey)
143  {
144  delete[] m_pszCurrentKey;
146  }
147 }
smooth NULL
Definition: ftsmooth.c:416
TCHAR * m_pszCurrentKey
Definition: Completion.cpp:110

Referenced by InvalidateCompletion().

◆ IsNewCompletion()

BOOL CCompletionList::IsNewCompletion ( const TCHAR pszContext,
const TCHAR pszBegin,
BOOL rblnNew 
)

Definition at line 149 of file Completion.cpp.

150 {
151  const TCHAR *pszCurrentKey = Tree.GetCurrentPath();
152  if (!m_pszContext ||
153  !m_pszBegin ||
154  !m_pszCurrentKey ||
155  (_tcscmp(m_pszContext,pszContext) != 0) ||
156  (_tcscmp(m_pszBegin,pszBegin) != 0) ||
157  (_tcscmp(m_pszCurrentKey,pszCurrentKey)))
158  { // new completion
159  DeleteList();
160  rblnNew = TRUE;
161  if (m_pszContext)
162  {
163  delete[] m_pszContext;
164  m_pszContext = NULL;
165  }
166 
167  if (m_pszBegin)
168  {
169  delete[] m_pszBegin;
170  m_pszBegin = NULL;
171  }
172 
173  if (m_pszCurrentKey)
174  {
175  delete[] m_pszCurrentKey;
177  }
178 
179  size_t s = _tcslen(pszContext);
180  m_pszContext = new (std::nothrow) TCHAR[s+1];
181  if (!m_pszContext)
182  return FALSE;
183  _tcscpy(m_pszContext,pszContext);
184 
185  s = _tcslen(pszBegin);
186  m_pszBegin = new (std::nothrow) TCHAR[s+1];
187  if (!m_pszBegin)
188  {
189  delete[] m_pszContext;
190  m_pszContext = NULL;
191  return FALSE;
192  }
193  _tcscpy(m_pszBegin,pszBegin);
194 
195  s = _tcslen(pszCurrentKey);
196  m_pszCurrentKey = new (std::nothrow) TCHAR[s+1];
197  if (!m_pszCurrentKey)
198  {
199  delete[] m_pszContext;
200  delete[] m_pszBegin;
201  m_pszContext = NULL;
202  m_pszBegin = NULL;
203  return FALSE;
204  }
205  _tcscpy(m_pszCurrentKey,pszCurrentKey);
206 
207  return TRUE;
208  }
209 
210  rblnNew = FALSE;
211  return TRUE;
212 }
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
#define TRUE
Definition: types.h:120
const TCHAR * GetCurrentPath() const
TCHAR * m_pszContext
Definition: Completion.cpp:108
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define FALSE
Definition: types.h:117
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
TCHAR * m_pszCurrentKey
Definition: Completion.cpp:110
char TCHAR
Definition: xmlstorage.h:189
TCHAR * m_pszBegin
Definition: Completion.cpp:109
CRegistryTree Tree
GLdouble s
Definition: gl.h:2039

Referenced by CompletionCallback().

Member Data Documentation

◆ m_nCount

unsigned __int64 CCompletionList::m_nCount
private

Definition at line 111 of file Completion.cpp.

Referenced by Add(), CCompletionList(), DeleteList(), Get(), and GetCount().

◆ m_nLastSearched

unsigned int CCompletionList::m_nLastSearched
private

Definition at line 107 of file Completion.cpp.

Referenced by Get().

◆ m_pHead

CCompletionMatch* CCompletionList::m_pHead
private

Definition at line 104 of file Completion.cpp.

Referenced by Add(), CCompletionList(), DeleteList(), and Get().

◆ m_pLastSearched

CCompletionMatch* CCompletionList::m_pLastSearched
private

Definition at line 106 of file Completion.cpp.

Referenced by Add(), CCompletionList(), and Get().

◆ m_pszBegin

TCHAR* CCompletionList::m_pszBegin
private

Definition at line 109 of file Completion.cpp.

Referenced by Add(), CCompletionList(), GetBegin(), IsNewCompletion(), and ~CCompletionList().

◆ m_pszContext

TCHAR* CCompletionList::m_pszContext
private

Definition at line 108 of file Completion.cpp.

Referenced by CCompletionList(), GetContext(), IsNewCompletion(), and ~CCompletionList().

◆ m_pszCurrentKey

TCHAR* CCompletionList::m_pszCurrentKey
private

Definition at line 110 of file Completion.cpp.

Referenced by CCompletionList(), Invalidate(), IsNewCompletion(), and ~CCompletionList().

◆ m_pTail

CCompletionMatch* CCompletionList::m_pTail
private

Definition at line 105 of file Completion.cpp.

Referenced by Add(), CCompletionList(), DeleteList(), and Get().


The documentation for this class was generated from the following file: