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
00061 #define LOG_TMERR(pctxt,stat) ((pctxt != 0) ? LOG_RTERR (pctxt, stat) : stat)
00062
00075 class EXTRTCLASS ASN1CTime : public ASN1CType {
00076 protected:
00077 OSBOOL parsed;
00078 OSBOOL derRules;
00079
00080 char*& timeStr;
00081 int strSize;
00082
00083 EXTRTMETHOD void checkCapacity();
00084
00085
00086
00087
00088 EXTRTMETHOD char*& getTimeStringPtr ();
00089
00090 virtual ASN1TTime& getTimeObj () = 0;
00091 virtual const ASN1TTime& getTimeObj () const = 0;
00092
00093 EXTRTMETHOD ASN1CTime(char*& buf, int bufSize, OSBOOL useDerRules);
00094 EXTRTMETHOD ASN1CTime(ASN1VisibleString& buf, OSBOOL useDerRules);
00095 private:
00096 char timeStrBuf[MAX_TIMESTR_SIZE];
00097 char* pTimeStr;
00098
00099 EXTRTMETHOD void privateInit ();
00100
00101 public:
00102 enum {
00103 January = 1, Jan = 1,
00104 February = 2, Feb = 2,
00105 March = 3, Mar = 3,
00106 April = 4, Apr = 4,
00107 May = 5,
00108 June = 6, Jun = 6,
00109 July = 7, Jul = 7,
00110 August = 8, Aug = 8,
00111 September = 9, Sep = 9,
00112 October = 10, Oct = 10,
00113 November = 11, Nov = 11,
00114 December = 12, Dec = 12
00115 };
00116
00131 EXTRTMETHOD ASN1CTime (OSRTMessageBufferIF& msgBuf, char*& buf, int bufSize,
00132 OSBOOL useDerRules);
00133
00149 EXTRTMETHOD ASN1CTime (OSRTMessageBufferIF& msgBuf, ASN1VisibleString& buf,
00150 OSBOOL useDerRules);
00151
00152 EXTRTMETHOD ASN1CTime (OSRTContext& ctxt, char*& buf, int bufSize,
00153 OSBOOL useDerRules);
00154
00155 EXTRTMETHOD ASN1CTime (OSRTContext& ctxt, ASN1VisibleString& buf,
00156 OSBOOL useDerRules);
00157
00164 EXTRTMETHOD ASN1CTime (const ASN1CTime& original);
00165
00166 EXTRTMETHOD ~ASN1CTime();
00167
00179 virtual EXTRTMETHOD int getYear();
00180
00195 virtual EXTRTMETHOD int getMonth();
00196
00209 virtual EXTRTMETHOD int getDay();
00210
00223 virtual EXTRTMETHOD int getHour();
00224
00236 virtual EXTRTMETHOD int getMinute();
00237
00249 virtual EXTRTMETHOD int getSecond();
00250
00263 virtual EXTRTMETHOD int getFraction();
00264
00276 virtual EXTRTMETHOD double getFractionAsDouble();
00277
00287 virtual EXTRTMETHOD int getFractionStr(char* const pBuf, size_t bufSize);
00288
00297 virtual EXTRTMETHOD int getFractionLen();
00298
00314 virtual EXTRTMETHOD int getDiffHour();
00315
00331 virtual EXTRTMETHOD int getDiffMinute();
00332
00348 virtual EXTRTMETHOD int getDiff();
00349
00359 virtual EXTRTMETHOD OSBOOL getUTC();
00360
00377 virtual EXTRTMETHOD time_t getTime();
00378
00383 void setDER (OSBOOL bvalue) { derRules = bvalue; }
00384
00396 virtual EXTRTMETHOD int setUTC(OSBOOL utc);
00397
00409 virtual EXTRTMETHOD int setYear(short year_);
00410
00425 virtual EXTRTMETHOD int setMonth(short month_);
00426
00439 virtual EXTRTMETHOD int setDay(short day_);
00440
00453 virtual EXTRTMETHOD int setHour(short hour_);
00454
00466 virtual EXTRTMETHOD int setMinute(short minute_);
00467
00479 virtual EXTRTMETHOD int setSecond(short second_);
00480
00496 virtual EXTRTMETHOD int setFraction(int fraction, int fracLen = -1);
00497
00509 virtual EXTRTMETHOD int setFraction (double frac, int fracLen);
00510
00520 virtual EXTRTMETHOD int setFraction (char const* frac);
00521
00538 virtual int setTime(time_t time, OSBOOL diffTime) = 0;
00539
00557 virtual EXTRTMETHOD int setDiffHour(short dhour);
00558
00577 virtual EXTRTMETHOD int setDiff(short dhour, short dminute);
00578
00595 virtual EXTRTMETHOD int setDiff(short inMinutes);
00596
00609 virtual EXTRTMETHOD int parseString(const char* string);
00610
00620 virtual EXTRTMETHOD void clear();
00621
00626 virtual EXTRTMETHOD int equals (ASN1CTime&);
00627
00628
00629 EXTRTMETHOD size_t getTimeStringLen ();
00630
00631
00632 EXTRTMETHOD const char* getTimeString (char* pbuf, size_t bufsize);
00633
00634 EXTRTMETHOD const ASN1CTime& operator = (const ASN1CTime& );
00635 virtual EXTRTMETHOD OSBOOL operator == (ASN1CTime&);
00636 virtual EXTRTMETHOD OSBOOL operator != (ASN1CTime&);
00637 virtual EXTRTMETHOD OSBOOL operator > (ASN1CTime&);
00638 virtual EXTRTMETHOD OSBOOL operator < (ASN1CTime&);
00639 virtual EXTRTMETHOD OSBOOL operator >= (ASN1CTime&);
00640 virtual EXTRTMETHOD OSBOOL operator <= (ASN1CTime&);
00641
00642 protected:
00643
00644
00645
00646
00647 virtual int compileString() = 0;
00648
00649 } ;
00650
00651 #else
00652 typedef class _ASN1CTime : public ASN1CType {
00653 protected:
00654 _ASN1CTime(char*& buf, int bufSize, OSBOOL useDerRules) {}
00655 _ASN1CTime(ASN1VisibleString& buf, OSBOOL useDerRules) {}
00656 public:
00657 _ASN1CTime (OSRTMessageBufferIF& msgBuf, char*& , int, OSBOOL) :
00658 ASN1CType (msgBuf) {}
00659 _ASN1CTime (OSRTMessageBufferIF& msgBuf, ASN1VisibleString&, OSBOOL) :
00660 ASN1CType (msgBuf) {}
00661 _ASN1CTime(OSRTContext& ctxt, char*& buf, int bufSize,
00662 OSBOOL useDerRules) : ASN1CType (ctxt) {}
00663 _ASN1CTime(OSRTContext& ctxt, ASN1VisibleString& buf,
00664 OSBOOL useDerRules) : ASN1CType (ctxt) {}
00665 } ASN1CTime;
00666
00667 #endif // _NO_UTILS_CLASSES
00668
00676 #endif //__ASN1CTIME_H__
00677