Boolean.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-09
  6. * Changed: 2020-08-09
  7. *
  8. * */
  9. #ifndef BOOLEAN_HPP
  10. #define BOOLEAN_HPP
  11. #include "../base/Class.hpp"
  12. #include "IBoxing.hpp"
  13. namespace ls_std {
  14. class Boolean : public Class, IBoxing {
  15. public:
  16. explicit Boolean(bool _value);
  17. Boolean();
  18. ~Boolean() = default;
  19. // conversion operator
  20. operator bool() const;
  21. // stream operators
  22. friend std::ostream& operator<<(std::ostream& outputStream, const Boolean& _boolean) {
  23. outputStream << _boolean._toString();
  24. return outputStream;
  25. }
  26. // logical operators
  27. friend bool operator!(const Boolean& _boolean) {
  28. return !_boolean.value;
  29. }
  30. // bool operator&&(const Boolean& _boolean) const;
  31. // bool operator&&(bool _value) const;
  32. // bool operator&&(int _value) const;
  33. // bool operator||(const Boolean& _boolean) const;
  34. // bool operator||(bool _value) const;
  35. // bool operator||(int _value) const;
  36. // implementation
  37. void parse(std::string parseText) override;
  38. std::string toString() override;
  39. private:
  40. bool value {};
  41. const std::string TRUE_STRING = "true";
  42. const std::string FALSE_STRING = "false";
  43. std::string _toString() const;
  44. };
  45. }
  46. #endif