diff options
Diffstat (limited to 'c++-libbu++/src/boolean.cpp')
| -rw-r--r-- | c++-libbu++/src/boolean.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/c++-libbu++/src/boolean.cpp b/c++-libbu++/src/boolean.cpp new file mode 100644 index 0000000..729e644 --- /dev/null +++ b/c++-libbu++/src/boolean.cpp | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | #include "gats/boolean.h" | ||
| 2 | |||
| 3 | #include <bu/formatter.h> | ||
| 4 | #include <bu/stream.h> | ||
| 5 | |||
| 6 | Gats::Boolean::Boolean() : | ||
| 7 | bVal( false ) | ||
| 8 | { | ||
| 9 | } | ||
| 10 | |||
| 11 | Gats::Boolean::Boolean( bool bVal ) : | ||
| 12 | bVal( bVal ) | ||
| 13 | { | ||
| 14 | } | ||
| 15 | |||
| 16 | Gats::Boolean::~Boolean() | ||
| 17 | { | ||
| 18 | } | ||
| 19 | |||
| 20 | Gats::Object *Gats::Boolean::clone() const | ||
| 21 | { | ||
| 22 | return new Gats::Boolean( bVal ); | ||
| 23 | } | ||
| 24 | |||
| 25 | void Gats::Boolean::write( Bu::Stream &rOut ) const | ||
| 26 | { | ||
| 27 | if( bVal ) | ||
| 28 | { | ||
| 29 | rOut.write("1", 1 ); | ||
| 30 | } | ||
| 31 | else | ||
| 32 | { | ||
| 33 | rOut.write("0", 1 ); | ||
| 34 | } | ||
| 35 | } | ||
| 36 | |||
| 37 | void Gats::Boolean::read( Bu::Stream &rIn, char cType ) | ||
| 38 | { | ||
| 39 | if( cType == '1' ) | ||
| 40 | { | ||
| 41 | bVal = true; | ||
| 42 | } | ||
| 43 | else | ||
| 44 | { | ||
| 45 | bVal = false; | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Boolean &b ) | ||
| 50 | { | ||
| 51 | return f << "(bool) " << b.getValue(); | ||
| 52 | } | ||
| 53 | |||
