PSCF v1.1
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
13namespace Util
14{
15
16 /*
17 * Default constructor.
18 */
20 : value_(0),
21 width_(Format::defaultWidth())
22 {}
23
24 /*
25 * Constructor, value only.
26 */
27 Int::Int(int value)
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 */
56 { return value_; }
57
58 /*
59 * Get field width.
60 */
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:25
Wrapper for an int, for formatted ostream output.
Definition: Int.h:37
int value()
Get the integer value.
Definition: Int.cpp:55
void setWidth(int width)
Set the output field width.
Definition: Int.cpp:49
void setValue(int value)
Set the integer value.
Definition: Int.cpp:43
Int()
Default constructor.
Definition: Int.cpp:19
int width()
Get the minimum field width.
Definition: Int.cpp:61
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