]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ConfigOption.h
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
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.
9 #ifndef SQUID_CONFIGOPTION_H
10 #define SQUID_CONFIGOPTION_H
18 namespace Configuration
{
20 /// Interface for basic/low-level manipulation of a squid.conf directive value.
21 /// Hides T's declarations from squid.conf parsing/reconfiguring/reporting code.
23 /// Implementations/specializations must not modify the current configuration
24 /// (i.e. the Config objects and similar/related global state). To facilitate
25 /// reuse, implementations/specializations should also be independent from any
26 /// specific configuration directive name and its squid.conf location.
28 /// TODO: Support multi-directive components of various kinds.
33 /* the code adding "TYPE: T" to cf.data.pre must specialize these */
35 /// creates a new T instance using the given parser; never returns nil
36 static T
Parse(ConfigParser
&);
38 /// reports the current T instance configuration in squid.conf format
39 static void Print(std::ostream
&, const T
&);
41 /// destroys Parse() result
45 } // namespace Configuration
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.
61 virtual ~ConfigOption() {}
63 virtual bool parse(char const *option
, const char *value
, int reconfiguring
) = 0;
64 virtual void dump(StoreEntry
* e
) const = 0;
67 class ConfigOptionVector
: public ConfigOption
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
;
78 class ConfigOptionAdapter
: public ConfigOption
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
) {}
84 bool parse(char const *option
, const char *value
, int isaReconf
) override
{
86 return (object
.*parser
)(option
, value
, isaReconf
);
91 void dump(StoreEntry
* e
) const override
{
98 bool (C::*parser
)(char const *option
, const char *value
, int reconfiguring
) ;
99 void (C::*dumper
)(StoreEntry
* e
) const;
102 #endif /* SQUID_CONFIGOPTION_H */