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.

130 lines
3.1 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 cb, BYTE const *pb);
  26. void Set(WCHAR const *pwcs) { Set((WORD)((lstrlenW(pwcs)+1)*sizeof(WCHAR)),
  27. (BYTE const *)pwcs); }
  28. inline void Set(CDfName const *pdfn);
  29. CDfName(WORD const cb, BYTE const *pb) { Set(cb, pb); }
  30. CDfName(WCHAR const *pwcs) { Set(pwcs); }
  31. WORD GetLength(void) const { return _cb; }
  32. BYTE *GetBuffer(void) const { return (BYTE *) _ab; }
  33. // Make a copy of a possibly byte-array name in a WCHAR string
  34. void CopyString(WCHAR const *pwcs);
  35. BOOL IsEqual(CDfName const *pdfn) const;
  36. inline BOOL operator > (CDfName const &dfRight) const;
  37. inline BOOL operator >= (CDfName const &dfRight) 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 int Compare(CDfName const &dfRight) const;
  43. inline int Compare(CDfName const *pdfRight) const;
  44. inline void Zero();
  45. };
  46. inline int CDfName::Compare(CDfName const &dfRight) const
  47. {
  48. int iCmp = GetLength() - dfRight.GetLength();
  49. if (iCmp == 0)
  50. {
  51. iCmp = dfwcsnicmp((WCHAR *)GetBuffer(),
  52. (WCHAR *)dfRight.GetBuffer(),
  53. GetLength() / sizeof(WCHAR));
  54. }
  55. return(iCmp);
  56. }
  57. inline int CDfName::Compare(CDfName const *pdfRight) const
  58. {
  59. return Compare(*pdfRight);
  60. }
  61. inline BOOL CDfName::operator > (CDfName const &dfRight) const
  62. {
  63. return (Compare(dfRight) > 0);
  64. }
  65. inline BOOL CDfName::operator >= (CDfName const &dfRight) const
  66. {
  67. return (Compare(dfRight) >= 0);
  68. }
  69. inline BOOL CDfName::operator < (CDfName const &dfRight) const
  70. {
  71. return (Compare(dfRight) < 0);
  72. }
  73. inline BOOL CDfName::operator <= (CDfName const &dfRight) const
  74. {
  75. return (Compare(dfRight) <= 0);
  76. }
  77. inline BOOL CDfName::operator == (CDfName const &dfRight) const
  78. {
  79. return (Compare(dfRight) == 0);
  80. }
  81. inline BOOL CDfName::operator != (CDfName const &dfRight) const
  82. {
  83. return (Compare(dfRight) != 0);
  84. }
  85. inline void CDfName::Set(WORD cb, BYTE const *pb)
  86. {
  87. if (cb > CBSTORAGENAME)
  88. cb = CBSTORAGENAME;
  89. if (pb)
  90. memcpy(_ab, pb, cb);
  91. _cb = cb;
  92. }
  93. inline void CDfName::Set(CDfName const *pdfn)
  94. {
  95. Set(pdfn->GetLength(), pdfn->GetBuffer());
  96. }
  97. inline void CDfName::Zero()
  98. {
  99. memset (_ab, 0, sizeof(_ab));
  100. _cb = 0;
  101. }
  102. #endif // #ifndef __DFNAME_HXX__