Panda3D
Loading...
Searching...
No Matches
httpEntityTag.I
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 httpEntityTag.I
10 * @author drose
11 * @date 2003-01-28
12 */
13
14/**
15 *
16 */
17INLINE HTTPEntityTag::
18HTTPEntityTag() {
19 _weak = false;
20}
21
22/**
23 * This constructor accepts an explicit weak flag and a literal (not quoted)
24 * tag string.
25 */
26INLINE HTTPEntityTag::
27HTTPEntityTag(bool weak, const std::string &tag) :
28 _weak(weak),
29 _tag(tag)
30{
31}
32
33/**
34 *
35 */
36INLINE HTTPEntityTag::
37HTTPEntityTag(const HTTPEntityTag &copy) :
38 _weak(copy._weak),
39 _tag(copy._tag)
40{
41}
42
43/**
44 *
45 */
46INLINE void HTTPEntityTag::
47operator = (const HTTPEntityTag &copy) {
48 _weak = copy._weak;
49 _tag = copy._tag;
50}
51
52/**
53 * Returns true if the entity tag is marked as "weak". A consistent weak
54 * entity tag does not guarantee that its resource has not changed in any way,
55 * but it does promise that the resource has not changed in any semantically
56 * meaningful way.
57 */
58INLINE bool HTTPEntityTag::
59is_weak() const {
60 return _weak;
61}
62
63/**
64 * Returns the tag as a literal string.
65 */
66INLINE const std::string &HTTPEntityTag::
67get_tag() const {
68 return _tag;
69}
70
71/**
72 * Returns true if the two tags have "strong" equivalence: they are the same
73 * tag, and both are "strong".
74 */
75INLINE bool HTTPEntityTag::
76strong_equiv(const HTTPEntityTag &other) const {
77 return _tag == other._tag && !_weak && !other._weak;
78}
79
80/**
81 * Returns true if the two tags have "weak" equivalence: they are the same
82 * tag, and one or both may be "weak".
83 */
84INLINE bool HTTPEntityTag::
85weak_equiv(const HTTPEntityTag &other) const {
86 return _tag == other._tag;
87}
88
89/**
90 * The == operator tests object equivalence; see also strong_equiv() and
91 * weak_equiv() for the two kinds of HTTP equivalence.
92 */
93INLINE bool HTTPEntityTag::
94operator == (const HTTPEntityTag &other) const {
95 return _weak == other._weak && _tag == other._tag;
96}
97
98/**
99 *
100 */
101INLINE bool HTTPEntityTag::
102operator != (const HTTPEntityTag &other) const {
103 return !operator == (other);
104}
105
106/**
107 *
108 */
109INLINE bool HTTPEntityTag::
110operator < (const HTTPEntityTag &other) const {
111 if (_weak != other._weak) {
112 return (int)_weak < (int)other._weak;
113 }
114 return _tag < other._tag;
115}
116
117/**
118 * Returns a number less than zero if this HTTPEntityTag sorts before the
119 * other one, greater than zero if it sorts after, or zero if they are
120 * equivalent.
121 */
123compare_to(const HTTPEntityTag &other) const {
124 if (_weak != other._weak) {
125 return (int)_weak - (int)other._weak;
126 }
127 return strcmp(_tag.c_str(), other._tag.c_str());
128}
129
130/**
131 *
132 */
133INLINE void HTTPEntityTag::
134output(std::ostream &out) const {
135 out << get_string();
136}
137
138
139INLINE std::ostream &
140operator << (std::ostream &out, const HTTPEntityTag &entityTag) {
141 entityTag.output(out);
142 return out;
143}
A container for an "entity tag" from an HTTP server.
bool weak_equiv(const HTTPEntityTag &other) const
Returns true if the two tags have "weak" equivalence: they are the same tag, and one or both may be "...
std::string get_string() const
Returns the entity tag formatted for sending to an HTTP server (the tag is quoted,...
const std::string & get_tag() const
Returns the tag as a literal string.
bool operator==(const HTTPEntityTag &other) const
The == operator tests object equivalence; see also strong_equiv() and weak_equiv() for the two kinds ...
int compare_to(const HTTPEntityTag &other) const
Returns a number less than zero if this HTTPEntityTag sorts before the other one, greater than zero i...
bool strong_equiv(const HTTPEntityTag &other) const
Returns true if the two tags have "strong" equivalence: they are the same tag, and both are "strong".
bool is_weak() const
Returns true if the entity tag is marked as "weak".