PSCF v1.1
Str.h
1#ifndef UTIL_STR_H
2#define UTIL_STR_H
3
4/*
5* Util Package - C++ Utilities for Scientific Computation
6*
7* Copyright 2010 - 2017, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include <iostream>
12
13namespace Util
14{
15
36 class Str
37 {
38
39 public:
40
42
43
47 Str();
48
54 explicit Str(std::string value);
55
62 Str(std::string value, int width);
63
65
67
73 void setValue(std::string value);
74
80 void setWidth(int width);
81
83
85
87 std::string value() const;
88
90 int width() const;
91
93
94 private:
95
96 std::string value_;
97 int width_;
98
99 //friends:
100
101 friend std::istream& operator>>(std::istream& in, Str &object);
102 friend std::ostream& operator<<(std::ostream& out, const Str &object);
103
104 };
105
113 std::istream& operator>>(std::istream& in, Str &object);
114
122 std::ostream& operator<<(std::ostream& out, const Str &object);
123
124}
125#endif
Wrapper for a std::string, for formatted ostream output.
Definition: Str.h:37
int width() const
Return default string width.
Definition: Str.cpp:43
Str()
Default constructor.
Definition: Str.cpp:17
void setValue(std::string value)
Set the string value.
Definition: Str.cpp:34
friend std::istream & operator>>(std::istream &in, Str &object)
Input stream extractor for an Str object.
Definition: Str.cpp:49
std::string value() const
Return string value.
Definition: Str.cpp:40
void setWidth(int width)
Set the default width.
Definition: Str.cpp:37
friend std::ostream & operator<<(std::ostream &out, const Str &object)
Output stream inserter for an Str object.
Definition: Str.cpp:58
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