Public Member Functions | Private Attributes

KeyInSingle Class Reference

Pattern where a value::Single object, recognised as a key, is followed by any value::Value. More...

#include <keyvalue/pattern/KeyInSingle.h>

Inheritance diagram for KeyInSingle:
Inheritance graph
[legend]

List of all members.

Public Member Functions

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

Private Attributes

bool isEmpty_
string key_
value::Value value_

Detailed Description

Pattern where a value::Single object, recognised as a key, is followed by any value::Value.

The content of value::Value object will be the value associated to the key. No further checks are performed.


Member Function Documentation

bool parse ( frontend::Queue queue  )  [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.

Implements Pattern.

::std::pair<string, value::Value> pop (  )  [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.

Implements Pattern.

bool isEmpty (  )  const [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.

Implements Pattern.