Return to WQLSelectStatement.h CVS log | Up to [Pegasus] / pegasus / src / Pegasus / WQL |
1 mike 1.1.2.1 //%///////////////////////////////////////////////////////////////////////////// 2 // 3 // Copyright (c) 2000, 2001 BMC Software, Hewlett-Packard Company, IBM, 4 // The Open Group, Tivoli Systems 5 // 6 // Permission is hereby granted, free of charge, to any person obtaining a copy 7 // of this software and associated documentation files (the "Software"), to 8 // deal in the Software without restriction, including without limitation the 9 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 // sell copies of the Software, and to permit persons to whom the Software is 11 // furnished to do so, subject to the following conditions: 12 // 13 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN 14 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED 15 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 16 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 17 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 18 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 19 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 // 22 mike 1.1.2.1 //============================================================================== 23 // 24 // Author: Mike Brasher (mbrasher@bmc.com) 25 // 26 // Modified By: 27 // 28 //%///////////////////////////////////////////////////////////////////////////// 29 30 #ifndef Pegasus_WQLSelectStatement_h 31 #define Pegasus_WQLSelectStatement_h 32 33 #include <Pegasus/Common/Config.h> 34 #include <Pegasus/Common/Array.h> 35 #include <Pegasus/Common/String.h> 36 #include <Pegasus/WQL/WQLOperation.h> 37 #include <Pegasus/WQL/WQLOperand.h> | ||
38 mike 1.1.2.2 #include <Pegasus/WQL/WQLPropertySource.h> | ||
39 mike 1.1.2.1 40 PEGASUS_NAMESPACE_BEGIN 41 | ||
42 mike 1.1.2.4 /** This class represents a compiled WQL1 select statement. | ||
43 mike 1.1.2.1 44 An instance of WQLSelectStatement is passed to WQLParser::parse() which | ||
45 mike 1.1.2.4 parses the WQL1 SELECT statement and initializes the WQLSelectStatement 46 instance. A WQL1 SELECT statement has the following form: | ||
47 mike 1.1.2.1 48 <pre> | ||
49 mike 1.1.2.4 SELECT <property>... 50 FROM <class name> 51 WHERE <where clause> | ||
52 mike 1.1.2.1 </pre> 53 | ||
54 mike 1.1.2.4 The properties are obtained with the getProperties() method. The class 55 name is obtained with getClassName(). The where clause is evaluated by 56 calling evaluateWhereClause() with the appropriate arguments. If 57 hasWhereClause() returns false, then there is no where clause. | ||
58 mike 1.1.2.1 59 The components of the where clause are stored in two arrays: one for 60 operands and one for operators (these are placed in proper order by the 61 YACC parser). Evaluation is performed using a Boolean stack. See the 62 implementation of evaluateWhereClause() for details. 63 */ 64 class PEGASUS_WQL_LINKAGE WQLSelectStatement 65 { 66 public: 67 68 /** Default constructor. 69 */ 70 WQLSelectStatement(); 71 72 /** Destructor. 73 */ 74 ~WQLSelectStatement(); 75 76 /** Clears all data members of this object. 77 */ 78 void clear(); 79 mike 1.1.2.1 80 /** Accessor. 81 */ 82 const String& getClassName() const 83 { 84 return _className; 85 } 86 87 /** Modifier. This method should not be called by the user (only by the 88 parser). 89 */ 90 void setClassName(const String& className) 91 { 92 _className = className; 93 } 94 95 /** Returns the number of property names which were indicated in the 96 selection list. 97 */ 98 Uint32 getPropertyNameCount() const 99 { 100 mike 1.1.2.1 return _propertyNames.size(); 101 } 102 103 /** Gets the i-th property name in the list. 104 */ 105 const String& getPropertyName(Uint32 i) 106 { 107 return _propertyNames[i]; 108 } 109 110 /** Appends a property name to the property name list. This user should 111 not call this method; it should only be called by the parser. 112 */ 113 void appendPropertyName(const String& x) 114 { 115 _propertyNames.append(x); 116 } 117 118 /** Appends an operation to the operation array. This method should only 119 be called by the parser itself. 120 */ 121 mike 1.1.2.1 void appendOperation(WQLOperation x) 122 { 123 _operations.append(x); 124 } 125 126 /** Appends an operand to the operation array. This method should only 127 be called by the parser itself. 128 */ 129 void appendOperand(const WQLOperand& x) 130 { 131 _operands.append(x); 132 } 133 134 /** Returns true if this class has a where clause. 135 */ 136 Boolean hasWhereClause() const 137 { 138 return _operations.size() != 0; 139 } 140 | ||
141 mike 1.1.2.2 /** Evalautes the where clause using the symbol table to resolve symbols. | ||
142 mike 1.1.2.1 */ | ||
143 mike 1.1.2.3 Boolean evaluateWhereClause(const WQLPropertySource* source) const; | ||
144 mike 1.1.2.1 145 /** Prints out the members of this class. 146 */ 147 void print() const; 148 149 private: 150 151 // 152 // The name of the target class. For example: 153 // 154 // SELECT * 155 // FROM TargetClass 156 // WHERE ... 157 // 158 159 String _className; 160 161 // 162 // The list of property names being selected. For example, see "firstName", 163 // and "lastName" below. 164 // 165 mike 1.1.2.1 // SELECT firstName, lastName 166 // FROM TargetClass 167 // WHERE ... 168 // 169 170 Array<String> _propertyNames; 171 172 // 173 // The list of operations encountered while parsing the WHERE clause. 174 // Consider this query: 175 // 176 // SELECT * 177 // FROM TargetClass 178 // WHERE count > 10 OR peak < 20 AND state = "OKAY" 179 // 180 // This would generate the following stream of WQLOperations: 181 // 182 // WQL_GT 183 // WQL_LT 184 // WQL_EQ 185 // WQL_AND 186 mike 1.1.2.1 // WQL_OR 187 // 188 189 Array<WQLOperation> _operations; 190 191 // 192 // The list of operands encountered while parsing the WHERE clause. They 193 // query just above would generate the following stream of operands: 194 // 195 // count, 10, peak, 20, state, "OKAY" 196 // 197 198 Array<WQLOperand> _operands; 199 }; 200 201 PEGASUS_NAMESPACE_END 202 203 #endif /* Pegasus_WQLSelectStatement_h */ |
No CVS admin address has been configured |
Powered by ViewCVS 0.9.2 |