string.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. //----------------------------------------------------------------------------
  24. //
  25. // Westwood Studios Pacific.
  26. //
  27. // Confidential Information
  28. // Copyright(C) 2001 - All Rights Reserved
  29. //
  30. //----------------------------------------------------------------------------
  31. //
  32. // Project: WSYS Library
  33. //
  34. // Module: String
  35. //
  36. // File name: wsys/string.h
  37. //
  38. // Created: 11/02/01
  39. //
  40. //----------------------------------------------------------------------------
  41. #pragma once
  42. #ifndef __WSYS_STRING_H
  43. #define __WSYS_STRING_H
  44. //----------------------------------------------------------------------------
  45. // Includes
  46. //----------------------------------------------------------------------------
  47. #include "Lib/BaseType.h"
  48. //----------------------------------------------------------------------------
  49. // Forward References
  50. //----------------------------------------------------------------------------
  51. //----------------------------------------------------------------------------
  52. // Type Defines
  53. //----------------------------------------------------------------------------
  54. class WSYS_String
  55. {
  56. protected:
  57. Char *m_data; ///< actual string data
  58. public:
  59. explicit WSYS_String(const Char *string = NULL);
  60. ~WSYS_String();
  61. // operators
  62. Bool operator== (const char *rvalue) const;
  63. Bool operator!= (const char *rvalue) const;
  64. const WSYS_String& operator= (const WSYS_String &string);
  65. const WSYS_String& operator= (const Char *string);
  66. const WSYS_String& operator+= (const WSYS_String &string);
  67. const WSYS_String& operator+= (const Char *string);
  68. friend WSYS_String operator+ (const WSYS_String &string1, const WSYS_String &string2);
  69. friend WSYS_String operator+ (const Char *string1, const WSYS_String &string2);
  70. friend WSYS_String operator+ (const WSYS_String &string1, const Char *string2);
  71. const Char & operator[] (Int index) const;
  72. Char & operator[] (Int index);
  73. operator const Char * (void) const;
  74. operator Char * (void) const ;
  75. // methods
  76. void makeUpperCase( void );
  77. void makeLowerCase( void );
  78. Int length(void) const;
  79. Bool isEmpty(void) const;
  80. Int _cdecl format(const Char *format, ...);
  81. void set( const Char *string );
  82. Char* get( void ) const;
  83. };
  84. //----------------------------------------------------------------------------
  85. // Inlining
  86. //----------------------------------------------------------------------------
  87. inline Char* WSYS_String::get( void ) const { return m_data;};
  88. inline const Char& WSYS_String::operator[] (Int index) const{ return m_data[index];};
  89. inline Char& WSYS_String::operator[] (Int index) { return m_data[index];};
  90. inline WSYS_String::operator const Char * (void) const { return m_data;};
  91. inline WSYS_String::operator Char * (void) const {return m_data;};
  92. #endif // __WSYS_STRING_H