CmpiData.h

Go to the documentation of this file.
00001 
00002 /*
00003  *
00004  * CmpiData.h
00005  *
00006  * (C) Copyright IBM Corp. 2003
00007  *
00008  * THIS FILE IS PROVIDED UNDER THE TERMS OF THE COMMON PUBLIC LICENSE
00009  * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
00010  * CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT.
00011  *
00012  * You can obtain a current copy of the Common Public License from
00013  * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html
00014  *
00015  * Author:        Adrian Schuur <schuur@de.ibm.com>
00016  * Contributors:
00017  *
00018  * Description: CMPI C++ helper class
00019  *
00020  */
00021 
00022 #ifndef _CmpiData_h_
00023 #define _CmpiData_h_
00024 #include "OW_config.h"
00025 
00026 #include "cmpidt.h"
00027 //#include "CmpiString.h"
00028 #include "CmpiString.h"
00029 
00030 class CmpiArray;
00031 class CmpiInstance;
00032 class CmpiObjectPath;
00033 
00044 class CmpiData {
00045    friend class CmpiInstance;
00046    friend class CmpiObjectPath;
00047    friend class CmpiResult;
00048    friend class CmpiArgs;
00049    friend class CmpiContext;
00050    friend class CmpiPropertyMI;
00051   protected:
00052 
00053    CMPIData data;
00054 
00055   public:
00058    CmpiData(CMPIData& data)
00059       { this->data=data; }
00060 
00063 //  public:
00064 
00067    CmpiData() {}
00068 
00071    inline CmpiData(CmpiString& d)
00072       { data.value.chars=(char*)d.charPtr(); data.type=CMPI_chars;}
00073 
00076    inline CmpiData(const char* d)
00077       { data.value.chars=(char*)d;  data.type=CMPI_chars; }
00078 
00081    inline CmpiData(CMPISint8 d)
00082       { data.value.sint8=d;  data.type=CMPI_sint8; }
00085    inline CmpiData(CMPISint16 d)
00086       { data.value.sint16=d; data.type=CMPI_sint16;}
00089    inline CmpiData(CMPISint32 d)
00090       { data.value.sint32=d; data.type=CMPI_sint32;}
00093    inline CmpiData(int d)
00094       { data.value.sint32=d; data.type=CMPI_sint32;}
00097    inline CmpiData(CMPISint64 d)
00098       { data.value.sint64=d; data.type=CMPI_sint64;}
00099 
00102    inline CmpiData(CMPIBoolean d)
00103       { data.value.boolean=d;  data.type=CMPI_boolean;}
00106    inline CmpiData(CMPIUint16 d)
00107       { data.value.sint16=d; data.type=CMPI_uint16;}
00110    inline CmpiData(CMPIUint32 d)
00111       { data.value.sint32=d; data.type=CMPI_uint32;}
00114    inline CmpiData(unsigned int d)
00115       { data.value.sint32=d; data.type=CMPI_uint32;}
00118    inline CmpiData(CMPIUint64 d)
00119       { data.value.sint64=d; data.type=CMPI_uint64;}
00120       
00123    inline CmpiData(CMPIInstance* d)
00124       { data.value.inst = d; data.type=CMPI_instance;}
00125       
00128    inline CmpiData(CMPIObjectPath* d)
00129       { data.value.ref = d; data.type=CMPI_ref;}
00130       
00133    inline CmpiData(CMPIArray* d)
00134       { data.value.array = d; data.type=CMPI_ARRAY;}
00135 
00136 
00139    inline void operator>>(CmpiString& v) const
00140       { if (data.type!=CMPI_string) throw CMPI_RC_ERR_TYPE_MISMATCH;
00141         else v=CmpiString(data.value.string);
00142       }
00143 
00146    inline void operator>>(CMPISint8& v)
00147       { if (data.type!=CMPI_sint8) throw CMPI_RC_ERR_TYPE_MISMATCH;
00148         else v=data.value.sint8;
00149       }
00152    inline void operator>>(CMPISint16& v)
00153       { if (data.type!=CMPI_sint16) throw CMPI_RC_ERR_TYPE_MISMATCH;
00154         else v=data.value.sint16;
00155       }
00158    inline void operator>>(CMPISint32& v)
00159       { if (data.type!=CMPI_sint32) throw CMPI_RC_ERR_TYPE_MISMATCH;
00160         else v=data.value.sint32;
00161       }
00164    inline void operator>>(int& v)
00165       { if (data.type!=CMPI_sint32) throw CMPI_RC_ERR_TYPE_MISMATCH;
00166         else v=data.value.sint32;
00167       }
00170    inline void operator>>(CMPISint64& v)
00171       { if (data.type!=CMPI_sint64) throw CMPI_RC_ERR_TYPE_MISMATCH;
00172         else v=data.value.sint64;
00173       }
00174 
00177    inline void operator>>(CMPIUint8& v)
00178       { if (data.type!=CMPI_uint8) throw CMPI_RC_ERR_TYPE_MISMATCH;
00179         else v=data.value.uint8;
00180       }
00183    inline void operator>>(CMPIUint16& v)
00184       { if (data.type!=CMPI_uint16) throw CMPI_RC_ERR_TYPE_MISMATCH;
00185         else v=data.value.uint16;
00186       }
00189    inline void operator>>(CMPIUint32& v)
00190       { if (data.type!=CMPI_uint32) throw CMPI_RC_ERR_TYPE_MISMATCH;
00191         else v=data.value.uint32;
00192       }
00195    inline void operator>>(unsigned int& v)
00196       { if (data.type!=CMPI_uint32) throw CMPI_RC_ERR_TYPE_MISMATCH;
00197         else v=data.value.uint32;
00198       }
00201    inline void operator>>(CMPIUint64& v)
00202       { if (data.type!=CMPI_uint64) throw CMPI_RC_ERR_TYPE_MISMATCH;
00203         else v=data.value.uint64;
00204       }
00205 
00208    void operator>>(CmpiArray& v);
00209 
00212    void operator>>(CmpiInstance& v);
00213 
00216    void operator>>(CmpiObjectPath& v);
00217 
00218    bool operator==(const CmpiData& d);
00219 
00220    // check null value
00221    bool isNull() {return data.state == CMPI_nullValue;}  
00222 };
00223 
00224 #endif
00225 
00226 
00227 

Generated on Thu Feb 9 08:47:48 2006 for openwbem by  doxygen 1.4.6