GY-63_MS5611/libraries/Troolean/Troolean.h

67 lines
1.3 KiB
C
Raw Normal View History

2020-11-27 05:33:55 -05:00
#pragma once
2018-01-28 09:34:55 -05:00
//
// FILE: Troolean.h
// AUTHOR: Rob Tillaart
2022-12-02 08:12:22 -05:00
// VERSION: 0.1.7
2020-11-27 05:33:55 -05:00
// PURPOSE: Arduino Library for a three state logic datatype supporting {true false unknown}
// URL: https://github.com/RobTillaart/Troolean
// https://en.wikipedia.org/wiki/Three-valued_logic
2018-01-28 09:34:55 -05:00
// Kleene and Priest logics
2021-01-29 06:31:58 -05:00
2018-01-28 09:34:55 -05:00
#include "Arduino.h"
#include "Printable.h"
2022-12-02 08:12:22 -05:00
#define TROOLEAN_LIB_VERSION (F("0.1.7"))
2021-01-29 06:31:58 -05:00
2022-11-26 10:50:57 -05:00
// VALUE MEANING
// 0 = false
// -1 = unknown
// other = true
2021-12-29 07:05:17 -05:00
#define unknown -1
2021-01-29 06:31:58 -05:00
2018-01-28 09:34:55 -05:00
class Troolean: public Printable
{
public:
Troolean();
2022-11-26 10:50:57 -05:00
Troolean(const int8_t); // 0 = false, -1 = unknown anything else = true
2018-01-28 09:34:55 -05:00
Troolean(const Troolean&);
2022-12-02 08:12:22 -05:00
// PRINTING
2018-01-28 09:34:55 -05:00
size_t printTo(Print&) const;
2022-12-02 08:12:22 -05:00
// EQUALITIES
2018-01-28 09:34:55 -05:00
bool operator == (const Troolean&);
bool operator == (const bool&);
bool operator == (const int&);
bool operator != (const Troolean&);
bool operator != (const bool&);
bool operator != (const int&);
operator bool() const;
2022-12-02 08:12:22 -05:00
// NEGATE
Troolean operator ! (); // not, negate
2018-01-28 09:34:55 -05:00
2022-12-02 08:12:22 -05:00
// LOGICAL OPERATORS
2018-01-28 09:34:55 -05:00
Troolean operator && (const Troolean&);
Troolean operator && (const bool&);
Troolean operator || (const Troolean&);
Troolean operator || (const bool&);
2022-12-02 08:12:22 -05:00
bool isTrue();
bool isFalse();
bool isUnknown();
2018-01-28 09:34:55 -05:00
2021-12-29 07:05:17 -05:00
2018-01-28 09:34:55 -05:00
private:
int8_t _value;
};
2021-12-29 07:05:17 -05:00
2022-11-26 10:50:57 -05:00
// -- END OF FILE --
2021-12-29 07:05:17 -05:00