00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <Sequence/SimParams.hpp>
00025 #include <Sequence/Portability/StringStreams.hpp>
00026 #include <iostream>
00027 #include <cctype>
00028
00029 namespace Sequence
00030 {
00031 SimParams::SimParams (void):_command_line(""),_howmany(0),tsam(0)
00032 {}
00033
00034 int SimParams::fromfile ( FILE * openfile )
00035 {
00036 _command_line.clear();
00037 _command_line.reserve(100);
00038 int ch;
00039 while( (ch=std::fgetc(openfile)) != EOF )
00040 {
00041 if (ch == '\n')
00042 break;
00043 else
00044 _command_line += char(ch);
00045 }
00046
00047
00048 while( (ch=std::fgetc(openfile)) != EOF )
00049 {
00050 if ((!isdigit(ch)&&!isspace(ch))|| ch=='\n')
00051 break;
00052 }
00053 istr in(_command_line.c_str());
00054 std::string ms;
00055 in >> ms >> tsam >> _howmany;
00056 return (ch);
00057 }
00058
00059 std::istream & SimParams::read (std::istream & s)
00063 {
00064 _command_line.clear();
00065 char ch;
00066
00067 while (s.get(ch))
00068 {
00069 if (ch == '\n')
00070 {
00071 break;
00072 }
00073 else
00074 {
00075 _command_line += ch;
00076 }
00077 }
00078
00079
00080
00081
00082 while (1)
00083 {
00084 s.get (ch);
00085 if ((!isdigit(int(ch))&&!isspace(int(ch)))|| ch=='\n')
00086 break;
00087
00088
00089 }
00090
00091
00092
00093 istr in(_command_line.c_str());
00094 std::string ms;
00095 in >> ms >> tsam >> _howmany;
00096 return s;
00097 }
00098
00099 std::ostream & operator<< (std::ostream & stream, class SimParams & object)
00105 {
00106 stream << object._command_line;
00107 return (stream);
00108 }
00109
00110 std::istream& operator>>(std::istream& s, SimParams& c)
00116 {
00117 return c.read (s);
00118 }
00119 }