1 #ifndef CLASSIC_FIELDMAP_ICC
2 #define CLASSIC_FIELDMAP_ICC
8 #include <boost/type_index.hpp>
16 std::streampos start = in.tellg();
19 if (in.eof() && !file_length_known) {
22 std::istringstream interpreter(buffer, std::istringstream::in);
26 if (interpreter.rdstate() ^ std::ios_base::eofbit) {
32 std::string expecting(boost::typeindex::type_id<T>().pretty_name());
33 interpretWarning((interpreter.rdstate() ^ std::ios_base::eofbit), read_all, expecting, buffer);
35 return (!(interpreter.rdstate() ^ std::ios_base::eofbit) && read_all);
38 template<
class S,
class T>
43 std::streampos start = in.tellg();
46 if (in.eof() && !file_length_known) {
49 std::istringstream interpreter(buffer, std::istringstream::in);
51 interpreter >> value1;
52 if (interpreter.rdstate()) read_all =
false;
54 interpreter >> value2;
56 if (interpreter.rdstate() ^ std::ios_base::eofbit) {
62 std::string expecting(boost::typeindex::type_id<S>().pretty_name());
63 expecting += std::string(
" ") + boost::typeindex::type_id<T>().pretty_name();
64 interpretWarning((interpreter.rdstate() ^ std::ios_base::eofbit), read_all, expecting, buffer);
66 return (!(interpreter.rdstate() ^ std::ios_base::eofbit) && read_all);
69 template<
class S,
class T,
class U>
74 std::streampos start = in.tellg();
77 if (in.eof() && !file_length_known) {
80 std::istringstream interpreter(buffer, std::istringstream::in);
82 interpreter >> value1;
84 interpreter >> value2;
85 if (interpreter.rdstate()) read_all =
false;
87 interpreter >> value3;
89 if (interpreter.rdstate() ^ std::ios_base::eofbit) {
95 std::string expecting(boost::typeindex::type_id<S>().pretty_name() + std::string(
" ") +
96 boost::typeindex::type_id<T>().pretty_name() + std::string(
" ") +
97 boost::typeindex::type_id<U>().pretty_name());
98 interpretWarning((interpreter.rdstate() ^ std::ios_base::eofbit), read_all, expecting, buffer);
100 return (!(interpreter.rdstate() ^ std::ios_base::eofbit) && read_all);
103 template<
class S,
class T,
class U,
class V>
106 bool read_all =
true;
108 std::streampos start = in.tellg();
111 if (in.eof() && !file_length_known) {
114 std::istringstream interpreter(buffer, std::istringstream::in);
116 interpreter >> value1;
118 interpreter >> value2;
120 interpreter >> value3;
121 if (interpreter.rdstate()) read_all =
false;
123 interpreter >> value4;
125 if (interpreter.rdstate() ^ std::ios_base::eofbit) {
131 std::string expecting(boost::typeindex::type_id<S>().pretty_name() + std::string(
" ") +
132 boost::typeindex::type_id<T>().pretty_name() + std::string(
" ") +
133 boost::typeindex::type_id<U>().pretty_name() + std::string(
" ") +
134 boost::typeindex::type_id<V>().pretty_name());
135 interpretWarning((interpreter.rdstate() ^ std::ios_base::eofbit), read_all, expecting, buffer);
137 return (!(interpreter.rdstate() ^ std::ios_base::eofbit) && read_all);
141 bool Fieldmap::interpretLine(std::ifstream & in, S & value1, S & value2, S & value3, S & value4, S & value5, S & value6,
const bool & file_length_known)
143 bool read_all =
true;
145 std::streampos start = in.tellg();
148 if (in.eof() && !file_length_known) {
151 std::istringstream interpreter(buffer, std::istringstream::in);
153 interpreter >> value1;
155 interpreter >> value2;
157 interpreter >> value3;
159 interpreter >> value4;
161 interpreter >> value5;
162 if (interpreter.rdstate()) read_all =
false;
164 interpreter >> value6;
166 if (interpreter.rdstate() ^ std::ios_base::eofbit) {
172 std::string expecting(boost::typeindex::type_id<S>().pretty_name() + std::string(
" ") +
173 boost::typeindex::type_id<S>().pretty_name() + std::string(
" ") +
174 boost::typeindex::type_id<S>().pretty_name() + std::string(
" ") +
175 boost::typeindex::type_id<S>().pretty_name() + std::string(
" ") +
176 boost::typeindex::type_id<S>().pretty_name() + std::string(
" ") +
177 boost::typeindex::type_id<S>().pretty_name());
178 interpretWarning((interpreter.rdstate() ^ std::ios_base::eofbit), read_all, expecting, buffer);
180 return (!(interpreter.rdstate() ^ std::ios_base::eofbit) && read_all);
void missingValuesWarning()
void interpretWarning(const std::ios_base::iostate &state, const bool &read_all, const std::string &error_msg, const std::string &found)
bool interpretLine(std::ifstream &in, S &value, const bool &file_length_known=true)
void getLine(std::ifstream &in, std::string &buffer)