Files
sw_openocd/src/helper/string_choices.h
T
Marc Schink caf7ffc7eb helper: Add string_choices.h
Add the helper function str_enabled_disabled() to select between the two
strings 'enabled' and 'disabled' depending on a boolean value.

Additional functions for frequently used strings can be added in the future
if required.

Change-Id: I2d8ae96b141f87966836e6e4c3a2ed6d12b71fa5
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/9006
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2025-08-02 12:54:56 +00:00

23 lines
659 B
C

/* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef OPENOCD_HELPER_STRING_CHOICES_H
#define OPENOCD_HELPER_STRING_CHOICES_H
#include <helper/types.h>
/*
* This file contains helper functions that return one of two strings depending
* on a boolean value. The format of these functions is 'str_$true_$false' where
* $true and $false are the two corresponding strings.
*
* These helper functions are beneficial because they improve code consistency
* and reduce the number of hardcoded strings.
*/
static inline const char *str_enabled_disabled(bool value)
{
return value ? "enabled" : "disabled";
}
#endif /* OPENOCD_HELPER_STRING_CHOICES_H */