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.

120 lines
2.6 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name :
  4. tstr.cxx
  5. Abstract:
  6. Class that is used for string manipulation
  7. Author:
  8. Christopher Achille (cachille)
  9. Project:
  10. Internet Services Setup
  11. Revision History:
  12. January 2002: Created
  13. --*/
  14. #ifndef TSTR_HXX
  15. #define TSTR_HXX
  16. #define TSTR_SNPRINTF_RESIZER_SIZE 100
  17. #define TSTR_SNPRINTF_RESIZER_TRIES 5
  18. // TSTR
  19. //
  20. // String class used to simplify string manipulation
  21. //
  22. class TSTR {
  23. private:
  24. BUFFER m_buff;
  25. BOOL m_bSensitiveData : 1; // Does this data contain sensitive information?
  26. static TCHAR ToLower(TCHAR cChar);
  27. public:
  28. TSTR();
  29. TSTR(DWORD dwInitialSize);
  30. ~TSTR();
  31. // String Queries
  32. LPTSTR QueryStr();
  33. DWORD QueryLen();
  34. DWORD QuerySize();
  35. // String Modification
  36. BOOL Resize(DWORD dwChars);
  37. BOOL Copy(LPCTSTR szSource);
  38. BOOL Copy(TSTR &strSource);
  39. BOOL Append(LPCTSTR szSource);
  40. BOOL Append(TSTR &strSource);
  41. BOOL Format(LPTSTR szFormat ... );
  42. // String Checks
  43. BOOL IsEqual(LPCTSTR szCompareString, BOOL bCaseSensitive = TRUE);
  44. BOOL SubStringExists(LPTSTR szCompareString, BOOL bCaseSensitive = TRUE);
  45. LPTSTR FindSubString(LPTSTR szSubString, BOOL bCaseSensitive = TRUE);
  46. //
  47. BOOL LoadString( UINT uResourceId );
  48. // Set Flags
  49. void MarkSensitiveData( BOOL bIsSensitive );
  50. };
  51. // TSTR_PATH
  52. //
  53. // String class used to simplify modification of Physical Path's
  54. //
  55. class TSTR_PATH : public TSTR {
  56. public:
  57. TSTR_PATH();
  58. TSTR_PATH(DWORD dwInitialSize);
  59. BOOL PathAppend(LPCTSTR szSource);
  60. BOOL PathAppend(TSTR &strSource);
  61. BOOL RemoveTrailingPath();
  62. BOOL ExpandEnvironmentVariables();
  63. BOOL RetrieveSystemDir();
  64. BOOL RetrieveWindowsDir();
  65. };
  66. // TSTR_MSZ
  67. //
  68. // Class used to simplify modification of MultiSz's
  69. //
  70. class TSTR_MSZ {
  71. private:
  72. BUFFER m_buff;
  73. LPTSTR FindNextString(LPTSTR szCurrentString);
  74. LPTSTR FindEnd(LPTSTR szCurrentString);
  75. LPTSTR Find(LPTSTR szSource, BOOL bCaseSensitive = FALSE );
  76. // BOOL AddString( DWORD dwIndex
  77. public:
  78. TSTR_MSZ();
  79. // String Queries
  80. LPTSTR QueryMultiSz();
  81. LPTSTR QueryString( DWORD dwIndex );
  82. DWORD QueryLen();
  83. // Operations
  84. BOOL IsPresent(LPTSTR szSource, BOOL bCaseSensitive = FALSE );
  85. BOOL Resize(DWORD dwChars);
  86. BOOL Add(LPCTSTR szSource);
  87. BOOL Remove(LPTSTR szSource, BOOL bCaseSensitive = FALSE );
  88. BOOL Copy(LPTSTR szSource);
  89. BOOL Empty();
  90. };
  91. #endif