VR-Forces Development_Version Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Public Attributes
makVrv::CPreprocessor::Token Class Reference

A input token. More...

Public Types

enum  Kind {
  TK_EOS, TK_ERROR, TK_WHITESPACE, TK_NEWLINE,
  TK_LINECONT, TK_NUMBER, TK_KEYWORD, TK_PUNCTUATION,
  TK_DIRECTIVE, TK_STRING, TK_COMMENT, TK_LINECOMMENT,
  TK_TEXT
}

Public Member Functions

 Token ()
 Token (Kind iType)
 Token (Kind iType, const char *iString, size_t iLength)
 Token (const Token &iOther)
 ~Token ()
Tokenoperator= (const Token &iOther)
 Assignment operator.
void Append (const char *iString, size_t iLength)
 Append a string to this token.
void Append (const Token &iOther)
 Append a token to this token.
void AppendNL (int iCount)
 Append given number of newlines to this token.
int CountNL ()
 Count number of newlines in this token.
bool GetValue (long &oValue) const
 Get the numeric value of the token.
void SetValue (long iValue)
 Set the numeric value of the token.
bool operator== (const Token &iOther)
 Test two tokens for equality.

Public Attributes

Kind Type
 Token type.
size_t Allocated
 True if string was allocated (and must be freed)
union {
   const char *   String
 A pointer somewhere into the input buffer.
   char *   Buffer
 A memory-allocated string.
}; 
size_t Length
 Token length in bytes.

Detailed Description

A input token.

For performance reasons most tokens will point to portions of the input stream, so no unneeded memory allocation is done. However, in some cases we must allocate different memory for token storage, in this case this is signalled by setting the Allocated member to non-zero in which case the destructor will know that it must free memory on object destruction.

Again for performance reasons we use malloc/realloc/free here because C++-style new[] lacks the realloc() counterpart.

Member Enumeration Documentation

Enumerator:
TK_EOS 
TK_ERROR 
TK_WHITESPACE 
TK_NEWLINE 
TK_LINECONT 
TK_NUMBER 
TK_KEYWORD 
TK_PUNCTUATION 
TK_DIRECTIVE 
TK_STRING 
TK_COMMENT 
TK_LINECOMMENT 
TK_TEXT 

Constructor & Destructor Documentation

makVrv::CPreprocessor::Token::Token ( )
inline
makVrv::CPreprocessor::Token::Token ( Kind  iType)
inline
makVrv::CPreprocessor::Token::Token ( Kind  iType,
const char iString,
size_t  iLength 
)
inline
makVrv::CPreprocessor::Token::Token ( const Token iOther)
inline

References Allocated, Length, String, and Type.

makVrv::CPreprocessor::Token::~Token ( )
inline

References Allocated, and Buffer.

Member Function Documentation

Token& makVrv::CPreprocessor::Token::operator= ( const Token iOther)
inline

Assignment operator.

References Allocated, Buffer, Length, String, and Type.

void makVrv::CPreprocessor::Token::Append ( const char iString,
size_t  iLength 
)

Append a string to this token.

void makVrv::CPreprocessor::Token::Append ( const Token iOther)

Append a token to this token.

void makVrv::CPreprocessor::Token::AppendNL ( int  iCount)

Append given number of newlines to this token.

int makVrv::CPreprocessor::Token::CountNL ( )

Count number of newlines in this token.

bool makVrv::CPreprocessor::Token::GetValue ( long &  oValue) const

Get the numeric value of the token.

void makVrv::CPreprocessor::Token::SetValue ( long  iValue)

Set the numeric value of the token.

bool makVrv::CPreprocessor::Token::operator== ( const Token iOther)
inline

Test two tokens for equality.

References Length, and String.

Member Data Documentation

Kind makVrv::CPreprocessor::Token::Type

Token type.

Referenced by operator=(), and Token().

size_t makVrv::CPreprocessor::Token::Allocated
mutable

True if string was allocated (and must be freed)

Referenced by operator=(), Token(), and ~Token().

const char* makVrv::CPreprocessor::Token::String

A pointer somewhere into the input buffer.

Referenced by operator=(), operator==(), and Token().

char* makVrv::CPreprocessor::Token::Buffer

A memory-allocated string.

Referenced by operator=(), and ~Token().

union { ... }
size_t makVrv::CPreprocessor::Token::Length

Token length in bytes.

Referenced by operator=(), operator==(), and Token().


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

Document ID: Generated on Tue Mar 8 22:13:38 EST 2016 from SVN revision 162938
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)