iash  v0.5
Library to provide a bash-like shell in an application
Token.h
1 /*
2  * Token.h
3  *
4  * Created on: Nov 22, 2016
5  * Author: paul
6  */
7 
8 #ifndef SRC_TOOLS_TOKEN_H_
9 #define SRC_TOOLS_TOKEN_H_
10 
11 #include <string>
12 
23 class Token {
24 public:
37  Token (const std::string& rawToken, const char precedingDelim,
38  const char followingDelim);
39 
45  const std::string& getToken () const;
46 
53  const std::string& finalize ();
54 
60  const char getPrecedingDelimiter () const;
61 
67  const char getFollowingDelimiter () const;
68 
76  bool isToken (const char delim) const;
77 
86  static bool isToken (const std::string &candidate, const char delim);
87 
96  bool operator== (const Token& other) const;
97 private:
104  static bool isWhitespace (const char c);
105 
106  std::string m_token;
107  char m_precedingDelim;
108  char m_followingDelim;
109 };
110 
111 #endif /* SRC_TOOLS_TOKEN_H_ */
const std::string & getToken() const
Gets the content of the Token.
Definition: Token.cpp:23
bool operator==(const Token &other) const
Checks for equality between tokens.
Definition: Token.cpp:73
const char getFollowingDelimiter() const
Gets the delimiter that came after this Token in the source string.
Definition: Token.cpp:68
const std::string & finalize()
Removes any Tokenizer-specific formatting.
Definition: Token.cpp:28
bool isToken(const char delim) const
Checks if this Token instance is also a Token for the given delimiter.
Definition: Token.cpp:78
Represents a single unit of a command language.
Definition: Token.h:23
Token(const std::string &rawToken, const char precedingDelim, const char followingDelim)
Creates a Token with the given content and surrounding delimiters.
Definition: Token.cpp:11
const char getPrecedingDelimiter() const
Gets the delimiter that came before this Token in the source string.
Definition: Token.cpp:63