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

numbers.h

Go to the documentation of this file.
00001 // Copyright (C) 1999-2001 Open Source Telecom Corporation.
00002 //  
00003 // This program is free software; you can redistribute it and/or modify
00004 // it under the terms of the GNU General Public License as published by
00005 // the Free Software Foundation; either version 2 of the License, or
00006 // (at your option) any later version.
00007 // 
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 // 
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the Free Software 
00015 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00016 // 
00017 // As a special exception to the GNU General Public License, permission is 
00018 // granted for additional uses of the text contained in its release 
00019 // of Common C++.
00020 // 
00021 // The exception is that, if you link the Common C++ library with other
00022 // files to produce an executable, this does not by itself cause the
00023 // resulting executable to be covered by the GNU General Public License.
00024 // Your use of that executable is in no way restricted on account of
00025 // linking the Common C++ library code into it.
00026 // 
00027 // This exception does not however invalidate any other reasons why
00028 // the executable file might be covered by the GNU General Public License.
00029 // 
00030 // This exception applies only to the code released under the 
00031 // name Common C++.  If you copy code from other releases into a copy of
00032 // Common C++, as the General Public License permits, the exception does
00033 // not apply to the code that you add in this way.  To avoid misleading
00034 // anyone as to the status of such modified files, you must delete
00035 // this exception notice from them.
00036 // 
00037 // If you write modifications of your own for Common C++, it is your choice
00038 // whether to permit this exception to apply to your modifications.
00039 // If you do not wish that, delete this exception notice.  
00040 
00041 #ifndef __CCXX_NUMBERS_H__
00042 #define __CCXX_NUMBERS_H__
00043 
00044 #ifndef __CCXX_CONFIG_H__
00045 #include <cc++/config.h>
00046 #endif
00047 
00048 #ifndef __CCXX_STRCHAR_H__
00049 #include <cc++/strchar.h>
00050 #endif
00051 
00052 #include <ctime>
00053 
00054 #ifdef  __NAMESPACES__
00055 namespace ost {
00056 #ifdef __BORLANDC__
00057         using std::tm;
00058         using std::time_t;
00059 #endif
00060 #endif
00061 
00070 class CCXX_CLASS_EXPORT Number
00071 {
00072 protected:
00073         char *buffer;
00074         unsigned size;
00075 
00076 public:
00082         Number(char *buffer, unsigned size);
00083 
00084         void setValue(long value);
00085         const char *getBuffer()
00086                 {return buffer;};
00087 
00088         long getValue();
00089 
00090         long operator()()
00091                 {return getValue();};
00092 
00093         operator long()
00094                 {return getValue();};
00095 
00096         operator char*()
00097                 {return buffer;};
00098 
00099         long operator=(long value);
00100         long operator+=(long value);
00101         long operator-=(long value);
00102         long operator--();
00103         long operator++();
00104         int operator==(Number &num);
00105         int operator!=(Number &num);
00106         int operator<(Number &num);
00107         int operator<=(Number &num);
00108         int operator>(Number &num);
00109         int operator>=(Number &num);
00110 
00111         friend long operator+(Number &num, long val);
00112         friend long operator+(long val, Number &num);
00113         friend long operator-(Number &num, long val);
00114         friend long operator-(long val, Number &num);
00115 };
00116 
00117 class CCXX_CLASS_EXPORT ZNumber : public Number
00118 {
00119 public:
00120         ZNumber(char *buf, unsigned size);
00121         void setValue(long value);
00122         long operator=(long value);
00123 };
00124 
00133 class CCXX_CLASS_EXPORT Date
00134 {
00135 private:
00136         long julian;
00137 
00138 protected:
00139         void toJulian(long year, long month, long day);
00140         void fromJulian(char *buf);
00141 
00146         virtual void Update(void)
00147                 {return;};
00148 
00149 public:
00150 
00151         Date(time_t tm);
00152         Date(tm *dt);
00153         Date(char *str, size_t size = 0);
00154         Date(int year, unsigned month, unsigned day);   
00155         Date();
00156 
00157         int getYear(void);
00158         unsigned getMonth(void);
00159         unsigned getDay(void);
00160         unsigned getDayOfWeek(void);
00161         char *getDate(char *buffer);
00162         time_t getDate(void);
00163         long getValue(void);
00164         tm *getDate(tm *buf);
00165         bool is_ok(void);
00166 
00167         friend Date operator+(Date &date, long val);
00168         friend Date operator-(Date &date, long val);
00169         friend Date operator+(long val, Date &date);
00170         friend Date operator-(long val, Date &date);
00171 
00172         operator long()
00173                 {return getValue();};
00174 
00175         std::string operator()();
00176         Date& operator++();
00177         Date& operator--();
00178         Date& operator+=(long val);
00179         Date& operator-=(long val);
00180         int operator==(Date &date);
00181         int operator!=(Date &date);
00182         int operator<(Date &date);
00183         int operator<=(Date &date);
00184         int operator>(Date &date);
00185         int operator>=(Date &date);
00186         bool operator!()
00187                 {return !is_ok();};
00188 };
00189 
00196 class CCXX_CLASS_EXPORT DateNumber : public Number, public Date
00197 {
00198 protected:
00199         void Update(void)
00200                 {fromJulian(buffer);};
00201 
00202 public:
00203         DateNumber(char *buffer);
00204 };
00205 
00206 #ifdef  __NAMESPACES__
00207 };
00208 #endif
00209 
00210 #endif
00211 

Generated at Tue Nov 20 12:34:33 2001 for CommonC++ by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001