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

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

#include <Parser.h>

Inheritance diagram for Utility::StringGroupParser:
Utility::AbstractParser

Public Member Functions

 StringGroupParser (const char *accept_strs[], uint8_t size)
 Constructor. More...
 
virtual ~StringGroupParser ()
 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 strings given.

Refer to the usage below.

const char* ACCEPT_STRS[] = {
"AA",
"BB",
"CC"
};
const unsigned char ACCEPT_STRS_LENGTH = sizeof(ACCEPT_STRS) / sizeof(ACCEPT_STRS[0]);
Utility::StringGroupParser sgp(ACCEPT_STRS, ACCEPT_STRS_LENGTH);
sgp.parse("Aa"); // == true
sgp.index(); // == 0
sgp.parse("AA"); // == true
sgp.index(); // == 0
sgp.parse("CX"); // == false
sgp.index(); // == -1
Attention
No case sensitivity on parsing.

Constructor & Destructor Documentation

Utility::StringGroupParser::StringGroupParser ( const char *  accept_strs[],
uint8_t  size 
)

Constructor.

Parameters
[in]accept_strsPointer of condition array sorted with dictionary order.
[in]sizeSize of the condition array.
Attention
Should give the class array sorted with dictionary order, because it runs binary search internally.
virtual Utility::StringGroupParser::~StringGroupParser ( )
virtual

Destructor.

Member Function Documentation

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

Parse input string.

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

Implements Utility::AbstractParser.


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