version 1.2, 2015/04/20 18:10:35
|
version 1.3, 2015/04/20 18:20:37
|
|
|
WQL_TYPE_LE, | WQL_TYPE_LE, |
WQL_TYPE_GT, | WQL_TYPE_GT, |
WQL_TYPE_GE, | WQL_TYPE_GE, |
|
WQL_TYPE_LIKE, |
|
WQL_TYPE_ISA, |
WQL_TYPE_IDENTIFIER, | WQL_TYPE_IDENTIFIER, |
WQL_TYPE_BOOLEAN, | WQL_TYPE_BOOLEAN, |
WQL_TYPE_INTEGER, | WQL_TYPE_INTEGER, |
WQL_TYPE_REAL, | WQL_TYPE_REAL, |
WQL_TYPE_STRING, | WQL_TYPE_STRING, |
WQL_TYPE_NULL |
WQL_TYPE_NULL, |
|
WQL_TYPE_ANY |
} | } |
WQL_Type; | WQL_Type; |
| |
|
|
unsigned char boolean; | unsigned char boolean; |
long long integer; | long long integer; |
double real; | double real; |
MI_Char* string; |
/* property name or literal string */ |
|
ZChar* string; |
|
/* Example: SourceInstance.CIM_StorageVolume::OperationStatus */ |
|
ZChar* embeddedClassName; |
|
/* Example: SourceInstance.OperationStatus */ |
|
ZChar* embeddedPropertyName; |
} | } |
WQL_Value; | WQL_Value; |
| |
#define WQL_VALUE_BOOLEAN(X) { X, 0, 0, NULL } |
#define WQL_VALUE_BOOLEAN(X) { X, 0, 0, NULL, NULL, NULL } |
#define WQL_VALUE_INTEGER(X) { 0, X, 0, NULL } |
#define WQL_VALUE_INTEGER(X) { 0, X, 0, NULL , NULL, NULL} |
#define WQL_VALUE_REAL(X) { 0, 0, X, NULL } |
#define WQL_VALUE_REAL(X) { 0, 0, X, NULL , NULL, NULL} |
#define WQL_VALUE_STRING(X) { 0, 0, 0, X } |
#define WQL_VALUE_STRING(X) { 0, 0, 0, X , NULL, NULL} |
| |
/* Represents an operand or operator appearing in the WHERE clause */ | /* Represents an operand or operator appearing in the WHERE clause */ |
typedef struct _WQL_Symbol | typedef struct _WQL_Symbol |
|
|
} | } |
WQL_Symbol; | WQL_Symbol; |
| |
|
/* This parser supports WQL and CQL dialects */ |
|
typedef enum _WQL_Dialect |
|
{ |
|
WQL_DIALECT_WQL, |
|
WQL_DIALECT_CQL |
|
} |
|
WQL_Dialect; |
|
|
/* Output structure from WQL parser */ | /* Output structure from WQL parser */ |
typedef struct _WQL | typedef struct _WQL |
{ | { |
/* Properties given by SELECT list */ | /* Properties given by SELECT list */ |
const MI_Char* properties[WQL_MAX_PROPERTIES]; |
const ZChar* properties[WQL_MAX_PROPERTIES]; |
size_t nproperties; | size_t nproperties; |
| |
/* Class name given by FROM clause */ | /* Class name given by FROM clause */ |
const MI_Char* className; |
const ZChar* className; |
| |
/* Condition symbols given by WHERE class (in postfix order) */ | /* Condition symbols given by WHERE class (in postfix order) */ |
WQL_Symbol symbols[WQL_MAX_SYMBOLS]; | WQL_Symbol symbols[WQL_MAX_SYMBOLS]; |
|
|
int deleteBatch; | int deleteBatch; |
| |
/* The query text */ | /* The query text */ |
MI_Char* text; |
ZChar* text; |
|
|
|
/* Dialect being parsed: WQL or CQL */ |
|
WQL_Dialect dialect; |
} | } |
WQL; | WQL; |
| |
WQL* WQL_Parse(const MI_Char* text, Batch* batch); |
WQL* WQL_Parse( |
|
const ZChar* text, |
|
Batch* batch, |
|
WQL_Dialect dialect); |
| |
WQL* WQL_Clone(const WQL* self, Batch* batch); | WQL* WQL_Clone(const WQL* self, Batch* batch); |
| |
|
|
/* Return non-zero if the two WQL instances are identical */ | /* Return non-zero if the two WQL instances are identical */ |
int WQL_Identical(const WQL* x, const WQL* y); | int WQL_Identical(const WQL* x, const WQL* y); |
| |
/* Lookup function passed to WQL_Eval() */ |
/* Signature of Lookup() function called by WQL_Eval(). |
|
* name - |
|
* The property to be looked up. |
|
* embeddedClassName - |
|
* If non-null, the class type when 'name' is an embedded instance |
|
* property (uses ISA relationship). |
|
* embeddedPropertyName - |
|
* If non-null, the name of a property of the embedded instances |
|
* given by 'name'. |
|
* symbol - |
|
* Holds the result of the lookup operation (usually the value |
|
* of the property given by 'name'. |
|
* batch - |
|
* Batch allocator in case any memory must be allocated. |
|
* data - |
|
* The data argument passed to Lookup() function. |
|
* |
|
* More on these parameters: |
|
* name |
|
* embeddedClassName |
|
* embeddedPropertyName |
|
* |
|
* There are 4 conditions involving these parameters to consider: |
|
* |
|
* Case 1: (name && !embeddedClassName && !embeddedPropertyName) |
|
* Get the value of the property given by the 'name' parameter. |
|
* |
|
* Case 2: (name && embeddedClassName && !embeddedPropertyName) |
|
* Perform an ISA operation where the instance is given by the 'name' |
|
* embedded instance property and the classname is given by the |
|
* 'embeddedClassName' parameter. |
|
* WQL Example: SourceInstance ISA CIM_StorageVolume |
|
* name=SourceInstance |
|
* embeddedClassName=CIM_StorageVolume |
|
* embeddedPropertyName=NULL |
|
* |
|
* Case 3: (name && !embeddedClassName && embeddedPropertyName) |
|
* Get the value of the property given by the 'embeddedPropertyName' |
|
* parameter from the instance given by the 'name' parameter. |
|
* WQL Example: SourceInstance.OperationalStatus |
|
* name=SourceInstance |
|
* embeddedClassName=NULL |
|
* embeddedPropertyName=OperationalStatus |
|
* |
|
* Case 4: (name && embeddedClassName && embeddedPropertyName) |
|
* Get the value of the property given by the 'embeddedPropertyName' |
|
* parameter from the instance given by the 'name' parameter and |
|
* require that the the class satisfy the ISA relationship with |
|
* the 'embeddedClassName' parameter. |
|
* WQL Example: SourceInstance.CIM_StorageVolume.OperationalStatus |
|
* name=SourceInstance |
|
* embeddedClassName=CIM_StorageVolume |
|
* embeddedPropertyName=OperationalStatus |
|
* |
|
*/ |
typedef int (*WQL_Lookup)( | typedef int (*WQL_Lookup)( |
const MI_Char* name, |
const ZChar* name, |
|
const ZChar* embeddedClassName, |
|
const ZChar* embeddedPropertyName, |
WQL_Symbol* symbol, | WQL_Symbol* symbol, |
Batch* batch, | Batch* batch, |
void* data); | void* data); |
|
|
* property values from an MI_Instance( the data parameter is an MI_Instance). | * property values from an MI_Instance( the data parameter is an MI_Instance). |
*/ | */ |
int WQL_LookupInstanceProperty( | int WQL_LookupInstanceProperty( |
const MI_Char* name_, |
const ZChar* name, |
|
const ZChar* embeddedClassName, |
|
const ZChar* embeddedPropertyName, |
WQL_Symbol* symbol, | WQL_Symbol* symbol, |
Batch* batch, | Batch* batch, |
void* data); | void* data); |
|
|
/* Return non-zero if the WQL property list contains the given property */ | /* Return non-zero if the WQL property list contains the given property */ |
MI_Boolean WQL_ContainsProperty( | MI_Boolean WQL_ContainsProperty( |
const WQL* self, | const WQL* self, |
const MI_Char* propertyName); |
const ZChar* propertyName); |
| |
/* Validate the query against the given class declaration */ |
/* Validate the query against the given class declaration: returns 0 or -1 */ |
int WQL_Validate( | int WQL_Validate( |
const WQL* self, | const WQL* self, |
const MI_ClassDecl* cd); | const MI_ClassDecl* cd); |