Single argument token. More...

#include <senf/Utils/Console/Parse.hh>

Public Types

enum  TokenType {
  None = 0, PathSeparator = 0x0001, ArgumentGroupOpen = 0x0002, ArgumentGroupClose = 0x0004,
  DirectoryGroupOpen = 0x0008, DirectoryGroupClose = 0x0010, CommandTerminator = 0x0020, OtherPunctuation = 0x0040,
  BasicString = 0x0080, HexString = 0x0100, Word = 0x0200
}
 
enum  TokenGroup {
  ArgumentGrouper, DirectoryGrouper, Punctuation, String,
  SimpleArgument
}
 

Public Member Functions

 Token ()
 Create empty token. More...
 
 Token (TokenType type, std::string token)
 Create token with given type and value. More...
 
 Token (TokenType type, std::string token, detail::FilePositionWithIndex const &pos)
 Create token with given type and value. More...
 
std::string const & value () const
 String value of token. More...
 
TokenType type () const
 Token type. More...
 
unsigned line () const
 Line number of token in source. More...
 
unsigned column () const
 Column number of token in source. More...
 
unsigned index () const
 Index (char count) of token in source. More...
 
bool is (unsigned tokens) const
 Check, whether tokens type matches tokens. More...
 
bool operator== (Token const &other) const
 
bool operator!= (Token const &other) const
 

Related Functions

(Note that these are not member functions.)

Token NoneToken ()
 Create a None token. More...
 
Token PathSeparatorToken ()
 Create a PathSeparator ['/'] token. More...
 
Token ArgumentGroupOpenToken ()
 Create an ArgumentGroupOpen ['('] token. More...
 
Token ArgumentGroupCloseToken ()
 Create a ArgumentGroupClose [')'] token. More...
 
Token DirectoryGroupOpenToken ()
 Create a DirectoryGroupOpen ['{'] token. More...
 
Token DirectoryGroupCloseToken ()
 Create a DirectoryGroupClose ['}'] token. More...
 
Token CommandTerminatorToken ()
 Create a CommandTerminator [';'] token. More...
 
Token OtherPunctuationToken (std::string const &value)
 Create a OtherPunctuation ['=', ','] token with the given value. More...
 
Token BasicStringToken (std::string const &value)
 Create a BasicString token with the given value. More...
 
Token HexStringToken (std::string const &value)
 Create a HexString token with the given value. More...
 
Token WordToken (std::string const &value)
 Create a Word token with the given value. More...
 

Detailed Description

Single argument token.

All command arguments are split into tokens by the parser. Each token is returned as an Token instance.

Definition at line 234 of file Parse.hh.

Member Enumeration Documentation

◆ TokenGroup

Enumerator
ArgumentGrouper 
DirectoryGrouper 
Punctuation 
String 
SimpleArgument 

Definition at line 251 of file Parse.hh.

◆ TokenType

Enumerator
None 
PathSeparator 
ArgumentGroupOpen 
ArgumentGroupClose 
DirectoryGroupOpen 
DirectoryGroupClose 
CommandTerminator 
OtherPunctuation 
BasicString 
HexString 
Word 

Definition at line 237 of file Parse.hh.

Constructor & Destructor Documentation

◆ Token() [1/3]

senf::console::Token::Token ( )

Create empty token.

◆ Token() [2/3]

senf::console::Token::Token ( TokenType  type,
std::string  token 
)

Create token with given type and value.

◆ Token() [3/3]

senf::console::Token::Token ( TokenType  type,
std::string  token,
detail::FilePositionWithIndex const &  pos 
)

Create token with given type and value.

Definition at line 123 of file Parse.cc.

Member Function Documentation

◆ column()

unsigned senf::console::Token::column ( ) const

Column number of token in source.

◆ index()

unsigned senf::console::Token::index ( ) const

Index (char count) of token in source.

◆ is()

bool senf::console::Token::is ( unsigned  tokens) const

Check, whether tokens type matches tokens.

tokens is a bit-mask of token types to check.

◆ line()

unsigned senf::console::Token::line ( ) const

Line number of token in source.

◆ operator!=()

bool senf::console::Token::operator!= ( Token const &  other) const

◆ operator==()

bool senf::console::Token::operator== ( Token const &  other) const

◆ type()

TokenType senf::console::Token::type ( ) const

Token type.

◆ value()

std::string const& senf::console::Token::value ( ) const

String value of token.

This value is properly unquoted

Friends And Related Function Documentation

◆ ArgumentGroupCloseToken()

Token ArgumentGroupCloseToken ( )
related

Create a ArgumentGroupClose [')'] token.

◆ ArgumentGroupOpenToken()

Token ArgumentGroupOpenToken ( )
related

Create an ArgumentGroupOpen ['('] token.

◆ BasicStringToken()

Token BasicStringToken ( std::string const &  value)
related

Create a BasicString token with the given value.

◆ CommandTerminatorToken()

Token CommandTerminatorToken ( )
related

Create a CommandTerminator [';'] token.

◆ DirectoryGroupCloseToken()

Token DirectoryGroupCloseToken ( )
related

Create a DirectoryGroupClose ['}'] token.

◆ DirectoryGroupOpenToken()

Token DirectoryGroupOpenToken ( )
related

Create a DirectoryGroupOpen ['{'] token.

◆ HexStringToken()

Token HexStringToken ( std::string const &  value)
related

Create a HexString token with the given value.

◆ NoneToken()

Token NoneToken ( )
related

Create a None token.

◆ OtherPunctuationToken()

Token OtherPunctuationToken ( std::string const &  value)
related

Create a OtherPunctuation ['=', ','] token with the given value.

◆ PathSeparatorToken()

Token PathSeparatorToken ( )
related

Create a PathSeparator ['/'] token.

◆ WordToken()

Token WordToken ( std::string const &  value)
related

Create a Word token with the given value.


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