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 #ifdef  __NAMESPACES__
00053 namespace ost {
00054 #ifdef __BORLANDC__
00055         using std::tm;
00056         using std::time_t;
00057 #endif
00058 #endif
00059 
00068 class Number
00069 {
00070 protected:
00071         char *buffer;
00072         unsigned size;
00073 
00074 public:
00080         Number(char *buffer, unsigned size);
00081 
00082         void setValue(long value);
00083         const char *getBuffer()
00084                 {return buffer;};
00085 
00086         long getValue();
00087 
00088         long operator()()
00089                 {return getValue();};
00090 
00091         operator long()
00092                 {return getValue();};
00093 
00094         operator char*()
00095                 {return buffer;};
00096 
00097         long operator=(long value);
00098         long operator+=(long value);
00099         long operator-=(long value);
00100         long operator--();
00101         long operator++();
00102         int operator==(Number &num);
00103         int operator!=(Number &num);
00104         int operator<(Number &num);
00105         int operator<=(Number &num);
00106         int operator>(Number &num);
00107         int operator>=(Number &num);
00108 
00109         friend long operator+(Number &num, long val);
00110         friend long operator+(long val, Number &num);
00111         friend long operator-(Number &num, long val);
00112         friend long operator-(long val, Number &num);
00113 };
00114 
00115 class ZNumber : public Number
00116 {
00117 public:
00118         ZNumber(char *buf, unsigned size);
00119         void setValue(long value);
00120         long operator=(long value);
00121 };
00122 
00131 class Date
00132 {
00133 private:
00134         long julian;
00135 
00136 protected:
00137         void toJulian(long year, long month, long day);
00138         void fromJulian(char *buf);
00139 
00144         virtual void Update(void)
00145                 {return;};
00146 
00147 public:
00148 
00149         Date(time_t tm);
00150         Date(tm *dt);
00151         Date(char *str, size_t size = 0);
00152         Date(int year, unsigned month, unsigned day);   
00153         Date();
00154 
00155         int getYear(void);
00156         unsigned getMonth(void);
00157         unsigned getDay(void);
00158         unsigned getDayOfWeek(void);
00159         char *getDate(char *buffer);
00160         time_t getDate(void);
00161         long getValue(void);
00162         tm *getDate(tm *buf);
00163         bool is_ok(void);
00164 
00165         friend Date operator+(Date &date, long val);
00166         friend Date operator-(Date &date, long val);
00167         friend Date operator+(long val, Date &date);
00168         friend Date operator-(long val, Date &date);
00169 
00170         operator long()
00171                 {return getValue();};
00172 
00173         std::string operator()();
00174         Date& operator++();
00175         Date& operator--();
00176         Date& operator+=(long val);
00177         Date& operator-=(long val);
00178         int operator==(Date &date);
00179         int operator!=(Date &date);
00180         int operator<(Date &date);
00181         int operator<=(Date &date);
00182         int operator>(Date &date);
00183         int operator>=(Date &date);
00184         bool operator!()
00185                 {return !is_ok();};
00186 };
00187 
00194 class DateNumber : public Number, public Date
00195 {
00196 protected:
00197         void Update(void)
00198                 {fromJulian(buffer);};
00199 
00200 public:
00201         DateNumber(char *buffer);
00202 };
00203 
00204 #ifdef  __NAMESPACES__
00205 };
00206 #endif
00207 
00208 #endif
00209 

Generated at Fri Nov 2 11:45:27 2001 for CommonC++ by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001