Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   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_THREAD_H__
00049 #include <cc++/thread.h>
00050 #else
00051 #ifdef  __CCXX_NAMESPACE_H__
00052 #include <cc++/macros.h>
00053 #endif
00054 #endif
00055 
00056 #ifndef __CCXX_STRCHAR_H__
00057 #include <cc++/strchar.h>
00058 #endif
00059 
00060 #ifdef __BORLANDC__
00061         using std::tm;
00062         using std::time_t;
00063 #endif
00064 
00073 class Number
00074 {
00075 protected:
00076         char *buffer;
00077         unsigned size;
00078 
00079 public:
00085         Number(char *buffer, unsigned size);
00086 
00087         void setValue(long value);
00088         const char *getBuffer()
00089                 {return buffer;};
00090 
00091         long getValue();
00092 
00093         long operator()()
00094                 {return getValue();};
00095 
00096         operator long()
00097                 {return getValue();};
00098 
00099         operator char*()
00100                 {return buffer;};
00101 
00102         long operator=(long value);
00103         long operator+=(long value);
00104         long operator-=(long value);
00105         long operator--();
00106         long operator++();
00107         int operator==(Number &num);
00108         int operator!=(Number &num);
00109         int operator<(Number &num);
00110         int operator<=(Number &num);
00111         int operator>(Number &num);
00112         int operator>=(Number &num);
00113 
00114         friend long operator+(Number &num, long val);
00115         friend long operator+(long val, Number &num);
00116         friend long operator-(Number &num, long val);
00117         friend long operator-(long val, Number &num);
00118 };
00119 
00120 class ZNumber : public Number
00121 {
00122 public:
00123         ZNumber(char *buf, unsigned size);
00124         void setValue(long value);
00125         long operator=(long value);
00126 };
00127 
00136 class Date
00137 {
00138 private:
00139         long julian;
00140 
00141 protected:
00142         void toJulian(long year, long month, long day);
00143         void fromJulian(char *buf);
00144 
00149         virtual void Update(void)
00150                 {return;};
00151 
00152 public:
00153 
00154         Date(time_t tm);
00155         Date(tm *dt);
00156         Date(char *str, size_t size = 0);
00157         Date(int year, unsigned month, unsigned day);   
00158         Date();
00159 
00160         int getYear(void);
00161         unsigned getMonth(void);
00162         unsigned getDay(void);
00163         unsigned getDayOfWeek(void);
00164         char *getDate(char *buffer);
00165         time_t getDate(void);
00166         long getValue(void);
00167         tm *getDate(tm *buf);
00168         bool is_ok(void);
00169 
00170         friend Date operator+(Date &date, long val);
00171         friend Date operator-(Date &date, long val);
00172         friend Date operator+(long val, Date &date);
00173         friend Date operator-(long val, Date &date);
00174 
00175         operator long()
00176                 {return getValue();};
00177 
00178         std::string operator()();
00179         Date& operator++();
00180         Date& operator--();
00181         Date& operator+=(long val);
00182         Date& operator-=(long val);
00183         int operator==(Date &date);
00184         int operator!=(Date &date);
00185         int operator<(Date &date);
00186         int operator<=(Date &date);
00187         int operator>(Date &date);
00188         int operator>=(Date &date);
00189         bool operator!()
00190                 {return !is_ok();};
00191 };
00192 
00199 class DateNumber : public Number, public Date
00200 {
00201 protected:
00202         void Update(void)
00203                 {fromJulian(buffer);};
00204 
00205 public:
00206         DateNumber(char *buffer);
00207 };
00208 
00209 #ifdef  __CCXX_NAMESPACE_H__
00210 #undef  __CCXX_NAMESPACE_H__
00211 #include <cc++/namespace.h>
00212 #endif
00213 
00214 #endif
00215 

Generated at Tue Oct 16 11:17:16 2001 for CommonC++ by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001