Panda3D
 All Classes Functions Variables Enumerations
httpEntityTag.I
00001 // Filename: httpEntityTag.I
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 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: HTTPEntityTag::Constructor
00018 //       Access: Published
00019 //  Description: 
00020 ////////////////////////////////////////////////////////////////////
00021 INLINE HTTPEntityTag::
00022 HTTPEntityTag() {
00023   _weak = false;
00024 }
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //     Function: HTTPEntityTag::Constructor
00028 //       Access: Published
00029 //  Description: This constructor accepts an explicit weak flag and a
00030 //               literal (not quoted) tag string.
00031 ////////////////////////////////////////////////////////////////////
00032 INLINE HTTPEntityTag::
00033 HTTPEntityTag(bool weak, const string &tag) :
00034   _weak(weak),
00035   _tag(tag)
00036 {
00037 }
00038 
00039 ////////////////////////////////////////////////////////////////////
00040 //     Function: HTTPEntityTag::Copy Constructor
00041 //       Access: Published
00042 //  Description:
00043 ////////////////////////////////////////////////////////////////////
00044 INLINE HTTPEntityTag::
00045 HTTPEntityTag(const HTTPEntityTag &copy) : 
00046   _weak(copy._weak),
00047   _tag(copy._tag)
00048 {
00049 }
00050 
00051 ////////////////////////////////////////////////////////////////////
00052 //     Function: HTTPEntityTag::Copy Assignment Operator
00053 //       Access: Published
00054 //  Description:
00055 ////////////////////////////////////////////////////////////////////
00056 INLINE void HTTPEntityTag::
00057 operator = (const HTTPEntityTag &copy) {
00058   _weak = copy._weak;
00059   _tag = copy._tag;
00060 }
00061 
00062 ////////////////////////////////////////////////////////////////////
00063 //     Function: HTTPEntityTag::is_weak
00064 //       Access: Published
00065 //  Description: Returns true if the entity tag is marked as "weak".
00066 //               A consistent weak entity tag does not guarantee that
00067 //               its resource has not changed in any way, but it does
00068 //               promise that the resource has not changed in any
00069 //               semantically meaningful way.
00070 ////////////////////////////////////////////////////////////////////
00071 INLINE bool HTTPEntityTag::
00072 is_weak() const {
00073   return _weak;
00074 }
00075 
00076 ////////////////////////////////////////////////////////////////////
00077 //     Function: HTTPEntityTag::get_tag
00078 //       Access: Published
00079 //  Description: Returns the tag as a literal string.
00080 ////////////////////////////////////////////////////////////////////
00081 INLINE const string &HTTPEntityTag::
00082 get_tag() const {
00083   return _tag;
00084 }
00085 
00086 ////////////////////////////////////////////////////////////////////
00087 //     Function: HTTPEntityTag::strong_equiv
00088 //       Access: Published
00089 //  Description: Returns true if the two tags have "strong" equivalence:
00090 //               they are the same tag, and both are "strong".
00091 ////////////////////////////////////////////////////////////////////
00092 INLINE bool HTTPEntityTag::
00093 strong_equiv(const HTTPEntityTag &other) const {
00094   return _tag == other._tag && !_weak && !other._weak;
00095 }
00096 
00097 ////////////////////////////////////////////////////////////////////
00098 //     Function: HTTPEntityTag::weak_equiv
00099 //       Access: Published
00100 //  Description: Returns true if the two tags have "weak" equivalence:
00101 //               they are the same tag, and one or both may be "weak".
00102 ////////////////////////////////////////////////////////////////////
00103 INLINE bool HTTPEntityTag::
00104 weak_equiv(const HTTPEntityTag &other) const {
00105   return _tag == other._tag;
00106 }
00107 
00108 ////////////////////////////////////////////////////////////////////
00109 //     Function: HTTPEntityTag::Operator ==
00110 //       Access: Published
00111 //  Description: The == operator tests object equivalence; see also
00112 //               strong_equiv() and weak_equiv() for the two kinds of
00113 //               HTTP equivalence.
00114 ////////////////////////////////////////////////////////////////////
00115 INLINE bool HTTPEntityTag::
00116 operator == (const HTTPEntityTag &other) const {
00117   return _weak == other._weak && _tag == other._tag;
00118 }
00119 
00120 ////////////////////////////////////////////////////////////////////
00121 //     Function: HTTPEntityTag::Operator !=
00122 //       Access: Published
00123 //  Description:
00124 ////////////////////////////////////////////////////////////////////
00125 INLINE bool HTTPEntityTag::
00126 operator != (const HTTPEntityTag &other) const {
00127   return !operator == (other);
00128 }
00129 
00130 ////////////////////////////////////////////////////////////////////
00131 //     Function: HTTPEntityTag::Operator <
00132 //       Access: Published
00133 //  Description:
00134 ////////////////////////////////////////////////////////////////////
00135 INLINE bool HTTPEntityTag::
00136 operator < (const HTTPEntityTag &other) const {
00137   if (_weak != other._weak) {
00138     return (int)_weak < (int)other._weak;
00139   }
00140   return _tag < other._tag;
00141 }
00142 
00143 ////////////////////////////////////////////////////////////////////
00144 //     Function: HTTPEntityTag::compare_to
00145 //       Access: Published
00146 //  Description: Returns a number less than zero if this HTTPEntityTag
00147 //               sorts before the other one, greater than zero if it
00148 //               sorts after, or zero if they are equivalent.
00149 ////////////////////////////////////////////////////////////////////
00150 INLINE int HTTPEntityTag::
00151 compare_to(const HTTPEntityTag &other) const {
00152   if (_weak != other._weak) {
00153     return (int)_weak - (int)other._weak;
00154   }
00155   return strcmp(_tag.c_str(), other._tag.c_str());
00156 }
00157 
00158 ////////////////////////////////////////////////////////////////////
00159 //     Function: HTTPEntityTag::output
00160 //       Access: Published
00161 //  Description: 
00162 ////////////////////////////////////////////////////////////////////
00163 INLINE void HTTPEntityTag::
00164 output(ostream &out) const {
00165   out << get_string();
00166 }
00167 
00168 
00169 INLINE ostream &
00170 operator << (ostream &out, const HTTPEntityTag &entityTag) {
00171   entityTag.output(out);
00172   return out;
00173 }
00174 
00175 
 All Classes Functions Variables Enumerations