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.

127 lines
3.6 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. *+-------------------------------------------------------------------------*/
  33. class CDynamicPathEntry : public CXMLObject
  34. {
  35. protected:
  36. enum PathEntryType
  37. {
  38. NDTYP_STRING = 0x01,
  39. NDTYP_CUSTOM = 0x02
  40. };
  41. public:
  42. // comparison
  43. bool operator ==(const CDynamicPathEntry &rhs) const;
  44. bool operator < (const CDynamicPathEntry &rhs) const;
  45. SC ScInitialize(bool bIs10Path, /*[IN,OUT]*/ByteVector::iterator &iter);
  46. void Write (ByteVector& v) const; // write the contents to a byte vector
  47. virtual void Persist(CPersistor &persistor);
  48. DEFINE_XML_TYPE(XML_TAG_DYNAMIC_PATH_ENTRY);
  49. protected:
  50. BYTE m_type; // string or custom ID?
  51. // compiler error C2621 prevents making the next two fields a union.
  52. ByteVector m_byteVector; // the actual data if it is a custom ID
  53. std::wstring m_strEntry; // the actual data if it is a string.
  54. };
  55. /*+-------------------------------------------------------------------------*
  56. * class CBookmark
  57. *
  58. *
  59. * PURPOSE: Maintains a persistent representation of a scope node.
  60. *
  61. *+-------------------------------------------------------------------------*/
  62. class CBookmark : public CXMLObject
  63. {
  64. friend class CScopeTree;
  65. typedef std::list<CDynamicPathEntry> CDynamicPath;
  66. public:
  67. enum { ID_Unknown = -1 };
  68. CBookmark(MTNODEID idStatic = ID_Unknown) : m_idStatic (idStatic) , m_bIsFastBookmark(true) {}
  69. CBookmark(bool bIsFastBookmark) : m_idStatic (0), m_bIsFastBookmark(bIsFastBookmark) {}
  70. virtual ~CBookmark () {}
  71. bool IsValid () const { return (m_idStatic != ID_Unknown); }
  72. bool IsStatic () const { ASSERT (IsValid()); return (m_dynamicPath.empty()); }
  73. bool IsDynamic () const { return (!IsStatic());}
  74. void Reset() {m_idStatic = ID_Unknown; m_dynamicPath.clear();}
  75. IStream & Load(IStream &stm);
  76. IStream & Save(IStream &stm) const;
  77. // Casts
  78. operator HBOOKMARK() const;
  79. static CBookmark * GetBookmark(HBOOKMARK hbm);
  80. // XML
  81. DEFINE_XML_TYPE(XML_TAG_BOOKMARK);
  82. virtual void Persist(CPersistor &persistor);
  83. public:
  84. bool operator ==(const CBookmark& other) const;
  85. bool operator !=(const CBookmark& other) const;
  86. bool operator < (const CBookmark& other) const;
  87. void SetFastBookmark(bool b) {m_bIsFastBookmark = b;}
  88. protected:
  89. MTNODEID m_idStatic;
  90. CDynamicPath m_dynamicPath;
  91. protected:
  92. bool m_bIsFastBookmark;
  93. bool IsFastBookmark() {return m_bIsFastBookmark;}
  94. };
  95. inline IStream& operator>> (IStream& stm, CBookmark& bm)
  96. {
  97. return bm.Load(stm);
  98. }
  99. inline IStream& operator<< (IStream& stm, const CBookmark& bm)
  100. {
  101. return bm.Save(stm);
  102. }
  103. #include "bookmark.inl"
  104. #endif // BOOKMARK_H