[cig-commits] r8139 - in cs/spatialdata-0.1/trunk/libsrc: spatialdb
utils
brad at geodynamics.org
brad at geodynamics.org
Wed Oct 17 17:48:25 PDT 2007
Author: brad
Date: 2007-10-17 17:48:25 -0700 (Wed, 17 Oct 2007)
New Revision: 8139
Modified:
cs/spatialdata-0.1/trunk/libsrc/spatialdb/SimpleIOAscii.cc
cs/spatialdata-0.1/trunk/libsrc/utils/LineParser.cc
Log:
Added more error checking of stream state.
Modified: cs/spatialdata-0.1/trunk/libsrc/spatialdb/SimpleIOAscii.cc
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/spatialdb/SimpleIOAscii.cc 2007-10-18 00:13:23 UTC (rev 8138)
+++ cs/spatialdata-0.1/trunk/libsrc/spatialdb/SimpleIOAscii.cc 2007-10-18 00:48:25 UTC (rev 8139)
@@ -89,6 +89,8 @@
throw std::runtime_error(msg.str());
} // default
} // switch
+ if (!filein.good())
+ throw std::runtime_error("Unknown error while reading.");
} catch (const std::exception& err) {
std::ostringstream msg;
msg << "Error occurred while reading spatial database file '"
@@ -101,9 +103,9 @@
<< filename() << "'.\n";
throw std::runtime_error(msg.str());
} // try/catch
+
} // read
-#include <iostream>
// ----------------------------------------------------------------------
// Read ascii database file.
void
@@ -179,12 +181,14 @@
buffer.ignore(maxIgnore, '=');
std::string rbuffer(buffer.str());
filein.putback('\n');
+ filein.clear();
int i = rbuffer.length()-1;
while (i >= 0) {
filein.putback(rbuffer[i]);
if ('=' == rbuffer[i--])
break;
} // while
+ filein.clear();
spatialdata::geocoords::CSPicklerAscii::unpickle(filein, ppCS);
} else {
std::ostringstream msg;
@@ -196,7 +200,7 @@
buffer.clear();
buffer >> token;
} // while
- if (token != "}")
+ if (token != "}" || !filein.good())
throw std::runtime_error("I/O error while parsing SimpleDB settings.");
bool ok = true;
Modified: cs/spatialdata-0.1/trunk/libsrc/utils/LineParser.cc
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/utils/LineParser.cc 2007-10-18 00:13:23 UTC (rev 8138)
+++ cs/spatialdata-0.1/trunk/libsrc/utils/LineParser.cc 2007-10-18 00:48:25 UTC (rev 8139)
@@ -80,6 +80,7 @@
const size_t size = buffer.length();
for (int i=size-1; i >= 0; --i)
_in.putback(buffer[i]);
+ _in.clear();
} // putback
More information about the cig-commits
mailing list