# Poco

# class Token

Library: Foundation
Package: Streams
Header: Poco/Token.h

## Description

The base class for all token classes that can be registered with the StreamTokenizer.

## Inheritance

Known Derived Classes: InvalidToken, EOFToken, WhitespaceToken

## Member Summary

Member Functions: asChar, asFloat, asInteger, asString, finish, is, start, tokenClass, tokenString

## Enumerations

### Class

IDENTIFIER_TOKEN

KEYWORD_TOKEN

SEPARATOR_TOKEN

OPERATOR_TOKEN

STRING_LITERAL_TOKEN

CHAR_LITERAL_TOKEN

INTEGER_LITERAL_TOKEN

LONG_INTEGER_LITERAL_TOKEN

FLOAT_LITERAL_TOKEN

DOUBLE_LITERAL_TOKEN

COMMENT_TOKEN

SPECIAL_COMMENT_TOKEN

PREPROCESSOR_TOKEN

WHITESPACE_TOKEN

EOF_TOKEN

INVALID_TOKEN

USER_TOKEN

## Constructors

### Token

Token();

Creates the Token.

## Destructor

### ~Token

virtual ~Token();

Destroys the Token.

## Member Functions

### asChar

virtual char asChar() const;

Returns a char representation of the token.

### asFloat

virtual double asFloat() const;

Returns a floating-point representation of the token.

### asInteger

virtual int asInteger() const;

Returns an integer representation of the token.

### asString

virtual std::string asString() const;

Returns a string representation of the token.

### finish

virtual void finish(
std::istream & istr
);

Builds the token by reading and appending the remaining characters from istr.

### is

bool is(
Class tokenClass
) const;

Returns true if and only if the token has the given class.

### start

virtual bool start(
char c,
std::istream & istr
);

Checks if the given character (and, optionally, the next character in the input stream) start a valid token. Returns true if so, false otherwise.

The current read position in istr must not be changed. In other words, only the peek() method of istream may be used.

If the character starts the token, it should be set as the token's value.

### tokenClass

virtual Class tokenClass() const;

Returns the kind of the token.

### tokenString

const std::string & tokenString() const;

Returns the token's raw string.

## Variables

### _value

std::string _value;