51 lines
1.4 KiB
C++
51 lines
1.4 KiB
C++
#pragma once
|
|
#include <string>
|
|
|
|
namespace bts::core {
|
|
|
|
class BoolName {
|
|
public:
|
|
explicit constexpr BoolName(bool value);
|
|
|
|
[[nodiscard]] static constexpr const std::string &true_false(bool value);
|
|
[[nodiscard]] static constexpr const std::string &yes_no(bool value);
|
|
[[nodiscard]] static constexpr const std::string &y_n(bool value);
|
|
[[nodiscard]] static constexpr const std::string &on_off(bool value);
|
|
|
|
private:
|
|
bool value_;
|
|
|
|
struct Names {
|
|
static inline const std::string _TRUE = "true";
|
|
static inline const std::string _FALSE = "false";
|
|
static inline const std::string YES = "yes";
|
|
static inline const std::string NO = "no";
|
|
static inline const std::string Y = "y";
|
|
static inline const std::string N = "n";
|
|
static inline const std::string ON = "on";
|
|
static inline const std::string OFF = "off";
|
|
};
|
|
};
|
|
|
|
//////////////////////////////////////////////////
|
|
// Definition
|
|
//////////////////////////////////////////////////
|
|
|
|
constexpr const std::string &BoolName::true_false(bool value) {
|
|
return value ? Names::_TRUE : Names::_FALSE;
|
|
}
|
|
|
|
constexpr const std::string &BoolName::yes_no(bool value) {
|
|
return value ? Names::YES : Names::NO;
|
|
}
|
|
|
|
constexpr const std::string &BoolName::y_n(bool value) {
|
|
return value ? Names::Y : Names::N;
|
|
}
|
|
|
|
constexpr const std::string &BoolName::on_off(bool value) {
|
|
return value ? Names::ON : Names::OFF;
|
|
}
|
|
|
|
} // namespace bts::core
|