home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / wbemtime.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  5.5 KB  |  151 lines

  1. #pragma option push -b -a8 -pc -A- /*P_O_Push*/
  2. //***************************************************************************
  3. //
  4. //  Copyright (c) 1997-1999 Microsoft Corporation
  5. //
  6. //  wbemtime.h
  7. //
  8. //  Purpose: declares the WBEMTime and WBEMTimeSpan objects which are 
  9. //  similar to the MFC CTime and CTimeSpan objects.  The WBEM versions
  10. //  are capable of storing down to the nsec and also have functions for
  11. //  Creating from and getting BSTRs.
  12. //
  13. //  Note; The current implementation of WBEMTime does not support dates 
  14. //  before 1601;
  15. //
  16. //***************************************************************************
  17.  
  18. #if _MSC_VER > 1000
  19. #pragma once
  20. #endif
  21.  
  22. #ifndef WBEMTIME_HEADERFILE_IS_INCLUDED
  23. #define WBEMTIME_HEADERFILE_IS_INCLUDED
  24.  
  25. #define INVALID_TIME 0xffffffffffffffff
  26.  
  27. #include <polarity.h>
  28. #include <time.h>
  29. #pragma warning( disable : 4290 ) // Ignore 'C++ Exception Specification ignored'
  30. #include <ProvExce.h>
  31.  
  32. ///////////////////////////////////////////////////////////////////////////
  33. // WBEMTimeSpan - This class holds time span values. 
  34.  
  35. class POLARITY WBEMTimeSpan 
  36. {
  37. private:
  38.  
  39.     ULONGLONG m_Time;
  40.     friend class WBEMTime;
  41.  
  42. public:
  43.  
  44.     WBEMTimeSpan ()                                                { m_Time = INVALID_TIME ; }
  45.     WBEMTimeSpan ( const BSTR bstrDMTFFormat )                    { *this = bstrDMTFFormat ; }
  46.  
  47.     WBEMTimeSpan ( 
  48.  
  49.         int iDays , 
  50.         int iHours , 
  51.         int iMinutes ,  
  52.         int iSeconds , 
  53.         int iMSec=0 , 
  54.         int iUSec=0, 
  55.         int iNSec=0 
  56.     ) ;
  57.  
  58.     WBEMTimeSpan operator+ (const WBEMTimeSpan &uAdd ) const ;
  59.     const WBEMTimeSpan &operator+= ( const WBEMTimeSpan &uAdd ) ;
  60.  
  61.     WBEMTimeSpan operator- (const WBEMTimeSpan &uSub ) const ;
  62.     const WBEMTimeSpan &operator-= ( const WBEMTimeSpan &uSub ) ;
  63.  
  64.     const WBEMTimeSpan &operator= ( const BSTR pDMTFFormat ) ; 
  65.  
  66.     BOOL operator== ( const WBEMTimeSpan &a ) const                { return m_Time == a.m_Time ; }
  67.     BOOL operator!= ( const WBEMTimeSpan &a ) const                { return m_Time != a.m_Time ; }
  68.     BOOL operator<  ( const WBEMTimeSpan &a ) const                { return m_Time < a.m_Time ; }
  69.     BOOL operator<= ( const WBEMTimeSpan &a ) const                { return m_Time <= a.m_Time ; }
  70.     BOOL operator>  ( const WBEMTimeSpan &a ) const                { return m_Time > a.m_Time ; }
  71.     BOOL operator>= ( const WBEMTimeSpan &a ) const                { return m_Time >= a.m_Time ; }
  72.  
  73.     BSTR GetBSTR ( void ) const throw ( CHeap_Exception ) ;
  74.  
  75.     bool IsOk () const                                            { return m_Time != INVALID_TIME ? true : false; }
  76.     ULONGLONG GetTime () const                                    { return m_Time ; }
  77.     void Clear ( void )                                            { m_Time = INVALID_TIME ; }
  78.     
  79.     // These are all deprecated
  80.     WBEMTimeSpan ( const FILETIME &ft )    ;
  81.     WBEMTimeSpan ( const time_t & t ) ;
  82.     const WBEMTimeSpan &operator= ( const FILETIME &ft ) ;
  83.     const WBEMTimeSpan &operator= ( const time_t &t ) ;
  84.     BOOL Gettime_t ( time_t *ptime_t ) const ;
  85.     BOOL GetFILETIME ( FILETIME *pst ) const ;
  86.  
  87. };
  88.  
  89. ///////////////////////////////////////////////////////////////////////////
  90. // WBEMTime - This class holds time values. 
  91.  
  92. class POLARITY WBEMTime 
  93. {
  94. public:
  95.  
  96.     WBEMTime ()                                                    { m_uTime = INVALID_TIME ; }
  97.     WBEMTime ( const BSTR bstrDMTFFormat )                        { *this = bstrDMTFFormat ; }
  98.     WBEMTime ( const SYSTEMTIME &st )                            { *this = st ; }
  99.     WBEMTime ( const FILETIME &ft )                                { *this = ft ; }
  100.     WBEMTime ( const struct tm &tmin )                            { *this = tmin ; }
  101.     WBEMTime ( const time_t &t )                                { *this = t ; }
  102.  
  103.     WBEMTime        operator+ ( const WBEMTimeSpan &uAdd ) const ;
  104.     const WBEMTime &operator+=( const WBEMTimeSpan &ts ) ;
  105.  
  106.     WBEMTimeSpan    operator- ( const WBEMTime &sub ) ;
  107.  
  108.     WBEMTime        operator- ( const WBEMTimeSpan &sub ) const;
  109.     const WBEMTime &operator-=( const WBEMTimeSpan &sub );
  110.  
  111.     const WBEMTime &operator= ( const BSTR bstrDMTFFormat ) ; 
  112.     const WBEMTime &operator= ( const SYSTEMTIME &st ) ;
  113.     const WBEMTime &operator= ( const FILETIME &ft ) ;
  114.     const WBEMTime &operator= ( const struct tm &tmin ) ;
  115.     const WBEMTime &operator= ( const time_t & t) ;
  116.  
  117.     BOOL operator== ( const WBEMTime &a ) const                    { return m_uTime == a.m_uTime ; }
  118.     BOOL operator!= ( const WBEMTime &a ) const                    { return m_uTime != a.m_uTime ; }
  119.     BOOL operator<  ( const WBEMTime &a ) const                    { return m_uTime < a.m_uTime ; }
  120.     BOOL operator<= ( const WBEMTime &a ) const                    { return m_uTime <= a.m_uTime ; }
  121.     BOOL operator>  ( const WBEMTime &a ) const                    { return m_uTime > a.m_uTime ; }
  122.     BOOL operator>= ( const WBEMTime &a ) const                    { return m_uTime >= a.m_uTime ; }
  123.  
  124.     BSTR GetBSTR ( void ) const throw ( CHeap_Exception ) ;
  125.     BOOL GetStructtm (struct tm *ptm ) const;
  126.     BOOL Gettime_t ( time_t *ptime_t ) const;
  127.     BOOL GetSYSTEMTIME ( SYSTEMTIME *pst ) const;
  128.     BOOL GetFILETIME ( FILETIME *pst ) const;
  129.  
  130.     BOOL SetDMTF ( const BSTR wszText ) ;
  131.     BSTR GetDMTF ( BOOL bLocal = FALSE ) const throw ( CHeap_Exception ) ;
  132.  
  133.     BSTR GetDMTFNonNtfs(void) const ;
  134.  
  135.     void Clear ( void )                                            { m_uTime = INVALID_TIME ; }
  136.  
  137.     bool IsOk () const                                            { return m_uTime != INVALID_TIME ? true : false; }
  138.     ULONGLONG GetTime () const                                    { return m_uTime ; }
  139.  
  140.     static LONG WINAPI GetLocalOffsetForDate(const struct tm *tmin);
  141.     static LONG WINAPI GetLocalOffsetForDate(const SYSTEMTIME *pst);
  142.     static LONG WINAPI GetLocalOffsetForDate(const FILETIME *pft);
  143.     static LONG WINAPI GetLocalOffsetForDate(const time_t &t);
  144.  
  145. private:
  146.     ULONGLONG m_uTime;
  147. };
  148.  
  149. #endif
  150. #pragma option pop /*P_O_Pop*/
  151.