UriScheme.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 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_SRC_ANYP_URISCHEME_H
10 #define SQUID_SRC_ANYP_URISCHEME_H
11 
12 #include "anyp/ProtocolType.h"
13 #include "sbuf/SBuf.h"
14 
15 #include <iosfwd>
16 #include <optional>
17 #include <vector>
18 
19 namespace AnyP
20 {
21 
23 using KnownPort = uint16_t;
24 
26 using Port = std::optional<KnownPort>;
27 
31 class UriScheme
32 {
33 public:
34  typedef std::vector<SBuf> LowercaseSchemeNames;
35 
38  UriScheme(AnyP::ProtocolType const aScheme, const char *img = nullptr);
40  UriScheme(AnyP::UriScheme &&) = default;
42 
45  image_ = o.image_;
46  return *this;
47  }
49 
50  operator AnyP::ProtocolType() const { return theScheme_; }
51  // XXX: does not account for comparison of unknown schemes (by image)
52  bool operator != (AnyP::ProtocolType const & aProtocol) const { return theScheme_ != aProtocol; }
53 
57  SBuf image() const {return image_;}
58 
59  Port defaultPort() const;
60 
62  static void Init();
63 
66 
67 private:
71 
74 
77 };
78 
79 inline std::ostream &
80 operator <<(std::ostream &os, const UriScheme &scheme)
81 {
82  os << scheme.image();
83  return os;
84 }
85 
86 } // namespace AnyP
87 
88 #endif /* SQUID_SRC_ANYP_URISCHEME_H */
89 
static AnyP::ProtocolType FindProtocolType(const SBuf &)
Definition: UriScheme.cc:52
@ PROTO_NONE
Definition: ProtocolType.h:24
AnyP::ProtocolType theScheme_
This is a typecode pointer into the enum/registry of protocols handled.
Definition: UriScheme.h:73
std::ostream & operator<<(std::ostream &, const Host &)
Definition: Host.cc:80
Definition: SBuf.h:93
bool operator!=(AnyP::ProtocolType const &aProtocol) const
Definition: UriScheme.h:52
ProtocolType
Definition: ProtocolType.h:23
UriScheme(const AnyP::UriScheme &o)
Definition: UriScheme.h:39
Definition: forward.h:14
AnyP::UriScheme & operator=(const AnyP::UriScheme &o)
Definition: UriScheme.h:43
static LowercaseSchemeNames LowercaseSchemeNames_
Definition: UriScheme.h:70
uint16_t KnownPort
validated/supported port number; these values are never zero
Definition: UriScheme.h:23
static void Init()
initializes down-cased protocol scheme names array
Definition: UriScheme.cc:38
SBuf image() const
Definition: UriScheme.h:57
Port defaultPort() const
Definition: UriScheme.cc:71
SBuf image_
the string representation
Definition: UriScheme.h:76
std::optional< KnownPort > Port
validated/supported port number (if any)
Definition: UriScheme.h:26
std::vector< SBuf > LowercaseSchemeNames
Definition: UriScheme.h:34

 

Introduction

Documentation

Support

Miscellaneous