Simpatico  v1.10
Int.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 "Int.h"
9 #include "Format.h"
10 
11 #include <iostream>
12 
13 namespace Util
14 {
15 
16  /*
17  * Default constructor.
18  */
20  : value_(0),
21  width_(Format::defaultWidth())
22  {}
23 
24  /*
25  * Constructor, value only.
26  */
28  : value_(value),
29  width_(Format::defaultWidth())
30  {}
31 
32  /*
33  * Constructor, value and width.
34  */
35  Int::Int(int value, int width)
36  : value_(value),
37  width_(width)
38  {}
39 
40  /*
41  * Set value.
42  */
43  void Int::setValue(int value)
44  { value_ = value; }
45 
46  /*
47  * Set field Width.
48  */
49  void Int::setWidth(int width)
50  { width_ = width; }
51 
52  /*
53  * Get value.
54  */
55  int Int::value()
56  { return value_; }
57 
58  /*
59  * Get field width.
60  */
61  int Int::width()
62  { return width_; }
63 
71  std::istream& operator>>(std::istream& in, Int &object)
72  {
73  in >> object.value_;
74  return in;
75  }
76 
84  std::ostream& operator<<(std::ostream& out, const Int &object)
85  {
86  out.width(object.width_);
87  out << object.value_;
88  return out;
89  }
90 
91 }
Base class for output wrappers for formatted C++ ostream output.
Definition: Format.h:24
void setWidth(int width)
Set the output field width.
Definition: Int.cpp:49
Int()
Default constructor.
Definition: Int.cpp:19
int value()
Get the integer value.
Definition: Int.cpp:55
int width()
Get the minimum field width.
Definition: Int.cpp:61
Utility classes for scientific computation.
Definition: accumulators.mod:1
friend std::istream & operator>>(std::istream &in, Int &object)
Input stream extractor for an Int object.
Definition: Int.cpp:71
Wrapper for an int, for formatted ostream output.
Definition: Int.h:36
void setValue(int value)
Set the integer value.
Definition: Int.cpp:43
friend std::ostream & operator<<(std::ostream &out, const Int &object)
Output stream inserter for an Int object.
Definition: Int.cpp:84