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_ANYP_URISCHEME_H
10#define SQUID_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
19namespace AnyP
20{
21
23using KnownPort = uint16_t;
24
26using Port = std::optional<KnownPort>;
27
32{
33public:
34 typedef std::vector<SBuf> LowercaseSchemeNames;
35
38 UriScheme(AnyP::ProtocolType const aScheme, const char *img = nullptr);
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
67private:
71
74
77};
78
79inline std::ostream &
80operator <<(std::ostream &os, const UriScheme &scheme)
81{
82 os << scheme.image();
83 return os;
84}
85
86} // namespace AnyP
87
88#endif /* SQUID_ANYP_URISCHEME_H */
89
std::vector< SBuf > LowercaseSchemeNames
Definition: UriScheme.h:34
UriScheme(const AnyP::UriScheme &o)
Definition: UriScheme.h:39
AnyP::ProtocolType theScheme_
This is a typecode pointer into the enum/registry of protocols handled.
Definition: UriScheme.h:73
AnyP::UriScheme & operator=(AnyP::UriScheme &&)=default
static void Init()
initializes down-cased protocol scheme names array
Definition: UriScheme.cc:38
static AnyP::ProtocolType FindProtocolType(const SBuf &)
Definition: UriScheme.cc:52
SBuf image_
the string representation
Definition: UriScheme.h:76
AnyP::UriScheme & operator=(const AnyP::UriScheme &o)
Definition: UriScheme.h:43
UriScheme(AnyP::UriScheme &&)=default
Port defaultPort() const
Definition: UriScheme.cc:71
SBuf image() const
Definition: UriScheme.h:57
static LowercaseSchemeNames LowercaseSchemeNames_
Definition: UriScheme.h:70
bool operator!=(AnyP::ProtocolType const &aProtocol) const
Definition: UriScheme.h:52
Definition: SBuf.h:94
Definition: forward.h:15
std::optional< KnownPort > Port
validated/supported port number (if any)
Definition: UriScheme.h:26
uint16_t KnownPort
validated/supported port number; these values are never zero
Definition: UriScheme.h:23
std::ostream & operator<<(std::ostream &os, ProtocolType const &p)
Definition: ProtocolType.h:52
ProtocolType
Definition: ProtocolType.h:23
@ PROTO_NONE
Definition: ProtocolType.h:24

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors