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.

161 lines
2.5 KiB

  1. /*++
  2. Copyright (C) 2000 Microsoft Corporation
  3. All rights reserved.
  4. Module Name:
  5. String.hxx
  6. Abstract:
  7. Short implementation of strings.
  8. Author:
  9. Steve Kiraly (SteveKi) 03-Mar-2000
  10. Revision History:
  11. --*/
  12. #ifndef _CORE_STRING_HXX_
  13. #define _CORE_STRING_HXX_
  14. class TString
  15. {
  16. public:
  17. //
  18. // For the default constructor, we initialize m_pszString to a
  19. // global gszState[kValid] string. This allows the class to be used
  20. // in functions that take raw pointers to strings, while at the same
  21. // time is prevents an extra memory allocation.
  22. //
  23. TString(
  24. VOID
  25. );
  26. explicit
  27. TString(
  28. IN LPCTSTR psz
  29. );
  30. TString(
  31. IN const TString &String
  32. );
  33. ~TString(
  34. VOID
  35. );
  36. BOOL
  37. bEmpty(
  38. VOID
  39. ) const;
  40. HRESULT
  41. IsValid(
  42. VOID
  43. ) const;
  44. HRESULT
  45. Update(
  46. IN LPCTSTR pszNew
  47. );
  48. HRESULT
  49. LoadStringFromRC(
  50. IN HINSTANCE hInst,
  51. IN UINT uID
  52. );
  53. UINT
  54. TString::
  55. uLen(
  56. VOID
  57. ) const;
  58. HRESULT
  59. TString::
  60. Cat(
  61. IN LPCTSTR psz
  62. );
  63. HRESULT
  64. WINAPIV
  65. TString::
  66. Format(
  67. IN LPCTSTR pszFmt,
  68. IN ...
  69. );
  70. HRESULT
  71. TString::
  72. vFormat(
  73. IN LPCTSTR pszFmt,
  74. IN va_list avlist
  75. );
  76. HRESULT
  77. WINAPIV
  78. TString::
  79. FormatMsg(
  80. IN LPCTSTR pszFmt,
  81. IN ...
  82. );
  83. operator LPCTSTR( VOID ) const
  84. { return m_pszString; }
  85. VOID
  86. ToUpper(
  87. void
  88. );
  89. VOID
  90. ToLower(
  91. void
  92. );
  93. private:
  94. //
  95. // Not defined; Clients are forced to use Update rather than
  96. // using the assignment operator, since the assignment
  97. // may fail due to lack of memory, etc.
  98. //
  99. TString& operator=(LPCTSTR psz);
  100. TString& operator=(const TString& String);
  101. enum EStringStatus
  102. {
  103. kValid = 0,
  104. kInValid = 1,
  105. };
  106. enum EConstants
  107. {
  108. kStrIncrement = 256,
  109. kStrMaxFormatSize = 1024 * 100,
  110. kStrMax = 1024,
  111. };
  112. LPTSTR
  113. TString::
  114. vsntprintf(
  115. IN LPCTSTR szFmt,
  116. IN va_list pArgs
  117. );
  118. VOID
  119. TString::
  120. vFree(
  121. IN LPTSTR pszString
  122. );
  123. LPTSTR m_pszString;
  124. static TCHAR gszNullState[2];
  125. };
  126. #endif