PSCF v1.1
PolymerType.cpp
1/*
2* PSCF - Polymer Self-Consistent Field Theory
3*
4* Copyright 2016 - 2022, The Regents of the University of Minnesota
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include "PolymerType.h"
9#include <util/global.h>
10#include <string>
11
12namespace Pscf
13{
14
15 using namespace Util;
16
17 /*
18 * Input stream extractor for a PolymerType enumeration.
19 */
20 std::istream& operator >> (std::istream& in, PolymerType::Enum& type)
21 {
22 std::string buffer;
23 in >> buffer;
24 if (buffer == "Branched" || buffer == "branched") {
25 type = PolymerType::Branched;
26 } else
27 if (buffer == "Linear" || buffer == "linear") {
28 type = PolymerType::Linear;
29 } else {
30 std::string msg = "Unknown input PolymerType value string: ";
31 msg += buffer;
32 UTIL_THROW(msg.c_str());
33 }
34 return in;
35 }
36
37 /*
38 * Input stream extractor for a PolymerType enumeration.
39 */
40 std::ostream& operator << (std::ostream& out, PolymerType::Enum& type)
41 {
42 if (type == PolymerType::Branched) {
43 out << "branched";
44 } else
45 if (type == PolymerType::Linear) {
46 out << "linear";
47 } else {
48 // This should never happen
49 UTIL_THROW("Error writing a PolymerType value");
50 }
51 return out;
52 }
53
54}
File containing preprocessor macros for error handling.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Definition: global.h:51
C++ namespace for polymer self-consistent field theory (PSCF).
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