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

integer.hh

00001 /*
00002 *  Name:      integer.hh
00003 *  Author:    Rafael Jesus Alcantara Perez
00004 *  Summary:   UESQLC base SQL type integer
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_INTEGER__
00027 #define _UESQL_INTEGER__
00028 
00029 #include "type.hh"
00030 
00031 
00033 namespace uesqlc
00034 {
00035 
00037   class TInteger : public IType
00038   {
00039 
00040     private:
00041 
00043       long int   liValue;
00044 
00045 
00046     public:
00047 
00048       //
00049       //  C O N S T R U C T O R S
00050       //
00051 
00053       TInteger (void) :
00054         IType   ()    ,
00055         liValue (0L)  {}
00056 
00058       TInteger (const TInteger& rktINTEGER) :
00059         IType   ()                          ,
00060         liValue (rktINTEGER.liValue)
00061       {
00062         setNull (rktINTEGER.isNull());
00063       }
00064 
00065       TInteger (const long int kliVALUE) :
00066         IType   ()                       ,
00067         liValue (kliVALUE)
00068       {
00069         setNull (false);
00070       }
00071 
00072       TInteger (const int kiVALUE) :
00073         IType   ()                 ,
00074         liValue (kiVALUE)
00075       {
00076         setNull (false);
00077       }
00078 
00079       explicit TInteger (const bool kgVALUE) :
00080         IType   ()                           ,
00081         liValue (kgVALUE)
00082       {
00083         setNull (false);
00084       }
00085 
00086       explicit TInteger (const char* pkcINTEGER) :
00087         IType   ()                               ,
00088         liValue (0L)
00089       {
00090         set (pkcINTEGER);
00091       }
00092 
00093       explicit TInteger (const std::string& rkyINTEGER) :
00094         IType   ()                                      ,
00095         liValue (0L)
00096       {
00097         set (rkyINTEGER);
00098       }
00099 
00106       void set (const char* pkcVALUE)
00107       {
00108         setNull ( !pkcVALUE || !*pkcVALUE );
00109         if ( !isNull() )
00110         {
00111           liValue = std::atol (pkcVALUE);
00112         }
00113       }
00114 
00121       void set (const std::string& rkyVALUE)
00122       {
00123         set (rkyVALUE.c_str());
00124       }
00125 
00126 
00127     public:
00128 
00129       //
00130       //  S E L E C T O R S
00131       //
00132 
00137       mpcl::text::TString get (void) const
00138       {
00139         mpcl::text::TString   yResult;
00140 
00141         if ( isNull() )
00142         {
00143           yResult = "null";
00144         }
00145         else
00146         {
00147           yResult = mpcl::text::Format ("%ld", liValue);
00148         }
00149         return yResult;
00150       }
00151 
00153       operator long int (void) const
00154       {
00155         return liValue;
00156       }
00157 
00158   };  // class TInteger
00159 
00160 }  // namespace uesqlc
00161 
00162 
00163 #endif  // not _UESQL_INTEGER__

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