Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

136 lines
3.3 KiB

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