OpenBarnyard
 
Loading...
Searching...
No Matches
T2StringParser< StringTraits > Class Template Reference

#include <T2String.h>

Public Types

using CharType = typename StringTraits::CharType
 
using ConstString = typename T2StringViewBase<StringTraits>
 

Public Member Functions

 T2StringParser (ConstString a_pchBuffer, TSIZE a_uiBufferSize=-1)
 
 T2StringParser ()
 
void SetBuffer (ConstString a_pchBuffer, TSIZE a_uiBufferSize=-1)
 
void Reset ()
 
TSIZE Tell () const
 
void Set (TSIZE a_uiPos)
 
TBOOL PeekToken (CharType *a_pszToken, TSIZE a_uiTokenMaxSize)
 
TBOOL ReadToken (CharType *a_pszToken, TSIZE a_uiTokenMaxSize)
 
TBOOL IsOver () const
 

Detailed Description

template<class StringTraits = T2StringTraits<TCHAR>>
class T2StringParser< StringTraits >

Definition at line 263 of file T2String.h.

Member Typedef Documentation

◆ CharType

template<class StringTraits = T2StringTraits<TCHAR>>
using T2StringParser< StringTraits >::CharType = typename StringTraits::CharType

Definition at line 266 of file T2String.h.

◆ ConstString

template<class StringTraits = T2StringTraits<TCHAR>>
using T2StringParser< StringTraits >::ConstString = typename T2StringViewBase<StringTraits>

Definition at line 267 of file T2String.h.

Constructor & Destructor Documentation

◆ T2StringParser() [1/2]

template<class StringTraits = T2StringTraits<TCHAR>>
T2StringParser< StringTraits >::T2StringParser ( ConstString a_pchBuffer,
TSIZE a_uiBufferSize = -1 )
inline

Definition at line 270 of file T2String.h.

271 {
273 }
void SetBuffer(ConstString a_pchBuffer, TSIZE a_uiBufferSize=-1)
Definition T2String.h:280

◆ T2StringParser() [2/2]

template<class StringTraits = T2StringTraits<TCHAR>>
T2StringParser< StringTraits >::T2StringParser ( )
inline

Definition at line 275 of file T2String.h.

276 {
277 m_uiBufferSize = 0;
278 }

Member Function Documentation

◆ IsOver()

template<class StringTraits = T2StringTraits<TCHAR>>
TBOOL T2StringParser< StringTraits >::IsOver ( ) const
inline

Definition at line 373 of file T2String.h.

374 {
375 return m_BufferPos >= m_BufferEnd;
376 }

◆ PeekToken()

template<class StringTraits = T2StringTraits<TCHAR>>
TBOOL T2StringParser< StringTraits >::PeekToken ( CharType * a_pszToken,
TSIZE a_uiTokenMaxSize )
inline

Definition at line 308 of file T2String.h.

309 {
312
315 ConstString cursor = m_BufferPos.SkipSpaces();
316
320
321 // Copy until we have the last byte for the \0 character or the buffer is over
322 while ( uiSizeLeft > 1 && cursor < m_BufferEnd )
323 {
325 TBOOL bIsEscapeChar = cChar == '\\';
327
328 if ( !bIsPrevCharEscape && ( cChar == '"' || cChar == '\'' ) )
329 {
331
332 if ( !bIsInQuotes )
333 {
334 // The quotes are closed so the token is over
335 cursor += 1;
336 bIsValid = TTRUE;
337 break;
338 }
339 }
340 else if ( !bIsInQuotes && bIsBreakToken )
341 {
342 // Break (stop) character is found and it's not in quotes
343 cursor += 1;
344 bIsValid = TTRUE;
345 break;
346 }
347 else
348 {
349 // Copy the character
350 *( pchCopyCursor++ ) = cChar;
351 }
352
353 cursor += 1;
355 }
356
357 if ( cursor >= m_BufferEnd && !bIsInQuotes )
358 bIsValid = TTRUE;
359
360 m_BufferLastPeek = cursor;
361 *pchCopyCursor = '\0';
362 return bIsValid;
363 }
#define TASSERT(X,...)
Definition Defines.h:138
typename T2StringViewBase< StringTraits > ConstString
Definition T2String.h:267
typename StringTraits::CharType CharType
Definition T2String.h:266

◆ ReadToken()

template<class StringTraits = T2StringTraits<TCHAR>>
TBOOL T2StringParser< StringTraits >::ReadToken ( CharType * a_pszToken,
TSIZE a_uiTokenMaxSize )
inline

Definition at line 365 of file T2String.h.

366 {
368 m_BufferPos = m_BufferLastPeek;
369
370 return bResult;
371 }
TBOOL PeekToken(CharType *a_pszToken, TSIZE a_uiTokenMaxSize)
Definition T2String.h:308

◆ Reset()

template<class StringTraits = T2StringTraits<TCHAR>>
void T2StringParser< StringTraits >::Reset ( )
inline

Definition at line 293 of file T2String.h.

294 {
295 m_BufferPos = m_Buffer;
296 }

◆ Set()

template<class StringTraits = T2StringTraits<TCHAR>>
void T2StringParser< StringTraits >::Set ( TSIZE a_uiPos)
inline

Definition at line 303 of file T2String.h.

304 {
305 m_BufferPos = m_Buffer + a_uiPos;
306 }

◆ SetBuffer()

template<class StringTraits = T2StringTraits<TCHAR>>
void T2StringParser< StringTraits >::SetBuffer ( ConstString a_pchBuffer,
TSIZE a_uiBufferSize = -1 )
inline

Definition at line 280 of file T2String.h.

281 {
282 m_Buffer = a_pchBuffer;
283 m_BufferPos = a_pchBuffer;
284
285 if ( a_pchBuffer )
286 m_uiBufferSize = ( a_uiBufferSize == -1 ) ? a_pchBuffer.Length() : a_uiBufferSize;
287 else
288 m_uiBufferSize = 0;
289
290 m_BufferEnd = m_Buffer + m_uiBufferSize;
291 }

◆ Tell()

template<class StringTraits = T2StringTraits<TCHAR>>
TSIZE T2StringParser< StringTraits >::Tell ( ) const
inline

Definition at line 298 of file T2String.h.

299 {
300 return m_BufferPos - m_Buffer;
301 }

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