9#ifndef SQUID_SRC_ACL_OPTIONS_H
10#define SQUID_SRC_ACL_OPTIONS_H
85 virtual void print(std::ostream &os)
const = 0;
115 explicit operator bool()
const {
return enabled(); }
128template <
class Recipient>
134 Option(nameThatEnables, nameThatDisables, vex) {}
181 void print(std::ostream &os)
const override
214 assert(!
"boolean options do not have ...=values (for now)");
Stores configuration of a typical boolean flag or a single-value Option.
bool valued
whether a configured option had a value
bool configured
whether the option was present in squid.conf
bool disabled
whether the option was turned off
OptionValue(const Value &aValue)
bool enabled() const
whether the option is explicitly turned "on" (with or without a value)
Value value
final value storage, possibly after conversions
void reset()
go back to the default-initialized state
A single option supported by an ACL: -x[=value] or –name[=value].
virtual bool configured() const =0
virtual void enable() const =0
called after parsing onName without a value (e.g., -x or –enable-x)
const char *const onName
A name that must be used to explicitly enable this Option (required).
virtual void print(std::ostream &os) const =0
prints a configuration snippet (as an admin could have typed)
virtual void configureWith(const SBuf &rawValue) const =0
called after parsing onName and a value (e.g., -x=v or –enable-x=v)
virtual void disable() const =0
called after parsing offName (e.g., +i or –disable-x)
virtual void unconfigure() const =0
clear enable(), configureWith(), or disable() effects
virtual bool disabled() const =0
whether disable() has been called
ValueExpectation valueExpectation
expect "=value" part?
virtual bool valued() const =0
const char *const offName
a type-specific Option (e.g., a boolean –toggle or -m=SBuf)
void disable() const override
called after parsing offName (e.g., +i or –disable-x)
void unconfigure() const override
clear enable(), configureWith(), or disable() effects
void linkWith(Recipient *recipient) const
who to tell when this option is enabled
bool configured() const override
void configureWith(const SBuf &rawValue) const override
called after parsing onName and a value (e.g., -x=v or –enable-x=v)
void import(const SBuf &rawValue) const
bool disabled() const override
whether disable() has been called
Recipient * recipient_
parsing results storage
void printValue(std::ostream &os) const
void print(std::ostream &os) const override
prints a configuration snippet (as an admin could have typed)
TypedOption(const char *nameThatEnables, const char *nameThatDisables=nullptr, ValueExpectation vex=valueNone)
void enable() const override
called after parsing onName without a value (e.g., -x or –enable-x)
bool valued() const override
TypedOption< BooleanOptionValue > BooleanOption
TypedOption< TextOptionValue > TextOption
const BooleanOption & CaseSensitivityOption()
const Options & NoOptions()
OptionValue< SBuf > TextOptionValue
void ParseFlags(const Options &options)
std::ostream & operator<<(std::ostream &o, const Answer &a)
std::vector< const Option * > Options
OptionValue< bool > BooleanOptionValue