home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / visbuild / rapsheet / cppwv23 / iaddrrec.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-08  |  6.0 KB  |  159 lines

  1. /******************************************************************************
  2. * .FILE:        iaddrrec.cpp                                                  *
  3. *                                                                             *
  4. * .DESCRIPTION: Implementation for the class, IAddressRecord                  *
  5. *                                                                             *
  6. * .CLASSES:     IAddressRecord                                                *
  7. *                                                                             *
  8. * .COPYRIGHT:                                                                 *
  9. *    Licensed Material - Program-Property of IBM                              *
  10. *    (C) Copyright IBM Corp. 1992, 1996 - All Rights Reserved                 *
  11. *                                                                             *
  12. * .DISCLAIMER:                                                                *
  13. *   The following [enclosed] code is sample code created by IBM               *
  14. *   Corporation.  This sample code is not part of any standard IBM product    *
  15. *   and is provided to you solely for the purpose of assisting you in the     *
  16. *   development of your applications.  The code is provided 'AS IS',          *
  17. *   without warranty of any kind.  IBM shall not be liable for any damages    *
  18. *   arising out of your use of the sample code, even if they have been        *
  19. *   advised of the possibility of such damages.                               *
  20. *                                                                             *
  21. * .NOTE: WE RECOMMEND USING A FIXED SPACE FONT TO LOOK AT THE SOURCE          *
  22. *                                                                             *
  23. ******************************************************************************/
  24. #include "iaddrrec.hpp"               //IAddressRecord header
  25.  
  26. /*******************************************************************
  27.  * Manager Member Functions
  28.  *******************************************************************/
  29. IAddressRecord :: IAddressRecord() :
  30.                      IRecord(),
  31.                      dMySize(57L)
  32. {
  33.    dParentSize = size();
  34.    setSize( dParentSize + dMySize );  //pad with '\x00'
  35. }
  36.  
  37. IAddressRecord :: IAddressRecord ( const IString & stringData ) :
  38.                      IRecord(),
  39.                      dMySize(57L)
  40. {
  41.    dParentSize = size();
  42.    *this = stringData;
  43.    setSize( dParentSize + dMySize );  //truncate or pad as appropriate
  44. }
  45.  
  46. IAddressRecord :: IAddressRecord ( const IAddressRecord & aRecord ) :
  47.                      IRecord(),
  48.                      dMySize(57L)
  49. {
  50.    dParentSize = size();
  51.    *this = aRecord;
  52.   /*------------------------------------------------------------------
  53.    * NOTE:  this record would have gotten set with the correct size
  54.    *        if had called the IRecord (aRecord) constructor, but
  55.    *        need to determine what dParentSize is (the assignment
  56.    *        operators need this info).
  57.    *-----------------------------------------------------------------*/
  58. }
  59.  
  60. IAddressRecord :: ~IAddressRecord()
  61. {
  62. }
  63.  
  64. /*******************************************************************
  65.  * Access Member Functions
  66.  *******************************************************************/
  67. /*------------------------------------------------------------------
  68.  * street
  69.  *-----------------------------------------------------------------*/
  70. IString IAddressRecord :: street () const
  71. {
  72.    IString buffer;
  73.    return field(buffer, 1, 30);   //pad with NULLs
  74. }
  75.  
  76. IAddressRecord & IAddressRecord :: setStreet
  77.   (IString iStreet)
  78. {
  79.    setField(iStreet, 1, 30);      //pad with NULLs
  80.    return *this;
  81. }
  82.  
  83. /*------------------------------------------------------------------
  84.  * city
  85.  *-----------------------------------------------------------------*/
  86. IString IAddressRecord :: city () const
  87. {
  88.    IString buffer;
  89.    return field(buffer, 31, 20);  //pad with NULLs
  90. }
  91.  
  92. IAddressRecord & IAddressRecord :: setCity
  93.   (const IString & iCity)
  94. {
  95.    setField(iCity, 31, 20);       //pad with NULLs
  96.    return *this;
  97. }
  98.  
  99. /*------------------------------------------------------------------
  100.  * state
  101.  *-----------------------------------------------------------------*/
  102. IString IAddressRecord :: state () const
  103. {
  104.    IString buffer;
  105.    return field(buffer, 51, 2);   //pad with NULLs
  106. }
  107.  
  108. IAddressRecord & IAddressRecord :: setState
  109.   (const IString iState)
  110. {
  111.    setField(iState, 51, 2);       //pad with NULLs
  112.    return *this;
  113. }
  114.  
  115. /*------------------------------------------------------------------
  116.  * zip
  117.  *-----------------------------------------------------------------*/
  118. IString IAddressRecord :: zip () const
  119. {
  120.    IString buffer;
  121.    return field(buffer, 53, 5);   //pad with NULLs
  122. }
  123.  
  124. IAddressRecord & IAddressRecord :: setZip
  125.   (const IString & iZip)
  126. {
  127.    setField(iZip, 53, 5);         //pad with NULLs
  128.    return *this;
  129. }
  130.  
  131.  
  132. /*******************************************************************
  133.  * Implementor Member Functions
  134.  *******************************************************************/
  135. /*------------------------------------------------------------------------------
  136. | Function Name: IAddressRecord :: operator =
  137. |
  138. | Implementation:
  139. |   Replace our data with the source IAddressRecord data.
  140. ------------------------------------------------------------------------------*/
  141. IAddressRecord & IAddressRecord :: operator = ( const IAddressRecord & aRecord )
  142. {
  143.   IRecord::operator=(aRecord);
  144.   return( *this );
  145. }
  146.  
  147. /*------------------------------------------------------------------------------
  148. | Function Name: IAddressRecord :: operator =
  149. |
  150. | Implementation:
  151. |   Replace our data with the source IString data.
  152. ------------------------------------------------------------------------------*/
  153. IAddressRecord & IAddressRecord :: operator = ( const IString & aString )
  154. {
  155.   IRecord::operator=(aString);
  156.   setSize (dParentSize + dMySize);
  157.   return( *this );
  158. }
  159.