OWBI1_CIMDataType.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 "OWBI1_config.h"
00037 #include "OWBI1_CIMDataType.hpp"
00038 #include "OWBI1_CIMDataTypeRep.hpp"
00039 #include "OWBI1_CIMValue.hpp"
00040 #include "OWBI1_CIMValueRep.hpp"
00041 #include "OWBI1_CIMName.hpp"
00042 #include "OWBI1_CIMNameRep.hpp"
00043 
00044 namespace OWBI1
00045 {
00046 using namespace detail;
00047 using std::istream;
00048 using std::ostream;
00049 
00051 CIMDataType::CIMDataType() :
00052    CIMBase(), m_rep(new CIMDataTypeRep(OpenWBEM::CIMDataType()))
00053 {
00054 }
00056 CIMDataType::CIMDataType(CIMNULL_t) :
00057    CIMBase(), m_rep(new CIMDataTypeRep(OpenWBEM::CIMDataType(OpenWBEM::CIMNULL)))
00058 {
00059 }
00061 CIMDataType::CIMDataType(CIMDataType::Type type) :
00062    CIMBase(), m_rep(new CIMDataTypeRep(OpenWBEM::CIMDataType(OpenWBEM::CIMDataType::Type(type))))
00063 {
00064 }
00066 CIMDataType::CIMDataType(CIMDataType::Type type, Int32 size) :
00067    CIMBase(), m_rep(new CIMDataTypeRep(OpenWBEM::CIMDataType(OpenWBEM::CIMDataType::Type(type), size)))
00068 {
00069 }
00071 CIMDataType::CIMDataType(const CIMDataType& arg) :
00072    CIMBase(), m_rep(arg.m_rep) {}
00073 
00075 CIMDataType::CIMDataType(const CIMDataTypeRepRef& rep)
00076    : m_rep(rep)
00077 {
00078 }
00079 
00081 CIMDataType::~CIMDataType()
00082 {
00083 }
00085 void
00086 CIMDataType::setNull()
00087 {
00088    m_rep->datatype.setNull();
00089 }
00091 CIMDataType&
00092 CIMDataType::operator = (const CIMDataType& arg)
00093 {
00094    m_rep = arg.m_rep;
00095    return *this;
00096 }
00098 bool
00099 CIMDataType::isArrayType() const
00100 {
00101    return m_rep->datatype.isArrayType();
00102 }
00104 bool
00105 CIMDataType::isNumericType() const
00106 {
00107    return m_rep->datatype.isNumericType();
00108 }
00110 // STATIC
00111 bool
00112 CIMDataType::isNumericType(CIMDataType::Type type)
00113 {
00114    return OpenWBEM::CIMDataType::isNumericType(OpenWBEM::CIMDataType::Type(type));
00115 }
00117 bool
00118 CIMDataType::isReferenceType() const
00119 {
00120    return m_rep->datatype.isReferenceType();
00121 }
00123 CIMDataType::Type
00124 CIMDataType::getType() const
00125 {
00126    return CIMDataType::Type(m_rep->datatype.getType());
00127 }
00129 Int32
00130 CIMDataType::getSize() const
00131 {
00132    return m_rep->datatype.getSize();
00133 }
00135 String
00136 CIMDataType::getRefClassName() const
00137 {
00138    return m_rep->datatype.getRefClassName().c_str();
00139 }
00141 CIMDataType::operator CIMDataType::safe_bool () const
00142 {
00143    return m_rep->datatype ? &CIMDataType::m_rep : 0;
00144 }
00146 bool
00147 CIMDataType::operator!() const
00148 {
00149    return !m_rep->datatype;
00150 }
00152 bool
00153 CIMDataType::setToArrayType(Int32 size)
00154 {
00155    return m_rep->datatype.setToArrayType(size);
00156 }
00158 bool
00159 CIMDataType::syncWithValue(const CIMValue& value)
00160 {
00161    return m_rep->datatype.syncWithValue(value.getRep()->value);
00162 }
00164 CIMDataType::CIMDataType(const CIMName& refClassName) 
00165    : m_rep(new CIMDataTypeRep(OpenWBEM::CIMDataType(refClassName.getRep()->name)))
00166 {
00167 }
00169 bool
00170 CIMDataType::equals(const CIMDataType& arg) const
00171 {
00172    return m_rep->datatype.equals(arg.m_rep->datatype);
00173 }
00175 void
00176 CIMDataType::readObject(istream &istrm)
00177 {
00178    m_rep->datatype.readObject(istrm);
00179 }
00181 void
00182 CIMDataType::writeObject(ostream &ostrm) const
00183 {
00184    m_rep->datatype.writeObject(ostrm);
00185 }
00187 String
00188 CIMDataType::toString() const
00189 {
00190    return m_rep->datatype.toString().c_str();
00191 }
00193 String
00194 CIMDataType::toMOF() const
00195 {
00196    return m_rep->datatype.toMOF().c_str();
00197 }
00198 
00200 String
00201 CIMDataType::getArrayMOF() const
00202 {
00203    return m_rep->datatype.getArrayMOF().c_str();
00204 }
00206 // STATIC
00207 CIMDataType::Type
00208 CIMDataType::strToSimpleType(const String& strType)
00209 {
00210    return CIMDataType::Type(OpenWBEM::CIMDataType::strToSimpleType(strType.c_str()));
00211 }
00213 // STATIC
00214 CIMDataType
00215 CIMDataType::getDataType(const String& strType)
00216 {
00217    return CIMDataType(new CIMDataTypeRep(OpenWBEM::CIMDataType::getDataType(strType.c_str())));
00218 }
00219 
00221 CIMDataTypeRepRef
00222 CIMDataType::getRep() const
00223 {
00224    return m_rep;
00225 }
00226 
00228 bool operator<(const CIMDataType& x, const CIMDataType& y)
00229 {
00230    return *x.m_rep < *y.m_rep;
00231 }
00232 
00234 bool operator==(const CIMDataType& x, const CIMDataType& y)
00235 {
00236    return *x.m_rep == *y.m_rep;
00237 }
00238 
00240 bool operator<=(const CIMDataType& x, const CIMDataType& y)
00241 {
00242     return !(y < x);
00243 }
00244 
00246 bool operator>(const CIMDataType& x, const CIMDataType& y)
00247 {
00248     return y < x;
00249 }
00250 
00252 bool operator>=(const CIMDataType& x, const CIMDataType& y)
00253 {
00254     return !(x < y);
00255 }
00256 
00258 bool operator!=(const CIMDataType& x, const CIMDataType& y)
00259 {
00260    return !(x == y);
00261 }
00262 
00263 } // end namespace OWBI1
00264 

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