(file) Return to CQLParser.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / CQL

Diff for /pegasus/src/Pegasus/CQL/CQLParser.h between version 1.2 and 1.3

version 1.2, 2004/11/21 12:13:07 version 1.3, 2004/12/02 21:57:18
Line 41 
Line 41 
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 /** This class is the main interface to the CQL parser used for parsing CQL1  /** This class is the main interface to the CQL parser used for parsing CQL compliant statements.
     compliant SQL statements.  
  
     Here's an example which parses a SELECT statement:     Here's an example which parses a SELECT statement:
  
Line 54 
Line 53 
  
         Array<Sint8> text(TEXT, sizeof(TEXT));         Array<Sint8> text(TEXT, sizeof(TEXT));
  
         WQLSelectStatement selectStatement;          CQLSelectStatement selectStatement;
  
         WQLParser parser;          CQLParser parser;
  
         try         try
         {         {
             parser.parse(text, selectStatement);             parser.parse(text, selectStatement);
         }         }
         catch (ParseError&)          catch (QueryException&)
         {  
             ...  
         }  
         catch (MissingNullTerminator&)  
         {         {
             ...             ...
         }         }
     </pre>     </pre>
  
     Note that the text must be NULL terminated or else the MissingNullTerminator  
     exception is thrown.  
   
     The text is read and the result is left in the selectStatement output     The text is read and the result is left in the selectStatement output
     argument.     argument.
  
     At this point you might wish to peek at the contents of the selectStatement.  
     This may be done by calling WQLSelectStatement::print() like this:  
   
     <pre>  
         WQLSelectStatement selectStatement;  
         ...  
         selectStatement.print();  
     </pre>  
   
     For the above query text, the following is printed:  
   
     <pre>  
         WQLSelectStatement  
         {  
             _className: "MyClass"  
   
             _propertyNames[0]: "X"  
             _propertyNames[1]: "Y"  
   
             _operations[0]: "WQL_GT"  
             _operations[1]: "WQL_LT"  
             _operations[2]: "WQL_AND"  
   
             _operands[0]: "PROPERTY_NAME: X"  
             _operands[1]: "INTEGER_VALUE: 10"  
             _operands[2]: "PROPERTY_NAME: Y"  
             _operands[3]: "INTEGER_VALUE: 3"  
         }  
     </pre>  
   
     The WQLSelectStatement::evaluateWhereClause() method may be called to  
     determine whether a particular instance (whose properties are made  
     available to he evaluateWhereClause() by a user implementation of the  
     WQLPropertySource class). This method returns true, if the where clause  
     matches this instance. Here is an example:  
   
     <pre>  
         WQLSelectStatement selectStatement;  
         ...  
         WQLPropertySource* propertySource = new MyPropertySource(...);  
   
         if (selectStatement.evaluateWhereClause(propertySource))  
         {  
             // It's a match!  
         }  
     </pre>  
   
     The evaluateWhereClause() method calls propertySource->getValue() to  
     obtain values for each of the properties referred to in where clause (X  
     and Y in the above query example).  
   
     The implementer of the WQLPropertySource interface must provide the  
     implementation of getValue() to produce values for the target data  
     types. The WQL library makes no assumptions about the nature of the  
     target data representation. This was done so that this libary could be  
     adapted to multiple data representations.  
   
     For use with Pegasus CIMInstance objects, a CIMInstancePropertySource  
     class could be developed whose getValue() method fetches values from  
     a CIMInstance. Here is an example of how it might be used.  
   
     <pre>  
         CIMInstancePropertySource* propertySource  
             = new CIMInstancePropertySource(...);  
   
         CIMInstance instance;  
   
         while (instance = GetNextInstance(...))  
         {  
             propertySource->setInstance(currentInstance);  
   
             if (selectStatement.evaluateWhereClause(propertySource))  
             {  
                 // It's a match!  
             }  
         }  
     </pre>  
   
     Of course the numeration of instances is left to the user of WQL.  
 */ */
 class PEGASUS_CQL_LINKAGE CQLParser class PEGASUS_CQL_LINKAGE CQLParser
 { {
Line 168 
Line 81 
         Please note that this method is not thread safe. It must be guarded         Please note that this method is not thread safe. It must be guarded
         with mutexes by the caller.         with mutexes by the caller.
  
         @param text null-terminated C-string which points to SQL statement.          @param text null-terminated C-string which points to CQL statement.
         @param statement object which holds the compiled version of the SELECT         @param statement object which holds the compiled version of the SELECT
             statement upon return.             statement upon return.
         @exception ParseError if text is not a valid SELECT statement.          @exception CQLSyntaxErrorException if text is not a valid SELECT statement.
         @exception MissingNullTerminator if text argument is not         @exception MissingNullTerminator if text argument is not
             terminated with a null.             terminated with a null.
     */     */
Line 207 
Line 120 
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END
 #endif #endif
 #endif /* Pegasus_WQLParser_h */  #endif /* Pegasus_CQLParser_h */


Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2