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.

180 lines
4.2 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. UATOM.HXX
  7. Universal Atom Management class definitions
  8. Win32 Atom Management of Unicode strings.
  9. FILE HISTORY:
  10. DavidHov 9/10/91 Created
  11. KeithMo 23-Oct-1991 Added forward references.
  12. */
  13. #ifndef _UATOM_HXX_
  14. #define _UATOM_HXX_
  15. #include "base.hxx"
  16. //
  17. // Forward references.
  18. //
  19. DLL_CLASS HUATOM;
  20. DLL_CLASS UATOM;
  21. DLL_CLASS UATOM_LINKAGE;
  22. DLL_CLASS UATOM_MANAGER;
  23. DLL_CLASS UATOM_REGION;
  24. /*************************************************************************
  25. NAME: HUATOM
  26. SYNOPSIS: Universal Atom Handle
  27. Converts any string to a 32 bit handle regardless
  28. of content.
  29. INTERFACE: Just construct using a string.
  30. PARENT: <parentclass>
  31. USES: <included class list>
  32. CAVEATS: Remember to use an object, not a pointer to a string
  33. to construct the HUATOM.
  34. NOTES:
  35. HISTORY:
  36. DavidHov 9/10/91 Created
  37. **************************************************************************/
  38. DLL_CLASS HUATOM
  39. {
  40. public:
  41. // Default constructor for use in static and structure declarations.
  42. inline HUATOM () : _puaAtom( (UATOM *) NULL ) {}
  43. // Constructor for use in constructing from a pointer.
  44. inline HUATOM ( UATOM * puAtom ) : _puaAtom( puAtom ) {}
  45. // Construct using a string.
  46. HUATOM ( const TCHAR * puzStr, BOOL fExists = FALSE ) ;
  47. // Return a pointer to the underlying text
  48. const TCHAR * QueryText () const ;
  49. // Return a pointer to the underlying NLS_STR in the table
  50. const NLS_STR * QueryNls () const ;
  51. // Standard functions and operators.
  52. // Return standard error codes if invalid
  53. APIERR QueryError () const ;
  54. // Compare two HUATOMs
  55. inline BOOL operator==( const HUATOM & huaAtom ) const
  56. { return _puaAtom == huaAtom._puaAtom ; }
  57. // Compare two HUATOMs for inequality
  58. inline BOOL operator!=( const HUATOM & huaAtom ) const
  59. { return _puaAtom != huaAtom._puaAtom ; }
  60. // Return TRUE if HUATOM is invalid
  61. inline BOOL operator ! () const
  62. { return _puaAtom == NULL ; }
  63. // If cast BOOL, return TRUE if HUATOM is valid
  64. inline operator BOOL () const
  65. { return _puaAtom != NULL ; }
  66. // Assignment operator: just move the opaque pointer
  67. // BUGBUG: if ref parameter is 'const', intermediate variable
  68. // construction is marked 'const', and C compiler error results.
  69. #if defined(_CFRONT_PASS_)
  70. #define CONST_HACK
  71. #else
  72. #define CONST_HACK const
  73. #endif
  74. inline HUATOM & operator= ( CONST_HACK HUATOM & huaAtom )
  75. { _puaAtom = huaAtom._puaAtom ; return *this ; }
  76. // Cast to void *; return opaque pointer
  77. inline operator void * () const
  78. { return (void *) _puaAtom ; }
  79. inline operator const TCHAR * () const
  80. { return QueryText() ; }
  81. inline operator const NLS_STR * () const
  82. { return QueryNls() ; }
  83. inline operator const NLS_STR & () const
  84. { return *QueryNls() ; }
  85. private:
  86. UATOM * _puaAtom ;
  87. };
  88. /*************************************************************************
  89. NAME: UATOM_MANAGER
  90. SYNOPSIS: Universal Atom Management control functions.
  91. The underlying hashing and table routines for HUATOM.
  92. INTERFACE: Application must call UATOM_MANGER::Initialize() before
  93. any HUATOMs are created.
  94. PARENT: BASE
  95. USES: none
  96. CAVEATS:
  97. NOTES:
  98. HISTORY:
  99. DavidHov 9/10/91 Created
  100. **************************************************************************/
  101. DLL_CLASS UATOM_MANAGER : public BASE
  102. {
  103. friend class HUATOM ;
  104. public:
  105. // Create the atom management space and instance
  106. static APIERR Initialize ();
  107. // Destroy the atom management space.
  108. static APIERR Terminate () ;
  109. // Return a pointer to the atom manager instance
  110. static UATOM_MANAGER * Instance () ;
  111. private:
  112. UATOM_MANAGER ();
  113. ~ UATOM_MANAGER () ;
  114. static UATOM_MANAGER * pInstance ; // Private instance pointer
  115. UATOM * Tokenize // Tokenizing function
  116. ( const TCHAR * puzStr, BOOL fExists = FALSE ) ;
  117. UATOM_REGION * _pumRegion ; // Atom storage region
  118. };
  119. #endif // _UATOM_HXX_