xstraw.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. ** Command & Conquer Renegade(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. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Command & Conquer *
  23. * *
  24. * $Archive:: /G/wwlib/XSTRAW.H $*
  25. * *
  26. * $Author:: Eric_c $*
  27. * *
  28. * $Modtime:: 4/02/99 12:01p $*
  29. * *
  30. * $Revision:: 2 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if _MSC_VER >= 1000
  36. #pragma once
  37. #endif // _MSC_VER >= 1000
  38. #ifndef XSTRAW_H
  39. #define XSTRAW_H
  40. #include "buff.h"
  41. #include "straw.h"
  42. #include "wwfile.h"
  43. #include <stddef.h>
  44. /*
  45. ** This class is used to manage a buffer as a data source. Data requests will draw from the
  46. ** buffer supplied until the buffer is exhausted.
  47. */
  48. class BufferStraw : public Straw
  49. {
  50. public:
  51. BufferStraw(Buffer const & buffer) : BufferPtr(buffer), Index(0) {}
  52. BufferStraw(void const * buffer, int length) : BufferPtr((void*)buffer, length), Index(0) {}
  53. virtual int Get(void * source, int slen);
  54. private:
  55. Buffer BufferPtr;
  56. int Index;
  57. // void const * BufferPtr;
  58. // int Length;
  59. bool Is_Valid(void) {return(BufferPtr.Is_Valid());}
  60. BufferStraw(BufferStraw & rvalue);
  61. BufferStraw & operator = (BufferStraw const & pipe);
  62. };
  63. /*
  64. ** This class is used to manage a file as a data source. Data requests will draw from the
  65. ** file until the file has been completely read.
  66. */
  67. class FileStraw : public Straw
  68. {
  69. public:
  70. FileStraw(FileClass * file) : File(file), HasOpened(false) {}
  71. FileStraw(FileClass & file) : File(&file), HasOpened(false) {}
  72. virtual ~FileStraw(void);
  73. virtual int Get(void * source, int slen);
  74. private:
  75. FileClass * File;
  76. bool HasOpened;
  77. bool Valid_File(void) {return(File != NULL);}
  78. FileStraw(FileStraw & rvalue);
  79. FileStraw & operator = (FileStraw const & pipe);
  80. };
  81. #endif