++



         

UserQuery


UserQuery , , , - query(). . Query eval_query():

// ,

UserQuery user_query;

string text;

vector<string> query_text;

//

do {

while( cin >> text )

query_text.push_back( text );

// UserQuery

user_query.query( &query_text );

//

// Query*

Query *query = user_query.eval_query();

}

while ( /* */ );

UserQuery:

#ifndef USER_QUERY_H

#define USER_QUERY_H

#include <string>

#include <vector>

#include <map>

#include <stack>

typedef pair<short,short> location;

typedef vector<location,allocator> loc;

#include "Query.h"

class UserQuery {

public:

UserQuery( vector< string,allocator > *pquery = 0 )

: _query( pquery ), _eval( 0 ), _paren( 0 ) {}

Query *eval_query(); //

void query( vector< string,allocator > *pq );

void displayQuery();

static void word_map( map<string,loc*,less<string>,allocator> *pwm ) {

if ( !_word_map ) _word_map = pwm;

}

private:

enum QueryType { WORD = 1, AND, OR, NOT, RPAREN, LPAREN };

QueryType evalQueryString( const string &query );

void evalWord( const string &query );

void evalAnd();

void evalOr();