Panda3D

httpDate.h

00001 // Filename: httpDate.h
00002 // Created by:  drose (28Jan03)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef HTTPDATE_H
00016 #define HTTPDATE_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include <time.h>
00021 
00022 ////////////////////////////////////////////////////////////////////
00023 //       Class : HTTPDate
00024 // Description : A container for an HTTP-legal time/date indication.
00025 //               This can accept a string from an HTTP header and will
00026 //               decode it into a C time_t value; conversely, it can
00027 //               accept a time_t value and encode it for output as a
00028 //               string.
00029 ////////////////////////////////////////////////////////////////////
00030 class EXPCL_PANDAEXPRESS HTTPDate {
00031 PUBLISHED:
00032   INLINE HTTPDate();
00033   INLINE HTTPDate(time_t time);
00034   HTTPDate(const string &format);
00035   INLINE HTTPDate(const HTTPDate &copy);
00036   INLINE void operator = (const HTTPDate &copy);
00037   INLINE static HTTPDate now();
00038 
00039   INLINE bool is_valid() const;
00040 
00041   string get_string() const;
00042   INLINE time_t get_time() const;
00043 
00044   INLINE bool operator == (const HTTPDate &other) const;
00045   INLINE bool operator != (const HTTPDate &other) const;
00046   INLINE bool operator < (const HTTPDate &other) const;
00047   INLINE bool operator > (const HTTPDate &other) const;
00048   INLINE int compare_to(const HTTPDate &other) const;
00049 
00050   INLINE void operator += (int seconds);
00051   INLINE void operator -= (int seconds);
00052 
00053   INLINE HTTPDate operator + (int seconds) const;
00054   INLINE HTTPDate operator - (int seconds) const;
00055   INLINE int operator - (const HTTPDate &other) const;
00056 
00057   bool input(istream &in);
00058   void output(ostream &out) const;
00059 
00060 private:
00061   static string get_token(const string &str, size_t &pos);
00062 
00063   time_t _time;
00064 };
00065 
00066 INLINE istream &operator >> (istream &in, HTTPDate &date);
00067 INLINE ostream &operator << (ostream &out, const HTTPDate &date);
00068 
00069 #include "httpDate.I"
00070 
00071 #endif
 All Classes Functions Variables Enumerations