Simpatico  v1.10
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 
11 namespace 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 
38  bool Bool::value()
39  { return value_; }
40 
41  int Bool::width()
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 }
Base class for output wrappers for formatted C++ ostream output.
Definition: Format.h:24
friend std::istream & operator>>(std::istream &in, Bool &object)
Input stream extractor for an Bool object.
Definition: Bool.cpp:47
Utility classes for scientific computation.
Definition: accumulators.mod:1
Wrapper for an bool value, for formatted ostream output.
Definition: Bool.h:35
Bool()
Default constructor.
Definition: Bool.cpp:15
friend std::ostream & operator<<(std::ostream &out, const Bool &object)
Output stream inserter for an Bool object.
Definition: Bool.cpp:56