guit  0.1
 All Classes Functions Variables Typedefs Enumerations Friends
gbool.hpp
1 //
2 // Bool Prop
3 // Guit GUI Toolkit
4 // Copyright © 2019/2020 Eric Lecolinet. All rights reserved.
5 // http://www.telecom-paris.fr/~elc
6 //
7 
8 #ifndef GuitBool_hpp
9 #define GuitBool_hpp
10 #include <gvarprop.hpp>
11 namespace guit {
12 
14 class GBool : public GVarProp_<bool> {
15 public:
16  using Super = GVarProp_<bool> ;
17  using IsBool = bool;
18 
19  GBool();
20  GBool(bool value);
21  GBool(GString const& value);
22  GBool(GBool const&);
23  GBool* clone(bool copy_value) const override;
24 
25  GBool* toBool() override {return this;}
26  bool boolValue() const override {return value_;}
27  float floatValue() const override {return float(value_);}
28 
29  GBool& operator=(bool val) {set(val,false); return *this;}
30  GBool& operator=(GBool const& val) {set(val); return *this;}
31  GBool& operator=(GString const& val) {set(val); return *this;}
32 
33  using Super::set;
34  void set(GProp const&) override;
35 
37  auto operator~() {return GPropRef_<GBool>(*this);}
38 
52  GBoolExpr& operator-();
57 
58  using GType = GPropType_<GBool,GProp>;
59  static GType& Type();
60  GType& type() const override {return Type();}
61 };
62 
65 GBool& Bool();
66 inline GBool& Bool(bool value) {return *new GBool(value);}
67 GBool& Bool(GString const& value);
69 
70 }
71 #endif