home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / ioc / acdf5 / acdfpsn5.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  1.9 KB  |  82 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //                      SAMPLE CODE
  3. //
  4. // FileName:     ACDFPsn5.cpp
  5. //
  6. // ClassName:    APerson
  7. //
  8. // Description:  Compound Document Framework Collection Streaming
  9. //               A collection of this is class used in both the keyed
  10. //               and sequence collections.
  11. ///////////////////////////////////////////////////////////////////////////////
  12. #include "ACDFPsn5.hpp"
  13. #include <iexcept.hpp>
  14. #include <icconst.h>
  15. #include <assert.h>
  16.  
  17. TypeExtensionMacro(TPerson)
  18.  
  19. TPerson::TPerson(const IString& name, const IString& age)
  20. // Constructor 
  21. : fName(name), fAge(age)
  22. {   IFUNCTRACE_DEVELOP();}
  23.  
  24. TPerson::TPerson()
  25. // Default Constructor
  26. : fName(), fAge(0)
  27. {   IFUNCTRACE_DEVELOP();}
  28.  
  29. IBaseStream&
  30. TPerson::operator>>=(IBaseStream& toWhere) const
  31. // Stream class out
  32. {   IFUNCTRACE_DEVELOP();
  33.  
  34.     writeVersion(toWhere,kOriginalVersion);
  35.     fName >>= toWhere;
  36.     fAge >>= toWhere;
  37.     return toWhere;
  38. }
  39.  
  40. IBaseStream&
  41. TPerson::operator<<=(IBaseStream& fromWhere)
  42. //Stream class in
  43. {   IFUNCTRACE_DEVELOP();
  44.  
  45.     switch (readVersion(fromWhere)) 
  46.     {
  47.         case kOriginalVersion:
  48.             fName <<= fromWhere;
  49.             fAge <<= fromWhere;
  50.             break;
  51.         default:
  52.             ITHROWLIBRARYERROR(IC_STREAM_VERSION_UNSUPPORTED, 
  53.                       IBaseErrorInfo::invalidRequest,
  54.                       IException::recoverable);
  55.     }
  56.     return fromWhere;
  57. }
  58.  
  59.  
  60. IString TPerson::getName() const
  61. // Return the name 
  62. {   IFUNCTRACE_DEVELOP();
  63.     return fName;
  64. }
  65.  
  66. IString TPerson::getAge() const
  67. // Return the age
  68. {   IFUNCTRACE_DEVELOP();
  69.     return fAge;
  70. }
  71.  
  72. IBoolean TPerson::operator==(TPerson& myPerson)
  73. // Compare to the member data
  74. {   IFUNCTRACE_DEVELOP();
  75.     if (fName == myPerson.fName && fAge == myPerson.fAge)
  76.         return true;
  77.     else
  78.         return false;
  79. }
  80.  
  81.     
  82.