home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 25: Programming / pc_actual_25.iso / C_C++ / BorlandCompiler / freecommandLinetools.exe / Include / objpath.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-27  |  3.5 KB  |  137 lines

  1. /*++
  2.  
  3. Copyright (C) 1999 Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     OBJPATH.H
  8.  
  9. Abstract:
  10.  
  11.     object path parser
  12.  
  13. History:
  14.  
  15. --*/
  16.  
  17. #ifndef _OBJPATH_H_
  18. #pragma option push -b -a8 -pc -A- /*P_O_Push*/
  19. #define _OBJPATH_H_
  20.  
  21. #include <opathlex.h>
  22. #include <Polarity.h>
  23.  
  24. #define DELETE_ME
  25.  
  26. struct POLARITY KeyRef
  27. {
  28.     LPWSTR  m_pName;
  29.     VARIANT m_vValue;
  30.  
  31.     KeyRef();
  32.     KeyRef(LPCWSTR wszKeyName, const VARIANT* pvValue);
  33.    ~KeyRef();
  34. };
  35.  
  36. struct POLARITY ParsedObjectPath
  37. {
  38.     LPWSTR      m_pServer;              // NULL if no server
  39.     DWORD       m_dwNumNamespaces;      // 0 if no namespaces
  40.     DWORD       m_dwAllocNamespaces;    // size of m_paNamespaces
  41.     LPWSTR     *m_paNamespaces;         // NULL if no namespaces
  42.     LPWSTR      m_pClass;               // Class name
  43.     DWORD       m_dwNumKeys;            // 0 if no keys (just a class name)
  44.     DWORD       m_dwAllocKeys;          // size of m_paKeys
  45.     KeyRef    **m_paKeys;               // NULL if no keys specified
  46.     BOOL        m_bSingletonObj;        // true if object of class with no keys
  47.     ParsedObjectPath();
  48.    ~ParsedObjectPath();
  49.  
  50. public:
  51.     BOOL SetClassName(LPCWSTR wszClassName);
  52.     BOOL AddKeyRef(LPCWSTR wszKeyName, const VARIANT* pvValue);
  53.     BOOL AddKeyRef(KeyRef* pAcquireRef);
  54.     BOOL AddKeyRefEx(LPCWSTR wszKeyName, const VARIANT* pvValue);
  55.     BOOL AddNamespace(LPCWSTR wszNamespace);
  56.     LPWSTR GetKeyString();
  57.     LPWSTR GetNamespacePart();
  58.     LPWSTR GetParentNamespacePart();
  59.     void ClearKeys () ;
  60.     BOOL IsRelative(LPCWSTR wszMachine, LPCWSTR wszNamespace);
  61.     BOOL IsLocal(LPCWSTR wszMachine);
  62.     BOOL IsClass();
  63.     BOOL IsInstance();
  64.     BOOL IsObject();
  65. };
  66.  
  67. // NOTE:
  68. // The m_vValue in the KeyRef may not be of the expected type, i.e., the parser
  69. // cannot distinguish 16 bit integers from 32 bit integers if they fall within the
  70. // legal subrange of a 16 bit value.  Therefore, the parser only uses the following
  71. // types for keys:
  72. //      VT_I4, VT_R8, VT_BSTR
  73. // If the underlying type is different, the user of this parser must do appropriate
  74. // type conversion.
  75. //  
  76. typedef enum
  77. {
  78.     e_ParserAcceptRelativeNamespace,    // Allow a relative namespace
  79.     e_ParserAbsoluteNamespaceOnly,      // Require a full object path
  80.     e_ParserAcceptAll                   // Accept any recognizable subset of a path
  81. } ObjectParserFlags;
  82.  
  83. class POLARITY CObjectPathParser
  84. {
  85.     LPWSTR m_pInitialIdent;
  86.     int m_nCurrentToken;
  87.     CGenLexer *m_pLexer;
  88.     ParsedObjectPath *m_pOutput;
  89.     KeyRef *m_pTmpKeyRef;
  90.     
  91.     ObjectParserFlags m_eFlags;
  92.  
  93. private:
  94.     void Zero();
  95.     void Empty();
  96.  
  97.     int begin_parse();
  98.  
  99.     int ns_or_server();
  100.     int ns_or_class();
  101.     int objref();
  102.     int ns_list();
  103.     int ident_becomes_ns();
  104.     int ident_becomes_class();
  105.     int objref_rest();
  106.     int ns_list_rest();
  107.     int key_const();
  108.     int keyref_list();
  109.     int keyref();
  110.     int keyref_term();
  111.     int propname();    
  112.     int optional_objref();
  113.  
  114.     int NextToken();
  115.  
  116. public:
  117.     enum { NoError, SyntaxError, InvalidParameter };
  118.  
  119.     CObjectPathParser(ObjectParserFlags eFlags = e_ParserAbsoluteNamespaceOnly);
  120.    ~CObjectPathParser();
  121.  
  122.     int Parse(
  123.         LPCWSTR RawPath,
  124.         ParsedObjectPath **pOutput
  125.         );
  126.     static int WINAPI Unparse(
  127.         ParsedObjectPath* pInput,
  128.         DELETE_ME LPWSTR* pwszPath);
  129.  
  130.     static LPWSTR WINAPI GetRelativePath(LPWSTR wszFullPath);
  131.  
  132.     void Free(ParsedObjectPath *pOutput);
  133. };
  134.  
  135. #pragma option pop /*P_O_Pop*/
  136. #endif
  137.