OW_CIMDateTime.hpp

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 #ifndef OW_CIMDATETIME_HPP_INCLUDE_GUARD_
00037 #define OW_CIMDATETIME_HPP_INCLUDE_GUARD_
00038 #include "OW_config.h"
00039 #include "OW_Types.hpp"
00040 #include "OW_COWIntrusiveReference.hpp"
00041 #include "OW_CIMException.hpp"
00042 #include "OW_CIMNULL.hpp"
00043 #include "OW_String.hpp"
00044 #include "OW_CommonFwd.hpp"
00045 
00046 namespace OW_NAMESPACE
00047 {
00048 
00049 OW_DECLARE_APIEXCEPTION(CIMDateTime, OW_COMMON_API);
00050 
00051 // TODO: Document valid ranges for values in the class and add asserts for them.
00052 
00113 class OW_COMMON_API CIMDateTime
00114 {
00115 public:
00116    struct DateTimeData;
00117    
00121    CIMDateTime();
00122    ~CIMDateTime();
00127    explicit CIMDateTime(CIMNULL_t);
00132    CIMDateTime(const CIMDateTime& arg);
00133    
00134    enum EErrorCodes
00135    {
00136       E_INVALID_DATE_TIME_FORMAT
00137    };
00138 
00148    explicit CIMDateTime(const String& arg);
00156    CIMDateTime(const DateTime& arg);
00162    explicit CIMDateTime(UInt64 microSeconds);
00169    CIMDateTime& operator= (const CIMDateTime& arg);
00174    UInt16 getYear() const;
00179    UInt8 getMonth() const;
00184    UInt32 getDays() const;
00189    UInt32 getDay() const;
00194    UInt8 getHours() const;
00200    UInt8 getMinutes() const;
00206    UInt8 getSeconds() const;
00212    UInt32 getMicroSeconds() const;
00217    Int16 getUtc() const;
00224    bool equal(const CIMDateTime& arg) const;
00230    CIMDateTime& setYear(UInt16 arg);
00236    CIMDateTime& setMonth(UInt8 arg);
00242    CIMDateTime& setDays(UInt32 arg);
00248    CIMDateTime& setDay(UInt32 arg);
00254    CIMDateTime& setHours(UInt8 arg);
00260    CIMDateTime& setMinutes(UInt8 arg);
00266    CIMDateTime& setSeconds(UInt8 arg);
00272    CIMDateTime& setMicroSeconds(UInt32 arg);
00278    CIMDateTime& setUtc(Int16 arg);
00283    bool isInterval() const;
00287    void setInterval(bool val);
00292    void readObject(std::istream &istrm);
00297    void writeObject(std::ostream &ostrm) const;
00302    String toString() const;
00306    DateTime toDateTime() const;
00307 
00308    typedef COWIntrusiveReference<DateTimeData> CIMDateTime::*safe_bool;
00312    operator safe_bool () const;
00313    bool operator!() const;
00314 private:
00315 
00316 #ifdef OW_WIN32
00317 #pragma warning (push)
00318 #pragma warning (disable: 4251)
00319 #endif
00320 
00321    COWIntrusiveReference<DateTimeData> m_dptr;
00322 
00323 #ifdef OW_WIN32
00324 #pragma warning (pop)
00325 #endif
00326 
00327    friend OW_COMMON_API bool operator==(const CIMDateTime& x, const CIMDateTime& y);
00334    friend OW_COMMON_API bool operator<(const CIMDateTime& x, const CIMDateTime& y);
00335 };
00336 OW_COMMON_API std::ostream& operator<< (std::ostream& ostr, const CIMDateTime& arg);
00337 
00338 bool operator!=(const CIMDateTime& x, const CIMDateTime& y);
00339 bool operator>(const CIMDateTime& x, const CIMDateTime& y);
00340 bool operator<=(const CIMDateTime& x, const CIMDateTime& y);
00341 bool operator>=(const CIMDateTime& x, const CIMDateTime& y);
00342 
00343 
00344 
00345 } // end namespace OW_NAMESPACE
00346 
00347 #endif

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