[Liblas-commits] hg-main-tree: Silently discard comments in pipeline xml files

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Aug 11 19:20:21 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/d4c9e54323f4
changeset: 1050:d4c9e54323f4
user:      Pete Gadomski <pete.gadomski at gmail.com>
date:      Thu Aug 11 16:20:18 2011 -0700
description:
Silently discard comments in pipeline xml files

diffstat:

 src/PipelineReader.cpp               |   6 ++++--
 test/data/pipeline_readcomments.xml  |  18 ++++++++++++++++++
 test/data/pipeline_writecomments.xml |  26 ++++++++++++++++++++++++++
 test/unit/PipelineReaderTest.cpp     |   9 +++++++++
 4 files changed, 57 insertions(+), 2 deletions(-)

diffs (94 lines):

diff -r b0027041eb7a -r d4c9e54323f4 src/PipelineReader.cpp
--- a/src/PipelineReader.cpp	Thu Aug 11 15:48:12 2011 -0500
+++ b/src/PipelineReader.cpp	Thu Aug 11 16:20:18 2011 -0700
@@ -449,7 +449,8 @@
     m_inputXmlFile = filename;
 
     boost::property_tree::ptree tree;
-    boost::property_tree::xml_parser::read_xml(filename, tree);
+    boost::property_tree::xml_parser::read_xml(filename, tree,
+        boost::property_tree::xml_parser::no_comments);
 
     boost::optional<boost::property_tree::ptree> opt( tree.get_child_optional("WriterPipeline") );
     if (!opt.is_initialized())
@@ -472,7 +473,8 @@
     m_inputXmlFile = filename;
 
     boost::property_tree::ptree tree;
-    boost::property_tree::xml_parser::read_xml(filename, tree);
+    boost::property_tree::xml_parser::read_xml(filename, tree,
+        boost::property_tree::xml_parser::no_comments);
 
     boost::optional<boost::property_tree::ptree> opt( tree.get_child_optional("ReaderPipeline") );
     if (!opt.is_initialized())
diff -r b0027041eb7a -r d4c9e54323f4 test/data/pipeline_readcomments.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/pipeline_readcomments.xml	Thu Aug 11 16:20:18 2011 -0700
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<ReaderPipeline>
+        <Filter>
+            <Type>filters.crop</Type>
+            <Option>
+                <Name>bounds</Name>
+                <Value>([0,1000000],[0,1000000],[0,1000000])</Value>
+            </Option>
+            <Reader>
+                <Type>drivers.las.reader</Type>
+                <Option>
+                    <Name>filename</Name>
+                    <Value>1.2-with-color.las</Value>
+                </Option>
+                <!-- This is a comment -->
+            </Reader>
+        </Filter>
+</ReaderPipeline>
diff -r b0027041eb7a -r d4c9e54323f4 test/data/pipeline_writecomments.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/pipeline_writecomments.xml	Thu Aug 11 16:20:18 2011 -0700
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<WriterPipeline>
+    <Writer>
+        <Type>drivers.las.writer</Type>
+        <Option>
+            <Name>filename</Name>
+            <Value>out.las</Value>
+            <Description>junk junk junk</Description>
+        </Option>
+        <Filter>
+            <Type>filters.crop</Type>
+            <Option>
+                <Name>bounds</Name>
+                <Value>([0,1000000],[0,1000000],[0,1000000])</Value>
+            </Option>
+            <Reader>
+                <Type>drivers.las.reader</Type>
+                <Option>
+                    <Name>filename</Name>
+                    <Value>1.2-with-color.las</Value>
+                </Option>
+            </Reader>
+        </Filter>
+    </Writer>
+    <!-- This is a comment -->
+</WriterPipeline>
diff -r b0027041eb7a -r d4c9e54323f4 test/unit/PipelineReaderTest.cpp
--- a/test/unit/PipelineReaderTest.cpp	Thu Aug 11 15:48:12 2011 -0500
+++ b/test/unit/PipelineReaderTest.cpp	Thu Aug 11 16:20:18 2011 -0700
@@ -157,6 +157,15 @@
     PipelineReader readerR(managerR);
     BOOST_CHECK_THROW( readerR.readWriterPipeline(Support::datapath("pipeline_read.xml")), pipeline_xml_error);
 
+    // comments are ok
+    PipelineManager managerComments1;
+    PipelineReader readerComments1(managerComments1);
+    BOOST_CHECK_NO_THROW( readerComments1.readReaderPipeline(Support::datapath("pipeline_readcomments.xml")));
+
+    PipelineManager managerComments2;
+    PipelineReader readerComments2(managerComments2);
+    BOOST_CHECK_NO_THROW( readerComments2.readWriterPipeline(Support::datapath("pipeline_writecomments.xml")));
+
     return;
 }
 


More information about the Liblas-commits mailing list