67 onName(nameThatEnables),
68 offName(nameThatDisables),
86 if (!prefix_.isEmpty()) {
94 if (prefix_.length() < 2)
97 if (prefix_[0] ==
'-' && prefix_[1] ==
'-') {
98 if (prefix_.length() == 2)
104 if (prefix_.length() == 2) {
123 const char nextChar = *next;
124 if (!(nextChar ==
'-' || nextChar ==
'+'))
127 sawValue_ = strchr(next,
'=');
129 char *rawPrefix =
nullptr;
130 char *rawValue =
nullptr;
133 prefix_.assign(rawPrefix);
134 value_.assign(rawValue);
136 prefix_.assign(next);
146 debugs(28, 8,
"from " << prefix_ <<
" value: " << sawValue_);
147 hasValue = sawValue_;
156 debugs(28, 8,
"from " << prefix_ <<
" at " << letterPos_ <<
" value: " << sawValue_);
157 name.assign(prefix_.rawContent(), 1);
158 name.append(prefix_.at(letterPos_++));
159 if (letterPos_ >= prefix_.length()) {
160 hasValue = sawValue_;
178 for (
const auto option: options_) {
179 if (name.
cmp(option->onName) == 0)
181 if (option->offName && name.
cmp(option->offName) == 0)
193 const auto explicitOption = supportedOption(oex.
name);
194 const auto &option = *explicitOption.first;
195 if (explicitOption.second) {
197 if (option.configured())
198 debugs(28, 7,
"acl uses multiple " << oex.
name <<
" options");
199 switch (option.valueExpectation)
209 option.configureWith(oex.
value());
213 option.configureWith(oex.
value());
257 for (
const auto option: options)
#define TexcHere(msg)
legacy convenience macro; it is not difficult to type Here() now
A single option supported by an ACL: -x[=value] or –name[=value].
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)
Option(const char *nameThatEnables, const char *nameThatDisables=nullptr, ValueExpectation vex=valueNone)
parses/validates/stores ACL options; skips/preserves parameter flags
OptionsParser(const Options &options)
const Options & options_
caller-supported, linked options
SupportedOption supportedOption(const SBuf &name) const
std::pair< const Option *, bool > SupportedOption
a type-specific Option (e.g., a boolean –toggle or -m=SBuf)
static char * PeekAtToken()
static bool NextKvPair(char *&key, char *&value)
static char * NextToken()
int cmp(const SBuf &S, const size_type n) const
shorthand version for compare()
MemBlob::size_type size_type
#define debugs(SECTION, LEVEL, CONTENT)
const BooleanOption & CaseSensitivityOption()
const Options & NoOptions()
void ParseFlags(const Options &options)
std::ostream & operator<<(std::ostream &o, const Answer &a)
std::vector< const Option * > Options
SBuf ToSBuf(Args &&... args)
slowly stream-prints all arguments into a freshly allocated SBuf