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.

177 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. //#include <string.h>
  16. //#include <mbstring.h>
  17. #include "buffers.h"
  18. //
  19. //==============================================================================
  20. //
  21. // CTextString
  22. //
  23. class CTextString
  24. {
  25. public:
  26. // Constructors & Destructor
  27. CTextString()
  28. : m_bfUnicode(),
  29. m_bfAnsi()
  30. { m_fFlags = fBothGood; };
  31. virtual ~CTextString() {};
  32. // Properties
  33. // Methods
  34. void Clear(void)
  35. {
  36. m_bfUnicode.Clear();
  37. m_bfAnsi.Clear();
  38. m_fFlags = fBothGood;
  39. };
  40. void Reset(void)
  41. {
  42. m_bfUnicode.Reset();
  43. m_bfAnsi.Reset();
  44. m_fFlags = fBothGood;
  45. };
  46. virtual DWORD Length(void);
  47. // Operators
  48. CTextString &operator=(const CTextString &tz);
  49. LPCSTR operator=(LPCSTR sz);
  50. LPCWSTR operator=(LPCWSTR wsz);
  51. CTextString &operator+=(const CTextString &tz);
  52. LPCSTR operator+=(LPCSTR sz);
  53. LPCWSTR operator+=( LPCWSTR wsz);
  54. BOOL operator==(const CTextString &tz)
  55. { return (0 == Compare(tz)); };
  56. BOOL operator==(LPCSTR sz)
  57. { return (0 == Compare(sz)); };
  58. BOOL operator==(LPCWSTR wsz)
  59. { return (0 == Compare(wsz)); };
  60. BOOL operator!=(const CTextString &tz)
  61. { return (0 != Compare(tz)); };
  62. BOOL operator!=(LPCSTR sz)
  63. { return (0 != Compare(sz)); };
  64. BOOL operator!=(LPCWSTR wsz)
  65. { return (0 != Compare(wsz)); };
  66. BOOL operator<=(const CTextString &tz)
  67. { return (0 <= Compare(tz)); };
  68. BOOL operator<=(LPCSTR sz)
  69. { return (0 <= Compare(sz)); };
  70. BOOL operator<=(LPCWSTR wsz)
  71. { return (0 <= Compare(wsz)); };
  72. BOOL operator>=(const CTextString &tz)
  73. { return (0 >= Compare(tz)); };
  74. BOOL operator>=(LPCSTR sz)
  75. { return (0 >= Compare(sz)); };
  76. BOOL operator>=(LPCWSTR wsz)
  77. { return (0 >= Compare(wsz)); };
  78. BOOL operator<(const CTextString &tz)
  79. { return (0 < Compare(tz)); };
  80. BOOL operator<(LPCSTR sz)
  81. { return (0 < Compare(sz)); };
  82. BOOL operator<(LPCWSTR wsz)
  83. { return (0 < Compare(wsz)); };
  84. BOOL operator>(const CTextString &tz)
  85. { return (0 > Compare(tz)); };
  86. BOOL operator>(LPCSTR sz)
  87. { return (0 > Compare(sz)); };
  88. BOOL operator>(LPCWSTR wsz)
  89. { return (0 > Compare(wsz)); };
  90. operator LPCSTR(void)
  91. { return Ansi(); };
  92. operator LPCWSTR(void)
  93. { return Unicode(); };
  94. protected:
  95. enum {
  96. fNoneGood = 0,
  97. fAnsiGood = 1,
  98. fUnicodeGood = 2,
  99. fBothGood = 3
  100. } m_fFlags;
  101. // Properties
  102. CBuffer
  103. m_bfUnicode,
  104. m_bfAnsi;
  105. // Methods
  106. LPCWSTR Unicode(void); // Return the text as a Unicode string.
  107. LPCSTR Ansi(void); // Return the text as an Ansi string.
  108. int Compare(const CTextString &tz);
  109. int Compare(LPCSTR sz);
  110. int Compare(LPCWSTR wsz);
  111. virtual DWORD Length(LPCSTR szString);
  112. virtual DWORD Length(LPCWSTR szString);
  113. };
  114. //
  115. //==============================================================================
  116. //
  117. // CTextMultistring
  118. //
  119. class CTextMultistring
  120. : public CTextString
  121. {
  122. public:
  123. // Constructors & Destructor
  124. CTextMultistring()
  125. : CTextString()
  126. {};
  127. // Properties
  128. // Methods
  129. virtual DWORD Length(void);
  130. // Operators
  131. CTextMultistring &operator=(const CTextMultistring &tz);
  132. CTextMultistring &operator+=(const CTextMultistring &tz);
  133. LPCSTR operator=(LPCSTR sz);
  134. LPCWSTR operator=(LPCWSTR wsz);
  135. LPCSTR operator+=(LPCSTR sz);
  136. LPCWSTR operator+=( LPCWSTR wsz);
  137. protected:
  138. // Properties
  139. // Methods
  140. virtual DWORD Length(LPCSTR szString);
  141. virtual DWORD Length(LPCWSTR szString);
  142. };
  143. #endif // _TEXT_H_