#include <boolean_switch.h>
Provides a simple on/off switch that controls debugging and tracing output.
- Namespace
- xtd::diagnostics
- Library
- xtd.core
- Examples
- This example configuration section defines a xtd::diagnostics::boolean_switch with the xtd::diagnostics::boolean_switch::display_name property set to my_switch and the xtd::diagnostics::boolean_switch::enabled value set to true. Within your application, you can use the configured switch value by creating a xtd::diagnostics::boolean_switch with the same name, as shown in the following code example.
private:
public:
static void main() {
}
}
Represents the standard input, output, and error streams for console applications.
Definition console.h:26
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
Provides a simple on/off switch that controls debugging and tracing output.
Definition boolean_switch.h:41
bool enabled() const
Gets a value indicating whether the switch is enabled or disabled.
const xtd::ustring & display_name() const
Gets a name used to identify the switch.
- Note
- These debug and trace compiler switches are not required when using the xtd::diagnostics::boolean_switch class in isolation. They are only required in conjunction with xtd::diagnostics::trace or xtd::diagnostics::debug methods that are conditionally compiled.
- Note
- To improve performance, you can make xtd::diagnostics::boolean_switch members static in your class.
Inherits xtd::diagnostics::switch_base.
|
static bool | equals (const object &object_a, const object &object_b) noexcept |
| Determines whether the specified object instances are considered equal.
|
|
static bool | reference_equals (const object &object_a, const object &object_b) noexcept |
| Determines whether the specified object instances are the same instance.
|
|
◆ boolean_switch() [1/2]
xtd::diagnostics::boolean_switch::boolean_switch |
( |
const xtd::ustring & |
display_name, |
|
|
const xtd::ustring & |
description |
|
) |
| |
Initializes a new instance of the xtd::diagnostics::boolean_switch class with the specified display name and description.
- Parameters
-
display_name | The name to display on a user interface. |
description | The description of the switch. |
- Examples
- The following example creates a xtd::diagnostics::boolean_switch and uses the switch to determine whether to print an error message. The switch is created at the class level. The Main method passes its location to MyMethod, which prints an error message and where the error occurred.
private:
public:
if (data_switch.enabled())
}
static void main(const std::vector<xtd::ustring>& args) {
my_method("in Main");
}
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:48
◆ boolean_switch() [2/2]
Initializes a new instance of the xtd::diagnostics::boolean_switch class with the specified display name, description, and default switch value.
- Parameters
-
display_name | The name to display on a user interface. |
description | The description of the switch. |
default_switch_value | The default value of the switch. |
◆ enabled() [1/2]
bool xtd::diagnostics::boolean_switch::enabled |
( |
| ) |
const |
Gets a value indicating whether the switch is enabled or disabled.
- Returns
- true if the switch is enabled; otherwise, false. The default is false.
◆ enabled() [2/2]
void xtd::diagnostics::boolean_switch::enabled |
( |
bool |
enabled | ) |
|
Sets a value indicating whether the switch is enabled or disabled.
- Parameters
-
enabled | true if the switch is enabled; otherwise, false. The default is false. |
◆ on_value_changed()
void xtd::diagnostics::boolean_switch::on_value_changed |
( |
| ) |
|
|
overrideprotectedvirtual |
The documentation for this class was generated from the following file: