home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yeah09.zip / source / lib / StringEA.CPP < prev   
C/C++ Source or Header  |  1996-05-25  |  1KB  |  47 lines

  1. //------------------------------------------------------------
  2. //
  3. // Name:     StringEA.CPP
  4. // Version:  0.9
  5. // Author:   Björn Fahller.
  6. //
  7. // Copyright (C) Björn Fahller, 1996.
  8. //
  9. // Purpose:  Implementation of a string extended attribute (EAT_ASCII)
  10. //           based on the IString class from IBM Open Class Library,
  11. //           and EA (through TEA) from YEAH.
  12. //
  13. // History:
  14. //          Ver.  Date         What
  15. //          0.9   1996-05-26   First official release.
  16. //
  17. //------------------------------------------------------------
  18.  
  19.  
  20. #include "yea.h"
  21. #include <strstrea.h>
  22.  
  23. istrstream& StringEA::readFrom(istrstream& is)
  24. {
  25.   unsigned short length;
  26.   is.read((char*)(&length), sizeof(length));
  27.   char* p = new char[length];
  28.   is.read(p, length);
  29.   IString::operator=(IString(p, length));
  30.   delete p;
  31.   return is;
  32. }
  33.  
  34. ostrstream& StringEA::writeTo(ostrstream& os)
  35. {
  36.   unsigned short length = (unsigned short)IString::length();
  37.   os.write((char*)&length, sizeof(length));
  38.   os << *this;
  39.   return os;
  40. }
  41.  
  42. StringEA* StringEA::clone(void) const
  43. {
  44.   return new StringEA(*this);
  45. }
  46.  
  47.