Quantum GIS API Documentation
1.7.5-Wroclaw
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
core
qgssearchstring.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgssearchstring.cpp
3
interface for parsing and evaluation of search strings
4
--------------------
5
begin : 2005-07-26
6
copyright : (C) 2005 by Martin Dobias
7
email : won.der at centrum.sk
8
***************************************************************************/
9
10
/***************************************************************************
11
* *
12
* This program is free software; you can redistribute it and/or modify *
13
* it under the terms of the GNU General Public License as published by *
14
* the Free Software Foundation; either version 2 of the License, or *
15
* (at your option) any later version. *
16
* *
17
***************************************************************************/
18
/* $Id$ */
19
20
#include "
qgssearchstring.h
"
21
#include "
qgssearchtreenode.h
"
22
23
25
extern
QgsSearchTreeNode
*
parseSearchString
(
const
QString& str, QString& parserErrorMsg );
26
27
28
QgsSearchString::QgsSearchString
()
29
{
30
mTree
= NULL;
31
}
32
33
QgsSearchString::QgsSearchString
(
const
QString & str )
34
{
35
mTree
= NULL;
36
setString
( str );
37
}
38
39
QgsSearchString::QgsSearchString
(
const
QgsSearchString
& str )
40
{
41
if
( str.
mTree
)
42
mTree
=
new
QgsSearchTreeNode
( *str.
mTree
);
43
else
44
mTree
= NULL;
45
mString
= str.
mString
;
46
}
47
48
QgsSearchString
&
QgsSearchString::operator=
(
const
QgsSearchString
& str )
49
{
50
clear
();
51
52
if
( str.
mTree
)
53
mTree
=
new
QgsSearchTreeNode
( *str.
mTree
);
54
else
55
mTree
= NULL;
56
mString
= str.
mString
;
57
58
return
*
this
;
59
}
60
61
62
QgsSearchString::~QgsSearchString
()
63
{
64
delete
mTree
;
// deletes complete tree
65
}
66
67
68
bool
QgsSearchString::setString
( QString str )
69
{
70
mParserErrorMsg
.clear();
71
72
// empty string
73
if
( str.isEmpty() )
74
{
75
clear
();
76
return
true
;
77
}
78
79
// calls external C function that does all parsing
80
QgsSearchTreeNode
*
tree
=
parseSearchString
( str,
mParserErrorMsg
);
81
if
( tree )
82
{
83
delete
mTree
;
84
mTree
=
tree
;
85
mString
= str;
86
return
true
;
87
}
88
89
return
false
;
90
}
91
92
93
bool
QgsSearchString::setTree
(
QgsSearchTreeNode
* tree )
94
{
95
if
( tree == NULL )
96
{
97
clear
();
98
}
99
else
100
{
101
delete
mTree
;
102
mTree
=
new
QgsSearchTreeNode
( *tree );
103
mString
=
mTree
->
makeSearchString
();
104
}
105
return
true
;
106
}
107
108
bool
QgsSearchString::isEmpty
()
109
{
110
return
(
mTree
== NULL );
111
}
112
113
void
QgsSearchString::clear
()
114
{
115
delete
mTree
;
116
mTree
= NULL;
117
mString
.clear();
118
}
Generated on Wed Jun 13 2012 13:54:11 for Quantum GIS API Documentation by
1.8.1