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

Var.H

00001 /* $Id: Var.H,v 1.2 2000/11/03 22:03:28 rpav Exp $
00002  *
00003  * SFW - The Studio Framework
00004  * Copyright (C) 2000  Ryan Pavlik
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019  *
00020  */
00021 
00022 #ifndef VAR_H
00023 #define VAR_H
00024 
00025 #include <SFW/Object.H>
00026 
00027 namespace SFW {
00028     enum VarType {
00029         VAR_UNDEF = 0,
00030     VAR_STRING,
00031         VAR_CHAR,
00032     VAR_BOOL,
00033     VAR_INT,
00034     VAR_FLOAT
00035     };
00036 
00037     class var : public Object {
00038     protected:
00039         VarType type;
00040 
00041         union {
00042             string *s;
00043             char    c;
00044             bool    b;
00045             int     i;
00046             float   f;
00047         } u;
00048 
00049     public:
00050         TYPE_INFO(SFW::var, SFW::Object);
00051 
00052         var();
00053         var(const var &v);
00054         var(string);
00055         var(char);
00056         var(bool);
00057         var(int);
00058         var(float);
00059         ~var();
00060         
00061         operator string() const;
00062         operator char()   const;
00063         operator bool()   const;
00064         operator int()    const;
00065         operator float()  const;
00066 
00067         var  operator= (const var &p);
00068         bool operator< (const var &v) const;
00069 
00070         VarType varType();
00071     };
00072 
00073     enum LongVarType {
00074         VAR_LONG_UNDEF  = 0,
00075         VAR_LONG_DOUBLE,
00076         VAR_LONG_LONG
00077     };
00078         
00079     class longvar : public Object {
00080     protected:
00081         LongVarType type;
00082 
00083         union {
00084             double     d;
00085             long long ll;
00086         } u;
00087 
00088     public:
00089         TYPE_INFO(SFW::longvar, SFW::Object);
00090 
00091         longvar();
00092         longvar(const longvar &v);
00093         longvar(double);
00094         longvar(long long);
00095 
00096         operator long long() const;
00097         operator double()    const;
00098         operator string()    const;
00099 
00100         longvar operator= (const longvar &lv);
00101         bool    operator< (const longvar &lv) const;
00102 
00103         LongVarType varType();
00104     };
00105 
00106     STL_TO_SFW (VVector,      vector,      var);
00107     STL_TO_SFW (VDeque,       deque,       var);
00108     STL_TO_SFW (VList,        list,        var);
00109     STL_TO_SFW (VSet,         set,         var);
00110     STL_TO_SFW (VMultiSet,    multiset,    var);
00111     
00112     STL_TO_SFW (LVVector,     vector,      longvar);
00113     STL_TO_SFW (LVDeque,      deque,       longvar);
00114     STL_TO_SFW (LVList,       list,        longvar);
00115     STL_TO_SFW (LVSet,        set,         longvar);
00116     STL_TO_SFW (LVMultiSet,   multiset,    longvar);
00117     
00118     STL2_TO_SFW(Map,          map,         var,     Object*);
00119     STL2_TO_SFW(MultiMap,     multimap,    var,     Object*);
00120     STL2_TO_SFW(LMap,         map,         longvar, Object*);
00121     STL2_TO_SFW(LMultiMap,    multimap,    longvar, Object*);
00122 
00123     STL2_TO_SFW(VMap,         map,         var,     var);
00124     STL2_TO_SFW(VMultiMap,    multimap,    var,     var);
00125     STL2_TO_SFW(LVMap,        map,         longvar, longvar);
00126     STL2_TO_SFW(LVMultiMap,   multimap,    longvar, longvar);
00127 
00128     STL2_TO_SFW(PVMap,        map,         Object*, var);
00129     STL2_TO_SFW(PVMultiMap,   multimap,    Object*, var);
00130     STL2_TO_SFW(PLVMap,       map,         Object*, longvar);
00131     STL2_TO_SFW(PLVMultiMap,  multimap,    Object*, longvar);
00132 }
00133 
00134 #endif /* LONGVAR_H */

Generated at Tue Jan 2 15:38:34 2001 for SFW by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000