Classes | Public Member Functions

Pattern Class Reference

Protocol class which defines the interface for pattern recognition classes. More...

#include <keyvalue/pattern/Pattern.h>

Inheritance diagram for Pattern:
Inheritance graph
[legend]

List of all members.

Classes

class  QueueRaii
 This class implements RAII for a frontend::Queue. More...

Public Member Functions

virtual bool parse (frontend::Queue &queue)=0
 Parses the beginning of a frontend::Queue.
virtual ::std::pair< string,
value::Value
pop ()=0
 Gets and removes the next stored key-value pair.
virtual bool isEmpty () const =0
 Checks if the list of recognized key-value pairs is empty.

Detailed Description

Protocol class which defines the interface for pattern recognition classes.

Each derived class is able to parse the beginning of a queue in an attempt to recognise a specific pattern of key-value pairs.

When a pattern is recognised (by parse()), the corresponding key-value pairs are stored in a list to be extracted later (by pop()).


Member Function Documentation

virtual bool parse ( frontend::Queue queue  )  [pure virtual]

Parses the beginning of a frontend::Queue.

When a pattern is recognised, the value::Value objects which make it are removed from frontend::Queue and all corresponding key-value pairs are stored inside the this class for later queries.

Parameters:
queue : frontend::Queue to be parsed.
Returns:
If the pattern is recognised, then this method returns true. Otherwise, it returns false.

Implemented in KeyInSingle, KeysInMatrix, KeysInVector, and Table.

virtual ::std::pair<string, value::Value> pop (  )  [pure virtual]

Gets and removes the next stored key-value pair.

The debug version checks if there is any key-value pair be popped (by calling isEmpty()) and throw an exception when the check fails. Release version has undefined behavior when the list is empty.

Returns:
The key-value pair.
Exceptions:
LogicError : (Debug build only) When the list is empty.

Implemented in KeyInSingle, KeysInMatrix, KeysInVector, and Table.

virtual bool isEmpty (  )  const [pure virtual]

Checks if the list of recognized key-value pairs is empty.

Returns:
If the list is empty, this method returns true. Otherwise, it returns false.

Implemented in KeyInSingle, KeysInMatrix, KeysInVector, and Table.