YesNoNone.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_YESNONONE_H_
10#define SQUID_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
29{
30 enum SetHow : uint8_t { optUnspecified = 0, optImplicitly = 1, optConfigured = 2 };
31
32public:
33 // this constructor initializes to 'unspecified' state
36 option(false)
37 {}
38
39 // this constructor initializes to 'implicit' state
40 explicit YesNoNone(bool beSet):
42 option(beSet)
43 {}
44
47 explicit operator bool() const {
49 return option;
50 }
51
53 void configure(bool beSet) {
55 option = beSet;
56 }
57
59 void defaultTo(bool beSet) {
62 option = beSet;
63 }
64
67 bool configured() const {return setHow_ == optConfigured;}
68
69private:
71 bool option;
72};
73
74#endif /* SQUID_YESNONONE_H_ */
75
#define Must(condition)
Definition: TextException.h:75
@ optImplicitly
Definition: YesNoNone.h:30
@ optConfigured
Definition: YesNoNone.h:30
@ optUnspecified
Definition: YesNoNone.h:30
YesNoNone(bool beSet)
Definition: YesNoNone.h:40
SetHow setHow_
how the option was set
Definition: YesNoNone.h:70
void defaultTo(bool beSet)
enables or disables the option; updating to 'implicit' state
Definition: YesNoNone.h:59
void configure(bool beSet)
enables or disables the option; updating to 'configured' state
Definition: YesNoNone.h:53
bool configured() const
Definition: YesNoNone.h:67
bool option
specified yes/no value; meaningless if optUnspecified
Definition: YesNoNone.h:71
YesNoNone()
Definition: YesNoNone.h:34

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors