ConfigOption.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_CONFIGOPTION_H
10#define SQUID_CONFIGOPTION_H
11
12#include <iosfwd>
13#include <vector>
14
15class StoreEntry;
16class ConfigParser;
17
18namespace Configuration {
19
29template <class T>
31{
32public:
33 /* the code adding "TYPE: T" to cf.data.pre must specialize these */
34
36 static T Parse(ConfigParser &);
37
39 static void Print(std::ostream &, const T &);
40
42 static void Free(T);
43};
44
45} // namespace Configuration
46
47/*
48 * Deprecated squid.conf option wrappers used by cache_dir handling code. These
49 * classes are similar to Configuration::Component<T>, but they merge T with T
50 * parsing API, making them ill-suited for handling SquidConfig data members
51 * with built-in C++ types and, more importantly, forcing SquidConfig users to
52 * know about parsing/dumping/freeing capabilities of each SquidConfig
53 * component. They also do not hide T details from the generic squid.conf
54 * parsing code -- one has to provide a type-specific parse_T() for each T.
55 */
56
58{
59
60public:
61 virtual ~ConfigOption() {}
62
63 virtual bool parse(char const *option, const char *value, int reconfiguring) = 0;
64 virtual void dump(StoreEntry * e) const = 0;
65};
66
68{
69
70public:
71 ~ConfigOptionVector() override;
72 bool parse(char const *option, const char *value, int reconfiguring) override;
73 void dump(StoreEntry * e) const override;
74 std::vector<ConfigOption *>options;
75};
76
77template <class C>
79{
80
81public:
82 ConfigOptionAdapter(C& theObject, bool (C::*parseFP)(char const *option, const char *value, int reconfiguring), void (C::*dumpFP)(StoreEntry * e) const) : object(theObject), parser(parseFP), dumper(dumpFP) {}
83
84 bool parse(char const *option, const char *value, int isaReconf) override {
85 if (parser)
86 return (object.*parser)(option, value, isaReconf);
87
88 return false;
89 }
90
91 void dump(StoreEntry * e) const override {
92 if (dumper)
93 (object.*dumper)(e);
94 }
95
96private:
98 bool (C::*parser)(char const *option, const char *value, int reconfiguring) ;
99 void (C::*dumper)(StoreEntry * e) const;
100};
101
102#endif /* SQUID_CONFIGOPTION_H */
103
ConfigOptionAdapter(C &theObject, bool(C::*parseFP)(char const *option, const char *value, int reconfiguring), void(C::*dumpFP)(StoreEntry *e) const)
Definition: ConfigOption.h:82
void dump(StoreEntry *e) const override
Definition: ConfigOption.h:91
bool(C::* parser)(char const *option, const char *value, int reconfiguring)
Definition: ConfigOption.h:98
bool parse(char const *option, const char *value, int isaReconf) override
Definition: ConfigOption.h:84
void(C::* dumper)(StoreEntry *e) const
Definition: ConfigOption.h:99
~ConfigOptionVector() override
Definition: ConfigOption.cc:14
std::vector< ConfigOption * > options
Definition: ConfigOption.h:74
bool parse(char const *option, const char *value, int reconfiguring) override
Definition: ConfigOption.cc:23
void dump(StoreEntry *e) const override
Definition: ConfigOption.cc:38
virtual void dump(StoreEntry *e) const =0
virtual bool parse(char const *option, const char *value, int reconfiguring)=0
virtual ~ConfigOption()
Definition: ConfigOption.h:61
static void Free(T)
destroys Parse() result
static T Parse(ConfigParser &)
creates a new T instance using the given parser; never returns nil
static void Print(std::ostream &, const T &)
reports the current T instance configuration in squid.conf format
int reconfiguring
static uint32 C
Definition: md4.c:43

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors