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.

155 lines
3.8 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1995 - 1999
  3. Module Name:
  4. text
  5. Abstract:
  6. This header file provides a text handling class.
  7. Author:
  8. Doug Barlow (dbarlow) 10/5/1995
  9. Environment:
  10. Win32
  11. Notes:
  12. --*/
  13. #ifndef _TEXT_H_
  14. #define _TEXT_H_
  15. #ifdef __cplusplus
  16. //
  17. //==============================================================================
  18. //
  19. // CText
  20. //
  21. class CText
  22. {
  23. public:
  24. // Constructors & Destructor
  25. CText()
  26. : m_bfUnicode(),
  27. m_bfAnsi()
  28. { m_fFlags = fAllGood; };
  29. ~CText() {};
  30. // Properties
  31. // Methods
  32. void Empty(void)
  33. {
  34. m_bfUnicode.Empty();
  35. m_bfAnsi.Empty();
  36. m_fFlags = fAllGood;
  37. };
  38. ULONG Length(void);
  39. void LengthA(ULONG cchLen);
  40. void LengthW(ULONG cchLen);
  41. ULONG SpaceA(void);
  42. ULONG SpaceW(void);
  43. void SpaceA(ULONG cchLen);
  44. void SpaceW(ULONG cchLen);
  45. LPSTR AccessA(ULONG cchOffset = 0);
  46. LPWSTR AccessW(ULONG cchOffset = 0);
  47. LPCSTR Copy(LPCSTR sz);
  48. LPCWSTR Copy(LPCWSTR wsz);
  49. #ifdef UNICODE
  50. void Length(ULONG cchLen) { LengthW(cchLen); };
  51. ULONG Space(void) { return SpaceW(); };
  52. void Space(ULONG cchLen) { SpaceW(cchLen); };
  53. LPWSTR Access(ULONG cchOffset = 0) { return AccessW(cchOffset); };
  54. operator CBuffer&(void)
  55. { m_fFlags = fUnicodeGood; return m_bfUnicode; };
  56. #else
  57. void Length(ULONG cchLen) { LengthA(cchLen); };
  58. ULONG Space(void) { return SpaceA(); };
  59. void Space(ULONG cchLen) { SpaceA(cchLen); };
  60. LPSTR Access(ULONG cchOffset = 0) { return AccessA(cchOffset); };
  61. operator CBuffer&(void)
  62. { m_fFlags = fAnsiGood; return m_bfAnsi; };
  63. #endif
  64. // Operators
  65. CText &operator=(const CText &tz);
  66. LPCSTR operator=(LPCSTR sz);
  67. LPCWSTR operator=(LPCWSTR wsz);
  68. CText &operator+=(const CText &tz);
  69. LPCSTR operator+=(LPCSTR sz);
  70. LPCWSTR operator+=(LPCWSTR wsz);
  71. BOOL operator==(const CText &tz)
  72. { return (0 == Compare(tz)); };
  73. BOOL operator==(LPCSTR sz)
  74. { return (0 == Compare(sz)); };
  75. BOOL operator==(LPCWSTR wsz)
  76. { return (0 == Compare(wsz)); };
  77. BOOL operator!=(const CText &tz)
  78. { return (0 != Compare(tz)); };
  79. BOOL operator!=(LPCSTR sz)
  80. { return (0 != Compare(sz)); };
  81. BOOL operator!=(LPCWSTR wsz)
  82. { return (0 != Compare(wsz)); };
  83. BOOL operator<=(const CText &tz)
  84. { return (0 <= Compare(tz)); };
  85. BOOL operator<=(LPCSTR sz)
  86. { return (0 <= Compare(sz)); };
  87. BOOL operator<=(LPCWSTR wsz)
  88. { return (0 <= Compare(wsz)); };
  89. BOOL operator>=(const CText &tz)
  90. { return (0 >= Compare(tz)); };
  91. BOOL operator>=(LPCSTR sz)
  92. { return (0 >= Compare(sz)); };
  93. BOOL operator>=(LPCWSTR wsz)
  94. { return (0 >= Compare(wsz)); };
  95. BOOL operator<(const CText &tz)
  96. { return (0 < Compare(tz)); };
  97. BOOL operator<(LPCSTR sz)
  98. { return (0 < Compare(sz)); };
  99. BOOL operator<(LPCWSTR wsz)
  100. { return (0 < Compare(wsz)); };
  101. BOOL operator>(const CText &tz)
  102. { return (0 > Compare(tz)); };
  103. BOOL operator>(LPCSTR sz)
  104. { return (0 > Compare(sz)); };
  105. BOOL operator>(LPCWSTR wsz)
  106. { return (0 > Compare(wsz)); };
  107. operator LPCSTR(void)
  108. { return Ansi(); };
  109. operator LPCWSTR(void)
  110. { return Unicode(); };
  111. protected:
  112. enum {
  113. fNoneGood = 0,
  114. fAnsiGood = 1,
  115. fUnicodeGood = 2,
  116. fAllGood = 3
  117. } m_fFlags;
  118. // Properties
  119. CBuffer
  120. m_bfUnicode,
  121. m_bfAnsi;
  122. // Methods
  123. LPCWSTR Unicode(void); // Return the text as a Unicode string.
  124. LPCSTR Ansi(void); // Return the text as an Ansi string.
  125. int Compare(const CText &tz);
  126. int Compare(LPCSTR sz);
  127. int Compare(LPCWSTR wsz);
  128. };
  129. #endif // __cplusplus
  130. #endif // _TEXT_H_