Firmware for Arduino | PLEN Project Company Inc.
Utility::CharGroupParser Class Reference

Parser class that accepts only characters given. More...

#include <Parser.h>

Inheritance diagram for Utility::CharGroupParser:
Utility::AbstractParser

Public Member Functions

 CharGroupParser (const char *accept_chars)
 Constructor. More...
 
virtual ~CharGroupParser ()
 Destructor. More...
 
virtual bool parse (const char *input)
 Parse input string. More...
 
- Public Member Functions inherited from Utility::AbstractParser
virtual ~AbstractParser ()
 Destructor. More...
 
virtual const int8_t & index ()
 Get matched index of after parsing. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Utility::AbstractParser
 AbstractParser ()
 Constructor. More...
 
- Protected Attributes inherited from Utility::AbstractParser
int8_t m_index
 

Detailed Description

Parser class that accepts only characters given.

Refer to the usage below.

cgp.parse("a"); // == true
cgp.index(); // == 0
cgp.parse("b"); // == true
cgp.index(); // == 1
cgp.parse("ax"); // == true
cgp.index(); // == 0
cgp.parse("c"); // == false
cgp.index(); // == -1

Constructor & Destructor Documentation

Utility::CharGroupParser::CharGroupParser ( const char *  accept_chars)

Constructor.

Parameters
[in]accept_charsCondition string.
Note
The class runs linear search internally, so it is efficient to put a char that has high priority in heading of the accept_chars.
virtual Utility::CharGroupParser::~CharGroupParser ( )
virtual

Destructor.

Member Function Documentation

virtual bool Utility::CharGroupParser::parse ( const char *  input)
virtual

Parse input string.

In the implementation, parses the heading of the input. (i.e. Validate the input as ^[accept_chars].)

If you want ^[accept_chars]+$ to be validated, please edit the method yourself.

Parameters
[in]inputString you want to parse.
Returns
Result

Implements Utility::AbstractParser.


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