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

  1. /******************************************************************************
  2. * .FILE:        irsltrec.cpp                                                  *
  3. *                                                                             *
  4. * .DESCRIPTION: Implementation for the class, IResultRecord                   *
  5. *                                                                             *
  6. * .CLASSES:     IResultRecord                                                 *
  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 "irsltrec.hpp"               //IResultRecord header
  25.  
  26. /*******************************************************************
  27.  * Manager Member Functions
  28.  *******************************************************************/
  29. IResultRecord :: IResultRecord() :
  30.                      IRecord(),
  31.                      dMySize(32759L)
  32. {
  33.    dParentSize = size();
  34.    setSize( dParentSize + dMySize );  //pad with NULLs
  35. }
  36.  
  37. IResultRecord :: IResultRecord ( const IString & stringData ) :
  38.                      IRecord(),
  39.                      dMySize(32759L)
  40. {
  41.    dParentSize = size();
  42.    *this = stringData;
  43.    setSize( dParentSize + dMySize );  //truncate or pad as appropriate
  44. }
  45.  
  46. IResultRecord :: IResultRecord ( const IResultRecord & aRecord ) :
  47.                      IRecord(),
  48.                      dMySize(32759L)
  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. IResultRecord :: ~IResultRecord()
  61. {
  62. }
  63.  
  64. /*------------------------------------------------------------------------------
  65. | IResultRecord::asDebugInfo                                                   |
  66. |                                                                              |
  67. | Generate a string that identifies for debugging purposes what data           |
  68. | an IResultRecord instance contains.                                          |
  69. |                                                                              |
  70. ------------------------------------------------------------------------------*/
  71. IString IResultRecord :: asDebugInfo () const
  72. {
  73.   IString debugInfo("size=" + IString(dMySize) + ",");
  74.   debugInfo += "numResults=" + IString(numResults()) + ",";
  75.   debugInfo += "data=" + resultData() + ".";
  76.  
  77.   return debugInfo;
  78. }
  79.  
  80. /*******************************************************************
  81.  * Access Member Functions
  82.  *******************************************************************/
  83. /*------------------------------------------------------------------
  84.  * numResults
  85.  *-----------------------------------------------------------------*/
  86. unsigned short IResultRecord :: numResults () const
  87. {
  88.    unsigned short buffer;
  89.    return field(buffer, 1);
  90. }
  91.  
  92. IResultRecord & IResultRecord :: setNumResults
  93.   (unsigned short iNumResults)
  94. {
  95.    setField(iNumResults, 1);
  96.    return *this;
  97. }
  98.  
  99. /*------------------------------------------------------------------
  100.  * resultsData
  101.  *-----------------------------------------------------------------*/
  102. IString IResultRecord :: resultData () const
  103. {
  104.    IString buffer;
  105.    return field(buffer, 3, 32757);
  106.    }
  107.  
  108. IResultRecord & IResultRecord :: setResultData
  109.   (const IString & iResultData)
  110. {
  111.    setField(iResultData, 3, 32757);
  112.    return *this;
  113. }
  114.  
  115. /*******************************************************************
  116.  * Implementor Member Functions
  117.  *******************************************************************/
  118. /*------------------------------------------------------------------------------
  119. | Function Name: IResultRecord :: operator =
  120. |
  121. | Implementation:
  122. |   Replace our data with the source IResultRecord data.
  123. ------------------------------------------------------------------------------*/
  124. IResultRecord & IResultRecord :: operator = ( const IResultRecord & aRecord )
  125. {
  126.   IRecord::operator=(aRecord);
  127.   return( *this );
  128. }
  129.  
  130. /*------------------------------------------------------------------------------
  131. | Function Name: IResultRecord :: operator =
  132. |
  133. | Implementation:
  134. |   Replace our data with the source IString data.
  135. ------------------------------------------------------------------------------*/
  136. IResultRecord & IResultRecord :: operator = ( const IString & aString )
  137. {
  138.   IRecord::operator=(aString);
  139.   setSize (dParentSize + dMySize);
  140.   return( *this );
  141. }
  142.