errclass.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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. /* $Header: /Commando/Code/Tools/pluglib/errclass.h 5 6/25/99 10:46a Greg_h $ */
  19. /***********************************************************************************************
  20. *** Confidential - Westwood Studios ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Commando Tools - W3D export *
  24. * *
  25. * $Archive:: /Commando/Code/Tools/pluglib/errclass.h $*
  26. * *
  27. * $Author:: Greg_h $*
  28. * *
  29. * $Modtime:: 6/24/99 3:38p $*
  30. * *
  31. * $Revision:: 5 $*
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef ERRCLASS_H
  37. #define ERRCLASS_H
  38. #include <stdarg.h>
  39. class ErrorClass
  40. {
  41. public:
  42. ErrorClass(char * format,...);
  43. ErrorClass(const ErrorClass & that);
  44. ~ErrorClass(void) { if (error_message != NULL) free(error_message); }
  45. ErrorClass & operator = (const ErrorClass & that);
  46. char * error_message;
  47. };
  48. inline ErrorClass::ErrorClass(char * format,...)
  49. {
  50. va_list va;
  51. char tmp[1024];
  52. va_start(va,format);
  53. vsprintf(tmp,format,va);
  54. assert(strlen(tmp) < 1024);
  55. va_end(va);
  56. error_message = strdup(tmp);
  57. }
  58. inline ErrorClass::ErrorClass(const ErrorClass & that) :
  59. error_message(NULL)
  60. {
  61. *this = that;
  62. }
  63. inline ErrorClass & ErrorClass::operator = (const ErrorClass & that)
  64. {
  65. if (error_message != NULL) {
  66. free(error_message);
  67. error_message = NULL;
  68. }
  69. if (that.error_message != NULL) {
  70. error_message = strdup(that.error_message);
  71. }
  72. return *this;
  73. }
  74. #endif //ERRCLASS_H