00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __ASN1CTIME_H__
00026 #define __ASN1CTIME_H__
00027
00028 #ifndef _WIN32_WCE
00029 #include <time.h>
00030 #endif
00031 #include "rtsrc/asn1CppTypes.h"
00032 #include "rtsrc/ASN1TTime.h"
00033
00051
00052
00053
00054
00055
00056
00057
00058
00059 #ifndef _NO_UTILS_CLASSES
00060
00072 #define LOG_TMERR(pctxt,stat) ((pctxt != 0) ? LOG_RTERR (pctxt, stat) : stat)
00073
00086 class EXTRTCLASS ASN1CTime : public ASN1CType {
00087 protected:
00088 OSBOOL parsed;
00089 OSBOOL derRules;
00090
00091 char*& timeStr;
00092 int strSize;
00093
00094 EXTRTMETHOD void checkCapacity();
00095
00096
00097
00098
00099 EXTRTMETHOD char*& getTimeStringPtr ();
00100
00101 virtual ASN1TTime& getTimeObj () = 0;
00102 virtual const ASN1TTime& getTimeObj () const = 0;
00103
00104 EXTRTMETHOD ASN1CTime(char*& buf, int bufSize, OSBOOL useDerRules);
00105 EXTRTMETHOD ASN1CTime(ASN1VisibleString& buf, OSBOOL useDerRules);
00106 private:
00107 char timeStrBuf[MAX_TIMESTR_SIZE];
00108 char* pTimeStr;
00109
00110 EXTRTMETHOD void privateInit ();
00111
00112 public:
00113 enum {
00114 January = 1, Jan = 1,
00115 February = 2, Feb = 2,
00116 March = 3, Mar = 3,
00117 April = 4, Apr = 4,
00118 May = 5,
00119 June = 6, Jun = 6,
00120 July = 7, Jul = 7,
00121 August = 8, Aug = 8,
00122 September = 9, Sep = 9,
00123 October = 10, Oct = 10,
00124 November = 11, Nov = 11,
00125 December = 12, Dec = 12
00126 };
00127
00142 EXTRTMETHOD ASN1CTime (OSRTMessageBufferIF& msgBuf, char*& buf, int bufSize,
00143 OSBOOL useDerRules);
00144
00160 EXTRTMETHOD ASN1CTime (OSRTMessageBufferIF& msgBuf, ASN1VisibleString& buf,
00161 OSBOOL useDerRules);
00162
00163
00177 EXTRTMETHOD ASN1CTime (OSRTContext& ctxt, char*& buf, int bufSize,
00178 OSBOOL useDerRules);
00179
00192 EXTRTMETHOD ASN1CTime (OSRTContext& ctxt, ASN1VisibleString& buf,
00193 OSBOOL useDerRules);
00194
00201 EXTRTMETHOD ASN1CTime (const ASN1CTime& original);
00202
00206 EXTRTMETHOD ~ASN1CTime();
00207
00219 virtual EXTRTMETHOD int getYear();
00220
00235 virtual EXTRTMETHOD int getMonth();
00236
00249 virtual EXTRTMETHOD int getDay();
00250
00263 virtual EXTRTMETHOD int getHour();
00264
00276 virtual EXTRTMETHOD int getMinute();
00277
00289 virtual EXTRTMETHOD int getSecond();
00290
00303 virtual EXTRTMETHOD int getFraction();
00304
00316 virtual EXTRTMETHOD double getFractionAsDouble();
00317
00327 virtual EXTRTMETHOD int getFractionStr(char* const pBuf, size_t bufSize);
00328
00337 virtual EXTRTMETHOD int getFractionLen();
00338
00354 virtual EXTRTMETHOD int getDiffHour();
00355
00371 virtual EXTRTMETHOD int getDiffMinute();
00372
00388 virtual EXTRTMETHOD int getDiff();
00389
00399 virtual EXTRTMETHOD OSBOOL getUTC();
00400
00417 virtual EXTRTMETHOD time_t getTime();
00418
00423 void setDER (OSBOOL bvalue) { derRules = bvalue; }
00424
00436 virtual EXTRTMETHOD int setUTC(OSBOOL utc);
00437
00449 virtual EXTRTMETHOD int setYear(short year_);
00450
00465 virtual EXTRTMETHOD int setMonth(short month_);
00466
00479 virtual EXTRTMETHOD int setDay(short day_);
00480
00493 virtual EXTRTMETHOD int setHour(short hour_);
00494
00506 virtual EXTRTMETHOD int setMinute(short minute_);
00507
00519 virtual EXTRTMETHOD int setSecond(short second_);
00520
00536 virtual EXTRTMETHOD int setFraction(int fraction, int fracLen = -1);
00537
00549 virtual EXTRTMETHOD int setFraction (double frac, int fracLen);
00550
00560 virtual EXTRTMETHOD int setFraction (char const* frac);
00561
00578 virtual int setTime(time_t time, OSBOOL diffTime) = 0;
00579
00597 virtual EXTRTMETHOD int setDiffHour(short dhour);
00598
00617 virtual EXTRTMETHOD int setDiff(short dhour, short dminute);
00618
00635 virtual EXTRTMETHOD int setDiff(short inMinutes);
00636
00649 virtual EXTRTMETHOD int parseString(const char* string);
00650
00660 virtual EXTRTMETHOD void clear();
00661
00666 virtual EXTRTMETHOD int equals (ASN1CTime&);
00667
00673 EXTRTMETHOD size_t getTimeStringLen ();
00674
00683 EXTRTMETHOD const char* getTimeString (char* pbuf, size_t bufsize);
00684
00691 EXTRTMETHOD const ASN1CTime& operator = (const ASN1CTime& );
00692
00698 virtual EXTRTMETHOD OSBOOL operator == (ASN1CTime&);
00699
00705 virtual EXTRTMETHOD OSBOOL operator != (ASN1CTime&);
00706
00712 virtual EXTRTMETHOD OSBOOL operator > (ASN1CTime&);
00713
00719 virtual EXTRTMETHOD OSBOOL operator < (ASN1CTime&);
00720
00726 virtual EXTRTMETHOD OSBOOL operator >= (ASN1CTime&);
00727
00733 virtual EXTRTMETHOD OSBOOL operator <= (ASN1CTime&);
00734
00735 protected:
00741 virtual int compileString() = 0;
00742
00743 } ;
00744
00745 #else
00746 typedef class _ASN1CTime : public ASN1CType {
00747 protected:
00748 _ASN1CTime(char*& buf, int bufSize, OSBOOL useDerRules) {}
00749 _ASN1CTime(ASN1VisibleString& buf, OSBOOL useDerRules) {}
00750 public:
00751 _ASN1CTime (OSRTMessageBufferIF& msgBuf, char*& , int, OSBOOL) :
00752 ASN1CType (msgBuf) {}
00753 _ASN1CTime (OSRTMessageBufferIF& msgBuf, ASN1VisibleString&, OSBOOL) :
00754 ASN1CType (msgBuf) {}
00755 _ASN1CTime(OSRTContext& ctxt, char*& buf, int bufSize,
00756 OSBOOL useDerRules) : ASN1CType (ctxt) {}
00757 _ASN1CTime(OSRTContext& ctxt, ASN1VisibleString& buf,
00758 OSBOOL useDerRules) : ASN1CType (ctxt) {}
00759 } ASN1CTime;
00760
00761 #endif // _NO_UTILS_CLASSES
00762
00770 #endif //__ASN1CTIME_H__
00771