]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/anyp/ProtocolVersion.h
1 #ifndef SQUID_ANYP_PROTOCOLVERSION_H
2 #define SQUID_ANYP_PROTOCOLVERSION_H
4 #include "anyp/ProtocolType.h"
12 * Stores a protocol version label.
13 * For example HTTP/1.1 or ICY/1.0 or FTP/2.0
19 // BUG: major() and minor() are macros.
20 // we can't use a fast constructor syntax without renaming them globally
21 ProtocolVersion() : protocol(PROTO_NONE
) {
26 ProtocolVersion(ProtocolType which
, unsigned int aMajor
, unsigned int aMinor
) : protocol(which
) {
31 ProtocolType protocol
; ///< which protocol this version is for
32 unsigned int major
; ///< major version number
33 unsigned int minor
; ///< minor version number
35 bool operator==(const ProtocolVersion
& that
) const {
36 if (this->protocol
!= that
.protocol
)
39 if (this->major
!= that
.major
)
42 if (this->minor
!= that
.minor
)
48 bool operator!=(const ProtocolVersion
& that
) const {
49 return (((this->protocol
!= that
.protocol
) || this->major
!= that
.major
) || (this->minor
!= that
.minor
));
52 bool operator <(const ProtocolVersion
& that
) const {
53 if (this->protocol
!= that
.protocol
)
54 return false; // throw?
56 return (this->major
< that
.major
||
57 (this->major
== that
.major
&& this->minor
< that
.minor
));
60 bool operator >(const ProtocolVersion
& that
) const {
61 if (this->protocol
!= that
.protocol
)
62 return false; // throw?
64 return (this->major
> that
.major
||
65 (this->major
== that
.major
&& this->minor
> that
.minor
));
68 bool operator <=(const ProtocolVersion
& that
) const {
69 if (this->protocol
!= that
.protocol
)
70 return false; // throw?
72 return !(*this > that
);
75 bool operator >=(const ProtocolVersion
& that
) const {
76 if (this->protocol
!= that
.protocol
)
77 return false; // throw?
79 return !(*this < that
);
86 operator << (std::ostream
&os
, const AnyP::ProtocolVersion
&v
)
88 return (os
<< AnyP::ProtocolType_str
[v
.protocol
] << '/' << v
.major
<< '.' << v
.minor
);
91 #endif /* SQUID_ANYP_PROTOCOLVERSION_H */