[Liblas-commits] hg: if the stream goes kablooey while we're filtering, we're don...

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Jan 26 12:18:11 EST 2011


details:   http://hg.liblas.orghg/rev/09ff946e9e8b
changeset: 2823:09ff946e9e8b
user:      Howard Butler <hobu.inc at gmail.com>
date:      Wed Jan 26 11:18:07 2011 -0600
description:
if the stream goes kablooey while we're filtering, we're done reading points

diffstat:

 src/detail/reader/reader.cpp |  36 ++++++++++++++++++++++++++++++------
 1 files changed, 30 insertions(+), 6 deletions(-)

diffs (57 lines):

diff -r b419fa13bed9 -r 09ff946e9e8b src/detail/reader/reader.cpp
--- a/src/detail/reader/reader.cpp	Wed Jan 26 11:15:06 2011 -0600
+++ b/src/detail/reader/reader.cpp	Wed Jan 26 11:18:07 2011 -0600
@@ -164,8 +164,16 @@
             m_point->SetHeaderPtr(m_header);
     }
     
-    detail::read_n(m_point->GetData().front(), m_ifs, m_record_size);
-    ++m_current;
+    try
+    {
+        detail::read_n(m_point->GetData().front(), m_ifs, m_record_size);
+        ++m_current;
+        
+    } catch (std::runtime_error&)
+    {
+        // If the stream is no good anymore, we're done reading points
+        return;
+    }
 
     // Filter the points and continue reading until we either find 
     // one to keep or throw an exception.
@@ -177,14 +185,30 @@
         if (!FilterPoint(*m_point))
         {
 
-            detail::read_n(m_point->GetData().front(), m_ifs, m_record_size);
-            ++m_current;
+            try
+            {
+                detail::read_n(m_point->GetData().front(), m_ifs, m_record_size);
+                ++m_current;
+        
+            } catch (std::runtime_error&)
+            {
+                // If the stream is no good anymore, we're done reading points
+                return;
+            }
 
             while (!FilterPoint(*m_point))
             {
 
-                detail::read_n(m_point->GetData().front(), m_ifs, m_record_size);
-                ++m_current;
+                try
+                {
+                    detail::read_n(m_point->GetData().front(), m_ifs, m_record_size);
+                    ++m_current;
+        
+                } catch (std::runtime_error&)
+                {
+                    // If the stream is no good anymore, we're done reading points
+                    return;
+                }
                 if (m_current == m_size) 
                 {
                     bLastPoint = true;


More information about the Liblas-commits mailing list