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.

90 lines
3.3 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Turbo Vision - Version 2.0
  3. *
  4. * Copyright (c) 1994 by Borland International
  5. * All Rights Reserved.
  6. *
  7. Modified by Robert H�hne to be used for RHIDE.
  8. Modified to compile with gcc v3.x by Salvador E. Tropea, with the help of
  9. Andris Pavenis and Christoph Bauer.
  10. *
  11. *
  12. */
  13. /* ------------------------------------------------------------------------*/
  14. /* */
  15. /* class opstream */
  16. /* */
  17. /* Base class for writing streamable objects */
  18. /* */
  19. /* ------------------------------------------------------------------------*/
  20. #if defined( Uses_opstream ) && !defined( __opstream )
  21. #define __opstream
  22. class TStreamableClass;
  23. class TPWrittenObjects;
  24. class opstream : virtual public pstream
  25. {
  26. public:
  27. opstream( CLY_streambuf * );
  28. ~opstream();
  29. CLY_StreamPosT tellp();
  30. opstream& seekp( CLY_StreamPosT );
  31. opstream& seekp( CLY_StreamOffT, CLY_IOSSeekDir );
  32. opstream& flush();
  33. void writeByte( uchar );
  34. void writeBytes( const void *, size_t );
  35. void writeWord( ushort val ) { writeShort(val); };
  36. void writeString( const char * );
  37. void writeString16( const uint16 *str );
  38. void writeString( const uint16 *str ) { writeString16(str); };
  39. /* Platform dependent: */
  40. void writeShort(ushort val);
  41. void writeInt(uint val);
  42. void writeLong(ulong val);
  43. /* The following are platform independent (stores in little endian) */
  44. void write8(uint8 val) { writeByte(val); };
  45. void write16(uint16 val);
  46. void write32(uint32 val);
  47. void write64(uint64 val);
  48. opstream& operator << ( char val ) { writeByte(val); return *this; };
  49. #ifndef TVComp_BCPP
  50. opstream& operator << ( signed char val ) { writeByte(val); return *this; };
  51. #endif
  52. opstream& operator << ( unsigned char val ) { writeByte(val); return *this; };
  53. opstream& operator << ( signed short val ) { writeShort(val); return *this; };
  54. opstream& operator << ( unsigned short val ) { writeShort(val); return *this; };
  55. opstream& operator << ( signed int val ) { writeInt(val); return *this; };
  56. opstream& operator << ( unsigned int val ) { writeInt(val); return *this; };
  57. opstream& operator << ( signed long val ) { writeLong(val); return *this; };
  58. opstream& operator << ( unsigned long val ) { writeLong(val); return *this; };
  59. opstream& operator << ( float val ) { writeBytes(&val,sizeof(val)); return *this; };
  60. opstream& operator << ( double val ) { writeBytes(&val,sizeof(val)); return *this; };
  61. opstream& operator << ( long double val ) { writeBytes(&val,sizeof(val)); return *this; };
  62. friend opstream& operator << ( opstream&, TStreamable& );
  63. friend opstream& operator << ( opstream&, TStreamable * );
  64. protected:
  65. opstream();
  66. void writePrefix( const TStreamable& );
  67. void writeData( TStreamable& );
  68. void writeSuffix( const TStreamable& );
  69. P_id_type find( const void *adr );
  70. void registerObject( const void *adr );
  71. private:
  72. TPWrittenObjects *objs;
  73. };
  74. #endif // Uses_opstream