The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

irc::tokenstream Class Reference

irc::tokenstream reads a string formatted as per RFC1459 and RFC2812. More...

#include <hashcomp.h>

Inheritance diagram for irc::tokenstream:

Inheritance graph
[legend]
Collaboration diagram for irc::tokenstream:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 tokenstream (const std::string &source)
 Create a tokenstream and fill it with the provided data.
 ~tokenstream ()
 Destructor.
bool GetToken (std::string &token)
 Fetch the next token from the stream as a std::string.
bool GetToken (irc::string &token)
 Fetch the next token from the stream as an irc::string.
bool GetToken (int &token)
 Fetch the next token from the stream as an integer.
bool GetToken (long &token)
 Fetch the next token from the stream as a long integer.

Private Attributes

std::string tokens
 Original string.
std::string::iterator last_starting_position
 Last position of a seperator token.
std::string::iterator n
 Current string position.
bool last_pushed
 True if the last value was an ending value.

Detailed Description

irc::tokenstream reads a string formatted as per RFC1459 and RFC2812.

It will split the string into 'tokens' each containing one parameter from the string. For instance, if it is instantiated with the string: "PRIVMSG #test :foo bar baz qux" then each successive call to tokenstream::GetToken() will return "PRIVMSG", "#test", "foo bar baz qux", "". Note that if the whole string starts with a colon this is not taken to mean the string is all one parameter, and the first item in the list will be ":item". This is to allow for parsing 'source' fields from data.

Definition at line 280 of file hashcomp.h.


Constructor & Destructor Documentation

irc::tokenstream::tokenstream const std::string source  ) 
 

Create a tokenstream and fill it with the provided data.

Definition at line 160 of file hashcomp.cpp.

References last_starting_position, n, and tokens.

irc::tokenstream::~tokenstream  ) 
 

Destructor.

Definition at line 167 of file hashcomp.cpp.


Member Function Documentation

bool irc::tokenstream::GetToken long &  token  ) 
 

Fetch the next token from the stream as a long integer.

Parameters:
token The next token available, or undefined if none remain
Returns:
True if tokens are left to be read, false if the last token was just retrieved.

Definition at line 232 of file hashcomp.cpp.

References ConvToInt(), and GetToken().

bool irc::tokenstream::GetToken int &  token  ) 
 

Fetch the next token from the stream as an integer.

Parameters:
token The next token available, or undefined if none remain
Returns:
True if tokens are left to be read, false if the last token was just retrieved.

Definition at line 224 of file hashcomp.cpp.

References ConvToInt(), and GetToken().

bool irc::tokenstream::GetToken irc::string token  ) 
 

Fetch the next token from the stream as an irc::string.

Parameters:
token The next token available, or an empty string if none remain
Returns:
True if tokens are left to be read, false if the last token was just retrieved.

Definition at line 216 of file hashcomp.cpp.

References assign(), and GetToken().

bool irc::tokenstream::GetToken std::string token  ) 
 

Fetch the next token from the stream as a std::string.

Parameters:
token The next token available, or an empty string if none remain
Returns:
True if tokens are left to be read, false if the last token was just retrieved.

Definition at line 171 of file hashcomp.cpp.

References last_pushed, last_starting_position, n, and tokens.

Referenced by TreeSocket::Capab(), FilterBase::DecodeFilter(), ModuleAlias::DoCommand(), TreeSocket::ForceJoin(), GetToken(), CommandParser::ProcessCommand(), ModuleXLineDB::ReadDatabase(), and TreeSocket::Split().


Member Data Documentation

bool irc::tokenstream::last_pushed [private]
 

True if the last value was an ending value.

Definition at line 298 of file hashcomp.h.

Referenced by GetToken().

std::string::iterator irc::tokenstream::last_starting_position [private]
 

Last position of a seperator token.

Definition at line 290 of file hashcomp.h.

Referenced by GetToken(), and tokenstream().

std::string::iterator irc::tokenstream::n [private]
 

Current string position.

Definition at line 294 of file hashcomp.h.

Referenced by GetToken(), and tokenstream().

std::string irc::tokenstream::tokens [private]
 

Original string.

Definition at line 286 of file hashcomp.h.

Referenced by GetToken(), and tokenstream().


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