Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

lkmoney.h

00001 /* liblookdb: lkmoney.h - Money representation
00002     Copyright (C) 1998-2001 LOOK Systems
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Lesser General Public
00006     License as published by the Free Software Foundation; either
00007     version 2.1 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Lesser General Public License for more details.
00013 
00014     You should have received a copy of the GNU Lesser General Public
00015     License along with this library; if not, write to the Free Software
00016     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 */
00018 #ifndef LIBLOOKDB_LKMONEY_H
00019 #define LIBLOOKDB_LKMONEY_H
00020 
00021 // $Id: lkmoney.h,v 1.4 2001/07/04 15:53:18 clive Exp $
00022 
00023 #include "looktypes.h"
00024 #include "lktypebase.h"
00025 
00026 #include "lkstring.h"
00027 
00028 namespace look {
00029 
00030 // *****************************************************
00031 // LookMoney class
00032 // *****************************************************
00033 
00034 class LookFloat;
00035 class LookInteger;
00036 
00038 
00048 class LOOKTYPES_DLL LookMoney : public LookTypeBase
00049 {
00050 public:
00051 // Constructors.
00052 
00053 // if you want to get, eg 25 pounds, do LookMoney aMoney( 2500 );
00054         LookMoney( long thePence = 0 );
00055 
00056 // Destructor.
00057         ~LookMoney( void );
00058 
00059 // Copy constructor.
00060         LookMoney( const LookMoney &theOther );
00061 
00062 // Assignment operators
00063         LookMoney& operator=( const LookMoney &theOther );
00064         LookMoney& operator=( long thePence );
00065 
00066 // cast to long (pence)
00067         operator long( void ) const;
00068 
00069 // get a copy
00070         LookTypeBase* GetNewCopy( void ) const;
00071 
00072 // get my id
00073         long GetTypeID( void ) const;
00074 
00075 // explicit pence ops.
00076         void SetPence( long thePence );
00077         long GetPence( void ) const;
00078 
00079 // this method rounds too according to itsRoundingScheme
00080         void SetPence( double thePence );
00081 
00082 // try not to use these next two!
00083 // and pounds. ingress supplies data in pounds 
00084 // (not LookFloats here)
00085         void SetPounds( double thePounds );
00086         double GetPounds( void ) const;
00087 
00088 // Conversion to and from strings
00089         bool Set( const LookString& theString );
00090         LookString GetSimpleString( void ) const;
00091         LookString GetFullString( void ) const;
00092 
00093 // comparison operators
00094         bool operator==(const LookMoney &theValue) const;
00095         bool operator!=(const LookMoney &theValue) const;
00096         bool operator<=(const LookMoney &theValue) const;
00097         bool operator>=(const LookMoney &theValue) const;
00098         bool operator<(const LookMoney &theValue) const;
00099         bool operator>(const LookMoney &theValue) const;
00100 
00101 // arithmetic operators
00102         LookMoney operator+(const LookMoney &theValue) const;
00103         LookMoney& operator+=(const LookMoney &theValue);
00104 
00105         LookMoney operator-(const LookMoney &theValue) const;
00106         LookMoney& operator-=(const LookMoney &theValue);
00107 
00108 // can multiply by lookinteger and lookfloat
00109 // money * money makes no sense
00110         LookMoney operator*(const LookInteger& theMultiplier) const;
00111         LookMoney& operator*=(const LookInteger& theMultiplier);
00112 
00113         LookMoney operator*(const LookFloat& theMultiplier) const;
00114         LookMoney& operator*=(const LookFloat& theMultiplier);
00115 
00116 // how to round money when multipled by float and set as pounds
00117 
00119 
00130         enum RoundingScheme
00131         {
00132                 Nearest = 0,
00133                 TowardsZero,
00134                 AwayFromZero,
00135                 Up,
00136                 Down
00137         };
00138 
00140         static RoundingScheme GetRoundingScheme( void );
00142         static void SetRoundingScheme( RoundingScheme theRoundingScheme );
00143 
00144 protected:
00145 
00146 
00148         long itsPence;
00149 
00151 
00157         static RoundingScheme itsRoundingScheme;
00158 
00159 };
00160 
00161 
00162 } // end of "look" namespace
00163 #endif

Generated at Thu Jan 17 12:53:06 2002 for liblookdb by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001