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.

129 lines
4.1 KiB

  1. /*--------------------------------------------------------------------------*
  2. *
  3. * Microsoft Windows
  4. * Copyright (C) Microsoft Corporation, 1992 - 1999
  5. *
  6. * File: bookmark.h
  7. *
  8. * Contents: Interface file for CBookmark
  9. *
  10. * History: 05-Oct-98 jeffro Created
  11. *
  12. *--------------------------------------------------------------------------*/
  13. #ifndef BOOKMARK_H
  14. #define BOOKMARK_H
  15. #pragma once
  16. #include <windows.h>
  17. #include <vector>
  18. #include <objbase.h>
  19. #include "ndmgr.h"
  20. #include "ndmgrpriv.h"
  21. #include "stddbg.h"
  22. #include "stgio.h"
  23. #include "xmlbase.h"
  24. typedef std::vector<BYTE> ByteVector;
  25. #define BOOKMARK_CUSTOMSTREAMSIGNATURE "MMCCustomStream"
  26. //***************************************************************************
  27. // class CDynamicPathEntry
  28. //
  29. //
  30. // PURPOSE: Encapsulates a single entry in the dynamic path of a bookmark.
  31. //
  32. // NOTES: In MMC2.0 which shipped with WindowsXP, the m_type member could be
  33. // just one of NDTYP_STRING or NDTYP_CUSTOM. In MMC2.0 that shipped with
  34. // .net server, this was changed to allow a third possibility - a bitwise OR
  35. // of NDTYP_STRING and NDTYP_CUSTOM. This is because snap-ins that previously
  36. // did not implement a CCF_ format and later changed to implement the format
  37. // would find that their old bookmarks no longer worked.
  38. //
  39. // The pattern matching strategy has therefore changed to match whatever
  40. // data is present in the bookmark.
  41. //
  42. //****************************************************************************
  43. class CDynamicPathEntry : public CXMLObject
  44. {
  45. protected:
  46. enum PathEntryType
  47. {
  48. NDTYP_STRING = 0x01,
  49. NDTYP_CUSTOM = 0x02
  50. };
  51. public:
  52. // comparison
  53. bool operator ==(const CDynamicPathEntry &rhs) const;
  54. bool operator < (const CDynamicPathEntry &rhs) const;
  55. SC ScInitialize(bool bIs10Path, /*[IN,OUT]*/ByteVector::iterator &iter);
  56. virtual void Persist(CPersistor &persistor);
  57. DEFINE_XML_TYPE(XML_TAG_DYNAMIC_PATH_ENTRY);
  58. protected:
  59. BYTE m_type; // A combination of one or more flags from the enum PathEntryType - See above note.
  60. ByteVector m_byteVector; // the actual data if it is a custom ID
  61. std::wstring m_strEntry; // the actual data if it is a string.
  62. };
  63. /*+-------------------------------------------------------------------------*
  64. * class CBookmark
  65. *
  66. *
  67. * PURPOSE: Maintains a persistent representation of a scope node.
  68. *
  69. *+-------------------------------------------------------------------------*/
  70. class CBookmark : public CXMLObject
  71. {
  72. friend class CScopeTree;
  73. typedef std::list<CDynamicPathEntry> CDynamicPath;
  74. public:
  75. enum { ID_Unknown = -1 };
  76. CBookmark(MTNODEID idStatic = ID_Unknown) : m_idStatic (idStatic) , m_bIsFastBookmark(true) {}
  77. CBookmark(bool bIsFastBookmark) : m_idStatic (0), m_bIsFastBookmark(bIsFastBookmark) {}
  78. virtual ~CBookmark () {}
  79. bool IsValid () const { return (m_idStatic != ID_Unknown); }
  80. bool IsStatic () const { ASSERT (IsValid()); return (m_dynamicPath.empty()); }
  81. bool IsDynamic () const { return (!IsStatic());}
  82. void Reset() {m_idStatic = ID_Unknown; m_dynamicPath.clear();}
  83. IStream & Load(IStream &stm);
  84. // Casts
  85. operator HBOOKMARK() const;
  86. static CBookmark * GetBookmark(HBOOKMARK hbm);
  87. // XML
  88. DEFINE_XML_TYPE(XML_TAG_BOOKMARK);
  89. virtual void Persist(CPersistor &persistor);
  90. public:
  91. bool operator ==(const CBookmark& other) const;
  92. bool operator !=(const CBookmark& other) const;
  93. bool operator < (const CBookmark& other) const;
  94. void SetFastBookmark(bool b) {m_bIsFastBookmark = b;}
  95. protected:
  96. MTNODEID m_idStatic;
  97. CDynamicPath m_dynamicPath;
  98. protected:
  99. bool m_bIsFastBookmark;
  100. bool IsFastBookmark() {return m_bIsFastBookmark;}
  101. };
  102. inline IStream& operator>> (IStream& stm, CBookmark& bm)
  103. {
  104. return bm.Load(stm);
  105. }
  106. #include "bookmark.inl"
  107. #endif // BOOKMARK_H