OWBI1_CIMName.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 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 
00035 #include "OWBI1_config.h"
00036 #include "OWBI1_String.hpp"
00037 #include "OWBI1_CIMName.hpp"
00038 #include "OWBI1_CIMNameRep.hpp"
00039 #if defined(OWBI1_HAVE_OSTREAM)
00040 #include <ostream>
00041 #else
00042 #include <iostream>
00043 #endif
00044 /* #endif defined(OWBI1_HAVE_OSTREAM)*/
00045 
00046 namespace OWBI1
00047 {
00048 
00049 using namespace detail;
00050 
00052 CIMName::CIMName()
00053    : m_rep(new CIMNameRep(OpenWBEM::CIMName()))
00054 {
00055 }
00056 
00058 CIMName::CIMName(const String& name)
00059    : m_rep(new CIMNameRep(name.c_str()))
00060 {
00061 }
00062    
00064 CIMName::CIMName(const char* name)
00065    : m_rep(new CIMNameRep(name))
00066 {
00067 }
00068    
00070 CIMName::CIMName(const CIMName& name)
00071    : SerializableIFC(name)
00072    , m_rep(name.m_rep)
00073 {
00074 }
00075    
00077 CIMName::~CIMName()
00078 {
00079 }
00080 
00082 CIMName&
00083 CIMName::operator=(const String& name)
00084 {
00085    m_rep = new CIMNameRep(name.c_str());
00086    return *this;
00087 }
00088 
00090 CIMName&
00091 CIMName::operator=(const char* name)
00092 {
00093    m_rep = new CIMNameRep(name);
00094    return *this;
00095 }
00096 
00098 CIMName&
00099 CIMName::operator=(const CIMName& other)
00100 {
00101    m_rep = other.m_rep;
00102    return *this;
00103 }
00104 
00106 String
00107 CIMName::toString() const
00108 {
00109    return m_rep->name.toString().c_str();
00110 }
00111 
00113 const char*
00114 CIMName::c_str() const
00115 {
00116    return m_rep->name.toString().c_str();
00117 }
00118 
00120 void
00121 CIMName::readObject(std::istream &istrm)
00122 {
00123    m_rep->name.readObject(istrm);
00124 }
00126 void
00127 CIMName::writeObject(std::ostream &ostrm) const
00128 {
00129    m_rep->name.writeObject(ostrm);
00130 }
00131 
00133 bool 
00134 CIMName::isValid() const
00135 {
00136    return m_rep->name.isValid();
00137 }
00138 
00140 CIMName::operator CIMName::safe_bool () const
00141 {
00142    return isValid() ? &CIMName::m_rep : 0;
00143 }
00144    
00146 bool
00147 CIMName::operator!() const
00148 {
00149    return !isValid();
00150 }
00151 
00153 detail::CIMNameRepRef
00154 CIMName::getRep() const
00155 {
00156    return m_rep;
00157 }
00158 
00160 bool operator<(const CIMName& x, const CIMName& y)
00161 {
00162    return x.m_rep->name < y.m_rep->name;
00163 }
00164 
00166 bool operator==(const CIMName& x, const CIMName& y)
00167 {
00168    return x.m_rep->name == y.m_rep->name;
00169 }
00170 
00172 bool operator<=(const CIMName& x, const CIMName& y)
00173 {
00174     return !(y < x);
00175 }
00176 
00178 bool operator>(const CIMName& x, const CIMName& y)
00179 {
00180     return y < x;
00181 }
00182 
00184 bool operator>=(const CIMName& x, const CIMName& y)
00185 {
00186     return !(x < y);
00187 }
00188 
00190 bool operator!=(const CIMName& x, const CIMName& y)
00191 {
00192    return !(x == y);
00193 }
00194 
00196 std::ostream& operator<<(std::ostream& ostr, const CIMName& name)
00197 {
00198    ostr << name.toString();
00199    return ostr;
00200 }
00201 
00202 } // end namespace OWBI1
00203 
00204 
00205 
00206 
00207 

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