Squid Web Cache
master
Loading...
Searching...
No Matches
YesNoNone.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 1996-2025 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_SRC_BASE_YESNONONE_H
10
#define SQUID_SRC_BASE_YESNONONE_H
11
12
#include "
base/TextException.h
"
13
#include "
debug/Stream.h
"
14
15
// TODO: generalize / template to non-boolean option types
16
// and make YesNoNone the boolean instance of the template
17
28
class
YesNoNone
29
{
30
enum
SetHow
: uint8_t {
optUnspecified
= 0,
optImplicitly
= 1,
optConfigured
= 2 };
31
32
public
:
33
// this constructor initializes to 'unspecified' state
34
YesNoNone
():
35
setHow_
(
optUnspecified
),
36
option
(false)
37
{}
38
39
// this constructor initializes to 'implicit' state
40
explicit
YesNoNone
(
bool
beSet):
41
setHow_
(
optImplicitly
),
42
option
(beSet)
43
{}
44
47
explicit
operator
bool()
const
{
48
Must
(
setHow_
!=
optUnspecified
);
49
return
option
;
50
}
51
53
void
configure
(
bool
beSet) {
54
setHow_
=
optConfigured
;
55
option
= beSet;
56
}
57
59
void
defaultTo
(
bool
beSet) {
60
Must
(
setHow_
!=
optConfigured
);
61
setHow_
=
optImplicitly
;
62
option
= beSet;
63
}
64
67
bool
configured
()
const
{
return
setHow_
==
optConfigured
;}
68
69
private
:
70
SetHow
setHow_
;
71
bool
option
;
72
};
73
74
#endif
/* SQUID_SRC_BASE_YESNONONE_H */
75
TextException.h
Must
#define Must(condition)
Definition
TextException.h:75
YesNoNone
Definition
YesNoNone.h:29
YesNoNone::SetHow
SetHow
Definition
YesNoNone.h:30
YesNoNone::optImplicitly
@ optImplicitly
Definition
YesNoNone.h:30
YesNoNone::optConfigured
@ optConfigured
Definition
YesNoNone.h:30
YesNoNone::optUnspecified
@ optUnspecified
Definition
YesNoNone.h:30
YesNoNone::YesNoNone
YesNoNone(bool beSet)
Definition
YesNoNone.h:40
YesNoNone::setHow_
SetHow setHow_
how the option was set
Definition
YesNoNone.h:70
YesNoNone::defaultTo
void defaultTo(bool beSet)
enables or disables the option; updating to 'implicit' state
Definition
YesNoNone.h:59
YesNoNone::configure
void configure(bool beSet)
enables or disables the option; updating to 'configured' state
Definition
YesNoNone.h:53
YesNoNone::configured
bool configured() const
Definition
YesNoNone.h:67
YesNoNone::option
bool option
specified yes/no value; meaningless if optUnspecified
Definition
YesNoNone.h:71
YesNoNone::YesNoNone
YesNoNone()
Definition
YesNoNone.h:34
Stream.h
squid
src
base
YesNoNone.h
Generated by
1.9.8