Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

MCVariant.h

00001 #if !defined(__MCVARIANT_H_)
00002 #define __MCVARIANT_H_
00003 
00004 #ident "@(#)$Id: MCVariant.h,v 1.6 2004/12/02 07:05:20 mike Exp $"
00005 
00006 /*
00007  * Copyright Miba Consulting Ltd. (c) 2000-2003
00008  * 
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2.1 of the License, or (at your option) any later version.
00013  * 
00014  * This library is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00017  * Lesser General Public License for more details.
00018  * 
00019  * You should have received a copy of the GNU Lesser General Public
00020  * License along with this library; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00022  *
00023  */
00024 
00025 #include "mcllib/MCTypes.h"
00026 #include "mcllib/MCString.h"
00027 #include "mcllib/MCStringStream.h"
00028 #include "mcllib/MCSerializer.h"
00029 
00030 namespace mclpriv
00031 {
00032     class MCVTImpl;
00033 };
00034 
00035 namespace mcllib
00036 {
00049     class MCVariantType
00050     {
00051     public:
00053         typedef const MCVariantType& constref_MCVariantType;
00054 
00059         MCVariantType();
00061         ~MCVariantType();
00067         MCVariantType(const MCVariantType& vt);
00073         MCVariantType& operator=(const MCVariantType& vt);
00084         operator bool() const;
00091         bool isDefined() const;
00100         MCString toString() const;
00106         bool operator==(const MCVariantType& vt) const;
00112         bool operator<(const MCVariantType& vt) const;
00117         void put(MCSerializer& serializer) const;
00124         void put(MCStringStream& os) const;
00128         friend MCSerializer& operator<<(MCSerializer& os, MCVariantType& vt);
00132         friend MCStringStream& operator<<(MCStringStream& os,MCVariantType& vt);
00140         mcuint32 getTypeId() const;
00145         const MCString& getTypeName() const;
00152         static mcuint32 getTypeId(const char* typeName);
00158         static const MCString& getTypeName(mcuint32 typeId);
00175         static MCVariantType parse(const MCString& val);
00176     protected:
00178         MCVariantType(mcuint32 type);
00180         MCVariantType(const MCVariantType& vt, mcuint32 type);
00182         const mclpriv::MCVTImpl* getImpl() const;
00184         mclpriv::MCVTImpl* getImpl();
00185     private:
00186         // Opaque implementation data
00187         // Implementation information is encoded in this space
00188         char m_impl[16];
00189     };
00190 
00195     class MCVTBool : public MCVariantType
00196     {
00197     public:
00202         MCVTBool(const MCVariantType& vt);
00204         MCVTBool(bool val);
00205     };
00206 
00213     class MCVTNumeric : public MCVariantType
00214     {
00215     public:
00216         // Range of interesting numeric stuff?
00217     protected:
00218         // cannot be constructed direclt - use derived types
00220         MCVTNumeric(mcuint32 type);
00222         MCVTNumeric(const MCVariantType& vt, mcuint32 type);
00223     };
00224 
00231     class MCVTNumericFloat : public MCVTNumeric
00232     {
00233     public:
00235         operator mcfloat32();
00237         operator mcfloat64();
00238     protected:
00240         MCVTNumericFloat(mcuint32 type);
00242         MCVTNumericFloat(const MCVariantType& vt, mcuint32 type);
00243     };
00244 
00251     class MCVTNumericInt : public MCVTNumeric
00252     {
00253     public:
00255         operator mcint8();
00257         operator mcuint8();
00259         operator mcint16();
00261         operator mcuint16();
00263         operator mcint32();
00265         operator mcuint32();
00267         operator mcint64();
00269         operator mcuint64();
00270     protected:
00272         MCVTNumericInt(mcuint32 type);
00274         MCVTNumericInt(const MCVariantType& vt, mcuint32 type);
00275     };
00276 
00281     class MCVTInt8 : public MCVTNumericInt
00282     {
00283     public:
00288         MCVTInt8(const MCVariantType& vt);
00290         MCVTInt8(mcint8 val);
00291     };
00292 
00297     class MCVTUInt8 : public MCVTNumericInt
00298     {
00299     public:
00304         MCVTUInt8(const MCVariantType& vt);
00306         MCVTUInt8(mcuint8 val);
00307     };
00308 
00313     class MCVTInt16 : public MCVTNumericInt
00314     {
00315     public:
00320         MCVTInt16(const MCVariantType& vt);
00322         MCVTInt16(mcint16 val);
00323     };
00324 
00329     class MCVTUInt16 : public MCVTNumericInt
00330     {
00331     public:
00336         MCVTUInt16(const MCVariantType& vt);
00338         MCVTUInt16(mcuint16 val);
00339     };
00340 
00345     class MCVTInt32 : public MCVTNumericInt
00346     {
00347     public:
00352         MCVTInt32(const MCVariantType& vt);
00354         MCVTInt32(mcint32 val);
00355     };
00356 
00361     class MCVTUInt32 : public MCVTNumericInt
00362     {
00363     public:
00368         MCVTUInt32(const MCVariantType& vt);
00370         MCVTUInt32(mcuint32 val);
00371     };
00372 
00377     class MCVTInt64 : public MCVTNumericInt
00378     {
00379     public:
00384         MCVTInt64(const MCVariantType& vt);
00386         MCVTInt64(const mcint64& val);
00387     };
00388 
00393     class MCVTUInt64 : public MCVTNumericInt
00394     {
00395     public:
00400         MCVTUInt64(const MCVariantType& vt);
00402         MCVTUInt64(const mcuint64& val);
00403     };
00404 
00409     class MCVTFloat32 : public MCVTNumericFloat
00410     {
00411     public:
00416         MCVTFloat32(const MCVariantType& vt);
00418         MCVTFloat32(const mcfloat32& val);
00419     };
00420 
00425     class MCVTFloat64 : public MCVTNumericFloat
00426     {
00427     public:
00432         MCVTFloat64(const MCVariantType& vt);
00434         MCVTFloat64(const mcfloat64& val);
00435     };
00436 
00441     class MCVTString : public MCVariantType
00442     {
00443     public:
00448         MCVTString(const MCVariantType& vt);
00450         MCVTString(const MCString& val);
00452         operator MCString();
00453     };
00454 
00455 };
00456 
00457 #endif

Generated on Wed Jan 12 19:05:48 2005 for MCLLIB by  doxygen 1.3.9.1