(file) Return to Boolean.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

 1 mike  1.5 //%/////////////////////////////////////////////////////////////////////////////
 2           //
 3 kumpf 1.7 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
 4           // The Open Group, Tivoli Systems
 5 mike  1.5 //
 6           // Permission is hereby granted, free of charge, to any person obtaining a copy
 7 kumpf 1.7 // of this software and associated documentation files (the "Software"), to
 8           // deal in the Software without restriction, including without limitation the
 9           // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 mike  1.5 // sell copies of the Software, and to permit persons to whom the Software is
11           // furnished to do so, subject to the following conditions:
12           // 
13 kumpf 1.7 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
14 mike  1.5 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
15           // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
16 kumpf 1.7 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17           // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
18           // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 mike  1.5 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20           // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21           //
22           //==============================================================================
23           //
24           // Author: Mike Brasher (mbrasher@bmc.com)
25           //
26           // Modified By:
27           //
28           //%/////////////////////////////////////////////////////////////////////////////
29           
30           #ifndef Pegasus_Boolean_h
31           #define Pegasus_Boolean_h
32           
33           #include <Pegasus/Common/Config.h>
34           
35           PEGASUS_NAMESPACE_BEGIN
36           
37 mike  1.6 /** This class provides an implementation of the boolean for compilers which
38               do not support "bool" as a type.
39           
40               This class is not used by modern C++ compilers.
41           */
42 mike  1.5 class Boolean
43           {
44           public:
45           
46               Boolean() { }
47           
48               ~Boolean() { }
49           
50               Boolean(const Boolean& x) : _flag(x._flag) { }
51           
52               Boolean(int flag) : _flag(flag ? 1 : 0) { }
53           
54               Boolean& operator=(const Boolean& flag) { _flag = flag; return *this; }
55           
56               Boolean& operator=(int flag) { _flag = flag ? 1 : 0; return *this; }
57           
58               operator int() const { return _flag; }
59           
60               friend Boolean operator==(const Boolean& x, const Boolean& y);
61           
62               friend Boolean operator!=(const Boolean& x, const Boolean& y);
63 mike  1.5 
64           private:
65           
66               char _flag;
67           };
68           
69           inline Boolean operator==(const Boolean& x, const Boolean& y)
70           {
71               return x._flag == y._flag;
72           }
73           
74           inline Boolean operator!=(const Boolean& x, const Boolean& y)
75           {
76               return !operator==(x, y);
77           }
78           
79           #define true Boolean(1)
80           
81           #define false Boolean(0)
82           
83           PEGASUS_NAMESPACE_END
84 mike  1.5 
85           #endif /* Pegasus_Boolean_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2