home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv8.zip / VACPP / IBMCPP / samples / VISBUILD / RAPSHEET / CPPOV23 / ILSREC.CPP < prev    next >
Text File  |  1995-05-15  |  8KB  |  205 lines

  1. //****************************************************************************
  2. // ILastSeenRecord Class - C++ Source File (ilsrec.cpp)                      *
  3. //                                                                           *
  4. // COPYRIGHT: Copyright (C) International Business Machines Corp., 1994,1995 *
  5. //                                                                           *
  6. // DISCLAIMER OF WARRANTIES:                                                 *
  7. //   The following [enclosed] code is sample code created by IBM             *
  8. //   Corporation.  This sample code is not part of any standard IBM product  *
  9. //   and is provided to you solely for the purpose of assisting you in the   *
  10. //   development of your applications.  The code is provided "AS IS",        *
  11. //   without warranty of any kind.  IBM shall not be liable for any damages  *
  12. //   arising out of your use of the sample code, even if they have been      *
  13. //   advised of the possibility of such damages.                             *
  14. //****************************************************************************
  15. //NOTE: WE RECOMMEND USING A FIXED-SPACE FONT TO LOOK AT THE SOURCE.
  16. //
  17.  
  18. #include "ilsrec.hpp"               //ILastSeenRecord header
  19. #include <rap.h>
  20.  
  21. /*******************************************************************
  22.  * Manager Member Functions 
  23.  *******************************************************************/
  24. ILastSeenRecord :: ILastSeenRecord() :
  25.                      IRecord(),
  26.                      dMySize(sizeof(LAST_SEEN_STRUCT))
  27. {
  28.    dParentSize = size();
  29.    setSize( dParentSize + dMySize );  //pad with '\x00'
  30. }
  31.  
  32. ILastSeenRecord :: ILastSeenRecord ( const IString & stringData ) :
  33.                      IRecord(),
  34.                      dMySize(sizeof(LAST_SEEN_STRUCT))
  35. {
  36.    dParentSize = size();
  37.    *this = stringData;
  38.    setSize( dParentSize + dMySize );  //truncate or pad as appropriate
  39. }
  40.  
  41. ILastSeenRecord :: ILastSeenRecord ( const ILastSeenRecord & aRecord ) :
  42.                      IRecord(),
  43.                      dMySize(sizeof(LAST_SEEN_STRUCT))
  44. {
  45.    dParentSize = size();      
  46.    *this = aRecord;
  47.   /*------------------------------------------------------------------
  48.    * NOTE:  this record would have gotten set with the correct size
  49.    *        if had called the IRecord (aRecord) constructor, but
  50.    *        need to determine what dParentSize is (the assignment
  51.    *        operators need this info).
  52.    *-----------------------------------------------------------------*/
  53. }
  54.  
  55. ILastSeenRecord :: ~ILastSeenRecord()
  56. {
  57. }
  58.  
  59. /*******************************************************************
  60.  * Access Member Functions 
  61.  *******************************************************************/
  62.  
  63. /*------------------------------------------------------------------
  64.  * location
  65.  *-----------------------------------------------------------------*/
  66. IString ILastSeenRecord :: location () const
  67. {
  68.    IString buffer;
  69.    return field(buffer, offsetof(LAST_SEEN_STRUCT, lastSeenLocation)+1, LS_LOC_LEN);   //pad with NULLs
  70. }
  71.  
  72. ILastSeenRecord & ILastSeenRecord :: setLocation
  73.   (const IString & iLocation)
  74. {
  75.    setField(iLocation, offsetof(LAST_SEEN_STRUCT, lastSeenLocation)+1, LS_LOC_LEN);   //pad with NULLs
  76.    return *this;
  77.  
  78. }
  79.  
  80. /*------------------------------------------------------------------
  81.  * witness
  82.  *-----------------------------------------------------------------*/
  83. IString ILastSeenRecord :: witness() const
  84. {
  85.    IString buffer;
  86.    return field(buffer, offsetof(LAST_SEEN_STRUCT, lastSeenWitness)+1, LS_WITNESS_LEN);   //pad with NULLs
  87. }
  88.  
  89. ILastSeenRecord & ILastSeenRecord :: setWitness
  90.   (const IString & iWitness)
  91. {
  92.    setField(iWitness, offsetof(LAST_SEEN_STRUCT, lastSeenWitness)+1, LS_WITNESS_LEN); //pad with NULLs
  93.    return *this;
  94. }
  95.  
  96. /*------------------------------------------------------------------
  97.  * lastSeenDate
  98.  *-----------------------------------------------------------------*/
  99. IString ILastSeenRecord :: lastSeenDate() const
  100. {
  101.    IString buffer;
  102.    return field(buffer, offsetof(LAST_SEEN_STRUCT, lastSeenDate)+1, DATE_LEN);     //pad with NULLs
  103. }
  104.  
  105. ILastSeenRecord & ILastSeenRecord :: setLastSeenDate
  106.   (const IString & iLastSeenDate)
  107. {
  108.    setField(iLastSeenDate, offsetof(LAST_SEEN_STRUCT, lastSeenDate)+1, DATE_LEN); //pad with NULLs
  109.    return *this;
  110. }
  111.  
  112. /*------------------------------------------------------------------
  113.  * street
  114.  *-----------------------------------------------------------------*/
  115. IString ILastSeenRecord :: street() const
  116. {
  117.    IString buffer;
  118.    return field(buffer, offsetof(LAST_SEEN_STRUCT, lastSeenStreet)+1, ADDRESS_STREET_LEN);     //pad with NULLs
  119. }
  120.  
  121. ILastSeenRecord & ILastSeenRecord :: setStreet
  122.   (const IString & iStreet)
  123. {
  124.    setField(iStreet, offsetof(LAST_SEEN_STRUCT, lastSeenDate)+1, ADDRESS_STREET_LEN); //pad with NULLs
  125.    return *this;
  126. }
  127.  
  128. /*------------------------------------------------------------------
  129.  * city
  130.  *-----------------------------------------------------------------*/
  131. IString ILastSeenRecord :: city() const
  132. {
  133.    IString buffer;
  134.    return field(buffer, offsetof(LAST_SEEN_STRUCT, lastSeenCity)+1, ADDRESS_CITY_LEN);  //pad with NULLs
  135. }
  136.  
  137. ILastSeenRecord & ILastSeenRecord :: setCity
  138.   (const IString & iStreet)
  139. {
  140.    setField(iStreet, offsetof(LAST_SEEN_STRUCT, lastSeenCity)+1, ADDRESS_CITY_LEN);   //pad with NULLs
  141.    return *this;
  142. }
  143.  
  144.  
  145. /*------------------------------------------------------------------
  146.  * state
  147.  *-----------------------------------------------------------------*/
  148. IString ILastSeenRecord :: state() const
  149. {
  150.    IString buffer;
  151.    return field(buffer, offsetof(LAST_SEEN_STRUCT, lastSeenState)+1, ADDRESS_STATE_LEN);   //pad with NULLs
  152. }
  153.  
  154. ILastSeenRecord & ILastSeenRecord :: setState
  155.   (const IString & iStreet)
  156. {
  157.    setField(iStreet, offsetof(LAST_SEEN_STRUCT, lastSeenState)+1, ADDRESS_STATE_LEN); //pad with NULLs
  158.    return *this;
  159. }
  160.  
  161. /*------------------------------------------------------------------
  162.  * comment
  163.  *-----------------------------------------------------------------*/
  164. IString ILastSeenRecord :: comment() const
  165. {
  166.    IString buffer;
  167.    return field(buffer, offsetof(LAST_SEEN_STRUCT, lastSeenComment)+1, COMMENT_LEN);   //pad with NULLs
  168. }
  169.  
  170. ILastSeenRecord & ILastSeenRecord :: setComment
  171.   (const IString & iComment)
  172. {
  173.    setField(iComment, offsetof(LAST_SEEN_STRUCT, lastSeenComment)+1, COMMENT_LEN); //pad with NULLs
  174.    return *this;
  175. }
  176.  
  177.  
  178. /*******************************************************************
  179.  * Implementor Member Functions 
  180.  *******************************************************************/
  181. /*------------------------------------------------------------------------------
  182. | Function Name: ILastSeenRecord :: operator =
  183. |
  184. | Implementation:
  185. |   Replace our data with the source ILastSeenRecord data.
  186. ------------------------------------------------------------------------------*/
  187. ILastSeenRecord & ILastSeenRecord :: operator = ( const ILastSeenRecord & aRecord )
  188. {
  189.   IRecord::operator=(aRecord);
  190.   return( *this );
  191. }
  192.  
  193. /*------------------------------------------------------------------------------
  194. | Function Name: ILastSeenRecord :: operator =
  195. |
  196. | Implementation:
  197. |   Replace our data with the source IString data.
  198. ------------------------------------------------------------------------------*/
  199. ILastSeenRecord & ILastSeenRecord :: operator = ( const IString & aString )
  200. {
  201.   IRecord::operator=(aString);
  202.   setSize (dParentSize + dMySize);
  203.   return( *this );
  204. }
  205.