PSCF v1.1
Bool.cpp
1/*
2* Util Package - C++ Utilities for Scientific Computation
3*
4* Copyright 2010 - 2017, The Regents of the University of Minnesota
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include "Bool.h"
9#include "Format.h"
10
11namespace Util
12{
13
14 // Default constructor.
16 : value_(0),
17 width_(Format::defaultWidth())
18 {}
19
20 // Constructor, value only.
21 Bool::Bool(bool value)
22 : value_(value),
23 width_(Format::defaultWidth())
24 {}
25
27 Bool::Bool(bool value, int width)
28 : value_(value),
29 width_(width)
30 {}
31
32 void Bool::setValue(bool value)
33 { value_ = value; }
34
35 void Bool::setWidth(int width)
36 { width_ = width; }
37
39 { return value_; }
40
42 { return width_; }
43
44 /*
45 * Input stream extractor for an Bool object.
46 */
47 std::istream& operator>>(std::istream& in, Bool &object)
48 {
49 in >> object.value_;
50 return in;
51 }
52
53 /*
54 * Output stream inserter for an Bool object.
55 */
56 std::ostream& operator<<(std::ostream& out, const Bool &object)
57 {
58 out.width(object.width_);
59 out << object.value_;
60 return out;
61 }
62
63}
Wrapper for an bool value, for formatted ostream output.
Definition: Bool.h:36
void setValue(bool value)
Set the value.
Definition: Bool.cpp:32
int width()
Return default width (number of characters).
Definition: Bool.cpp:41
Bool()
Default constructor.
Definition: Bool.cpp:15
bool value()
Return value.
Definition: Bool.cpp:38
void setWidth(int width)
Set the output width.
Definition: Bool.cpp:35
Base class for output wrappers for formatted C++ ostream output.
Definition: Format.h:25
Utility classes for scientific computation.
Definition: accumulators.mod:1
std::istream & operator>>(std::istream &in, Pair< Data > &pair)
Input a Pair from an istream.
Definition: Pair.h:44
std::ostream & operator<<(std::ostream &out, const Pair< Data > &pair)
Output a Pair to an ostream, without line breaks.
Definition: Pair.h:57