Logo Pico-Framework A web-first embedded framework for C++
Loading...
Searching...
No Matches
WithFlag Class Reference

Temporarily sets a boolean flag and restores it automatically. More...

#include <WithFlag.h>

+ Collaboration diagram for WithFlag:

Public Member Functions

 WithFlag (bool &flag, bool value=true)
 Construct the WithFlag and set the flag to the desired value (default true).
 
 ~WithFlag ()
 Destructor restores the original value of the flag.
 

Private Attributes

bool & flag
 
bool previousValue
 

Detailed Description

Definition at line 21 of file WithFlag.h.

Constructor & Destructor Documentation

◆ WithFlag()

WithFlag::WithFlag ( bool &  flag,
bool  value = true 
)
inlineexplicit
Parameters
flagReference to the flag to modify.
valueThe value to temporarily set (default: true).

Definition at line 31 of file WithFlag.h.

33 flag = value;
34 }
bool & flag
Definition WithFlag.h:22
bool previousValue
Definition WithFlag.h:23

References flag.

◆ ~WithFlag()

WithFlag::~WithFlag ( )
inline

Definition at line 39 of file WithFlag.h.

39 {
41 }

References flag, and previousValue.

Member Data Documentation

◆ flag

bool& WithFlag::flag
private

Definition at line 22 of file WithFlag.h.

Referenced by WithFlag(), and ~WithFlag().

◆ previousValue

bool WithFlag::previousValue
private

Definition at line 23 of file WithFlag.h.

Referenced by ~WithFlag().


The documentation for this class was generated from the following file: