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