Leaked source code of windows server 2003
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.

303 lines
6.6 KiB

  1. //***************************************************************************
  2. //
  3. // INSTPATH.H
  4. //
  5. // Module: OLE MS Provider Framework
  6. //
  7. // Copyright (c) 1996-2001 Microsoft Corporation, All Rights Reserved
  8. //
  9. //***************************************************************************
  10. #define OLEMS_PATH_SERVER_SEPARATOR L"\\\\"
  11. #define OLEMS_PATH_NAMESPACE_SEPARATOR L"\\"
  12. #define OLEMS_PATH_PROPERTY_SEPARATOR L","
  13. #define OLEMS_PATH_CLASSOBJECT_SEPARATOR L":"
  14. #define OLEMS_PATH_CLASSPROPERTYSPEC_SEPARATOR L"."
  15. #define OLEMS_PATH_PROPERTYEQUIVALENCE L"="
  16. #define OLEMS_PATH_ARRAY_START_SEPARATOR L"{"
  17. #define OLEMS_PATH_ARRAY_END_SEPARATOR L"}"
  18. #define OLEMS_PATH_SERVER_DEFAULT L"."
  19. #define OLEMS_PATH_NAMESPACE_DEFAULT L"."
  20. #define OLEMS_PATH_SINGLETON L"*"
  21. //---------------------------------------------------------------------------
  22. //
  23. // Class: WbemLexiconValue
  24. //
  25. // Purpose: WbemLexiconValue provides a lexical token semantic value.
  26. //
  27. // Description: WbemAnalyser provides an implementation of a lexical
  28. // analyser token semantic value
  29. //
  30. //---------------------------------------------------------------------------
  31. union WbemLexiconValue
  32. {
  33. LONG integer ;
  34. WCHAR *string ;
  35. GUID guid ;
  36. WCHAR *token ;
  37. } ;
  38. //---------------------------------------------------------------------------
  39. //
  40. // Class: WbemLexicon
  41. //
  42. // Purpose: WbemLexicon provides a lexical token creating during
  43. // lexical analysis.
  44. //
  45. // Description: WbemAnalyser provides an implementation of a lexical
  46. // analyser token object
  47. //
  48. //---------------------------------------------------------------------------
  49. class WbemAnalyser;
  50. class WbemLexicon
  51. {
  52. friend WbemAnalyser ;
  53. public:
  54. enum LexiconToken {
  55. TOKEN_ID ,
  56. STRING_ID ,
  57. OID_ID ,
  58. INTEGER_ID ,
  59. COMMA_ID ,
  60. OPEN_BRACE_ID ,
  61. CLOSE_BRACE_ID ,
  62. COLON_ID ,
  63. DOT_ID ,
  64. AT_ID ,
  65. EQUALS_ID ,
  66. BACKSLASH_ID ,
  67. EOF_ID
  68. } ;
  69. private:
  70. WCHAR *tokenStream ;
  71. ULONG position ;
  72. LexiconToken token ;
  73. WbemLexiconValue value ;
  74. protected:
  75. public:
  76. WbemLexicon () ;
  77. ~WbemLexicon () ;
  78. WbemLexicon :: LexiconToken GetToken () ;
  79. WbemLexiconValue *GetValue () ;
  80. } ;
  81. //---------------------------------------------------------------------------
  82. //
  83. // Class: WbemAnalyser
  84. //
  85. // Purpose: WbemAnalyser provides a lexical analyser for parsing.
  86. //
  87. // Description: WbemAnalyser provides an implementation of a lexical
  88. // analyser used by WbemNamespacePath and WbemObjectPath
  89. // classes during path parsing.
  90. //
  91. //---------------------------------------------------------------------------
  92. class WbemAnalyser
  93. {
  94. private:
  95. WCHAR *stream ;
  96. ULONG position ;
  97. BOOL status ;
  98. BOOL IsEof ( WCHAR token ) ;
  99. BOOL IsLeadingDecimal ( WCHAR token ) ;
  100. BOOL IsDecimal ( WCHAR token ) ;
  101. BOOL IsOctal ( WCHAR token ) ;
  102. BOOL IsHex ( WCHAR token ) ;
  103. BOOL IsAlpha ( WCHAR token ) ;
  104. BOOL IsAlphaNumeric ( WCHAR token ) ;
  105. BOOL IsWhitespace ( WCHAR token ) ;
  106. LONG OctToDec ( WCHAR token ) ;
  107. LONG HexToDec ( WCHAR token ) ;
  108. WbemLexicon *GetToken () ;
  109. protected:
  110. public:
  111. WbemAnalyser ( WCHAR *tokenStream = NULL ) ;
  112. virtual ~WbemAnalyser () ;
  113. void Set ( WCHAR *tokenStream ) ;
  114. WbemLexicon *Get () ;
  115. void PutBack ( WbemLexicon *token ) ;
  116. virtual operator void * () ;
  117. } ;
  118. //---------------------------------------------------------------------------
  119. //
  120. // Class: WbemNamespacePath
  121. //
  122. // Purpose: Defines interface for OLE MS namespace path definitions.
  123. //
  124. // Description: WbemNamespacePath allows the creation of an OLE MS namespace
  125. // path definition using either a textual string convention or
  126. // via a programmatic interface.
  127. //
  128. //---------------------------------------------------------------------------
  129. class WbemNamespacePath
  130. {
  131. private:
  132. //
  133. // Lexical analysis information used when parsing token stream
  134. //
  135. BOOL pushedBack ;
  136. WbemAnalyser analyser ;
  137. WbemLexicon *pushBack ;
  138. //
  139. // Status of the object path based on parsing process. Initially set to TRUE on
  140. // object construction, set to FALSE prior to parsing process.
  141. //
  142. BOOL status ;
  143. //
  144. // component objects associated with namespace path
  145. //
  146. BOOL relative ;
  147. WCHAR *server ;
  148. void *nameSpaceList ;
  149. void *nameSpaceListPosition ;
  150. //
  151. // Utility Routines
  152. //
  153. void CleanUp () ;
  154. void SetUp () ;
  155. //
  156. // Recursive descent procedures
  157. //
  158. BOOL NameSpaceName () ;
  159. BOOL NameSpaceAbs () ;
  160. BOOL RecursiveNameSpaceAbs () ;
  161. BOOL RecursiveNameSpaceRel () ;
  162. BOOL NameSpaceRel () ;
  163. BOOL BackSlashFactoredServerSpec () ;
  164. BOOL BackSlashFactoredServerNamespace () ;
  165. //
  166. // Lexical analysis helper functions
  167. //
  168. void PushBack () ;
  169. WbemLexicon *Get () ;
  170. WbemLexicon *Match ( WbemLexicon :: LexiconToken tokenType ) ;
  171. protected:
  172. public:
  173. //
  174. // Constructor/Destructor.
  175. // Constructor initialises status of object to TRUE,
  176. // i.e. operator void* returns this.
  177. //
  178. WbemNamespacePath () ;
  179. WbemNamespacePath ( const WbemNamespacePath &nameSpacePathArg ) ;
  180. virtual ~WbemNamespacePath () ;
  181. BOOL Relative () const { return relative ; }
  182. //
  183. // Get server component
  184. //
  185. WCHAR *GetServer () const { return server ; } ;
  186. //
  187. // Set server component, object must be on heap,
  188. // deletion of object is under control of WbemNamespacePath.
  189. //
  190. void SetServer ( WCHAR *serverNameArg ) ;
  191. //
  192. // Move to position prior to first element of namespace component hierarchy
  193. //
  194. void Reset () ;
  195. //
  196. // Move to next position in namespace component hierarchy and return namespace
  197. // component. Value returned is a reference to the actual component within the
  198. // namespace component hierarchy container. Applications must not change contents
  199. // of value returned by reference. Next returns NULL when all namespace components
  200. // have been visited.
  201. //
  202. WCHAR *Next () ;
  203. BOOL IsEmpty () const ;
  204. ULONG GetCount () const ;
  205. //
  206. // Append namespace component, object must be on heap,
  207. // deletion of object is under control of WbemNamespacePath.
  208. //
  209. void Add ( WCHAR *namespacePath ) ;
  210. //
  211. // Parse token stream to form component objects
  212. //
  213. BOOL SetNamespacePath ( WCHAR *namespacePath ) ;
  214. void SetRelative ( BOOL relativeArg ) { relative = relativeArg ; }
  215. //
  216. // Serialise component objects to form token stream
  217. //
  218. WCHAR *GetNamespacePath () ;
  219. //
  220. // Concatenate Absolute/Relative path with Relative path
  221. //
  222. BOOL ConcatenatePath ( WbemNamespacePath &relative ) ;
  223. //
  224. // Return status of WbemNamespacePath.
  225. // Status can only change during a call to SetNamespacePath.
  226. //
  227. virtual operator void *() ;
  228. } ;