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

lknumeric.h

00001 /* liblookdb: lknumeric.h - Numeric 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_LKNUMERIC_H
00019 #define LIBLOOKDB_LKNUMERIC_H
00020 
00021 // $Id: lknumeric.h,v 1.4 2001/07/04 15:53:19 clive Exp $
00022 /* This is a number stored as a string - no precision issues. The reason it
00023    exists is that Oracle OCI tends to return numbers as strings (not int,
00024    float or money) and there's no way to tell if it's supposed to be int,
00025    float or money. This class can be converted to any of these.
00026 */
00027 
00028 #include "looktypes.h"
00029 #include "lktypebase.h"
00030 
00031 #include "lkstring.h"
00032 #include "lkfloat.h"
00033 #include "lkinteger.h"
00034 #include "lkmoney.h"
00035 
00036 namespace look {
00037 
00038 // *****************************************************
00039 // LookNumeric class
00040 // *****************************************************
00041 
00042 class LookFloat;
00043 class LookInteger;
00044 class LookMoney;
00045 
00047 
00056 class LOOKTYPES_DLL LookNumeric : public LookTypeBase
00057 {
00058 public:
00059 // Constructors.
00060 // can construct from money, long, lookinteger,
00061 // lookfloat (with precision)
00062         LookNumeric();
00063         LookNumeric( long theValue );
00064         LookNumeric( const LookInteger& theInt );
00065         LookNumeric( const LookMoney& theMoney );
00066         LookNumeric( const LookFloat& theFloat, int thePrecision );
00067 
00068 // Destructor.
00069         ~LookNumeric( void );
00070 
00071 // Copy constructor.
00072         LookNumeric( const LookNumeric &theOther );
00073 
00074 // Assignment operators
00075         LookNumeric& operator=( const LookNumeric &theOther );
00076         LookNumeric& operator=( long theValue );
00077         LookNumeric& operator=( const LookInteger& theInt );
00078         LookNumeric& operator=( const LookMoney& theMoney );
00079 
00080 // get a copy
00081         LookTypeBase* GetNewCopy( void ) const;
00082 
00083 // get my id
00084         long GetTypeID( void ) const;
00085 
00086 // set from a float (assignment won't do - we need a precision)
00087         void SetFloat( const LookFloat& theFloat, int thePrecision );
00088 
00089 // conversions to other number types
00090         LookFloat GetFloat( void );
00091         LookInteger GetInteger( void );
00092         LookMoney GetMoney( void );
00093 
00094 // Conversion to and from strings
00095         bool Set( const LookString& theString );
00096         LookString GetString( void ) const;
00097 
00098         // I'm not sure if we want these operators. convert to suitable class
00099         // first? (although == op will work better than float ==)
00100         /*
00101 // comparison operators
00102         bool operator==(const LookNumeric &theValue) const;
00103         bool operator!=(const LookNumeric &theValue) const;
00104         bool operator<=(const LookNumeric &theValue) const;
00105         bool operator>=(const LookNumeric &theValue) const;
00106         bool operator<(const LookNumeric &theValue) const;
00107         bool operator>(const LookNumeric &theValue) const;
00108 
00109 // arithmetic operators
00110         LookNumeric operator+(const LookNumeric &theValue) const;
00111         LookNumeric& operator+=(const LookNumeric &theValue);
00112 
00113         LookNumeric operator-(const LookNumeric &theValue) const;
00114         LookNumeric& operator-=(const LookNumeric &theValue);
00115         */
00116 
00117 protected:
00118 
00120         LookString itsString;
00121 
00122 };
00123 
00124 
00125 } // end of "look" namespace
00126 #endif

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