home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / frquery.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  4.1 KB  |  121 lines

  1. #pragma option push -b -a8 -pc -A- /*P_O_Push*/
  2. //***************************************************************************
  3. //
  4. //  Copyright (c) 1997-1999 Microsoft Corporation
  5. //
  6. //  FRQuery.h
  7. //
  8. //  Purpose: query support classes
  9. //
  10. //***************************************************************************
  11.  
  12. #if _MSC_VER > 1000
  13. #pragma once
  14. #endif
  15.  
  16. #ifndef _FRAMEWORK_QUERY_H_
  17. #define _FRAMEWORK_QUERY_H_
  18. #include <stdio.h>
  19. #include <sql_1.h>
  20. #include <comdef.h>
  21. #include <vector>
  22.  
  23. class POLARITY CFrameworkQuery
  24. {
  25. public:
  26.     CFrameworkQuery();
  27.     ~CFrameworkQuery();
  28.  
  29.     // Finds out if a particular field was requested by the query in either
  30.     // the Select statement, or the Where statement.  Only meaningful if we
  31.     // are in ExecQueryAsync and the query has been sucessfully parsed.
  32.     bool IsPropertyRequired(LPCWSTR propName);
  33.  
  34.     // Gets the class name from the query.  Only meaningful if we are
  35.     // in ExecQueryAsync and the query has been sucessfully parsed.  It
  36.     // is the responsibility of the caller to SysFreeString the returned
  37.     // string.
  38.     BSTR GetQueryClassName(void) { return SysAllocString(m_bstrtClassName); }
  39.  
  40.     // Given a property name, it will return all the values
  41.     // that the query requests in a CHStringArray.
  42.     // Select * from win32_directory where drive = "C:" GetValuesForProp(L"Drive") -> C:
  43.     // Where Drive = "C:" or Drive = "D:" GetValuesForProp(L"Drive") -> C:, D:
  44.     // Where Path = "\DOS" GetValuesForProp(L"Drive") -> (empty)
  45.     // Where Drive <> "C:" GetValuesForProp(L"Drive") -> (empty)
  46.     // Where Drive = "C:" or (Drive = "D:" and Mounted = true) GetValuesForProp(L"Drive") -> C:, D:
  47.     HRESULT GetValuesForProp(LPCWSTR wszPropName, CHStringArray& achNames);
  48.  
  49.     // Here's an overloaded version in case client wants to pass in a vector of _bstr_t's
  50.     HRESULT GetValuesForProp(LPCWSTR wszPropName, std::vector<_bstr_t>& vectorNames);
  51.  
  52.     // Returns a list of all the properties specified in the Select clause, plus.
  53.     // all the the properties from the Where clauses.  If the returned array is empty, all
  54.     // properties are required.
  55.     void GetRequiredProperties(CHStringArray &saProperties);
  56.  
  57.     // Boolean indicating if all properties are being requested.
  58.     bool AllPropertiesAreRequired(void) { return (m_csaPropertiesRequired.GetSize() == 0); }
  59.  
  60.     // Boolean indicating if only the key properties are required.
  61.     bool KeysOnly(void) { return m_bKeysOnly; }
  62.  
  63.     // Accessor function to retrieve wql query
  64.     const CHString &GetQuery() ;
  65.  
  66.     // Moves the values into the member variables.  Should never be called by users.
  67.     HRESULT Init(
  68.         
  69.         const BSTR bstrQueryFormat, 
  70.         const BSTR bstrQuery, 
  71.         long lFlags,
  72.         CHString &sNamespace
  73.     );
  74.  
  75.     // Moves the values into the member variables.  Should never be called by users.
  76.     HRESULT Init(
  77.  
  78.         ParsedObjectPath *pParsedObjectPath, 
  79.         IWbemContext *pCtx, 
  80.         LPCWSTR lpwszClassName,
  81.         CHString &sNamespace
  82.     );
  83.  
  84.     // Initializes the KeysOnly data member.  Should never be called by users.
  85.     void Init2(IWbemClassObject *IClass);
  86.  
  87.  
  88. protected:
  89.  
  90.     /*****************************************************************************/
  91.     /* The rest of these data members and functions are intended for Microsoft   */
  92.     /* internal use only. Use by third parties is unsupported and unrecommended. */
  93.     /*****************************************************************************/
  94.  
  95.     SQL_LEVEL_1_RPN_EXPRESSION *m_pLevel1RPNExpression;
  96.     CHStringArray m_csaPropertiesRequired;
  97.     enum QueryTypes{eUnknown, eWQLCommand, eContextObject} m_QueryType;
  98.  
  99.     DWORD IsInList(const CHStringArray &csaArray, LPCWSTR pwszValue);
  100.  
  101.     BOOL IsReference(LPCWSTR lpwszPropertyName);
  102.     const CHString &GetNamespace();
  103.  
  104. private:
  105.  
  106.     CHString m_sNamespace;
  107.     long m_lFlags;
  108.     IWbemClassObject *m_IClass;
  109.     CHString m_sQueryFormat;
  110.  
  111.     void Reset(void);
  112.     bool m_bKeysOnly;
  113.     bool m_AddKeys;
  114.     CHString m_sQuery;
  115.     bstr_t m_bstrtClassName;
  116.  
  117. };
  118.  
  119. #endif
  120. #pragma option pop /*P_O_Pop*/
  121.