home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / iordrrec.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  8.3 KB  |  159 lines

  1. #ifndef _IOrderedRecord_
  2. #define _IOrderedRecord_
  3. /*******************************************************************************
  4. * FILE NAME: iordrrec.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     IOrderedRecord - Base class for classes that represent records           *
  9. *                      that have an ordering relationship.                     *
  10. *                                                                              *
  11. * COPYRIGHT:                                                                   *
  12. *   IBM(R) VisualAge(TM) for C++                                               *
  13. *   (C) Copyright International Business Machines Corporation 1991, 1996       *
  14. *   Licensed Material - Program-Property of IBM - All Rights Reserved.         *
  15. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  16. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  17. *                                                                              *
  18. *   This program will not run in DOS mode.                                     *
  19. *                                                                              *
  20. * DISCLAIMER OF WARRANTIES:                                                    *
  21. *   The following [enclosed] code is sample code created by IBM                *
  22. *   Corporation.  This sample code is not part of any standard IBM product     *
  23. *   and is provided to you solely for the purpose of assisting you in the      *
  24. *   development of your applications.  The code is provided "AS IS",           *
  25. *   without warranty of any kind.  IBM shall not be liable for any damages     *
  26. *   arising out of your use of the sample code, even if they have been         *
  27. *   advised of the possibility of such damages.                                *
  28. *******************************************************************************/
  29. #ifndef _IRecord_
  30.   #include <irecord.hpp>
  31. #endif
  32.  
  33. #ifndef _ISTRING_
  34.   #include <istring.hpp>
  35. #endif
  36.  
  37. /*-------------------------- Pragma Library Support --------------------------*/
  38. #ifndef __NO_DEFAULT_LIBS__
  39.   #ifdef __OS2__
  40.     #ifdef __IMPORTLIB__
  41.        #pragma library("CPPOV03I.LIB")
  42.     #else
  43.        #pragma library("CPPOV03.LIB")
  44.     #endif
  45.   #endif
  46.   #ifdef __WINDOWS__
  47.     #ifdef __IMPORTLIB__
  48.        #pragma library("CPPWV03I.LIB")
  49.     #else
  50.        #pragma library("CPPWV03.LIB")
  51.     #endif
  52.   #endif
  53. #endif
  54.  
  55. // Align classes on four byte boundary.
  56. #pragma pack(4)
  57.  
  58. class IOrderedRecord : public IRecord {
  59. /*******************************************************************************
  60. *
  61. * This is the base class for all records that have an ordering relationship.
  62. * All the boolean comparison operators are defined.  See the description of
  63. * the comparison operators for considerations for subclasses.
  64. *
  65. *******************************************************************************/
  66.  
  67. public:
  68. /*------------------------- Constructors/Destructor ----------------------------
  69. | You can contruct an instance of this class as follows:                       |
  70. |   - Constructs an empty record of size 0.                                    |
  71. |   - Constructs a record containing the 'recordData'.  The record size is     |
  72. |     determined from the length of the IString.                               |
  73. |   - Copies the record data from the argument record.                         |
  74. |-----------------------------------------------------------------------------*/
  75. IOrderedRecord ( );
  76.  
  77. IOrderedRecord ( const IString & recordData );
  78.  
  79. IOrderedRecord ( const IOrderedRecord & aRecord );
  80.  
  81. virtual ~IOrderedRecord ( );
  82.  
  83. /*--------------------------------- Testing ------------------------------------
  84. | The following functions test for record properties:                          |
  85. |   isOrdered - Returns true.                                                  |
  86. ------------------------------------------------------------------------------*/
  87. IBoolean isOrdered ( ) const;
  88.  
  89. /*------------------------------- Comparison -----------------------------------
  90. | All boolean operators are defined for ordered records.  The following        |
  91. | operators are overloaded so that IOrderedRecords can be compared to IStrings |
  92. | as well as to other IOrderedRecords.  The virtual operators are implemented  |
  93. | as the corresponding IString operator.  The friend operators that include an |
  94. | IString parameter are implemented as a call to the virtual operator.  The    |
  95. | friend operators will never need to be overridden.  If needed, a subclass    |
  96. | may implement its own version of the virtual operator.  A subclass can also  |
  97. | use protected or private inheritance to hide these operators and then        |
  98. | explicitly make public the operators and other functions it wishes to expose.|
  99. |   operator == - True if and only if the records are identical.               |
  100. |   operator != - True if and only if the records are not identical.           |
  101. |   operator <  - True if and only if the first record is less than the        |
  102. |                 second, when compared as IStrings.                           |
  103. |   operator >  - Equivalent to '!(record1 <= record2)'.                       |
  104. |   operator <= - Equivalent to '(record1 < record2) || (record1 == record2)'. |
  105. |   operator >= - Equivalent to '!(record1 < record2)'.                        |
  106. ------------------------------------------------------------------------------*/
  107. virtual IBoolean operator == ( const IOrderedRecord & aRecord ) const;
  108. friend  IBoolean operator == ( const IOrderedRecord & record1,
  109.                                const IString & record2 );
  110. friend  IBoolean operator == ( const IString & record1,
  111.                                const IOrderedRecord & record2 );
  112.  
  113. virtual IBoolean operator != ( const IOrderedRecord & aRecord ) const;
  114. friend  IBoolean operator != ( const IOrderedRecord & record1,
  115.                                const IString & record2 );
  116. friend  IBoolean operator != ( const IString & record1,
  117.                                const IOrderedRecord & record2 );
  118.  
  119. virtual IBoolean operator < ( const IOrderedRecord & aRecord ) const;
  120. friend  IBoolean operator < ( const IOrderedRecord & record1,
  121.                               const IString & record2 );
  122. friend  IBoolean operator < ( const IString & record1,
  123.                               const IOrderedRecord & record2 );
  124.  
  125. virtual IBoolean operator > ( const IOrderedRecord & aRecord ) const;
  126. friend  IBoolean operator > ( const IOrderedRecord & record1,
  127.                               const IString & record2 );
  128. friend  IBoolean operator > ( const IString & record1,
  129.                               const IOrderedRecord & record2 );
  130.  
  131. virtual IBoolean operator <= ( const IOrderedRecord & aRecord ) const;
  132. friend  IBoolean operator <= ( const IOrderedRecord & record1,
  133.                                const IString & record2 );
  134. friend  IBoolean operator <= ( const IString & record1,
  135.                                const IOrderedRecord & record2 );
  136.  
  137. virtual IBoolean operator >= ( const IOrderedRecord & aRecord ) const;
  138. friend  IBoolean operator >= ( const IOrderedRecord & record1,
  139.                                const IString & record2 );
  140. friend  IBoolean operator >= ( const IString & record1,
  141.                                const IOrderedRecord & record2 );
  142.  
  143. /*--------------------------- Assignment Operator ------------------------------
  144. | The following operators allow the record's contents to be assigned from      |
  145. | another record or an IString.                                                |
  146. |   operator = - Replaces the contents of the record.  The target              |
  147. |                IOrdered Record size will be the source IOrderedRecord        |
  148. |                or IString size.                                              |
  149. |-----------------------------------------------------------------------------*/
  150. IOrderedRecord & operator = ( const IOrderedRecord & aRecord );
  151. IOrderedRecord & operator = ( const IString & aRecord );
  152.  
  153. }; // IOrderedRecord
  154.  
  155. // Resume compiler default packing.
  156. #pragma pack()
  157.  
  158. #endif // _IOrderedRecord_
  159.