]> git.ipfire.org Git - thirdparty/squid.git/blob - src/anyp/UriScheme.h
Cleanup: un-wrap C++ header includes
[thirdparty/squid.git] / src / anyp / UriScheme.h
1 #ifndef SQUID_ANYP_URISCHEME_H
2 #define SQUID_ANYP_URISCHEME_H
3
4 #include "anyp/ProtocolType.h"
5
6 #include <iosfwd>
7
8 namespace AnyP
9 {
10
11 /** This class represents a URI Scheme such as http:// https://, wais://, urn: etc.
12 * It does not represent the PROTOCOL that such schemes refer to.
13 */
14 class UriScheme
15 {
16 public:
17 UriScheme() : theScheme_(AnyP::PROTO_NONE) {}
18 UriScheme(AnyP::ProtocolType const aScheme) : theScheme_(aScheme) {}
19 ~UriScheme() {}
20
21 operator AnyP::ProtocolType() const { return theScheme_; }
22
23 bool operator != (AnyP::ProtocolType const & aProtocol) const { return theScheme_ != aProtocol; }
24
25 /** Get a char string representation of the scheme.
26 * Does not include the ':' or '://" terminators.
27 *
28 * An upper bound length of BUFSIZ bytes converted. Remainder will be truncated.
29 * The result of this call will remain usable only until any subsequest call
30 * and must be copied if persistence is needed.
31 */
32 char const *c_str() const;
33
34 private:
35 /// This is a typecode pointer into the enum/registry of protocols handled.
36 AnyP::ProtocolType theScheme_;
37 };
38
39 } // namespace AnyP
40
41 inline std::ostream &
42 operator << (std::ostream &os, AnyP::UriScheme const &scheme)
43 {
44 os << scheme.c_str();
45 return os;
46 }
47
48 #endif /* SQUID_ANYP_URISCHEME_H */