Panda3D

Loading...
Searching...
No Matches
httpDate.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file httpDate.h
10 * @author drose
11 * @date 2003-01-28
12 */
13
14#ifndef HTTPDATE_H
15#define HTTPDATE_H
16
17#include "pandabase.h"
18
19#include <time.h>
20
21/**
22 * A container for an HTTP-legal time/date indication. This can accept a
23 * string from an HTTP header and will decode it into a C time_t value;
24 * conversely, it can accept a time_t value and encode it for output as a
25 * string.
26 */
27 class EXPCL_PANDA_DOWNLOADER HTTPDate {
28PUBLISHED:
29 INLINE HTTPDate();
30 INLINE HTTPDate(time_t time);
31 HTTPDate(const std::string &format);
32 INLINE HTTPDate(const HTTPDate &copy);
33 INLINE void operator = (const HTTPDate &copy);
34 INLINE static HTTPDate now();
35
36 INLINE bool is_valid() const;
37
38 std::string get_string() const;
39 INLINE time_t get_time() const;
40
41 INLINE bool operator == (const HTTPDate &other) const;
42 INLINE bool operator != (const HTTPDate &other) const;
43 INLINE bool operator < (const HTTPDate &other) const;
44 INLINE bool operator > (const HTTPDate &other) const;
45 INLINE int compare_to(const HTTPDate &other) const;
46
47 INLINE void operator += (int seconds);
48 INLINE void operator -= (int seconds);
49
50 INLINE HTTPDate operator + (int seconds) const;
51 INLINE HTTPDate operator - (int seconds) const;
52 INLINE int operator - (const HTTPDate &other) const;
53
54 bool input(std::istream &in);
55 void output(std::ostream &out) const;
56
57 private:
58 static std::string get_token(const std::string &str, size_t &pos);
59
60 time_t _time;
61};
62
63INLINE std::istream &operator >> (std::istream &in, HTTPDate &date);
64INLINE std::ostream &operator << (std::ostream &out, const HTTPDate &date);
65
66#include "httpDate.I"
67
68#endif
HTTPDate
A container for an HTTP-legal time/date indication.
Definition httpDate.h:27
HTTPDate::compare_to
int compare_to(const HTTPDate &other) const
Returns a number less than zero if this HTTPDate sorts before the other one, greater than zero if it ...
Definition httpDate.I:105
HTTPDate::now
static HTTPDate now()
Returns an HTTPDate that represents the current time and date.
Definition httpDate.I:47
HTTPDate::get_time
time_t get_time() const
Returns the date as a C time_t value.
Definition httpDate.I:64
HTTPDate::is_valid
bool is_valid() const
Returns true if the date is meaningful, or false if it is -1 (which generally indicates the source st...
Definition httpDate.I:56
httpDate.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.