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

real.hh

00001 /*
00002 *  Name:      real.hh
00003 *  Author:    Rafael Jesus Alcantara Perez
00004 *  Summary:   UESQLC base SQL type real
00005 *  Date:      $Date: 2003/10/06 13:21:35 $
00006 *  Revision:  $Revision: 1.1 $
00007 *
00008 *  Copyright (C) 2002  Rafael Jesus Alcantara Perez <rafa@dedalo-ing.com>
00009 *
00010 *  This program is free software; you can redistribute it and/or modify
00011 *  it under the terms of the GNU General Public License as published by
00012 *  the Free Software Foundation; either version 2 of the License, or
00013 *  (at your option) any later version.
00014 *
00015 *  This program is distributed in the hope that it will be useful,
00016 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 *  GNU General Public License for more details.
00019 *
00020 *  You should have received a copy of the GNU General Public License
00021 *  along with this program; if not, write to the Free Software
00022 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00023 *  MA 02111-1307, USA.
00024 */
00025 
00026 #ifndef _UESQL_REAL__
00027 #define _UESQL_REAL__
00028 
00029 #include "type.hh"
00030 
00031 
00033 namespace uesqlc
00034 {
00035 
00037   class TReal : public IType
00038   {
00039 
00040     private:
00041 
00043       double   dValue;
00044 
00045 
00046     public:
00047 
00048       //
00049       //  C O N S T R U C T O R S
00050       //
00051 
00052       TReal (void) :
00053         IType  ()  ,
00054         dValue (0) {}
00055 
00057       TReal (const TReal& rktREAL) :
00058         IType  ()                  ,
00059         dValue (rktREAL.dValue)
00060       {
00061         setNull (rktREAL.isNull());
00062       }
00063 
00064       TReal (const double kdVALUE) :
00065         IType  ()                  ,
00066         dValue (kdVALUE)
00067       {
00068         setNull (false);
00069       }
00070 
00071       explicit TReal (const char* pkcREAL) :
00072         IType  ()                          ,
00073         dValue (0)
00074       {
00075         set (pkcREAL);
00076       }
00077 
00078       explicit TReal (const std::string& rkyREAL) :
00079         IType  ()                                 ,
00080         dValue (0)
00081       {
00082         set (rkyREAL);
00083       }
00084 
00091       void set (const char* pkcVALUE)
00092       {
00093         setNull ( !pkcVALUE || !*pkcVALUE );
00094         if ( !isNull() )
00095         {
00096           dValue = std::atof (pkcVALUE);
00097         }
00098       }
00099       
00106       void set (const std::string& rkyVALUE)
00107       {
00108         set (rkyVALUE.c_str());
00109       }
00110 
00111 
00112     public:
00113 
00114       //
00115       //  S E L E C T O R S
00116       //
00117 
00122       mpcl::text::TString get (void) const
00123       {
00124         mpcl::text::TString   yResult;
00125 
00126         if ( isNull() )
00127         {
00128           yResult = "null";
00129         }
00130         else
00131         {
00132           yResult = mpcl::text::Format ("%f", dValue);
00133         }
00134         return yResult;
00135       }
00136 
00143       mpcl::text::TString get (const char* pkcFORMAT) const
00144       {
00145         mpcl::text::TString   yResult;
00146 
00147         if ( isNull() )
00148         {
00149           yResult = "null";
00150         }
00151         else
00152         {
00153           yResult = mpcl::text::Format (pkcFORMAT, dValue);
00154         }
00155         return yResult;
00156       }
00157 
00159       operator long double (void) const
00160       {
00161         return dValue;
00162       }
00163 
00164   };  // class TReal
00165 
00166 }  // namespace uesqlc
00167 
00168 
00169 #endif  // not _UESQL_REAL__

Generated on Mon Oct 13 02:40:10 2003 for UESQLC by doxygen1.2.18