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.

123 lines
2.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: dfname.hxx
  7. //
  8. // Contents: CDfName header
  9. //
  10. // Classes: CDfName
  11. //
  12. // History: 14-May-93 DrewB Created
  13. //
  14. //----------------------------------------------------------------------------
  15. #ifndef __DFNAME_HXX__
  16. #define __DFNAME_HXX__
  17. // A name for a docfile element
  18. class CDfName
  19. {
  20. private:
  21. BYTE _ab[CBSTORAGENAME];
  22. WORD _cb;
  23. public:
  24. CDfName(void) { _cb = 0; }
  25. inline void Set(WORD const cb, BYTE const *pb);
  26. void Set(WCHAR const *pwcs) { Set((WORD)((lstrlenW(pwcs)+1)*sizeof(WCHAR)),
  27. (BYTE const *)pwcs); }
  28. void Set(char const *psz) { Set(strlen(psz)+1, (BYTE const *)psz); }
  29. inline void Set(CDfName const *pdfn);
  30. CDfName(WORD const cb, BYTE const *pb) { Set(cb, pb); }
  31. CDfName(WCHAR const *pwcs) { Set(pwcs); }
  32. CDfName(char const *psz) { Set(psz); }
  33. WORD GetLength(void) const { return _cb; }
  34. BYTE *GetBuffer(void) const { return (BYTE *) _ab; }
  35. // Make a copy of a possibly byte-array name in a WCHAR string
  36. void CopyString(WCHAR const *pwcs);
  37. BOOL IsEqual(CDfName const *pdfn) const;
  38. inline BOOL operator > (CDfName const &dfRight) const;
  39. inline BOOL operator >= (CDfName const &dfRight) const;
  40. inline BOOL operator < (CDfName const &dfRight) const;
  41. inline BOOL operator <= (CDfName const &dfRight) const;
  42. inline BOOL operator == (CDfName const &dfRight) const;
  43. inline BOOL operator != (CDfName const &dfRight) const;
  44. inline int Compare(CDfName const &dfRight) const;
  45. inline int Compare(CDfName const *pdfRight) const;
  46. };
  47. inline int CDfName::Compare(CDfName const &dfRight) const
  48. {
  49. int iCmp = GetLength() - dfRight.GetLength();
  50. if (iCmp == 0)
  51. {
  52. iCmp = dfwcsnicmp((WCHAR *)GetBuffer(),
  53. (WCHAR *)dfRight.GetBuffer(),
  54. GetLength());
  55. }
  56. return(iCmp);
  57. }
  58. inline int CDfName::Compare(CDfName const *pdfRight) const
  59. {
  60. return Compare(*pdfRight);
  61. }
  62. inline BOOL CDfName::operator > (CDfName const &dfRight) const
  63. {
  64. return (Compare(dfRight) > 0);
  65. }
  66. inline BOOL CDfName::operator >= (CDfName const &dfRight) const
  67. {
  68. return (Compare(dfRight) >= 0);
  69. }
  70. inline BOOL CDfName::operator < (CDfName const &dfRight) const
  71. {
  72. return (Compare(dfRight) < 0);
  73. }
  74. inline BOOL CDfName::operator <= (CDfName const &dfRight) const
  75. {
  76. return (Compare(dfRight) <= 0);
  77. }
  78. inline BOOL CDfName::operator == (CDfName const &dfRight) const
  79. {
  80. return (Compare(dfRight) == 0);
  81. }
  82. inline BOOL CDfName::operator != (CDfName const &dfRight) const
  83. {
  84. return (Compare(dfRight) != 0);
  85. }
  86. inline void CDfName::Set(WORD const cb, BYTE const *pb)
  87. {
  88. if (pb)
  89. memcpy(_ab, pb, cb);
  90. _cb = cb;
  91. }
  92. inline void CDfName::Set(CDfName const *pdfn)
  93. {
  94. Set(pdfn->GetLength(), pdfn->GetBuffer());
  95. }
  96. #endif // #ifndef __DFNAME_HXX__