Modify smack rule to access the privilege description DB
[platform/framework/native/appfw.git] / inc / FBaseBoolean.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FBaseBoolean.h
20  * @brief               This is the header file for the %Boolean class.
21  *
22  * This header file contains the declarations of the %Boolean class.
23  */
24 #ifndef _FBASE_BOOLEAN_H_
25 #define _FBASE_BOOLEAN_H_
26
27 #include <FBaseObject.h>
28 #include <FBaseString.h>
29
30
31 namespace Tizen { namespace Base
32 {
33 /**
34  *      @class  Boolean
35  *      @brief  This class is the wrapper class for the @c bool data type.
36  *
37  *      @since 2.0
38  *
39  * The %Boolean class wraps a bool type value. This enables passing a bool value to a method that only accepts an instance of the Object class.
40  * It provides methods to convert %Boolean instances to String and %String instances to %Boolean.
41  *
42  * The following example demonstrates how to use the %Boolean class.
43  *
44  *      @code
45  *
46  *      #include <FBase.h>
47  *
48  *      using namespace Tizen::Base;
49  *
50  *      void
51  *      MyClass::Test(void)
52  *      {
53  *              Boolean b1(true);
54  *
55  *              String string1(b1.ToString());          // string1 == L"true"
56  *
57  *
58  *              // Compares the string1 with L"true"
59  *              if (Boolean::Parse(string1))
60  *              {
61  *                      // ...
62  *              }
63  *
64  *      }
65  *      @endcode
66  */
67 class _OSP_EXPORT_ Boolean
68         : public Object
69 {
70 public:
71         /**
72          *      Initializes this instance of the %Boolean class with the specified @c value.
73          *
74          *      @since 2.0
75          *
76          *      @param[in]      value   The input @c bool value to initialize the %Boolean instance
77          */
78         Boolean(bool value);
79
80         /**
81          *      Copying of objects using this copy constructor is allowed.
82          *
83          *      @since 2.0
84          *
85          *      @param[in]      value   An instance of the %Boolean class
86          */
87         Boolean(const Boolean& value);
88
89         /**
90          *      Initializes this instance of %Boolean with the specified input string. @n
91      *  If the input is "true" (ignoring case), the object is initialized to @c true,
92          *      else @c false.
93          *
94          *      @since 2.0
95          *
96          *      @param[in]      value   An instance of String
97          */
98         Boolean(const String& value);
99
100         /**
101          *      This destructor overrides Tizen::Base::Object::~Object().
102          *
103          *      @since 2.0
104          */
105         virtual ~Boolean(void);
106
107         /**
108          *      Compares the values of two %Boolean instances.
109          *
110          *      @since 2.0
111          *
112          *      @return                 @c true if the values of the objects are equal, @n
113          *                                  else @c false.
114          *      @param[in]      rhs             An instance of %Boolean to compare with the current instance
115          */
116         bool operator ==(const Boolean& rhs) const;
117
118         /**
119          *      Checks whether the two %Boolean instances are not equal.
120          *
121          *      @since 2.0
122          *
123          *      @return                 @c true if the values of the objects are not equal, @n
124          *                                  else @c false
125          *      @param[in]      rhs             An instance of %Boolean to compare with the current instance
126          */
127         bool operator !=(const Boolean& rhs) const;
128
129         /**
130          *      Copying of objects using this copy assignment operator is allowed.
131          *
132          *      @since 2.0
133          *
134          *  @param[in]  rhs     An instance of %Boolean
135          */
136         Boolean& operator =(const Boolean& rhs);
137
138         /**
139          *      Converts an instance of the Object class to an instance of %Boolean and then
140          *      compares it with the calling %Boolean instance.
141          *
142          *      @since 2.0
143          *
144          *      @return                 @c true if the value of @c obj matches the value of the calling %Boolean instance, @n
145          *                                  else @c false
146          *      @param[in]      obj             A reference to the Object instance to compare with the calling %Boolean instance
147          *      @see                            Tizen::Base::Object::Equals()
148          */
149         virtual bool Equals(const Object& obj) const;
150
151         /**
152          *      Gets the hash value of the current instance.
153          *
154          *      @since 2.0
155          *
156          *      @return         The hash value of the current instance
157          *      @remarks        The two Tizen::Base::Object::Equals() instances must return the same hash value. For better performance, @n
158          *                              the used hash function must generate a random distribution for all inputs.
159          */
160         virtual int GetHashCode(void) const;
161
162         /**
163          *      Converts a bool value to an instance of %Boolean and then
164          *      compares it with the calling %Boolean instance.
165          *
166          *      @since 2.0
167          *
168          *  @return                     @c true if the parameter matches the calling %Boolean instance, @n
169          *                   else @c false
170          *  @param[in]  value   The @c bool value to compare to this instance
171          */
172         bool Equals(bool value) const;
173
174         /**
175          * Returns the value of the calling object as @c bool.
176          *
177          * @since 2.0
178          *
179          * @return              The value of the %Boolean instance as bool
180          */
181         bool ToBool(void) const;
182
183         /**
184          *      Parses the specified string and converts it to a @c bool value.
185          *
186          *      @since 2.0
187          *
188          *      @return         @c true if the value of the specified string is "true", @n
189          *                              else @c false
190          *      @param[in]      s                       An instance of String
191          *      @remarks        This method is case sensitive. @n
192          *                              It only accepts lowercase strings.
193          *
194          *      @code
195          *      bool b1 = Boolean::Parse(trueString); // trueString is L"true"
196          *      bool b1 = Boolean::Parse(falseString); // falseString is L"false"
197          *      @endcode
198          */
199         static bool Parse(const String& s);
200
201         /**
202          *      Parses the specified string and converts it to a @c bool value. @n
203          *      Case sensitivity can be controlled.
204          *
205          *      @since 2.0
206          *
207          *      @return         @c true if the value of the specified string is "true", @n
208          *                              else @c false
209          *      @param[in]      s                                       An instance of String
210          *      @param[in]      caseSensitive   Set to @c true to perform a
211          *                                                              case sensitive comparison of string @c s
212          *      @remarks        If @c caseSensitive is @c true, L"True" returns @c false, else @c true.
213          *
214          *  @code
215          *  bool b1 = Boolean::Parse(L"True", false ); // Returns @c true
216          *  bool b1 = Boolean::Parse(L"True", true); // Returns @c false
217          *  @endcode
218          */
219         static bool Parse(const String& s, bool caseSensitive);
220
221         /**
222          *      Converts the value of the calling instance from @c bool to String.
223          *
224          *      @since 2.0
225          *
226          *      @return @c true if this instance is @c true, @n
227          *                      else @c false
228          */
229         String ToString(void) const;
230
231         /**
232          *      Converts a @c bool parameter to a String
233          *      instance of the %String class and returns the string representation of the
234          *      input @c bool value (@c true or @c false).
235          *
236          *      @since 2.0
237          *
238          *      @return @c true if the parameter is @c true, @n
239          *                      else @c false
240          *      @param[in]      value   A @c bool value to convert to String
241          */
242         static String ToString(bool value);
243
244         /**
245          *      Returns a %Boolean instance whose value corresponds to the
246          *      primitive value @c true.
247          *
248          *      @since 2.0
249          *
250          *      @return         A %Boolean instance equivalent to @c true
251          */
252         static const Boolean GetTrue(void);
253
254         /**
255          *      Returns a %Boolean instance whose value corresponds to the primitive
256          *      value @c false.
257          *
258          *      @since 2.0
259          *
260          *      @return         A %Boolean instance equivalent to @c false
261          */
262         static const Boolean GetFalse(void);
263
264         /**
265          * A boolean value of this instance.
266          *
267          * @since 2.0
268          */
269         bool value;
270
271 private:
272         friend class _BooleanImpl;
273         class _BooleanImpl * __pBooleanImpl;
274
275 }; // Boolean
276
277 }} // Tizen::Base
278
279 #endif //_FBASE_BOOLEAN_H_