libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CRNProp3.h
Go to the documentation of this file.
1 /* Copyright 2006-2016 Yann LEYDIER, CoReNum, INSA-Lyon, ENS-Lyon
2  *
3  * This file is part of libcrn.
4  *
5  * libcrn is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * libcrn is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libcrn. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * file: CRNProp3.h
19  * \author Yann LEYDIER
20  */
21 
22 #ifndef CRNPROP3_HEADER
23 #define CRNPROP3_HEADER
24 
25 #include <CRNString.h>
26 
27 namespace crn
28 {
29 
30  /****************************************************************************/
40  class Prop3: public Object
41  {
42  public:
44  Prop3() noexcept :
45  value(Prop3::UNKNOWNval)
46  {}
48  Prop3(int val) noexcept;
49  Prop3(bool val) noexcept :
50  value(val ? TRUEval : FALSEval)
51  {}
52  Prop3(const Prop3 &) = default;
53  Prop3(Prop3 &&) = default;
54  ~Prop3() = default;
55 
56  Prop3& operator=(const Prop3 &) = default;
57  Prop3& operator=(Prop3 &&) = default;
58 
60  Prop3 operator|(const Prop3 &prop) const noexcept;
62  Prop3& operator|=(const Prop3 &prop) noexcept;
64  Prop3 operator&(const Prop3 &prop) const noexcept;
66  Prop3& operator&=(const Prop3 &prop) noexcept;
68  bool operator==(const Prop3 &prop) const noexcept;
70  Prop3& operator=(const int &prop) noexcept;
72  Prop3 operator!() const noexcept;
74  bool IsTrue() const noexcept;
76  bool IsFalse() const noexcept;
78  bool IsUnknown() const noexcept;
79 
81  String ToString() const;
83  int GetValue() const noexcept { return value; }
84 
85  static constexpr int FALSEval = 0;
86  static constexpr int TRUEval = 1;
87  static constexpr int UNKNOWNval = 2;
88  static Prop3 True() { return true; };
89  static Prop3 False() { return false; };
90  static Prop3 Unknown() { return Prop3{}; };
93  void Deserialize(xml::Element &el);
95  xml::Element Serialize(xml::Element &parent) const;
96 
97  private:
98 
99  int value;
103  };
104  template<> struct IsSerializable<Prop3> : public std::true_type {};
105  template<> struct IsClonable<Prop3> : public std::true_type {};
106 
108 }
109 #endif
110 
#define CRN_SERIALIZATION_CONSTRUCTOR(classname)
Defines a default constructor from xml element.
Definition: CRNObject.h:165
static Prop3 Unknown()
Definition: CRNProp3.h:90
bool operator==(const Prop3 &prop) const noexcept
Comparison.
Definition: CRNProp3.cpp:107
Prop3 & operator=(const Prop3 &)=default
XML element.
Definition: CRNXml.h:135
bool IsUnknown() const noexcept
Is unknown?
Definition: CRNProp3.cpp:179
Prop3 operator!() const noexcept
Complementary operator.
Definition: CRNProp3.cpp:129
void Deserialize(xml::Element &el)
Initializes the object from an XML element. Unsafe.
Definition: CRNProp3.cpp:189
bool IsFalse() const noexcept
Is false?
Definition: CRNProp3.cpp:177
bool IsTrue() const noexcept
Is true?
Definition: CRNProp3.cpp:175
static constexpr int UNKNOWNval
Definition: CRNProp3.h:87
Prop3() noexcept
Default constructor.
Definition: CRNProp3.h:44
A UTF32 character string class.
Definition: CRNString.h:61
Prop3 & operator|=(const Prop3 &prop) noexcept
Logical OR operator.
Definition: CRNProp3.cpp:145
static Prop3 False()
Definition: CRNProp3.h:89
xml::Element Serialize(xml::Element &parent) const
Dumps the object to an XML element. Unsafe.
Definition: CRNProp3.cpp:206
Prop3 operator&(const Prop3 &prop) const noexcept
Logical AND operator.
Definition: CRNProp3.cpp:91
Prop3(bool val) noexcept
Definition: CRNProp3.h:49
Prop3 operator|(const Prop3 &prop) const noexcept
Logical OR operator.
Definition: CRNProp3.cpp:75
Prop3 & operator&=(const Prop3 &prop) noexcept
Logical AND operator.
Definition: CRNProp3.cpp:163
int GetValue() const noexcept
Returns the internal integer value.
Definition: CRNProp3.h:83
#define CRN_DECLARE_CLASS_CONSTRUCTOR(classname)
Declares a class constructor.
Definition: CRNObject.h:173
static Prop3 True()
Definition: CRNProp3.h:88
CRN_ALIAS_SMART_PTR(ImageBW)
static constexpr int TRUEval
Definition: CRNProp3.h:86
A ternary proposition.
Definition: CRNProp3.h:40
static constexpr int FALSEval
Definition: CRNProp3.h:85
String ToString() const
Dumps value to a string.
Definition: CRNProp3.cpp:54
~Prop3()=default