Switch to unified view

a/src/query/wasastringtoquery.h b/src/query/wasastringtoquery.h
1
#ifndef _WASASTRINGTOQUERY_H_INCLUDED_
1
#ifndef _WASASTRINGTOQUERY_H_INCLUDED_
2
#define _WASASTRINGTOQUERY_H_INCLUDED_
2
#define _WASASTRINGTOQUERY_H_INCLUDED_
3
/* @(#$Id: wasastringtoquery.h,v 1.1 2006-11-30 18:12:16 dockes Exp $  (C) 2006 J.F.Dockes */
3
/* @(#$Id: wasastringtoquery.h,v 1.2 2006-12-08 10:54:38 dockes Exp $  (C) 2006 J.F.Dockes */
4
/*
4
/*
5
 *   This program is free software; you can redistribute it and/or modify
5
 *   This program is free software; you can redistribute it and/or modify
6
 *   it under the terms of the GNU General Public License as published by
6
 *   it under the terms of the GNU General Public License as published by
7
 *   the Free Software Foundation; either version 2 of the License, or
7
 *   the Free Software Foundation; either version 2 of the License, or
8
 *   (at your option) any later version.
8
 *   (at your option) any later version.
...
...
22
#include <vector>
22
#include <vector>
23
23
24
using std::string;
24
using std::string;
25
using std::vector;
25
using std::vector;
26
26
27
/** 
27
// A simple class to represent a parsed wasabi query string.
28
 * A simple class to represent a parsed wasabiSimple query
29
 * string. Can hold a string value or an array of subqueries.
30
 * The value can hold one or several words. In the latter case, it should 
31
 * be interpreted as a phrase (comes from a user-entered "quoted string").
32
 */
28
class WasaQuery {
33
class WasaQuery {
29
public:
34
public:
30
    enum Op {OP_NULL, OP_LEAF, OP_EXCL, OP_OR, OP_AND};
35
    enum Op {OP_NULL, OP_LEAF, OP_EXCL, OP_OR, OP_AND};
31
    typedef vector<WasaQuery*> subqlist_t;
36
    typedef vector<WasaQuery*> subqlist_t;
32
37
33
    WasaQuery() :  m_op(OP_NULL) {}
38
    WasaQuery() :  m_op(OP_NULL) {}
34
    ~WasaQuery();
39
    ~WasaQuery();
35
40
36
    // Get string describing this query
41
    // Get string describing the query tree from this point
37
    void describe(string &desc) const;
42
    void describe(string &desc) const;
38
43
39
    WasaQuery::Op            m_op;
44
    WasaQuery::Op            m_op;
40
    string                   m_fieldspec;
45
    string                   m_fieldspec;
46
    /* Valid for op == OP_LEAF */
47
    string                   m_value;
48
    /* Valid for conjunctions */
41
    vector<WasaQuery*>       m_subs;
49
    vector<WasaQuery*>       m_subs;
42
    string                   m_value;
43
};
50
};
44
51
45
52
46
// Wasabi query string parser class.
53
/**
54
 * Wasabi query string parser class. Could be a simple function
55
 * really, but there might be some parser initialization work done in
56
 * the constructor.
57
 */
47
class StringToWasaQuery {
58
class StringToWasaQuery {
48
public:
59
public:
49
    StringToWasaQuery();
60
    StringToWasaQuery();
50
    ~StringToWasaQuery();
61
    ~StringToWasaQuery();
51
    WasaQuery *stringToQuery(const string& str, string& reason);
62
    WasaQuery *stringToQuery(const string& str, string& reason);