[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 800cf4b 2/5: Clarify parsing of documents wit
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 800cf4b 2/5: Clarify parsing of documents with a single child element |
Date: |
Wed, 25 Jan 2017 01:45:53 +0000 (UTC) |
branch: master
commit 800cf4b275cda80c2b2dd8afaadf4f1298e9cd4b
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Clarify parsing of documents with a single child element
---
gpt_xml_document.cpp | 11 ++++-------
mec_xml_document.cpp | 11 ++++-------
single_cell_document.cpp | 11 ++++-------
3 files changed, 12 insertions(+), 21 deletions(-)
diff --git a/gpt_xml_document.cpp b/gpt_xml_document.cpp
index 7ef49a1..ad65a5e 100644
--- a/gpt_xml_document.cpp
+++ b/gpt_xml_document.cpp
@@ -66,13 +66,10 @@ void gpt_xml_document::parse(xml_lmi::dom_parser const&
parser)
{
xml::element const& root(parser.root_node(xml_root_name()));
xml::const_nodes_view const elements(root.elements());
- LMI_ASSERT(!elements.empty());
- xml::const_nodes_view::const_iterator i(elements.begin());
- *i >> input_data_;
- // XMLWRAPP !! It would be better to have operator+(int) in the
- // iterator class, and to write this check above as
- // LMI_ASSERT(elements.end() == 1 + i);
- LMI_ASSERT(elements.end() == ++i);
+ // A '.gpt' document's root contains only one child element.
+ LMI_ASSERT(1 == elements.size());
+ // "*elements.begin()" because there is no front():
+ *elements.begin() >> input_data_;
}
//============================================================================
diff --git a/mec_xml_document.cpp b/mec_xml_document.cpp
index e235e83..b92f41e 100644
--- a/mec_xml_document.cpp
+++ b/mec_xml_document.cpp
@@ -66,13 +66,10 @@ void mec_xml_document::parse(xml_lmi::dom_parser const&
parser)
{
xml::element const& root(parser.root_node(xml_root_name()));
xml::const_nodes_view const elements(root.elements());
- LMI_ASSERT(!elements.empty());
- xml::const_nodes_view::const_iterator i(elements.begin());
- *i >> input_data_;
- // XMLWRAPP !! It would be better to have operator+(int) in the
- // iterator class, and to write this check above as
- // LMI_ASSERT(elements.end() == 1 + i);
- LMI_ASSERT(elements.end() == ++i);
+ // A '.mec' document's root contains only one child element.
+ LMI_ASSERT(1 == elements.size());
+ // "*elements.begin()" because there is no front():
+ *elements.begin() >> input_data_;
}
//============================================================================
diff --git a/single_cell_document.cpp b/single_cell_document.cpp
index 0903210..5a76579 100644
--- a/single_cell_document.cpp
+++ b/single_cell_document.cpp
@@ -117,13 +117,10 @@ void single_cell_document::parse(xml_lmi::dom_parser
const& parser)
}
xml::const_nodes_view const elements(root.elements());
- LMI_ASSERT(!elements.empty());
- xml::const_nodes_view::const_iterator i(elements.begin());
- *i >> input_data_;
- // XMLWRAPP !! It would be better to have operator+(int) in the
- // iterator class, and to write this check above as
- // LMI_ASSERT(elements.end() == 1 + i);
- LMI_ASSERT(elements.end() == ++i);
+ // An '.ill' document's root contains only one child element.
+ LMI_ASSERT(1 == elements.size());
+ // "*elements.begin()" because there is no front():
+ *elements.begin() >> input_data_;
}
/// Ascertain whether input file comes from a system other than lmi.
- [lmi-commits] [lmi] master updated (2c94c87 -> 036a6b0), Greg Chicares, 2017/01/24
- [lmi-commits] [lmi] master de0060c 1/5: Last element is spelled "back()", Greg Chicares, 2017/01/24
- [lmi-commits] [lmi] master 800cf4b 2/5: Clarify parsing of documents with a single child element,
Greg Chicares <=
- [lmi-commits] [lmi] master 75129ca 4/5: Avoid undefined behavior; modernize a "while" statement, Greg Chicares, 2017/01/24
- [lmi-commits] [lmi] master 036a6b0 5/5: Modernize for statements, Greg Chicares, 2017/01/24
- [lmi-commits] [lmi] master cdfcd2d 3/5: Refactor, trivially, Greg Chicares, 2017/01/24