OW_CIMValue.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2001-2004 Vintela, Inc. All rights reserved.
00003 *
00004 * Redistribution and use in source and binary forms, with or without
00005 * modification, are permitted provided that the following conditions are met:
00006 *
00007 *  - Redistributions of source code must retain the above copyright notice,
00008 *    this list of conditions and the following disclaimer.
00009 *
00010 *  - Redistributions in binary form must reproduce the above copyright notice,
00011 *    this list of conditions and the following disclaimer in the documentation
00012 *    and/or other materials provided with the distribution.
00013 *
00014 *  - Neither the name of Vintela, Inc. nor the names of its
00015 *    contributors may be used to endorse or promote products derived from this
00016 *    software without specific prior written permission.
00017 *
00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00019 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 * ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc. OR THE CONTRIBUTORS
00022 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00023 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00024 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00027 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00028 * POSSIBILITY OF SUCH DAMAGE.
00029 *******************************************************************************/
00030 
00036 #include "OW_config.h"
00037 #include "OW_CIMValue.hpp"
00038 #include "OW_StringBuffer.hpp"
00039 #include "OW_CIMObjectPath.hpp"
00040 #include "OW_Assertion.hpp"
00041 #include "OW_BinarySerialization.hpp"
00042 #include "OW_CIMValueCast.hpp" // for OW_ValueCastException
00043 #include "OW_CIMDateTime.hpp"
00044 #include "OW_COWIntrusiveCountableBase.hpp"
00045 
00046 #include <new>
00047 #include <cassert>
00048 
00049 namespace OW_NAMESPACE
00050 {
00051 
00052 using std::istream;
00053 using std::ostream;
00055 class CIMValue::CIMValueImpl : public COWIntrusiveCountableBase
00056 {
00057 public:
00058    static CIMValueImpl createSimpleValue(CIMDataType::Type cimtype,
00059       const String& value);
00060    CIMValueImpl();
00061    CIMValueImpl(const CIMValueImpl& arg);
00062    explicit CIMValueImpl(Bool val);
00063    explicit CIMValueImpl(bool val);
00064    explicit CIMValueImpl(UInt8 arg);
00065    explicit CIMValueImpl(Int8 arg);
00066    explicit CIMValueImpl(UInt16 arg);
00067    explicit CIMValueImpl(Int16 arg);
00068    explicit CIMValueImpl(UInt32 arg);
00069    explicit CIMValueImpl(Int32 arg);
00070    explicit CIMValueImpl(UInt64 arg);
00071    explicit CIMValueImpl(Int64 arg);
00072    explicit CIMValueImpl(Real32 arg);
00073    explicit CIMValueImpl(Real64 arg);
00074    explicit CIMValueImpl(const Char16& arg);
00075    explicit CIMValueImpl(const String& arg);
00076    explicit CIMValueImpl(const CIMDateTime& arg);
00077    explicit CIMValueImpl(const CIMObjectPath& arg);
00078    explicit CIMValueImpl(const CIMClass& arg);
00079    explicit CIMValueImpl(const CIMInstance& arg);
00080    explicit CIMValueImpl(const BoolArray& arg);
00081    explicit CIMValueImpl(const Char16Array& arg);
00082    explicit CIMValueImpl(const UInt8Array& arg);
00083    explicit CIMValueImpl(const Int8Array& arg);
00084    explicit CIMValueImpl(const UInt16Array& arg);
00085    explicit CIMValueImpl(const Int16Array& arg);
00086    explicit CIMValueImpl(const UInt32Array& arg);
00087    explicit CIMValueImpl(const Int32Array& arg);
00088    explicit CIMValueImpl(const UInt64Array& arg);
00089    explicit CIMValueImpl(const Int64Array& arg);
00090    explicit CIMValueImpl(const Real64Array& arg);
00091    explicit CIMValueImpl(const Real32Array& arg);
00092    explicit CIMValueImpl(const StringArray& arg);
00093    explicit CIMValueImpl(const CIMDateTimeArray& arg);
00094    explicit CIMValueImpl(const CIMObjectPathArray& arg);
00095    explicit CIMValueImpl(const CIMClassArray& arg);
00096    explicit CIMValueImpl(const CIMInstanceArray& arg);
00097    ~CIMValueImpl();
00098    CIMValueImpl* clone() { return new CIMValueImpl(*this); }
00099    void get(Bool& val) const;
00100    void get(Char16& arg) const;
00101    void get(UInt8& arg) const;
00102    void get(Int8& arg) const;
00103    void get(UInt16& arg) const;
00104    void get(Int16& arg) const;
00105    void get(UInt32& arg) const;
00106    void get(Int32& arg) const;
00107    void get(UInt64& arg) const;
00108    void get(Int64& arg) const;
00109    void get(Real32& arg) const;
00110    void get(Real64& arg) const;
00111    void get(String& arg) const;
00112    void get(CIMDateTime& arg) const;
00113    void get(CIMObjectPath& arg) const;
00114    void get(CIMClass& arg) const;
00115    void get(CIMInstance& arg) const;
00116    void get(Char16Array& arg) const;
00117    void get(UInt8Array& arg) const;
00118    void get(Int8Array& arg) const;
00119    void get(UInt16Array& arg) const;
00120    void get(Int16Array& arg) const;
00121    void get(UInt32Array& arg) const;
00122    void get(Int32Array& arg) const;
00123    void get(UInt64Array& arg) const;
00124    void get(Int64Array& arg) const;
00125    void get(Real64Array& arg) const;
00126    void get(Real32Array& arg) const;
00127    void get(StringArray& arg) const;
00128    void get(BoolArray& arg) const;
00129    void get(CIMDateTimeArray& arg) const;
00130    void get(CIMObjectPathArray& arg) const;
00131    void get(CIMClassArray& arg) const;
00132    void get(CIMInstanceArray& arg) const;
00133    UInt32 getArraySize() const;
00134    CIMValueImpl& operator= (const CIMValueImpl& arg);
00135    CIMValueImpl& set(const CIMValueImpl& arg);
00136    bool equal(const CIMValueImpl& arg) const;
00137    bool operator== (const CIMValueImpl& arg) const
00138    {
00139       return equal(arg);
00140    }
00141    bool operator!= (const CIMValueImpl& arg) const
00142    {
00143       return !(*this == arg);
00144    }
00145    bool operator<= (const CIMValueImpl& arg) const
00146    {
00147       return !(arg < *this);
00148    }
00149    bool operator>= (const CIMValueImpl& arg) const
00150    {
00151       return !(*this < arg);
00152    }
00153    bool operator< (const CIMValueImpl& arg) const;
00154    bool operator> (const CIMValueImpl& arg) const
00155    {
00156       return arg < *this;
00157    }
00158    CIMDataType::Type getType() const
00159    {
00160       return m_type;
00161    }
00162    CIMDataType getCIMDataType() const
00163    {
00164       CIMDataType rval = CIMDataType(getType());
00165       if (m_isArray)
00166       {
00167          rval.setToArrayType(-1);
00168       }
00169       return rval;
00170    }
00171    bool sameType(const CIMValueImpl& arg) const
00172    {
00173       return(m_type == arg.m_type && m_isArray == arg.m_isArray);
00174    }
00175    bool isArray() const
00176    {
00177       return m_isArray;
00178    }
00179    void readObject(std::istream &istrm);
00180    void writeObject(std::ostream &ostrm) const;
00181    String toString(bool forMOF=false) const;
00182    String toMOF() const;
00183 private:
00184    union CIMValueData
00185    {
00186       UInt8 m_booleanValue;
00187       UInt8    m_uint8Value;
00188       Int8     m_sint8Value;
00189       UInt16   m_uint16Value;
00190       Int16    m_sint16Value;
00191       UInt32   m_uint32Value;
00192       Int32    m_sint32Value;
00193       UInt64   m_uint64Value;
00194       Int64    m_sint64Value;
00195       Real32   m_real32Value;
00196       Real64   m_real64Value;
00197       char bfr1[sizeof(BoolArray)];
00198       char bfr2[sizeof(UInt8Array)];
00199       char bfr3[sizeof(Int8Array)];
00200       char bfr4[sizeof(Char16Array)];
00201       char bfr5[sizeof(UInt16Array)];
00202       char bfr6[sizeof(Int16Array)];
00203       char bfr7[sizeof(UInt32Array)];
00204       char bfr8[sizeof(Int32Array)];
00205       char bfr9[sizeof(UInt64Array)];
00206       char bfr10[sizeof(Int64Array)];
00207       char bfr11[sizeof(Real64Array)];
00208       char bfr12[sizeof(Real32Array)];
00209       char bfr13[sizeof(StringArray)];
00210       char bfr14[sizeof(CIMObjectPathArray)];
00211       char bfr15[sizeof(CIMDateTimeArray)];
00212       char bfr16[sizeof(CIMObjectPath)];
00213       char bfr17[sizeof(Char16)];
00214       char bfr18[sizeof(CIMDateTime)];
00215       char bfr19[sizeof(String)];
00216       char bfr20[sizeof(CIMClass)];
00217       char bfr21[sizeof(CIMInstance)];
00218       char bfr22[sizeof(CIMClassArray)];
00219       char bfr23[sizeof(CIMInstanceArray)];
00220    };
00221 
00222    // Value used for the "numericvalue" type in Object paths
00223    bool isDefaultNumeric() const
00224    {
00225       return (m_type == CIMDataType::SINT64 && !m_isArray);
00226    }
00227 
00228    template<class T>
00229    bool castDefaultNumeric(T& arg) const
00230    {
00231       if (isDefaultNumeric())
00232       {
00233          arg = static_cast<T>(m_obj.m_sint64Value);
00234          return true;
00235       }
00236       return false;
00237    }
00238 
00239    void setupObject(const CIMValueData& odata, CIMDataType::Type type, bool isArray);
00240    void destroyObject();
00241    CIMDataType::Type m_type;
00242    Bool m_isArray;
00243    Bool m_objDestroyed;
00244    CIMValueData m_obj;
00245 };
00246 
00248 // STATIC
00249 CIMValue
00250 CIMValue::createSimpleValue(const String& cimtype,
00251    const String& value)
00252 {
00253    CIMDataType::Type type = CIMDataType::strToSimpleType(cimtype);
00254    if (type == CIMDataType::INVALID)
00255    {
00256       return CIMValue(CIMNULL);
00257    }
00258    CIMValueImpl impl = CIMValueImpl::createSimpleValue(type, value);
00259    CIMValue cv(CIMNULL);
00260    cv.m_impl = new CIMValueImpl(impl);
00261    return cv;
00262 }
00264 void           
00265 CIMValue::readObject(istream &istrm)
00266 {
00267    if (!m_impl)
00268    {
00269       m_impl = new CIMValueImpl;
00270    }
00271    m_impl->readObject(istrm);
00272 }
00274 CIMValue::CIMValue(CIMNULL_t)
00275    : CIMBase(), m_impl(0) { }
00277 CIMValue::CIMValue(const CIMValue& x)
00278    : CIMBase(), m_impl(x.m_impl) {}
00280 CIMValue::CIMValue(Bool x)
00281    : CIMBase(), m_impl(new CIMValueImpl(x)){}
00283 CIMValue::CIMValue(bool x)
00284    : CIMBase(), m_impl(new CIMValueImpl(x)){}
00286 CIMValue::CIMValue(UInt8 x)
00287    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00289 CIMValue::CIMValue(Int8 x)
00290    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00292 CIMValue::CIMValue(UInt16 x)
00293    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00295 CIMValue::CIMValue(Int16 x)
00296    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00298 CIMValue::CIMValue(UInt32 x)
00299    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00301 CIMValue::CIMValue(Int32 x)
00302    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00304 CIMValue::CIMValue(UInt64 x)
00305    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00307 CIMValue::CIMValue(Int64 x)
00308    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00310 CIMValue::CIMValue(Real32 x)
00311    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00313 CIMValue::CIMValue(Real64 x)
00314    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00316 CIMValue::CIMValue(const Char16& x)
00317    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00319 CIMValue::CIMValue(const String& x)
00320    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00322 CIMValue::CIMValue(const char* x)
00323    : CIMBase(), m_impl(new CIMValueImpl(String(x))) {}
00325 CIMValue::CIMValue(const CIMDateTime& x)
00326    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00328 CIMValue::CIMValue(const CIMObjectPath& x)
00329    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00331 CIMValue::CIMValue(const CIMClass& x)
00332    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00334 CIMValue::CIMValue(const CIMInstance& x)
00335    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00337 CIMValue::CIMValue(const CIMObjectPathArray& x)
00338    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00340 CIMValue::CIMValue(const BoolArray& x)
00341    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00343 CIMValue::CIMValue(const Char16Array& x)
00344    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00346 CIMValue::CIMValue(const UInt8Array& x)
00347    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00349 CIMValue::CIMValue(const Int8Array& x)
00350    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00352 CIMValue::CIMValue(const UInt16Array& x)
00353    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00355 CIMValue::CIMValue(const Int16Array& x)
00356    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00358 CIMValue::CIMValue(const UInt32Array& x)
00359    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00361 CIMValue::CIMValue(const Int32Array& x)
00362    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00364 CIMValue::CIMValue(const UInt64Array& x)
00365    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00367 CIMValue::CIMValue(const Int64Array& x)
00368    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00370 CIMValue::CIMValue(const Real64Array& x)
00371    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00373 CIMValue::CIMValue(const Real32Array& x)
00374    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00376 CIMValue::CIMValue(const StringArray& x)
00377    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00379 CIMValue::CIMValue(const CIMDateTimeArray& x)
00380    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00382 CIMValue::CIMValue(const CIMClassArray& x)
00383    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00385 CIMValue::CIMValue(const CIMInstanceArray& x)
00386    : CIMBase(), m_impl(new CIMValueImpl(x)) {}
00388 UInt32
00389 CIMValue::getArraySize() const
00390 {
00391    return m_impl->getArraySize();
00392 }
00394 void CIMValue::get(Bool& x) const
00395 {
00396    m_impl->get(x);
00397 }
00399 void CIMValue::get(Char16& x) const
00400 {
00401    m_impl->get(x);
00402 }
00404 void CIMValue::get(UInt8& x) const
00405 {
00406    m_impl->get(x);
00407 }
00409 void CIMValue::get(Int8& x) const
00410 {
00411    m_impl->get(x);
00412 }
00414 void CIMValue::get(UInt16& x) const
00415 {
00416    m_impl->get(x);
00417 }
00419 void CIMValue::get(Int16& x) const
00420 {
00421    m_impl->get(x);
00422 }
00424 void CIMValue::get(UInt32& x) const
00425 {
00426    m_impl->get(x);
00427 }
00429 void CIMValue::get(Int32& x) const
00430 {
00431    m_impl->get(x);
00432 }
00434 void CIMValue::get(UInt64& x) const
00435 {
00436    m_impl->get(x);
00437 }
00439 void CIMValue::get(Int64& x) const
00440 {
00441    m_impl->get(x);
00442 }
00444 void CIMValue::get(Real32& x) const
00445 {
00446    m_impl->get(x);
00447 }
00449 void CIMValue::get(Real64& x) const
00450 {
00451    m_impl->get(x);
00452 }
00454 void CIMValue::get(String& x) const
00455 {
00456    m_impl->get(x);
00457 }
00459 void CIMValue::get(CIMDateTime& x) const
00460 {
00461    m_impl->get(x);
00462 }
00464 void CIMValue::get(CIMObjectPath& x) const
00465 {
00466    m_impl->get(x);
00467 }
00469 void CIMValue::get(CIMClass& x) const
00470 {
00471    m_impl->get(x);
00472 }
00474 void CIMValue::get(CIMInstance& x) const
00475 {
00476    m_impl->get(x);
00477 }
00479 void CIMValue::get(Char16Array& x) const
00480 {
00481    m_impl->get(x);
00482 }
00484 void CIMValue::get(UInt8Array& x) const
00485 {
00486    m_impl->get(x);
00487 }
00489 void CIMValue::get(Int8Array& x) const
00490 {
00491    m_impl->get(x);
00492 }
00494 void CIMValue::get(UInt16Array& x) const
00495 {
00496    m_impl->get(x);
00497 }
00499 void CIMValue::get(Int16Array& x) const
00500 {
00501    m_impl->get(x);
00502 }
00504 void CIMValue::get(UInt32Array& x) const
00505 {
00506    m_impl->get(x);
00507 }
00509 void CIMValue::get(Int32Array& x) const
00510 {
00511    m_impl->get(x);
00512 }
00514 void CIMValue::get(UInt64Array& x) const
00515 {
00516    m_impl->get(x);
00517 }
00519 void CIMValue::get(Int64Array& x) const
00520 {
00521    m_impl->get(x);
00522 }
00524 void CIMValue::get(Real64Array& x) const
00525 {
00526    m_impl->get(x);
00527 }
00529 void CIMValue::get(Real32Array& x) const
00530 {
00531    m_impl->get(x);
00532 }
00534 void CIMValue::get(StringArray& x) const
00535 {
00536    m_impl->get(x);
00537 }
00539 void CIMValue::get(CIMObjectPathArray& x) const
00540 {
00541    m_impl->get(x);
00542 }
00544 void CIMValue::get(BoolArray& x) const
00545 {
00546    m_impl->get(x);
00547 }
00549 void CIMValue::get(CIMDateTimeArray& x) const
00550 {
00551    m_impl->get(x);
00552 }
00554 void CIMValue::get(CIMClassArray& x) const
00555 {
00556    m_impl->get(x);
00557 }
00559 void CIMValue::get(CIMInstanceArray& x) const
00560 {
00561    m_impl->get(x);
00562 }
00564 Bool CIMValue::toBool() const
00565 {
00566    Bool rval;
00567    m_impl->get(rval);
00568    return rval;
00569 }
00571 Char16 CIMValue::toChar16() const
00572 {
00573    Char16 rval;
00574    m_impl->get(rval);
00575    return rval;
00576 }
00578 UInt8 CIMValue::toUInt8() const
00579 {
00580    UInt8 rval;
00581    m_impl->get(rval);
00582    return rval;
00583 }
00585 Int8 CIMValue::toInt8() const
00586 {
00587    Int8 rval;
00588    m_impl->get(rval);
00589    return rval;
00590 }
00592 UInt16 CIMValue::toUInt16() const
00593 {
00594    UInt16 rval;
00595    m_impl->get(rval);
00596    return rval;
00597 }
00599 Int16 CIMValue::toInt16() const
00600 {
00601    Int16 rval;
00602    m_impl->get(rval);
00603    return rval;
00604 }
00606 UInt32 CIMValue::toUInt32() const
00607 {
00608    UInt32 rval;
00609    m_impl->get(rval);
00610    return rval;
00611 }
00613 Int32 CIMValue::toInt32() const
00614 {
00615    Int32 rval;
00616    m_impl->get(rval);
00617    return rval;
00618 }
00620 UInt64 CIMValue::toUInt64() const
00621 {
00622    UInt64 rval;
00623    m_impl->get(rval);
00624    return rval;
00625 }
00627 Int64 CIMValue::toInt64() const
00628 {
00629    Int64 rval;
00630    m_impl->get(rval);
00631    return rval;
00632 }
00634 Real32 CIMValue::toReal32() const
00635 {
00636    Real32 rval;
00637    m_impl->get(rval);
00638    return rval;
00639 }
00641 Real64 CIMValue::toReal64() const
00642 {
00643    Real64 rval;
00644    m_impl->get(rval);
00645    return rval;
00646 }
00648 CIMDateTime CIMValue::toCIMDateTime() const
00649 {
00650    CIMDateTime rval(CIMNULL);
00651    m_impl->get(rval);
00652    return rval;
00653 }
00655 CIMObjectPath CIMValue::toCIMObjectPath() const
00656 {
00657    CIMObjectPath rval(CIMNULL);
00658    m_impl->get(rval);
00659    return rval;
00660 }
00662 CIMClass CIMValue::toCIMClass() const
00663 {
00664    CIMClass rval(CIMNULL);
00665    m_impl->get(rval);
00666    return rval;
00667 }
00669 CIMInstance CIMValue::toCIMInstance() const
00670 {
00671    CIMInstance rval(CIMNULL);
00672    m_impl->get(rval);
00673    return rval;
00674 }
00676 CIMObjectPathArray CIMValue::toCIMObjectPathArray() const
00677 {
00678    CIMObjectPathArray rval;
00679    m_impl->get(rval);
00680    return rval;
00681 }
00683 Char16Array CIMValue::toChar16Array() const
00684 {
00685    Char16Array rval;
00686    m_impl->get(rval);
00687    return rval;
00688 }
00690 UInt8Array CIMValue::toUInt8Array() const
00691 {
00692    UInt8Array rval;
00693    m_impl->get(rval);
00694    return rval;
00695 }
00697 Int8Array CIMValue::toInt8Array() const
00698 {
00699    Int8Array rval;
00700    m_impl->get(rval);
00701    return rval;
00702 }
00704 UInt16Array CIMValue::toUInt16Array() const
00705 {
00706    UInt16Array rval;
00707    m_impl->get(rval);
00708    return rval;
00709 }
00711 Int16Array CIMValue::toInt16Array() const
00712 {
00713    Int16Array rval;
00714    m_impl->get(rval);
00715    return rval;
00716 }
00718 UInt32Array CIMValue::toUInt32Array() const
00719 {
00720    UInt32Array rval;
00721    m_impl->get(rval);
00722    return rval;
00723 }
00725 Int32Array CIMValue::toInt32Array() const
00726 {
00727    Int32Array rval;
00728    m_impl->get(rval);
00729    return rval;
00730 }
00732 UInt64Array CIMValue::toUInt64Array() const
00733 {
00734    UInt64Array rval;
00735    m_impl->get(rval);
00736    return rval;
00737 }
00739 Int64Array CIMValue::toInt64Array() const
00740 {
00741    Int64Array rval;
00742    m_impl->get(rval);
00743    return rval;
00744 }
00746 Real64Array CIMValue::toReal64Array() const
00747 {
00748    Real64Array rval;
00749    m_impl->get(rval);
00750    return rval;
00751 }
00753 Real32Array CIMValue::toReal32Array() const
00754 {
00755    Real32Array rval;
00756    m_impl->get(rval);
00757    return rval;
00758 }
00760 StringArray CIMValue::toStringArray() const
00761 {
00762    StringArray rval;
00763    m_impl->get(rval);
00764    return rval;
00765 }
00767 BoolArray CIMValue::toBoolArray() const
00768 {
00769    BoolArray rval;
00770    m_impl->get(rval);
00771    return rval;
00772 }
00774 CIMDateTimeArray CIMValue::toCIMDateTimeArray() const
00775 {
00776    CIMDateTimeArray rval;
00777    m_impl->get(rval);
00778    return rval;
00779 }
00781 CIMClassArray CIMValue::toCIMClassArray() const
00782 {
00783    CIMClassArray rval;
00784    m_impl->get(rval);
00785    return rval;
00786 }
00788 CIMInstanceArray CIMValue::toCIMInstanceArray() const
00789 {
00790    CIMInstanceArray rval;
00791    m_impl->get(rval);
00792    return rval;
00793 }
00795 void CIMValue::setNull()
00796 {
00797    m_impl = NULL;
00798 }
00800 CIMValue& CIMValue::set(const CIMValue& x)
00801 {
00802    m_impl = x.m_impl;
00803    return *this;
00804 }
00806 CIMValue& CIMValue::operator= (const CIMValue& x)
00807 {
00808    set(x);
00809    return *this;
00810 }
00812 bool CIMValue::equal(const CIMValue& x) const
00813 {
00814    if (x.m_impl == m_impl)
00815    {
00816       return true;
00817    }
00818    if (x.m_impl == NULL || m_impl == NULL)
00819    {
00820       return false;
00821    }
00822    return m_impl->equal(*x.m_impl);
00823 }
00825 bool CIMValue::operator== (const CIMValue& x) const
00826 {
00827    return equal(x);
00828 }
00830 bool CIMValue::operator!= (const CIMValue& x) const
00831 {
00832    return !(*this == x);
00833 }
00835 bool CIMValue::operator<= (const CIMValue& x) const
00836 {
00837    return !(x < *this);
00838 }
00840 bool CIMValue::operator>= (const CIMValue& x) const
00841 {
00842    return !(*this < x);
00843 }
00845 bool CIMValue::operator< (const CIMValue& x) const
00846 {
00847    if (x.m_impl == m_impl)
00848    {
00849       return false;
00850    }
00851    if (m_impl == NULL)
00852    {
00853       return true;
00854    }
00855    if (x.m_impl == NULL)
00856    {
00857       return false;
00858    }
00859    return m_impl->operator <(*x.m_impl);
00860 }
00862 bool CIMValue::operator> (const CIMValue& x) const
00863 {
00864    return x < *this;
00865 }
00867 CIMDataType::Type CIMValue::getType() const {  return m_impl->getType(); }
00869 CIMDataType CIMValue::getCIMDataType() const { return m_impl->getCIMDataType(); }
00871 bool CIMValue::sameType(const CIMValue& x) const
00872 {
00873    return m_impl->sameType(*x.m_impl);
00874 }
00876 bool CIMValue::isArray() const {  return m_impl->isArray(); }
00878 void CIMValue::writeObject(std::ostream &ostrm) const
00879 {
00880    m_impl->writeObject(ostrm);
00881 }
00883 String CIMValue::toString() const
00884 {
00885    if (m_impl)
00886    {
00887       return m_impl->toString();
00888    }
00889    else
00890    {
00891       return "(null)";
00892    }
00893 }
00895 String CIMValue::toMOF() const
00896 {
00897    return m_impl->toMOF();
00898 }
00900 bool
00901 CIMValue::isNumericType() const
00902 {
00903    return CIMDataType::isNumericType(getType());
00904 }
00906 // STATIC
00907 CIMValue::CIMValueImpl
00908 CIMValue::CIMValueImpl::createSimpleValue(CIMDataType::Type type,
00909    const String& value)
00910 {
00911    CIMValueImpl cimValue;
00912    switch (type)
00913    {
00914       case CIMDataType::UINT8:
00915          cimValue = CIMValueImpl(value.toUInt8());
00916          break;
00917          
00918       case CIMDataType::SINT8:
00919          cimValue = CIMValueImpl(value.toInt8());
00920          break;
00921       case CIMDataType::UINT16:
00922          cimValue = CIMValueImpl(value.toUInt16());
00923          break;
00924       case CIMDataType::SINT16:
00925          cimValue = CIMValueImpl(value.toInt16());
00926          break;
00927       case CIMDataType::UINT32:
00928          cimValue = CIMValueImpl(value.toUInt32());
00929          break;
00930       case CIMDataType::SINT32:
00931          cimValue = CIMValueImpl(value.toInt32());
00932          break;
00933       case CIMDataType::UINT64:
00934          cimValue = CIMValueImpl(value.toUInt64());
00935          break;
00936       case CIMDataType::SINT64:
00937          cimValue = CIMValueImpl(value.toInt64());
00938          break;
00939       case CIMDataType::BOOLEAN:
00940          cimValue = CIMValueImpl(value.toBool());
00941          break;
00942       case CIMDataType::REAL32:
00943          cimValue = CIMValueImpl(value.toReal32());
00944          break;
00945       case CIMDataType::REAL64:
00946          cimValue = CIMValueImpl(value.toReal64());
00947          break;
00948       case CIMDataType::CHAR16:
00949          cimValue = CIMValueImpl(Char16(value));
00950          break;
00951       case CIMDataType::DATETIME:
00952          cimValue = CIMValueImpl(CIMDateTime(value));
00953          break;
00954       case CIMDataType::STRING:
00955          cimValue = CIMValueImpl(value);
00956          break;
00957       case CIMDataType::REFERENCE:
00958          cimValue = CIMValueImpl(CIMObjectPath::parse(value));
00959          break;
00960       default:
00961          OW_ASSERT(0);
00962    }
00963    return cimValue;
00964 }
00966 CIMValue::CIMValueImpl::CIMValueImpl():
00967    m_type(CIMDataType::CIMNULL), m_isArray(false),
00968    m_objDestroyed(true), m_obj()
00969 {
00970 }
00972 CIMValue::CIMValueImpl::CIMValueImpl(const CIMValueImpl& arg) :
00973    COWIntrusiveCountableBase(arg),
00974    m_type(CIMDataType::CIMNULL), m_isArray(false),
00975    m_objDestroyed(true), m_obj()
00976 {
00977    setupObject(arg.m_obj, arg.m_type, arg.m_isArray);
00978 }
00980 CIMValue::CIMValueImpl::CIMValueImpl(Bool v) :
00981    m_type(CIMDataType::BOOLEAN), m_isArray(false),
00982    m_objDestroyed(false), m_obj()
00983 {
00984    m_obj.m_booleanValue = (v) ? 1 : 0;
00985 }
00987 CIMValue::CIMValueImpl::CIMValueImpl(bool v) :
00988    m_type(CIMDataType::BOOLEAN), m_isArray(false),
00989    m_objDestroyed(false), m_obj()
00990 {
00991    m_obj.m_booleanValue = (v) ? 1 : 0;
00992 }
00994 CIMValue::CIMValueImpl::CIMValueImpl(UInt8 v) :
00995    m_type(CIMDataType::UINT8), m_isArray(false),
00996    m_objDestroyed(false), m_obj()
00997 {
00998    m_obj.m_uint8Value = v;
00999 }
01001 CIMValue::CIMValueImpl::CIMValueImpl(Int8 v) :
01002    m_type(CIMDataType::SINT8), m_isArray(false),
01003    m_objDestroyed(false), m_obj()
01004 {
01005    m_obj.m_sint8Value = v;
01006 }
01008 CIMValue::CIMValueImpl::CIMValueImpl(const Char16& v) :
01009    m_type(CIMDataType::CHAR16), m_isArray(false),
01010    m_objDestroyed(false), m_obj()
01011 {
01012    new(&m_obj) Char16(v);
01013 }
01015 CIMValue::CIMValueImpl::CIMValueImpl(UInt16 v) :
01016    m_type(CIMDataType::UINT16), m_isArray(false),
01017    m_objDestroyed(false), m_obj()
01018 {
01019    m_obj.m_uint16Value = v;
01020 }
01022 CIMValue::CIMValueImpl::CIMValueImpl(Int16 v) :
01023    m_type(CIMDataType::SINT16), m_isArray(false),
01024    m_objDestroyed(false), m_obj()
01025 {
01026    m_obj.m_sint16Value = v;
01027 }
01029 CIMValue::CIMValueImpl::CIMValueImpl(UInt32 v) :
01030    m_type(CIMDataType::UINT32), m_isArray(false),
01031    m_objDestroyed(false), m_obj()
01032 {
01033    m_obj.m_uint32Value = v;
01034 }
01036 CIMValue::CIMValueImpl::CIMValueImpl(Int32 v) :
01037    m_type(CIMDataType::SINT32), m_isArray(false),
01038    m_objDestroyed(false), m_obj()
01039 {
01040    m_obj.m_sint32Value = v;
01041 }
01043 CIMValue::CIMValueImpl::CIMValueImpl(UInt64 v) :
01044    m_type(CIMDataType::UINT64), m_isArray(false),
01045    m_objDestroyed(false), m_obj()
01046 {
01047    m_obj.m_uint64Value = v;
01048 }
01050 CIMValue::CIMValueImpl::CIMValueImpl(Int64 v) :
01051    m_type(CIMDataType::SINT64), m_isArray(false),
01052    m_objDestroyed(false), m_obj()
01053 {
01054    m_obj.m_sint64Value = v;
01055 }
01057 CIMValue::CIMValueImpl::CIMValueImpl(Real32 v) :
01058    m_type(CIMDataType::REAL32), m_isArray(false),
01059    m_objDestroyed(false), m_obj()
01060 {
01061    m_obj.m_real32Value = v;
01062 }
01064 CIMValue::CIMValueImpl::CIMValueImpl(Real64 v) :
01065    m_type(CIMDataType::REAL64), m_isArray(false),
01066    m_objDestroyed(false), m_obj()
01067 {
01068    m_obj.m_real64Value = v;
01069 }
01071 CIMValue::CIMValueImpl::CIMValueImpl(const String& v) :
01072    m_type(CIMDataType::STRING), m_isArray(false),
01073    m_objDestroyed(false), m_obj()
01074 {
01075    new(&m_obj) String(v);
01076 }
01078 CIMValue::CIMValueImpl::CIMValueImpl(const CIMDateTime& v) :
01079    m_type(CIMDataType::DATETIME), m_isArray(false),
01080    m_objDestroyed(false), m_obj()
01081 {
01082    new(&m_obj) CIMDateTime(v);
01083 }
01085 CIMValue::CIMValueImpl::CIMValueImpl(const CIMObjectPath& v) :
01086    m_type(CIMDataType::REFERENCE), m_isArray(false),
01087    m_objDestroyed(false), m_obj()
01088 {
01089    new(&m_obj) CIMObjectPath(v);
01090 }
01092 CIMValue::CIMValueImpl::CIMValueImpl(const CIMClass& v) :
01093    m_type(CIMDataType::EMBEDDEDCLASS), m_isArray(false),
01094    m_objDestroyed(false), m_obj()
01095 {
01096    new(&m_obj) CIMClass(v);
01097 }
01099 CIMValue::CIMValueImpl::CIMValueImpl(const CIMInstance& v) :
01100    m_type(CIMDataType::EMBEDDEDINSTANCE), m_isArray(false),
01101    m_objDestroyed(false), m_obj()
01102 {
01103    new(&m_obj) CIMInstance(v);
01104 }
01106 CIMValue::CIMValueImpl::CIMValueImpl(const Char16Array& v) :
01107    m_type(CIMDataType::CHAR16), m_isArray(true),
01108    m_objDestroyed(false), m_obj()
01109 {
01110    new(&m_obj) Char16Array(v);
01111 }
01113 CIMValue::CIMValueImpl::CIMValueImpl(const UInt8Array& v) :
01114    m_type(CIMDataType::UINT8), m_isArray(true),
01115    m_objDestroyed(false), m_obj()
01116 {
01117    new(&m_obj) UInt8Array(v);
01118 }
01120 CIMValue::CIMValueImpl::CIMValueImpl(const Int8Array& v) :
01121    m_type(CIMDataType::SINT8), m_isArray(true),
01122    m_objDestroyed(false), m_obj()
01123 {
01124    new(&m_obj) Int8Array(v);
01125 }
01127 CIMValue::CIMValueImpl::CIMValueImpl(const UInt16Array& v) :
01128    m_type(CIMDataType::UINT16), m_isArray(true),
01129    m_objDestroyed(false), m_obj()
01130 {
01131    new(&m_obj) UInt16Array(v);
01132 }
01134 CIMValue::CIMValueImpl::CIMValueImpl(const Int16Array& v) :
01135    m_type(CIMDataType::SINT16), m_isArray(true),
01136    m_objDestroyed(false), m_obj()
01137 {
01138    new(&m_obj) Int16Array(v);
01139 }
01141 CIMValue::CIMValueImpl::CIMValueImpl(const UInt32Array& v) :
01142    m_type(CIMDataType::UINT32), m_isArray(true),
01143    m_objDestroyed(false), m_obj()
01144 {
01145    new(&m_obj) UInt32Array(v);
01146 }
01148 CIMValue::CIMValueImpl::CIMValueImpl(const Int32Array& v) :
01149    m_type(CIMDataType::SINT32), m_isArray(true),
01150    m_objDestroyed(false), m_obj()
01151 {
01152    new(&m_obj) Int32Array(v);
01153 }
01155 CIMValue::CIMValueImpl::CIMValueImpl(const UInt64Array& v) :
01156    m_type(CIMDataType::UINT64), m_isArray(true),
01157    m_objDestroyed(false), m_obj()
01158 {
01159    new(&m_obj) UInt64Array(v);
01160 }
01162 CIMValue::CIMValueImpl::CIMValueImpl(const Int64Array& v) :
01163    m_type(CIMDataType::SINT64), m_isArray(true),
01164    m_objDestroyed(false), m_obj()
01165 {
01166    new(&m_obj) Int64Array(v);
01167 }
01169 CIMValue::CIMValueImpl::CIMValueImpl(const Real64Array& v) :
01170    m_type(CIMDataType::REAL64), m_isArray(true),
01171    m_objDestroyed(false), m_obj()
01172 {
01173    new(&m_obj) Real64Array(v);
01174 }
01176 CIMValue::CIMValueImpl::CIMValueImpl(const Real32Array& v) :
01177    m_type(CIMDataType::REAL32), m_isArray(true),
01178    m_objDestroyed(false), m_obj()
01179 {
01180    new(&m_obj) Real32Array(v);
01181 }
01183 CIMValue::CIMValueImpl::CIMValueImpl(const StringArray& v) :
01184    m_type(CIMDataType::STRING), m_isArray(true),
01185    m_objDestroyed(false), m_obj()
01186 {
01187    new(&m_obj) StringArray(v);
01188 }
01190 CIMValue::CIMValueImpl::CIMValueImpl(const CIMDateTimeArray& v) :
01191    m_type(CIMDataType::DATETIME), m_isArray(true),
01192    m_objDestroyed(false), m_obj()
01193 {
01194    new(&m_obj) CIMDateTimeArray(v);
01195 }
01197 CIMValue::CIMValueImpl::CIMValueImpl(const CIMObjectPathArray& v) :
01198    m_type(CIMDataType::REFERENCE), m_isArray(true),
01199    m_objDestroyed(false), m_obj()
01200 {
01201    new(&m_obj) CIMObjectPathArray(v);
01202 }
01204 CIMValue::CIMValueImpl::CIMValueImpl(const BoolArray& v) :
01205    m_type(CIMDataType::BOOLEAN), m_isArray(true),
01206    m_objDestroyed(false), m_obj()
01207 {
01208    new(&m_obj) BoolArray(v);
01209 }
01211 CIMValue::CIMValueImpl::CIMValueImpl(const CIMClassArray& v) :
01212    m_type(CIMDataType::EMBEDDEDCLASS), m_isArray(true),
01213    m_objDestroyed(false), m_obj()
01214 {
01215    new(&m_obj) CIMClassArray(v);
01216 }
01218 CIMValue::CIMValueImpl::CIMValueImpl(const CIMInstanceArray& v) :
01219    m_type(CIMDataType::EMBEDDEDINSTANCE), m_isArray(true),
01220    m_objDestroyed(false), m_obj()
01221 {
01222    new(&m_obj) CIMInstanceArray(v);
01223 }
01225 CIMValue::CIMValueImpl::~CIMValueImpl()
01226 {
01227    destroyObject();
01228 }
01230 UInt32
01231 CIMValue::CIMValueImpl::getArraySize() const
01232 {
01233    if (m_type == CIMDataType::CIMNULL)
01234    {
01235       return 0;
01236    }
01237    if (!m_isArray)
01238    {
01239       return 1;
01240    }
01241    UInt32 sz = 0;
01242    switch (m_type)
01243    {
01244       case CIMDataType::UINT8:
01245          sz = (reinterpret_cast<const UInt8Array*>(&m_obj))->size();
01246       break;
01247       case CIMDataType::SINT8:
01248          sz = (reinterpret_cast<const Int8Array*>(&m_obj))->size();
01249       break;
01250       case CIMDataType::UINT16:
01251          sz = (reinterpret_cast<const UInt16Array*>(&m_obj))->size();
01252       break;
01253       case CIMDataType::SINT16:
01254          sz = (reinterpret_cast<const Int16Array*>(&m_obj))->size();
01255       break;
01256       case CIMDataType::UINT32:
01257          sz = (reinterpret_cast<const UInt32Array*>(&m_obj))->size();
01258       break;
01259       case CIMDataType::SINT32:
01260          sz = (reinterpret_cast<const Int32Array*>(&m_obj))->size();
01261       break;
01262       case CIMDataType::UINT64:
01263          sz = (reinterpret_cast<const UInt64Array*>(&m_obj))->size();
01264       break;
01265       case CIMDataType::SINT64:
01266          sz = (reinterpret_cast<const Int64Array*>(&m_obj))->size();
01267       break;
01268       case CIMDataType::BOOLEAN:
01269          sz = (reinterpret_cast<const BoolArray*>(&m_obj))->size();
01270       break;
01271       case CIMDataType::REAL32:
01272          sz = (reinterpret_cast<const Real32Array*>(&m_obj))->size();
01273       break;
01274       case CIMDataType::REAL64:
01275          sz = (reinterpret_cast<const Real64Array*>(&m_obj))->size();
01276       break;
01277       case CIMDataType::CHAR16:
01278          sz = (reinterpret_cast<const Char16Array*>(&m_obj))->size();
01279       break;
01280       case CIMDataType::DATETIME:
01281          sz = (reinterpret_cast<const CIMDateTimeArray*>(&m_obj))->size();
01282       break;
01283       case CIMDataType::STRING:
01284          sz = (reinterpret_cast<const StringArray*>(&m_obj))->size();
01285       break;
01286       case CIMDataType::REFERENCE:
01287          sz = (reinterpret_cast<const CIMObjectPathArray*>(&m_obj))->size();
01288       break;
01289       case CIMDataType::EMBEDDEDCLASS:
01290          sz = (reinterpret_cast<const CIMClassArray*>(&m_obj))->size();
01291       break;
01292       case CIMDataType::EMBEDDEDINSTANCE:
01293          sz = (reinterpret_cast<const CIMInstanceArray*>(&m_obj))->size();
01294       break;
01295       default:
01296          sz = 0;
01297    }
01298    return sz;
01299 }
01301 void
01302 CIMValue::CIMValueImpl::setupObject(const CIMValueData& odata, CIMDataType::Type type, bool isArray)
01303 {
01304    destroyObject();
01305    m_objDestroyed = false;
01306    m_type = type;
01307    m_isArray = isArray;
01308    if (isArray)
01309    {
01310       switch (m_type)
01311       {
01312          case CIMDataType::UINT8:
01313             new(&m_obj) UInt8Array(*(reinterpret_cast<const UInt8Array*>(&odata)));
01314          break;
01315          case CIMDataType::SINT8:
01316             new(&m_obj) Int8Array(*(reinterpret_cast<const Int8Array*>(&odata)));
01317          break;
01318          case CIMDataType::UINT16:
01319             new(&m_obj) UInt16Array(*(reinterpret_cast<const UInt16Array*>(&odata)));
01320          break;
01321          case CIMDataType::SINT16:
01322             new(&m_obj) Int16Array(*(reinterpret_cast<const Int16Array*>(&odata)));
01323          break;
01324          case CIMDataType::UINT32:
01325             new(&m_obj) UInt32Array(*(reinterpret_cast<const UInt32Array*>(&odata)));
01326          break;
01327          case CIMDataType::SINT32:
01328             new(&m_obj) Int32Array(*(reinterpret_cast<const Int32Array*>(&odata)));
01329          break;
01330          case CIMDataType::UINT64:
01331             new(&m_obj) UInt64Array(*(reinterpret_cast<const UInt64Array*>(&odata)));
01332          break;
01333          case CIMDataType::SINT64:
01334             new(&m_obj) Int64Array(*(reinterpret_cast<const Int64Array*>(&odata)));
01335          break;
01336          case CIMDataType::BOOLEAN:
01337             new(&m_obj) BoolArray(*(reinterpret_cast<const BoolArray*>(&odata)));
01338          break;
01339          case CIMDataType::REAL32:
01340             new(&m_obj) Real32Array(*(reinterpret_cast<const Real32Array*>(&odata)));
01341          break;
01342          case CIMDataType::REAL64:
01343             new(&m_obj) Real64Array(*(reinterpret_cast<const Real64Array*>(&odata)));
01344          break;
01345          case CIMDataType::CHAR16:
01346             new(&m_obj) Char16Array(*(reinterpret_cast<const Char16Array*>(&odata)));
01347          break;
01348          case CIMDataType::DATETIME:
01349             new(&m_obj) CIMDateTimeArray(*(reinterpret_cast<const CIMDateTimeArray*>(&odata)));
01350          break;
01351          case CIMDataType::STRING:
01352             new(&m_obj) StringArray(*(reinterpret_cast<const StringArray*>(&odata)));
01353          break;
01354          case CIMDataType::REFERENCE:
01355             new(&m_obj) CIMObjectPathArray(*(reinterpret_cast<const CIMObjectPathArray*>(&odata)));
01356          break;
01357          case CIMDataType::EMBEDDEDCLASS:
01358             new(&m_obj) CIMClassArray(*(reinterpret_cast<const CIMClassArray*>(&odata)));
01359          break;
01360          case CIMDataType::EMBEDDEDINSTANCE:
01361             new(&m_obj) CIMInstanceArray(*(reinterpret_cast<const CIMInstanceArray*>(&odata)));
01362          break;
01363          default:
01364             m_objDestroyed = true;
01365             m_type = CIMDataType::CIMNULL;
01366             break;
01367       }
01368    }
01369    else
01370    {
01371       switch (m_type)
01372       {
01373          case CIMDataType::UINT8:
01374          case CIMDataType::SINT8:
01375          case CIMDataType::UINT16:
01376          case CIMDataType::SINT16:
01377          case CIMDataType::UINT32:
01378          case CIMDataType::SINT32:
01379          case CIMDataType::UINT64:
01380          case CIMDataType::SINT64:
01381          case CIMDataType::BOOLEAN:
01382          case CIMDataType::REAL32:
01383          case CIMDataType::REAL64:
01384             ::memmove(&m_obj, &odata, sizeof(m_obj));
01385             break;
01386          case CIMDataType::CHAR16:
01387             new(&m_obj) Char16(*(reinterpret_cast<const Char16*>(&odata)));
01388          break;
01389          case CIMDataType::REFERENCE:
01390             new(&m_obj) CIMObjectPath(*(reinterpret_cast<const CIMObjectPath*>(&odata)));
01391          break;
01392          case CIMDataType::DATETIME:
01393             new(&m_obj) CIMDateTime(*(reinterpret_cast<const CIMDateTime*>(&odata)));
01394          break;
01395          case CIMDataType::STRING:
01396             new(&m_obj) String(*(reinterpret_cast<const String*>(&odata)));
01397          break;
01398          case CIMDataType::EMBEDDEDCLASS:
01399             new(&m_obj) CIMClass(*(reinterpret_cast<const CIMClass*>(&odata)));
01400          break;
01401          case CIMDataType::EMBEDDEDINSTANCE:
01402             new(&m_obj) CIMInstance(*(reinterpret_cast<const CIMInstance*>(&odata)));
01403          break;
01404          default:
01405             m_objDestroyed = true;
01406             m_type = CIMDataType::CIMNULL;
01407             break;
01408       }
01409    }
01410 }
01412 void
01413 CIMValue::CIMValueImpl::destroyObject()
01414 {
01415    if (m_objDestroyed)
01416    {
01417       return;
01418    }
01419    m_objDestroyed = true;
01420    if (m_isArray)
01421    {
01422       switch (m_type)
01423       {
01424          case CIMDataType::UINT8:
01425             (reinterpret_cast<UInt8Array*>(&m_obj))->~UInt8Array();
01426          break;
01427          case CIMDataType::SINT8:
01428             (reinterpret_cast<Int8Array*>(&m_obj))->~Int8Array();
01429          break;
01430          case CIMDataType::UINT16:
01431             (reinterpret_cast<UInt16Array*>(&m_obj))->~UInt16Array();
01432          break;
01433          case CIMDataType::SINT16:
01434             (reinterpret_cast<Int16Array*>(&m_obj))->~Int16Array();
01435          break;
01436          case CIMDataType::UINT32:
01437             (reinterpret_cast<UInt32Array*>(&m_obj))->~UInt32Array();
01438          break;
01439          case CIMDataType::SINT32:
01440             (reinterpret_cast<Int32Array*>(&m_obj))->~Int32Array();
01441          break;
01442          case CIMDataType::UINT64:
01443             (reinterpret_cast<UInt64Array*>(&m_obj))->~UInt64Array();
01444          break;
01445          case CIMDataType::SINT64:
01446             (reinterpret_cast<Int64Array*>(&m_obj))->~Int64Array();
01447          break;
01448          case CIMDataType::BOOLEAN:
01449             (reinterpret_cast<BoolArray*>(&m_obj))->~BoolArray();
01450          break;
01451          case CIMDataType::REAL32:
01452             (reinterpret_cast<Real32Array*>(&m_obj))->~Real32Array();
01453          break;
01454          case CIMDataType::REAL64:
01455             (reinterpret_cast<Real64Array*>(&m_obj))->~Real64Array();
01456          break;
01457          case CIMDataType::CHAR16:
01458             (reinterpret_cast<Char16Array*>(&m_obj))->~Char16Array();
01459          break;
01460          case CIMDataType::DATETIME:
01461             (reinterpret_cast<CIMDateTimeArray*>(&m_obj))->~CIMDateTimeArray();
01462          break;
01463          case CIMDataType::STRING:
01464             (reinterpret_cast<StringArray*>(&m_obj))->~StringArray();
01465          break;
01466          case CIMDataType::REFERENCE:
01467             (reinterpret_cast<CIMObjectPathArray*>(&m_obj))->~CIMObjectPathArray();
01468          break;
01469          case CIMDataType::EMBEDDEDCLASS:
01470             (reinterpret_cast<CIMClassArray*>(&m_obj))->~CIMClassArray();
01471          break;
01472          case CIMDataType::EMBEDDEDINSTANCE:
01473             (reinterpret_cast<CIMInstanceArray*>(&m_obj))->~CIMInstanceArray();
01474          break;
01475          default:
01476             assert(0); // don't want to throw from a destructor, just segfault
01477       }
01478    }
01479    else
01480    {
01481       switch (m_type)
01482       {
01483          case CIMDataType::UINT8:
01484          case CIMDataType::SINT8:
01485          case CIMDataType::UINT16:
01486          case CIMDataType::SINT16:
01487          case CIMDataType::UINT32:
01488          case CIMDataType::SINT32:
01489          case CIMDataType::UINT64:
01490          case CIMDataType::SINT64:
01491          case CIMDataType::BOOLEAN:
01492          case CIMDataType::REAL32:
01493          case CIMDataType::REAL64:
01494             break;
01495          case CIMDataType::CHAR16:
01496             (reinterpret_cast<Char16*>(&m_obj))->~Char16();
01497             break;
01498          case CIMDataType::REFERENCE:
01499             (reinterpret_cast<CIMObjectPath*>(&m_obj))->~CIMObjectPath();
01500             break;
01501          case CIMDataType::DATETIME:
01502             (reinterpret_cast<CIMDateTime*>(&m_obj))->~CIMDateTime();
01503             break;
01504          case CIMDataType::STRING:
01505             (reinterpret_cast<String*>(&m_obj))->~String();
01506             break;
01507          case CIMDataType::EMBEDDEDCLASS:
01508             (reinterpret_cast<CIMClass*>(&m_obj))->~CIMClass();
01509             break;
01510          case CIMDataType::EMBEDDEDINSTANCE:
01511             (reinterpret_cast<CIMInstance*>(&m_obj))->~CIMInstance();
01512             break;
01513          default:
01514             assert(0); // don't want to throw from a destructor, just segfault
01515       }
01516    }
01517    m_type = CIMDataType::CIMNULL;
01518 }
01520 CIMValue::CIMValueImpl&
01521 CIMValue::CIMValueImpl::set(const CIMValueImpl& arg)
01522 {
01523    setupObject(arg.m_obj, arg.m_type, arg.m_isArray);
01524    return *this;
01525 }
01527 CIMValue::CIMValueImpl&
01528 CIMValue::CIMValueImpl::operator= (const CIMValueImpl& arg)
01529 {
01530    set(arg);
01531    return *this;
01532 }
01534 bool
01535 CIMValue::CIMValueImpl::equal(const CIMValueImpl& arg) const
01536 {
01537    bool cc = false;
01538    if (sameType(arg))
01539    {
01540       if (m_isArray)
01541       {
01542          switch (m_type)
01543          {
01544             case CIMDataType::CHAR16:
01545                cc = *(reinterpret_cast<const Char16Array*>(&m_obj)) ==
01546                   *(reinterpret_cast<const Char16Array*>(&arg.m_obj));
01547                break;
01548             case CIMDataType::UINT8:
01549                cc = *(reinterpret_cast<const UInt8Array*>(&m_obj)) ==
01550                   *(reinterpret_cast<const UInt8Array*>(&arg.m_obj));
01551                break;
01552             case CIMDataType::SINT8:
01553                cc = *(reinterpret_cast<const Int8Array*>(&m_obj)) == *(reinterpret_cast<const Int8Array*>(&arg.m_obj));
01554                break;
01555             case CIMDataType::UINT16:
01556                cc = *(reinterpret_cast<const UInt16Array*>(&m_obj)) ==
01557                   *(reinterpret_cast<const UInt16Array*>(&arg.m_obj));
01558                break;
01559             case CIMDataType::SINT16:
01560                cc = *(reinterpret_cast<const Int16Array*>(&m_obj)) ==
01561                   *(reinterpret_cast<const Int16Array*>(&arg.m_obj));
01562                break;
01563             case CIMDataType::UINT32:
01564                cc = *(reinterpret_cast<const UInt32Array*>(&m_obj)) ==
01565                   *(reinterpret_cast<const UInt32Array*>(&arg.m_obj));
01566                break;
01567             case CIMDataType::SINT32:
01568                cc = *(reinterpret_cast<const Int32Array*>(&m_obj)) ==
01569                   *(reinterpret_cast<const Int32Array*>(&arg.m_obj));
01570                break;
01571             case CIMDataType::UINT64:
01572                cc = *(reinterpret_cast<const UInt64Array*>(&m_obj)) ==
01573                   *(reinterpret_cast<const UInt64Array*>(&arg.m_obj));
01574                break;
01575             case CIMDataType::SINT64:
01576                cc = *(reinterpret_cast<const Int64Array*>(&m_obj)) ==
01577                   *(reinterpret_cast<const Int64Array*>(&arg.m_obj));
01578                break;
01579             case CIMDataType::STRING:
01580                cc = *(reinterpret_cast<const StringArray*>(&m_obj)) ==
01581                   *(reinterpret_cast<const StringArray*>(&arg.m_obj));
01582                break;
01583             case CIMDataType::REFERENCE:
01584                cc = *(reinterpret_cast<const CIMObjectPathArray*>(&m_obj)) ==
01585                   *(reinterpret_cast<const CIMObjectPathArray*>(&arg.m_obj));
01586                break;
01587             case CIMDataType::BOOLEAN:
01588                cc = *(reinterpret_cast<const BoolArray*>(&m_obj)) == *(reinterpret_cast<const BoolArray*>(&arg.m_obj));
01589                break;
01590             case CIMDataType::REAL32:
01591                cc = *(reinterpret_cast<const Real32Array*>(&m_obj)) ==
01592                   *(reinterpret_cast<const Real32Array*>(&arg.m_obj));
01593                break;
01594             case CIMDataType::REAL64:
01595                cc = *(reinterpret_cast<const Real64Array*>(&m_obj)) ==
01596                   *(reinterpret_cast<const Real64Array*>(&arg.m_obj));
01597                break;
01598             case CIMDataType::DATETIME:
01599                cc = *(reinterpret_cast<const CIMDateTimeArray*>(&m_obj)) ==
01600                   *(reinterpret_cast<const CIMDateTimeArray*>(&arg.m_obj));
01601                break;
01602             case CIMDataType::EMBEDDEDCLASS:
01603                cc = *(reinterpret_cast<const CIMClassArray*>(&m_obj)) ==
01604                   *(reinterpret_cast<const CIMClassArray*>(&arg.m_obj));
01605                break;
01606             case CIMDataType::EMBEDDEDINSTANCE:
01607                cc = *(reinterpret_cast<const CIMInstanceArray*>(&m_obj)) ==
01608                   *(reinterpret_cast<const CIMInstanceArray*>(&arg.m_obj));
01609                break;
01610             default:
01611                OW_ASSERT(0);
01612          }
01613       }
01614       else
01615       {
01616          switch (m_type)
01617          {
01618             case CIMDataType::UINT8:
01619                cc = m_obj.m_uint8Value == arg.m_obj.m_uint8Value;
01620                break;
01621             case CIMDataType::SINT8:
01622                cc = m_obj.m_sint8Value == arg.m_obj.m_sint8Value;
01623                break;
01624             case CIMDataType::UINT16:
01625                cc = m_obj.m_uint16Value == arg.m_obj.m_uint16Value;
01626                break;
01627             case CIMDataType::SINT16:
01628                cc = m_obj.m_sint16Value == arg.m_obj.m_sint16Value;
01629                break;
01630             case CIMDataType::UINT32:
01631                cc = m_obj.m_uint32Value == arg.m_obj.m_uint32Value;
01632                break;
01633             case CIMDataType::SINT32:
01634                cc = m_obj.m_sint32Value == arg.m_obj.m_sint32Value;
01635                break;
01636             case CIMDataType::UINT64:
01637                cc = m_obj.m_uint64Value == arg.m_obj.m_uint64Value;
01638                break;
01639             case CIMDataType::SINT64:
01640                cc = m_obj.m_sint64Value == arg.m_obj.m_sint64Value;
01641                break;
01642             case CIMDataType::CHAR16:
01643                cc = *(reinterpret_cast<const Char16*>(&m_obj)) == *(reinterpret_cast<const Char16*>(&arg.m_obj));
01644                break;
01645             case CIMDataType::STRING:
01646                cc = *(reinterpret_cast<const String*>(&m_obj)) == *(reinterpret_cast<const String*>(&arg.m_obj));
01647                break;
01648             case CIMDataType::BOOLEAN:
01649                cc = m_obj.m_booleanValue == arg.m_obj.m_booleanValue;
01650                break;
01651             case CIMDataType::REAL32:
01652                cc = m_obj.m_real32Value == arg.m_obj.m_real32Value;
01653                break;
01654             case CIMDataType::REAL64:
01655                cc = m_obj.m_real64Value == arg.m_obj.m_real64Value;
01656                break;
01657             case CIMDataType::DATETIME:
01658                cc = *(reinterpret_cast<const CIMDateTime*>(&m_obj)) ==
01659                   *(reinterpret_cast<const CIMDateTime*>(&arg.m_obj));
01660                break;
01661             case CIMDataType::REFERENCE:
01662                cc = *(reinterpret_cast<const CIMObjectPath*>(&m_obj)) ==
01663                   *(reinterpret_cast<const CIMObjectPath*>(&arg.m_obj));
01664                break;
01665             case CIMDataType::EMBEDDEDCLASS:
01666                cc = *(reinterpret_cast<const CIMClass*>(&m_obj)) ==
01667                   *(reinterpret_cast<const CIMClass*>(&arg.m_obj));
01668                break;
01669             case CIMDataType::EMBEDDEDINSTANCE:
01670                cc = *(reinterpret_cast<const CIMInstance*>(&m_obj)) ==
01671                   *(reinterpret_cast<const CIMInstance*>(&arg.m_obj));
01672                break;
01673             default:
01674                OW_ASSERT(0);
01675          }
01676       }
01677    }
01678    return cc;
01679 }
01681 bool
01682 CIMValue::CIMValueImpl::operator<(const CIMValueImpl& arg) const
01683 {
01684    bool cc = false;
01685    if (sameType(arg))
01686    {
01687       if (m_isArray)
01688       {
01689          switch (m_type)
01690          {
01691             case CIMDataType::CHAR16:
01692                cc = *(reinterpret_cast<const Char16Array*>(&m_obj)) <
01693                   *(reinterpret_cast<const Char16Array*>(&arg.m_obj));
01694                break;
01695             case CIMDataType::UINT8:
01696                cc = *(reinterpret_cast<const UInt8Array*>(&m_obj)) <
01697                   *(reinterpret_cast<const UInt8Array*>(&arg.m_obj));
01698                break;
01699             case CIMDataType::SINT8:
01700                cc = *(reinterpret_cast<const Int8Array*>(&m_obj)) < *(reinterpret_cast<const Int8Array*>(&arg.m_obj));
01701                break;
01702             case CIMDataType::UINT16:
01703                cc = *(reinterpret_cast<const UInt16Array*>(&m_obj)) <
01704                   *(reinterpret_cast<const UInt16Array*>(&arg.m_obj));
01705                break;
01706             case CIMDataType::SINT16:
01707                cc = *(reinterpret_cast<const Int16Array*>(&m_obj)) <
01708                   *(reinterpret_cast<const Int16Array*>(&arg.m_obj));
01709                break;
01710             case CIMDataType::UINT32:
01711                cc = *(reinterpret_cast<const UInt32Array*>(&m_obj)) <
01712                   *(reinterpret_cast<const UInt32Array*>(&arg.m_obj));
01713                break;
01714             case CIMDataType::SINT32:
01715                cc = *(reinterpret_cast<const Int32Array*>(&m_obj)) <
01716                   *(reinterpret_cast<const Int32Array*>(&arg.m_obj));
01717                break;
01718             case CIMDataType::UINT64:
01719                cc = *(reinterpret_cast<const UInt64Array*>(&m_obj)) <
01720                   *(reinterpret_cast<const UInt64Array*>(&arg.m_obj));
01721                break;
01722             case CIMDataType::SINT64:
01723                cc = *(reinterpret_cast<const Int64Array*>(&m_obj)) <
01724                   *(reinterpret_cast<const Int64Array*>(&arg.m_obj));
01725                break;
01726             case CIMDataType::STRING:
01727                cc = *(reinterpret_cast<const StringArray*>(&m_obj)) <
01728                   *(reinterpret_cast<const StringArray*>(&arg.m_obj));
01729                break;
01730             case CIMDataType::REFERENCE:
01731                cc = *(reinterpret_cast<const CIMObjectPathArray*>(&m_obj)) <
01732                   *(reinterpret_cast<const CIMObjectPathArray*>(&arg.m_obj));
01733                break;
01734             case CIMDataType::BOOLEAN:
01735                cc = *(reinterpret_cast<const BoolArray*>(&m_obj)) < *(reinterpret_cast<const BoolArray*>(&arg.m_obj));
01736                break;
01737             case CIMDataType::REAL32:
01738                cc = *(reinterpret_cast<const Real32Array*>(&m_obj)) <
01739                   *(reinterpret_cast<const Real32Array*>(&arg.m_obj));
01740                break;
01741             case CIMDataType::REAL64:
01742                cc = *(reinterpret_cast<const Real64Array*>(&m_obj)) <
01743                   *(reinterpret_cast<const Real64Array*>(&arg.m_obj));
01744                break;
01745             case CIMDataType::DATETIME:
01746                cc = *(reinterpret_cast<const CIMDateTimeArray*>(&m_obj)) <
01747                   *(reinterpret_cast<const CIMDateTimeArray*>(&arg.m_obj));
01748                break;
01749             case CIMDataType::EMBEDDEDCLASS:
01750                cc = *(reinterpret_cast<const CIMClassArray*>(&m_obj)) <
01751                   *(reinterpret_cast<const CIMClassArray*>(&arg.m_obj));
01752                break;
01753             case CIMDataType::EMBEDDEDINSTANCE:
01754                cc = *(reinterpret_cast<const CIMInstanceArray*>(&m_obj)) <
01755                   *(reinterpret_cast<const CIMInstanceArray*>(&arg.m_obj));
01756                break;
01757             default:
01758                OW_ASSERT(0);
01759          }
01760       }
01761       else
01762       {
01763          switch (m_type)
01764          {
01765             case CIMDataType::UINT8:
01766                cc = m_obj.m_uint8Value < arg.m_obj.m_uint8Value;
01767                break;
01768             case CIMDataType::SINT8:
01769                cc = m_obj.m_sint8Value < arg.m_obj.m_sint8Value;
01770                break;
01771             case CIMDataType::UINT16:
01772                cc = m_obj.m_uint16Value < arg.m_obj.m_uint16Value;
01773                break;
01774             case CIMDataType::SINT16:
01775                cc = m_obj.m_sint16Value < arg.m_obj.m_sint16Value;
01776                break;
01777             case CIMDataType::UINT32:
01778                cc = m_obj.m_uint32Value < arg.m_obj.m_uint32Value;
01779                break;
01780             case CIMDataType::SINT32:
01781                cc = m_obj.m_sint32Value < arg.m_obj.m_sint32Value;
01782                break;
01783             case CIMDataType::UINT64:
01784                cc = m_obj.m_uint64Value < arg.m_obj.m_uint64Value;
01785                break;
01786             case CIMDataType::SINT64:
01787                cc = m_obj.m_sint64Value < arg.m_obj.m_sint64Value;
01788                break;
01789             case CIMDataType::CHAR16:
01790                cc = *(reinterpret_cast<const Char16*>(&m_obj)) < *(reinterpret_cast<const Char16*>(&arg.m_obj));
01791                break;
01792             case CIMDataType::STRING:
01793                cc = *(reinterpret_cast<const String*>(&m_obj)) < *(reinterpret_cast<const String*>(&arg.m_obj));
01794                break;
01795             case CIMDataType::BOOLEAN:
01796                cc = m_obj.m_booleanValue < arg.m_obj.m_booleanValue;
01797                break;
01798             case CIMDataType::REAL32:
01799                cc = m_obj.m_real32Value < arg.m_obj.m_real32Value;
01800                break;
01801             case CIMDataType::REAL64:
01802                cc = m_obj.m_real64Value < arg.m_obj.m_real64Value;
01803                break;
01804             case CIMDataType::DATETIME:
01805                cc = *(reinterpret_cast<const CIMDateTime*>(&m_obj)) <
01806                   *(reinterpret_cast<const CIMDateTime*>(&arg.m_obj));
01807                break;
01808             case CIMDataType::REFERENCE:
01809                cc = *(reinterpret_cast<const CIMObjectPath*>(&m_obj)) <
01810                   *(reinterpret_cast<const CIMObjectPath*>(&arg.m_obj));
01811                break;
01812             case CIMDataType::EMBEDDEDCLASS:
01813                cc = *(reinterpret_cast<const CIMClass*>(&m_obj)) <
01814                   *(reinterpret_cast<const CIMClass*>(&arg.m_obj));
01815                break;
01816             case CIMDataType::EMBEDDEDINSTANCE:
01817                cc = *(reinterpret_cast<const CIMInstance*>(&m_obj)) <
01818                   *(reinterpret_cast<const CIMInstance*>(&arg.m_obj));
01819                break;
01820             default:
01821                OW_ASSERT(0);
01822          }
01823       }
01824    }
01825    return cc;
01826 }
01828 void
01829 CIMValue::CIMValueImpl::get(Bool& arg) const
01830 {
01831    if (m_type != CIMDataType::BOOLEAN || isArray())
01832    {
01833       OW_THROW(ValueCastException,
01834          "CIMValue::CIMValueImpl::get - Value is not a BOOLEAN");
01835    }
01836    arg = (m_obj.m_booleanValue != 0);
01837 }
01839 void
01840 CIMValue::CIMValueImpl::get(Char16& arg) const
01841 {
01842    if (m_type != CIMDataType::CHAR16 || isArray())
01843    {
01844       OW_THROW(ValueCastException,
01845          "CIMValue::CIMValueImpl::get - Value is not a CHAR16");
01846    }
01847    arg = *(reinterpret_cast<const Char16*>(&m_obj));
01848 }
01850 void
01851 CIMValue::CIMValueImpl::get(UInt8& arg) const
01852 {
01853    if (!castDefaultNumeric(arg))
01854    {
01855       if (m_type != CIMDataType::UINT8 || isArray())
01856       {
01857          OW_THROW(ValueCastException,
01858             "CIMValue::CIMValueImpl::get - Value is not a UINT8");
01859       }
01860       arg = m_obj.m_uint8Value;
01861    }
01862 }
01864 void
01865 CIMValue::CIMValueImpl::get(Int8& arg) const
01866 {
01867    if (!castDefaultNumeric(arg))
01868    {
01869       if (m_type != CIMDataType::SINT8 || isArray())
01870       {
01871          OW_THROW(ValueCastException,
01872             "CIMValue::CIMValueImpl::get - Value is not a SINT8");
01873       }
01874       arg = m_obj.m_sint8Value;
01875    }
01876 }
01878 void
01879 CIMValue::CIMValueImpl::get(UInt16& arg) const
01880 {
01881    if (!castDefaultNumeric(arg))
01882    {
01883       if (m_type != CIMDataType::UINT16 || isArray())
01884       {
01885          OW_THROW(ValueCastException,
01886             "CIMValue::CIMValueImpl::get - Value is not a UINT16");
01887       }
01888       arg = m_obj.m_uint16Value;
01889    }
01890 }
01892 void
01893 CIMValue::CIMValueImpl::get(Int16& arg) const
01894 {
01895    if (!castDefaultNumeric(arg))
01896    {
01897       if (m_type != CIMDataType::SINT16 || isArray())
01898       {
01899          OW_THROW(ValueCastException,
01900             "CIMValue::CIMValueImpl::get - Value is not a SINT16");
01901       }
01902       arg = m_obj.m_sint16Value;
01903    }
01904 }
01906 void
01907 CIMValue::CIMValueImpl::get(UInt32& arg) const
01908 {
01909    if (!castDefaultNumeric(arg))
01910    {
01911       if (m_type != CIMDataType::UINT32 || isArray())
01912       {
01913          OW_THROW(ValueCastException,
01914             "CIMValue::CIMValueImpl::get - Value is not a UINT32");
01915       }
01916       arg = m_obj.m_uint32Value;
01917    }
01918 }
01920 void
01921 CIMValue::CIMValueImpl::get(Int32& arg) const
01922 {
01923    if (!castDefaultNumeric(arg))
01924    {
01925       if (m_type != CIMDataType::SINT32 || isArray())
01926       {
01927          OW_THROW(ValueCastException,
01928             "CIMValue::CIMValueImpl::get - Value is not a SINT32");
01929       }
01930       arg = m_obj.m_sint32Value;
01931    }
01932 }
01934 void
01935 CIMValue::CIMValueImpl::get(UInt64& arg) const
01936 {
01937    if (!castDefaultNumeric(arg))
01938    {
01939       if (m_type != CIMDataType::UINT64 || isArray())
01940       {
01941          OW_THROW(ValueCastException,
01942             "CIMValue::CIMValueImpl::get - Value is not a UINT64");
01943       }
01944       arg = m_obj.m_uint64Value;
01945    }
01946 }
01948 void
01949 CIMValue::CIMValueImpl::get(Int64& arg) const
01950 {
01951    if (!castDefaultNumeric(arg))
01952    {
01953       if (m_type != CIMDataType::SINT64 || isArray())
01954       {
01955          OW_THROW(ValueCastException,
01956             "CIMValue::CIMValueImpl::get - Value is not a SINT64");
01957       }
01958       arg = m_obj.m_sint64Value;
01959    }
01960 }
01962 void
01963 CIMValue::CIMValueImpl::get(Real32& arg) const
01964 {
01965    if (!castDefaultNumeric(arg))
01966    {
01967       if (m_type != CIMDataType::REAL32 || isArray())
01968       {
01969          OW_THROW(ValueCastException,
01970             "CIMValue::CIMValueImpl::get - Value is not a REAL32");
01971       }
01972       arg = m_obj.m_real32Value;
01973    }
01974 }
01976 void
01977 CIMValue::CIMValueImpl::get(Real64& arg) const
01978 {
01979    if (!castDefaultNumeric(arg))
01980    {
01981       if (m_type != CIMDataType::REAL64 || isArray())
01982       {
01983          OW_THROW(ValueCastException,
01984             "CIMValue::CIMValueImpl::get - Value is not a REAL64");
01985       }
01986       arg = m_obj.m_real64Value;
01987    }
01988 }
01990 void
01991 CIMValue::CIMValueImpl::get(String& arg) const
01992 {
01993    if (m_type != CIMDataType::STRING || isArray())
01994    {
01995       OW_THROW(ValueCastException,
01996          "CIMValue::CIMValueImpl::get - Value is not a STRING");
01997    }
01998    arg = *(reinterpret_cast<const String*>(&m_obj));
01999 }
02001 void
02002 CIMValue::CIMValueImpl::get(CIMDateTime& arg) const
02003 {
02004    if (m_type != CIMDataType::DATETIME || isArray())
02005    {
02006       OW_THROW(ValueCastException,
02007          "CIMValue::CIMValueImpl::get - Value is not a DATETIME");
02008    }
02009    arg = *(reinterpret_cast<const CIMDateTime*>(&m_obj));
02010 }
02012 void
02013 CIMValue::CIMValueImpl::get(CIMObjectPath& arg) const
02014 {
02015    if (m_type != CIMDataType::REFERENCE || isArray())
02016    {
02017       OW_THROW(ValueCastException,
02018          "CIMValue::CIMValueImpl::get - Value is not a REFERENCE");
02019    }
02020    arg = *(reinterpret_cast<const CIMObjectPath*>(&m_obj));
02021 }
02023 void
02024 CIMValue::CIMValueImpl::get(CIMClass& arg) const
02025 {
02026    if (m_type != CIMDataType::EMBEDDEDCLASS || isArray())
02027    {
02028       OW_THROW(ValueCastException,
02029          "CIMValue::CIMValueImpl::get - Value is not a EMBEDDEDCLASS");
02030    }
02031    arg = *(reinterpret_cast<const CIMClass*>(&m_obj));
02032 }
02034 void
02035 CIMValue::CIMValueImpl::get(CIMInstance& arg) const
02036 {
02037    if (m_type != CIMDataType::EMBEDDEDINSTANCE || isArray())
02038    {
02039       OW_THROW(ValueCastException,
02040          "CIMValue::CIMValueImpl::get - Value is not a EMBEDDEDINSTANCE");
02041    }
02042    arg = *(reinterpret_cast<const CIMInstance*>(&m_obj));
02043 }
02045 void
02046 CIMValue::CIMValueImpl::get(Char16Array& arg) const
02047 {
02048    if (m_type != CIMDataType::CHAR16 || !isArray())
02049    {
02050       OW_THROW(ValueCastException,
02051          "CIMValue::CIMValueImpl::get - Value is not a CHAR16 ARRAY");
02052    }
02053    arg = *(reinterpret_cast<const Char16Array*>(&m_obj));
02054 }
02056 void
02057 CIMValue::CIMValueImpl::get(UInt8Array& arg) const
02058 {
02059    if (m_type != CIMDataType::UINT8 || !isArray())
02060    {
02061       OW_THROW(ValueCastException,
02062          "CIMValue::CIMValueImpl::get - Value is not a UINT8 ARRAY");
02063    }
02064    arg = *(reinterpret_cast<const UInt8Array*>(&m_obj));
02065 }
02067 void
02068 CIMValue::CIMValueImpl::get(Int8Array& arg) const
02069 {
02070    if (m_type != CIMDataType::SINT8 || !isArray())
02071    {
02072       OW_THROW(ValueCastException,
02073          "CIMValue::CIMValueImpl::get - Value is not a SINT8 ARRAY");
02074    }
02075    arg = *(reinterpret_cast<const Int8Array*>(&m_obj));
02076 }
02078 void
02079 CIMValue::CIMValueImpl::get(UInt16Array& arg) const
02080 {
02081    if (m_type != CIMDataType::UINT16 || !isArray())
02082    {
02083       OW_THROW(ValueCastException,
02084          "CIMValue::CIMValueImpl::get - Value is not a UINT16 ARRAY");
02085    }
02086    arg = *(reinterpret_cast<const UInt16Array*>(&m_obj));
02087 }
02089 void
02090 CIMValue::CIMValueImpl::get(Int16Array& arg) const
02091 {
02092    if (m_type != CIMDataType::SINT16 || !isArray())
02093    {
02094       OW_THROW(ValueCastException,
02095          "CIMValue::CIMValueImpl::get - Value is not a SINT16 ARRAY");
02096    }
02097    arg = *(reinterpret_cast<const Int16Array*>(&m_obj));
02098 }
02100 void
02101 CIMValue::CIMValueImpl::get(UInt32Array& arg) const
02102 {
02103    if (m_type != CIMDataType::UINT32 || !isArray())
02104    {
02105       OW_THROW(ValueCastException,
02106          "CIMValue::CIMValueImpl::get - Value is not a UINT32 ARRAY");
02107    }
02108    arg = *(reinterpret_cast<const UInt32Array*>(&m_obj));
02109 }
02111 void
02112 CIMValue::CIMValueImpl::get(Int32Array& arg) const
02113 {
02114    if (m_type != CIMDataType::SINT32 || !isArray())
02115    {
02116       OW_THROW(ValueCastException,
02117          "CIMValue::CIMValueImpl::get - Value is not a SINT32 ARRAY");
02118    }
02119    arg = *(reinterpret_cast<const Int32Array*>(&m_obj));
02120 }
02122 void
02123 CIMValue::CIMValueImpl::get(UInt64Array& arg) const
02124 {
02125    if (m_type != CIMDataType::UINT64 || !isArray())
02126    {
02127       OW_THROW(ValueCastException,
02128          "CIMValue::CIMValueImpl::get - Value is not a UINT64 ARRAY");
02129    }
02130    arg = *(reinterpret_cast<const UInt64Array*>(&m_obj));
02131 }
02133 void
02134 CIMValue::CIMValueImpl::get(Int64Array& arg) const
02135 {
02136    if (m_type != CIMDataType::SINT64 || !isArray())
02137    {
02138       OW_THROW(ValueCastException,
02139          "CIMValue::CIMValueImpl::get - Value is not a SINT64 ARRAY");
02140    }
02141    arg = *(reinterpret_cast<const Int64Array*>(&m_obj));
02142 }
02144 void
02145 CIMValue::CIMValueImpl::get(Real64Array& arg) const
02146 {
02147    if (m_type != CIMDataType::REAL64 || !isArray())
02148    {
02149       OW_THROW(ValueCastException,
02150          "CIMValue::CIMValueImpl::get - Value is not a REAL64 ARRAY");
02151    }
02152    arg = *(reinterpret_cast<const Real64Array*>(&m_obj));
02153 }
02155 void
02156 CIMValue::CIMValueImpl::get(Real32Array& arg) const
02157 {
02158    if (m_type != CIMDataType::REAL32 || !isArray())
02159    {
02160       OW_THROW(ValueCastException,
02161          "CIMValue::CIMValueImpl::get - Value is not a REAL32 ARRAY");
02162    }
02163    arg = *(reinterpret_cast<const Real32Array*>(&m_obj));
02164 }
02166 void
02167 CIMValue::CIMValueImpl::get(StringArray& arg) const
02168 {
02169    if (m_type != CIMDataType::STRING || !isArray())
02170    {
02171       OW_THROW(ValueCastException,
02172          "CIMValue::CIMValueImpl::get - Value is not a STRING ARRAY");
02173    }
02174    arg = *(reinterpret_cast<const StringArray*>(&m_obj));
02175 }
02177 void
02178 CIMValue::CIMValueImpl::get(BoolArray& arg) const
02179 {
02180    if (m_type != CIMDataType::BOOLEAN || !isArray())
02181    {
02182       OW_THROW(ValueCastException,
02183          "CIMValue::CIMValueImpl::get - Value is not a BOOLEAN ARRAY");
02184    }
02185    arg = *(reinterpret_cast<const BoolArray*>(&m_obj));
02186 }
02188 void
02189 CIMValue::CIMValueImpl::get(CIMDateTimeArray& arg) const
02190 {
02191    if (m_type != CIMDataType::DATETIME || !isArray())
02192    {
02193       OW_THROW(ValueCastException,
02194          "CIMValue::CIMValueImpl::get - Value is not a DATETIME ARRAY");
02195    }
02196    arg = *(reinterpret_cast<const CIMDateTimeArray*>(&m_obj));
02197 }
02199 void
02200 CIMValue::CIMValueImpl::get(CIMObjectPathArray& arg) const
02201 {
02202    if (m_type != CIMDataType::REFERENCE || !isArray())
02203    {
02204       OW_THROW(ValueCastException,
02205          "CIMValue::CIMValueImpl::get - Value is not a OBJECTPATH ARRAY");
02206    }
02207    arg = *(reinterpret_cast<const CIMObjectPathArray*>(&m_obj));
02208 }
02210 void
02211 CIMValue::CIMValueImpl::get(CIMClassArray& arg) const
02212 {
02213    if (isArray()) {
02214       if (m_type == CIMDataType::EMBEDDEDCLASS)
02215       {
02216          arg = *reinterpret_cast<CIMClassArray const *>(&m_obj);
02217          return;
02218       }
02219       else if (m_type == CIMDataType::EMBEDDEDINSTANCE &&
02220          reinterpret_cast<CIMInstanceArray const *>(&m_obj)->empty())
02221       {
02222          // When reading MOF, we cannot distinguish an empty array of
02223          // embedded instances from an empty array of embedded classes, so
02224          // we arbitrarily assign a type of EMBEDDEDINSTANCE.  This code is
02225          // here in case we guessed wrong.
02226          arg = CIMClassArray();
02227          return;
02228       }
02229    }
02230    OW_THROW(ValueCastException,
02231       "CIMValue::CIMValueImpl::get - Value is not a EMBEDDEDCLASS ARRAY");
02232 }
02234 void
02235 CIMValue::CIMValueImpl::get(CIMInstanceArray& arg) const
02236 {
02237    if (m_type != CIMDataType::EMBEDDEDINSTANCE || !isArray())
02238    {
02239       OW_THROW(ValueCastException,
02240          "CIMValue::CIMValueImpl::get - Value is not a EMBEDDEDINSTANCE ARRAY");
02241    }
02242    arg = *(reinterpret_cast<const CIMInstanceArray*>(&m_obj));
02243 }
02245 template<class T>
02246 static inline String toString(const T& x)
02247 {
02248    return String(x);
02249 }
02250 
02252 static inline String toString(const CIMObjectPath& x)
02253 {
02254    return x.toString();
02255 }
02256 
02258 static inline String toString(const Char16& x)
02259 {
02260    return x.toString();
02261 }
02262 
02264 static inline String toString(const CIMDateTime& x)
02265 {
02266    return x.toString();
02267 }
02268 
02270 template<class T>
02271 static String raToString(const T& ra, bool forMOF=false)
02272 {
02273    StringBuffer out;
02274    for (size_t i = 0; i < ra.size(); i++)
02275    {
02276       if (i > 0)
02277       {
02278          out += ',';
02279       }
02280       if (forMOF)
02281       {
02282          out += '"';
02283          out += toString(ra[i]);
02284          out += '"';
02285       }
02286       else
02287       {
02288          out += toString(ra[i]);
02289       }
02290    }
02291    return out.releaseString();
02292 }
02294 static String
02295 raToString(const Array<String>& ra, bool forMOF=false)
02296 {
02297    StringBuffer out;
02298    for (size_t i = 0; i < ra.size(); i++)
02299    {
02300       if (i > 0)
02301       {
02302          out += ',';
02303       }
02304       if (forMOF)
02305       {
02306          out += '"';
02307          out += CIMObjectPath::escape(ra[i]);
02308          out += '"';
02309       }
02310       else
02311       {
02312          out += ra[i];
02313       }
02314    }
02315    return out.releaseString();
02316 }
02318 static String
02319 raToString(const Array<CIMClass>& ra, bool forMOF=false)
02320 {
02321    StringBuffer out;
02322    for (size_t i = 0; i < ra.size(); i++)
02323    {
02324       if (i > 0)
02325       {
02326          out += ',';
02327       }
02328       if (forMOF)
02329       {
02330          out += '"';
02331          out += CIMObjectPath::escape(ra[i].toString());
02332          out += '"';
02333       }
02334       else
02335       {
02336          out += ra[i].toString();
02337       }
02338    }
02339    return out.releaseString();
02340 }
02342 static String
02343 raToString(const Array<CIMInstance>& ra, bool forMOF=false)
02344 {
02345    StringBuffer out;
02346    for (size_t i = 0; i < ra.size(); i++)
02347    {
02348       if (i > 0)
02349       {
02350          out += ',';
02351       }
02352       if (forMOF)
02353       {
02354          out += '"';
02355          out += CIMObjectPath::escape(ra[i].toString());
02356          out += '"';
02357       }
02358       else
02359       {
02360          out += ra[i].toString();
02361       }
02362    }
02363    return out.releaseString();
02364 }
02365 static String
02366 raToString(const Array<Bool>& ra, bool isString=false)
02367 {
02368    StringBuffer out;
02369    for (size_t i = 0; i < ra.size(); i++)
02370    {
02371       if (i > 0)
02372       {
02373          out += ',';
02374       }
02375       if (isString)
02376       {
02377          out += '"';
02378       }
02379       out += ra[i].toString();
02380       if (isString)
02381       {
02382          out += '"';
02383       }
02384    }
02385    return out.releaseString();
02386 }
02388 String
02389 CIMValue::CIMValueImpl::toString(bool forMOF) const
02390 {
02391    StringBuffer out;
02392    if (m_isArray)
02393    {
02394       switch (m_type)
02395       {
02396          case CIMDataType::BOOLEAN:
02397             out = raToString(*(reinterpret_cast<const BoolArray*>(&m_obj)));
02398             break;
02399          case CIMDataType::UINT8:
02400             out = raToString(*(reinterpret_cast<const UInt8Array*>(&m_obj)));
02401             break;
02402          case CIMDataType::SINT8:
02403             out = raToString(*(reinterpret_cast<const Int8Array*>(&m_obj)));
02404             break;
02405          // ATTN: UTF8
02406          case CIMDataType::CHAR16:
02407             out = raToString(*(reinterpret_cast<const Char16Array*>(&m_obj)));
02408             break;
02409          case CIMDataType::UINT16:
02410             out = raToString(*(reinterpret_cast<const UInt16Array*>(&m_obj)));
02411             break;
02412          case CIMDataType::SINT16:
02413             out = raToString(*(reinterpret_cast<const Int16Array*>(&m_obj)));
02414             break;
02415          case CIMDataType::UINT32:
02416             out = raToString(*(reinterpret_cast<const UInt32Array*>(&m_obj)));
02417             break;
02418          case CIMDataType::SINT32:
02419             out = raToString(*(reinterpret_cast<const Int32Array*>(&m_obj)));
02420             break;
02421          case CIMDataType::UINT64:
02422             out = raToString(*(reinterpret_cast<const UInt64Array*>(&m_obj)));
02423             break;
02424          case CIMDataType::SINT64:
02425             out = raToString(*(reinterpret_cast<const Int64Array*>(&m_obj)));
02426             break;
02427          case CIMDataType::REAL32:
02428             out = raToString(*(reinterpret_cast<const Real32Array*>(&m_obj)));
02429             break;
02430          case CIMDataType::REAL64:
02431             out = raToString(*(reinterpret_cast<const Real64Array*>(&m_obj)));
02432             break;
02433          case CIMDataType::STRING:
02434             out = raToString(*(reinterpret_cast<const StringArray*>(&m_obj)), forMOF);
02435             break;
02436          case CIMDataType::DATETIME:
02437             out = raToString(*(reinterpret_cast<const CIMDateTimeArray*>(&m_obj)), forMOF);
02438             break;
02439          case CIMDataType::REFERENCE:
02440             out = raToString(*(reinterpret_cast<const CIMObjectPathArray*>(&m_obj)));
02441             break;
02442          
02443          case CIMDataType::EMBEDDEDCLASS:
02444             out = raToString(*(reinterpret_cast<const CIMClassArray*>(&m_obj)));
02445             break;
02446          
02447          case CIMDataType::EMBEDDEDINSTANCE:
02448             out = raToString(*(reinterpret_cast<const CIMInstanceArray*>(&m_obj)));
02449             break;
02450          default:
02451             OW_ASSERT(0);
02452       }
02453    }
02454    else
02455    {
02456       switch (m_type)
02457       {
02458          case CIMDataType::BOOLEAN:
02459             out = Bool(m_obj.m_booleanValue != 0).toString();
02460             break;
02461          case CIMDataType::UINT8:
02462             out = String(static_cast<UInt32>(m_obj.m_uint8Value));
02463             break;
02464          case CIMDataType::SINT8:
02465             out = String(static_cast<Int32>(m_obj.m_sint8Value));
02466             break;
02467          case CIMDataType::CHAR16:
02468             out = String(static_cast<char>(reinterpret_cast<const Char16*>(&m_obj)->getValue()));
02469             break;
02470          case CIMDataType::UINT16:
02471             out = String(static_cast<UInt32>(m_obj.m_uint16Value));
02472             break;
02473          case CIMDataType::SINT16:
02474             out = String(static_cast<Int32>(m_obj.m_sint16Value));
02475             break;
02476          case CIMDataType::UINT32:
02477             out = String(m_obj.m_uint32Value);
02478             break;
02479          case CIMDataType::SINT32:
02480             out = String(m_obj.m_sint32Value);
02481             break;
02482          case CIMDataType::UINT64:
02483             out = String(m_obj.m_uint64Value);
02484             break;
02485          case CIMDataType::SINT64:
02486             out = String(m_obj.m_sint64Value);
02487             break;
02488          case CIMDataType::REAL32:
02489             out = String(m_obj.m_real32Value);
02490             break;
02491          case CIMDataType::REAL64:
02492             out = String(m_obj.m_real64Value);
02493             break;
02494          case CIMDataType::STRING:
02495             if (forMOF)
02496             {
02497                out = "\"";
02498                out += CIMObjectPath::escape(*(reinterpret_cast<const String*>(&m_obj)));
02499                out += "\"";
02500             }
02501             else
02502             {
02503                out = *(reinterpret_cast<const String*>(&m_obj));
02504             }
02505             break;
02506          case CIMDataType::DATETIME:
02507             if (forMOF)
02508             {
02509                out += "\"";
02510             }
02511             out += (reinterpret_cast<const CIMDateTime*>(&m_obj))->toString();
02512             if (forMOF)
02513             {
02514                out += "\"";
02515             }
02516             break;
02517          case CIMDataType::REFERENCE:
02518             if (forMOF)
02519             {
02520                out = reinterpret_cast<const CIMObjectPath*>(&m_obj)->toMOF(); 
02521             }
02522             else
02523             {
02524                out = (reinterpret_cast<const CIMObjectPath*>(&m_obj))->toString();
02525             }
02526             break;
02527          
02528          case CIMDataType::EMBEDDEDCLASS:
02529             if (forMOF)
02530             {
02531                out = "\"";
02532                out += CIMObjectPath::escape((reinterpret_cast<const CIMClass*>(&m_obj))->toString());
02533                out += "\"";
02534             }
02535             else
02536             {
02537                out = (reinterpret_cast<const CIMClass*>(&m_obj))->toString();
02538             }
02539             break;
02540          case CIMDataType::EMBEDDEDINSTANCE:
02541             if (forMOF)
02542             {
02543                out = "\"";
02544                out += CIMObjectPath::escape((reinterpret_cast<const CIMInstance*>(&m_obj))->toString());
02545                out += "\"";
02546             }
02547             else
02548             {
02549                out = (reinterpret_cast<const CIMInstance*>(&m_obj))->toString();
02550             }
02551             break;
02552          default:
02553             OW_ASSERT(0);
02554       }
02555    }
02556    return out.releaseString();
02557 }
02559 String
02560 CIMValue::CIMValueImpl::toMOF() const
02561 {
02562    StringBuffer rv;
02563    if (m_type == CIMDataType::CIMNULL
02564       || m_type == CIMDataType::INVALID)
02565    {
02566       return String();
02567    }
02568    if (m_isArray)
02569    {
02570       rv += '{';
02571    }
02572    rv += toString(true);
02573    if (m_isArray)
02574    {
02575       rv += '}';
02576    }
02577    return rv.releaseString();
02578 }
02580 // convType:   0 = no conversion
02581 //             1 = 16 bit
02582 //             2 = 32 bit
02583 //             3 = 64 bit
02584 template<class T>
02585 void
02586 readValue(istream& istrm, T& val, int convType)
02587 {
02588    BinarySerialization::read(istrm, &val, sizeof(val));
02589    switch (convType)
02590    {
02591       case 3:
02592       val = static_cast<T>(ntoh64(val));
02593       break;
02594 
02595       case 2:
02596       val = static_cast<T>(ntoh32(val));
02597       break;
02598 
02599       case 1:
02600       val = static_cast<T>(ntoh16(val));
02601       break;
02602    }
02603 }
02605 static Real64
02606 readReal64Value(istream& istrm)
02607 {
02608    String rstr;
02609    rstr.readObject(istrm);
02610    return rstr.toReal64();
02611 }
02613 static Real32
02614 readReal32Value(istream& istrm)
02615 {
02616    String rstr;
02617    rstr.readObject(istrm);
02618    return rstr.toReal32();
02619 }
02621 // convType:   0 = no conversion
02622 //             1 = 16 bit
02623 //             2 = 32 bit
02624 //             3 = 64 bit
02625 template<class T>
02626 void
02627 readArray(istream& istrm, T& ra, int convType)
02628 {
02629    ra.clear();
02630    UInt32 sz;
02631    BinarySerialization::readLen(istrm, sz);
02632    for (UInt32 i = 0; i < sz; i++)
02633    {
02634       typename T::value_type v;
02635       BinarySerialization::read(istrm, &v, sizeof(v));
02636       switch (convType)
02637       {
02638          case 3:
02639          v = static_cast<typename T::value_type>(ntoh64(v));
02640          break;
02641 
02642          case 2:
02643          v = static_cast<typename T::value_type>(ntoh32(v));
02644          break;
02645          
02646          case 1:
02647          v = static_cast<typename T::value_type>(ntoh16(v));
02648          break;
02649       }
02650       ra.push_back(v);
02651    }
02652 }
02653 static void
02654 readReal32Array(istream& istrm, Array<Real32>& ra)
02655 {
02656    ra.clear();
02657    UInt32 sz;
02658    BinarySerialization::readLen(istrm, sz);
02659    for (UInt32 i = 0; i < sz; i++)
02660    {
02661       Real32 v = readReal32Value(istrm);
02662       ra.push_back(v);
02663    }
02664 }
02665 static void
02666 readReal64Array(istream& istrm, Array<Real64>& ra)
02667 {
02668    ra.clear();
02669    UInt32 sz;
02670    BinarySerialization::readLen(istrm, sz);
02671    for (UInt32 i = 0; i < sz; i++)
02672    {
02673       Real64 v = readReal64Value(istrm);
02674       ra.push_back(v);
02675    }
02676 }
02678 template<class T>
02679 void
02680 readObjectArray(istream& istrm, T& ra)
02681 {
02682    BinarySerialization::readArray(istrm, ra);
02683 // ra.clear();
02684 // Int32 sz;
02685 // readValue(istrm, sz, 2);
02686 // for (Int32 i = 0; i < sz; i++)
02687 // {
02688 //    typename T::value_type v;
02689 //    v.readObject(istrm);
02690 //    ra.push_back(v);
02691 // }
02692 }
02694 void
02695 CIMValue::CIMValueImpl::readObject(istream &istrm)
02696 {
02697    CIMBase::readSig( istrm, OW_CIMVALUESIG );
02698    destroyObject();
02699    m_objDestroyed = false;
02700    UInt32 tmp;
02701    BinarySerialization::readLen(istrm, tmp);
02702    m_type = CIMDataType::Type(tmp);
02703    m_isArray.readObject(istrm);
02704    if (m_isArray)
02705    {
02706       switch (m_type)
02707       {
02708          case CIMDataType::BOOLEAN:
02709             new(&m_obj) BoolArray;
02710             readArray(istrm, *(reinterpret_cast<BoolArray*>(&m_obj)), 0);
02711             break;
02712          case CIMDataType::UINT8:
02713             new(&m_obj) UInt8Array;
02714             readArray(istrm, *(reinterpret_cast<UInt8Array*>(&m_obj)), 0);
02715             break;
02716          case CIMDataType::SINT8:
02717             new(&m_obj) Int8Array;
02718             readArray(istrm, *(reinterpret_cast<Int8Array*>(&m_obj)), 0);
02719             break;
02720          case CIMDataType::CHAR16:
02721             new(&m_obj) Char16Array;
02722             readObjectArray(istrm, *(reinterpret_cast<Char16Array*>(&m_obj)));
02723             break;
02724          case CIMDataType::UINT16:
02725             new(&m_obj) UInt16Array;
02726             readArray(istrm, *(reinterpret_cast<UInt16Array*>(&m_obj)), 1);
02727             break;
02728          case CIMDataType::SINT16:
02729             new(&m_obj) Int16Array;
02730             readArray(istrm, *(reinterpret_cast<Int16Array*>(&m_obj)), 1);
02731             break;
02732          case CIMDataType::UINT32:
02733             new(&m_obj) UInt32Array;
02734             readArray(istrm, *(reinterpret_cast<UInt32Array*>(&m_obj)), 2);
02735             break;
02736          case CIMDataType::SINT32:
02737             new(&m_obj) Int32Array;
02738             readArray(istrm, *(reinterpret_cast<Int32Array*>(&m_obj)), 2);
02739             break;
02740          case CIMDataType::UINT64:
02741             new(&m_obj) UInt64Array;
02742             readArray(istrm, *(reinterpret_cast<UInt64Array*>(&m_obj)), 3);
02743             break;
02744          case CIMDataType::SINT64:
02745             new(&m_obj) Int64Array;
02746             readArray(istrm, *(reinterpret_cast<Int64Array*>(&m_obj)), 3);
02747             break;
02748          case CIMDataType::REAL32:
02749             new(&m_obj) Real32Array;
02750             readReal32Array(istrm, *(reinterpret_cast<Real32Array*>(&m_obj)));
02751             break;
02752          case CIMDataType::REAL64:
02753             new(&m_obj) Real64Array;
02754             readReal64Array(istrm, *(reinterpret_cast<Real64Array*>(&m_obj)));
02755             break;
02756          case CIMDataType::STRING:
02757             new(&m_obj) StringArray;
02758             readObjectArray(istrm, *(reinterpret_cast<StringArray*>(&m_obj)));
02759             break;
02760          case CIMDataType::DATETIME:
02761             new(&m_obj) CIMDateTimeArray;
02762             readObjectArray(istrm, *(reinterpret_cast<CIMDateTimeArray*>(&m_obj)));
02763             break;
02764          case CIMDataType::REFERENCE:
02765             new(&m_obj) CIMObjectPathArray;
02766             readObjectArray(istrm, *(reinterpret_cast<CIMObjectPathArray*>(&m_obj)));
02767             break;
02768          case CIMDataType::EMBEDDEDCLASS:
02769             new(&m_obj) CIMClassArray;
02770             readObjectArray(istrm, *(reinterpret_cast<CIMClassArray*>(&m_obj)));
02771             break;
02772          case CIMDataType::EMBEDDEDINSTANCE:
02773             new(&m_obj) CIMInstanceArray;
02774             readObjectArray(istrm, *(reinterpret_cast<CIMInstanceArray*>(&m_obj)));
02775             break;
02776          default:
02777             OW_ASSERT(0);
02778       }
02779    }
02780    else
02781    {
02782       switch (m_type)
02783       {
02784          case CIMDataType::BOOLEAN:
02785             readValue(istrm, m_obj.m_booleanValue, 0);
02786             break;
02787          case CIMDataType::UINT8:
02788             readValue(istrm, m_obj.m_uint8Value, 0);
02789             break;
02790          case CIMDataType::SINT8:
02791             readValue(istrm, m_obj.m_sint8Value, 0);
02792             break;
02793          case CIMDataType::UINT16:
02794             readValue(istrm, m_obj.m_uint16Value, 1);
02795             break;
02796          case CIMDataType::SINT16:
02797             readValue(istrm, m_obj.m_sint16Value, 1);
02798             break;
02799          case CIMDataType::UINT32:
02800             readValue(istrm, m_obj.m_uint32Value, 2);
02801             break;
02802          case CIMDataType::SINT32:
02803             readValue(istrm, m_obj.m_sint32Value, 2);
02804             break;
02805          case CIMDataType::UINT64:
02806             readValue(istrm, m_obj.m_uint64Value, 3);
02807             break;
02808          case CIMDataType::SINT64:
02809             readValue(istrm, m_obj.m_sint64Value, 3);
02810             break;
02811          case CIMDataType::REAL32:
02812             m_obj.m_real32Value = readReal32Value(istrm);
02813             break;
02814          case CIMDataType::REAL64:
02815             m_obj.m_real64Value = readReal64Value(istrm);
02816             break;
02817          case CIMDataType::CHAR16:
02818             new(&m_obj) Char16;
02819             (reinterpret_cast<Char16*>(&m_obj))->readObject(istrm);
02820             break;
02821          case CIMDataType::STRING:
02822             new(&m_obj) String;
02823             (reinterpret_cast<String*>(&m_obj))->readObject(istrm);
02824             break;
02825          case CIMDataType::DATETIME:
02826             new(&m_obj) CIMDateTime(CIMNULL);
02827             (reinterpret_cast<CIMDateTime*>(&m_obj))->readObject(istrm);
02828             break;
02829          case CIMDataType::REFERENCE:
02830             new(&m_obj) CIMObjectPath(CIMNULL);
02831             (reinterpret_cast<CIMObjectPath*>(&m_obj))->readObject(istrm);
02832             break;
02833          case CIMDataType::EMBEDDEDCLASS:
02834             new(&m_obj) CIMClass(CIMNULL);
02835             (reinterpret_cast<CIMClass*>(&m_obj))->readObject(istrm);
02836             break;
02837          case CIMDataType::EMBEDDEDINSTANCE:
02838             new(&m_obj) CIMInstance(CIMNULL);
02839             (reinterpret_cast<CIMInstance*>(&m_obj))->readObject(istrm);
02840             break;
02841          default:
02842             OW_ASSERT(0);
02843       }
02844    }
02845 }
02847 // convType:   0 = no conversion
02848 //             1 = 16 bit
02849 //             2 = 32 bit
02850 //             3 = 64 bit
02851 template<class T>
02852 void
02853 writeValue(ostream& ostrm, T val, int convType)
02854 {
02855    T v;
02856    switch (convType)
02857    {
02858       case 3:
02859       v = static_cast<T>(hton64(val));
02860       break;
02861       
02862       case 2:
02863       v = static_cast<T>(hton32(val));
02864       break;
02865       
02866       case 1:
02867       v = static_cast<T>(hton16(val));
02868       break;
02869       
02870       default:
02871       v = val;
02872       break;
02873    }
02874    BinarySerialization::write(ostrm, &v, sizeof(v));
02875 }
02876 static void
02877 writeRealValue(ostream& ostrm, Real64 rv)
02878 {
02879    String v(rv);
02880    v.writeObject(ostrm);
02881 }
02883 // convType:   0 = no conversion
02884 //             1 = 16 bit
02885 //             2 = 32 bit
02886 //             3 = 64 bit
02887 template<class T>
02888 void
02889 writeArray(ostream& ostrm, const T& ra, int convType)
02890 {
02891    UInt32 sz = ra.size();
02892    BinarySerialization::writeLen(ostrm, sz);
02893    for (UInt32 i = 0; i < sz; i++)
02894    {
02895       typename T::value_type v;
02896       switch (convType)
02897       {
02898          case 3:
02899          v = static_cast<typename T::value_type>(hton64(ra[i]));
02900          break;
02901          
02902          case 2:
02903          v = static_cast<typename T::value_type>(hton32(ra[i]));
02904          break;
02905          
02906          case 1:
02907          v = static_cast<typename T::value_type>(hton16(ra[i]));
02908          break;
02909          
02910          default:
02911          v = static_cast<typename T::value_type>(ra[i]);
02912          break;
02913       }
02914       BinarySerialization::write(ostrm, &v, sizeof(v));
02915    }
02916 }
02917 static void
02918 writeArray(ostream& ostrm, const Array<Real32>& ra)
02919 {
02920    UInt32 sz = ra.size();
02921    BinarySerialization::writeLen(ostrm, sz);
02922    for (UInt32 i = 0; i < sz; i++)
02923    {
02924       writeRealValue(ostrm, static_cast<Real64>(ra[i]));
02925    }
02926 }
02927 static void
02928 writeArray(ostream& ostrm, const Array<Real64>& ra)
02929 {
02930    UInt32 sz = ra.size();
02931    BinarySerialization::writeLen(ostrm, sz);
02932    for (UInt32 i = 0; i < sz; i++)
02933    {
02934       writeRealValue(ostrm, ra[i]);
02935    }
02936 }
02938 template<class T>
02939 void
02940 writeObjectArray(ostream& ostrm, const T& ra)
02941 {
02942    BinarySerialization::writeArray(ostrm, ra);
02943 // Int32 sz = ra.size();
02944 // writeValue(ostrm, sz, 2);
02945 // for (Int32 i = 0; i < sz; i++)
02946 // {
02947 //    ra[i].writeObject(ostrm);
02948 // }
02949 }
02951 void
02952 CIMValue::CIMValueImpl::writeObject(ostream &ostrm) const
02953 {
02954    CIMBase::writeSig(ostrm, OW_CIMVALUESIG);
02955    BinarySerialization::writeLen(ostrm, m_type);
02956    m_isArray.writeObject(ostrm);
02957    if (m_isArray)
02958    {
02959       switch (m_type)
02960       {
02961          case CIMDataType::BOOLEAN:
02962             writeArray(ostrm, *(reinterpret_cast<const BoolArray*>(&m_obj)), 0);
02963             break;
02964          case CIMDataType::UINT8:
02965             writeArray(ostrm, *(reinterpret_cast<const UInt8Array*>(&m_obj)), 0);
02966             break;
02967          case CIMDataType::SINT8:
02968             writeArray(ostrm, *(reinterpret_cast<const Int8Array*>(&m_obj)), 0);
02969             break;
02970          case CIMDataType::UINT16:
02971             writeArray(ostrm, *(reinterpret_cast<const UInt16Array*>(&m_obj)), 1);
02972             break;
02973          case CIMDataType::SINT16:
02974             writeArray(ostrm, *(reinterpret_cast<const Int16Array*>(&m_obj)), 1);
02975             break;
02976          case CIMDataType::UINT32:
02977             writeArray(ostrm, *(reinterpret_cast<const UInt32Array*>(&m_obj)), 2);
02978             break;
02979          case CIMDataType::SINT32:
02980             writeArray(ostrm, *(reinterpret_cast<const Int32Array*>(&m_obj)), 2);
02981             break;
02982          case CIMDataType::UINT64:
02983             writeArray(ostrm, *(reinterpret_cast<const UInt64Array*>(&m_obj)), 3);
02984             break;
02985          case CIMDataType::SINT64:
02986             writeArray(ostrm, *(reinterpret_cast<const Int64Array*>(&m_obj)), 3);
02987             break;
02988          case CIMDataType::REAL32:
02989             writeArray(ostrm, *(reinterpret_cast<const Real32Array*>(&m_obj)));
02990             break;
02991          case CIMDataType::REAL64:
02992             writeArray(ostrm, *(reinterpret_cast<const Real64Array*>(&m_obj)));
02993             break;
02994          case CIMDataType::CHAR16:
02995             writeObjectArray(ostrm, *(reinterpret_cast<const Char16Array*>(&m_obj)));
02996             break;
02997          case CIMDataType::STRING:
02998             writeObjectArray(ostrm, *(reinterpret_cast<const StringArray*>(&m_obj)));
02999             break;
03000          case CIMDataType::DATETIME:
03001             writeObjectArray(ostrm, *(reinterpret_cast<const CIMDateTimeArray*>(&m_obj)));
03002             break;
03003          case CIMDataType::REFERENCE:
03004             writeObjectArray(ostrm, *(reinterpret_cast<const CIMObjectPathArray*>(&m_obj)));
03005             break;
03006          case CIMDataType::EMBEDDEDCLASS:
03007             writeObjectArray(ostrm, *(reinterpret_cast<const CIMClassArray*>(&m_obj)));
03008             break;
03009          case CIMDataType::EMBEDDEDINSTANCE:
03010             writeObjectArray(ostrm, *(reinterpret_cast<const CIMInstanceArray*>(&m_obj)));
03011             break;
03012          default:
03013             OW_ASSERT(0);
03014       }
03015    }
03016    else
03017    {
03018       switch (m_type)
03019       {
03020          case CIMDataType::BOOLEAN:
03021             writeValue(ostrm, m_obj.m_booleanValue, 0);
03022             break;
03023          case CIMDataType::UINT8:
03024             writeValue(ostrm, m_obj.m_uint8Value, 0);
03025             break;
03026          case CIMDataType::SINT8:
03027             writeValue(ostrm, m_obj.m_sint8Value, 0);
03028             break;
03029          case CIMDataType::UINT16:
03030             writeValue(ostrm, m_obj.m_uint16Value, 1);
03031             break;
03032          case CIMDataType::SINT16:
03033             writeValue(ostrm, m_obj.m_sint16Value, 1);
03034             break;
03035          case CIMDataType::UINT32:
03036             writeValue(ostrm, m_obj.m_uint32Value, 2);
03037             break;
03038          case CIMDataType::SINT32:
03039             writeValue(ostrm, m_obj.m_sint32Value, 2);
03040             break;
03041          case CIMDataType::UINT64:
03042             writeValue(ostrm, m_obj.m_uint64Value, 3);
03043             break;
03044          case CIMDataType::SINT64:
03045             writeValue(ostrm, m_obj.m_sint64Value, 3);
03046             break;
03047          case CIMDataType::REAL32:
03048             writeRealValue(ostrm, static_cast<Real64>(m_obj.m_real32Value));
03049             break;
03050          case CIMDataType::REAL64:
03051             writeRealValue(ostrm, m_obj.m_real64Value);
03052             break;
03053          case CIMDataType::CHAR16:
03054             (reinterpret_cast<const Char16*>(&m_obj))->writeObject(ostrm);
03055             break;
03056          case CIMDataType::STRING:
03057             (reinterpret_cast<const String*>(&m_obj))->writeObject(ostrm);
03058             break;
03059          case CIMDataType::DATETIME:
03060             (reinterpret_cast<const CIMDateTime*>(&m_obj))->writeObject(ostrm);
03061             break;
03062          case CIMDataType::REFERENCE:
03063             (reinterpret_cast<const CIMObjectPath*>(&m_obj))->writeObject(ostrm);
03064             break;
03065          case CIMDataType::EMBEDDEDCLASS:
03066             (reinterpret_cast<const CIMClass*>(&m_obj))->writeObject(ostrm);
03067             break;
03068          case CIMDataType::EMBEDDEDINSTANCE:
03069             (reinterpret_cast<const CIMInstance*>(&m_obj))->writeObject(ostrm);
03070             break;
03071          default:
03072             OW_ASSERT(0);
03073       }
03074    }
03075 }
03076 CIMValue::~CIMValue()
03077 {
03078 }
03079 
03080 } // end namespace OW_NAMESPACE
03081 

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