OWBI1_CIMDateTime.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_CIMDateTime.hpp"
00038 #include "OWBI1_CIMDateTimeRep.hpp"
00039 #include "OW_ExceptionIds.hpp"
00040 #include "OWBI1_DateTime.hpp"
00041 #include "OWBI1_DateTimeRep.hpp"
00042 
00043 #include <cstdio>
00044 #if defined(OWBI1_HAVE_ISTREAM) && defined(OWBI1_HAVE_OSTREAM)
00045 #include <istream>
00046 #include <ostream>
00047 #else
00048 #include <iostream>
00049 #endif
00050 
00051 namespace OWBI1
00052 {
00053 using std::ostream;
00054 using std::istream;
00055 using namespace detail;
00056 
00057 OWBI1_DEFINE_EXCEPTION_WITH_ID(CIMDateTime);
00058 
00060 CIMDateTime::CIMDateTime()
00061    : m_rep(new CIMDateTimeRep(OpenWBEM::CIMDateTime()))
00062 {
00063 }
00065 CIMDateTime::~CIMDateTime()
00066 {
00067 }
00069 CIMDateTime::CIMDateTime(CIMNULL_t)
00070    : m_rep(new CIMDateTimeRep(OpenWBEM::CIMDateTime(OpenWBEM::CIMNULL)))
00071 {
00072 }
00074 CIMDateTime::CIMDateTime(const CIMDateTime& arg)
00075    : m_rep(arg.m_rep)
00076 {
00077 }
00079 CIMDateTime::CIMDateTime(const String& arg) :
00080    m_rep(new CIMDateTimeRep(OpenWBEM::CIMDateTime(arg.c_str())))
00081 {
00082 }
00084 CIMDateTime::CIMDateTime(const DateTime& arg) :
00085    m_rep(new CIMDateTimeRep(OpenWBEM::CIMDateTime(arg.getRep()->datetime)))
00086 {
00087 }
00089 CIMDateTime::CIMDateTime(UInt64 microSeconds) :
00090    m_rep(new CIMDateTimeRep(OpenWBEM::CIMDateTime(microSeconds)))
00091 {
00092 }
00093 
00095 CIMDateTime::CIMDateTime(const CIMDateTimeRepRef& rep)
00096    : m_rep(rep)
00097 {
00098 }
00099 
00101 CIMDateTime&
00102 CIMDateTime::operator= (const CIMDateTime& arg)
00103 {
00104    m_rep = arg.m_rep;
00105    return *this;
00106 }
00108 CIMDateTime::operator CIMDateTime::safe_bool() const
00109 {
00110    return (m_rep->datetime) ?
00111       &CIMDateTime::m_rep : 0;
00112 }
00114 bool
00115 CIMDateTime::operator !() const
00116 {
00117    return (!m_rep->datetime);
00118 }
00120 CIMDateTime&
00121 CIMDateTime::setYear(UInt16 arg)
00122 {
00123    m_rep->datetime.setYear(arg);
00124    return *this;
00125 }
00127 CIMDateTime&
00128 CIMDateTime::setMonth(UInt8 arg)
00129 {
00130    m_rep->datetime.setMonth(arg);
00131    return *this;
00132 }
00134 CIMDateTime&
00135 CIMDateTime::setDays(UInt32 arg)
00136 {
00137    m_rep->datetime.setDays(arg);
00138    return *this;
00139 }
00141 CIMDateTime&
00142 CIMDateTime::setDay(UInt32 arg)
00143 {
00144    m_rep->datetime.setDay(arg);
00145    return *this;
00146 }
00148 CIMDateTime&
00149 CIMDateTime::setHours(UInt8 arg)
00150 {
00151    m_rep->datetime.setHours(arg);
00152    return *this;
00153 }
00155 CIMDateTime&
00156 CIMDateTime::setMinutes(UInt8 arg)
00157 {
00158    m_rep->datetime.setMinutes(arg);
00159    return *this;
00160 }
00162 CIMDateTime&
00163 CIMDateTime::setSeconds(UInt8 arg)
00164 {
00165    m_rep->datetime.setSeconds(arg);
00166    return *this;
00167 }
00169 CIMDateTime&
00170 CIMDateTime::setMicroSeconds(UInt32 arg)
00171 {
00172    m_rep->datetime.setMicroSeconds(arg);
00173    return *this;
00174 }
00176 CIMDateTime&
00177 CIMDateTime::setUtc(Int16 arg)
00178 {
00179    m_rep->datetime.setUtc(arg);
00180    return *this;
00181 }
00183 bool
00184 CIMDateTime::equal(const CIMDateTime& arg) const
00185 {
00186    return m_rep->datetime.equal(arg.m_rep->datetime);
00187 }
00189 void
00190 CIMDateTime::readObject(istream &istrm)
00191 {
00192    m_rep->datetime.readObject(istrm);
00193 }
00195 void
00196 CIMDateTime::writeObject(ostream &ostrm) const
00197 {
00198    m_rep->datetime.writeObject(ostrm);
00199 }
00201 String
00202 CIMDateTime::toString() const
00203 {
00204    return m_rep->datetime.toString().c_str();
00205 }
00207 DateTime
00208 CIMDateTime::toDateTime() const
00209 {
00210    return DateTime(toString());
00211 }
00213 ostream&
00214 operator<< (ostream& ostr, const CIMDateTime& arg)
00215 {
00216    ostr << arg.toString();
00217    return ostr;
00218 }
00219 
00221 UInt16
00222 CIMDateTime::getYear() const {  return m_rep->datetime.getYear(); }
00224 UInt8
00225 CIMDateTime::getMonth() const {  return m_rep->datetime.getMonth(); }
00227 UInt32
00228 CIMDateTime::getDays() const {  return m_rep->datetime.getDays(); }
00230 UInt32
00231 CIMDateTime::getDay() const {  return m_rep->datetime.getDay(); }
00233 UInt8
00234 CIMDateTime::getHours() const {  return m_rep->datetime.getHours(); }
00236 UInt8
00237 CIMDateTime::getMinutes() const {  return m_rep->datetime.getMinutes(); }
00239 UInt8
00240 CIMDateTime::getSeconds() const {  return m_rep->datetime.getSeconds(); }
00242 UInt32
00243 CIMDateTime::getMicroSeconds() const {  return m_rep->datetime.getMicroSeconds(); }
00245 Int16
00246 CIMDateTime::getUtc() const {  return m_rep->datetime.getUtc(); }
00248 bool
00249 CIMDateTime::isInterval() const {  return m_rep->datetime.isInterval();}
00251 void
00252 CIMDateTime::setInterval(bool val) { m_rep->datetime.setInterval(val); }
00253 
00255 CIMDateTimeRepRef
00256 CIMDateTime::getRep() const
00257 {
00258    return m_rep;
00259 }
00260 
00262 bool operator==(const CIMDateTime& x, const CIMDateTime& y)
00263 {
00264    return x.equal(y);
00265 }
00267 bool operator<(const CIMDateTime& x, const CIMDateTime& y)
00268 {
00269    return x.m_rep->datetime < y.m_rep->datetime;
00270 }
00271 
00273 bool operator!=(const CIMDateTime& x, const CIMDateTime& y)
00274 {
00275    return !(x == y);
00276 }
00277 
00279 bool operator>(const CIMDateTime& x, const CIMDateTime& y)
00280 {
00281    return y < x;
00282 }
00283 
00285 bool operator<=(const CIMDateTime& x, const CIMDateTime& y)
00286 {
00287    return !(y < x);
00288 }
00289 
00291 bool operator>=(const CIMDateTime& x, const CIMDateTime& y)
00292 {
00293    return !(x < y);
00294 }
00295 
00296 } // end namespace OWBI1
00297 

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