@@ -121,12 +121,12 @@ void DomParser::parse_context()
121
121
}
122
122
123
123
doc_ = new Document (context_->myDoc );
124
- // This is to indicate to release_underlying that we took the
124
+ // This is to indicate to release_underlying() that we took the
125
125
// ownership on the doc.
126
126
context_->myDoc = nullptr ;
127
127
128
- // Free the parse context, but keep the document alive so people can navigate the DOM tree:
129
- // TODO: Why not keep the context alive too?
128
+ // Free the parser context because it's not needed anymore,
129
+ // but keep the document alive so people can navigate the DOM tree:
130
130
Parser::release_underlying ();
131
131
}
132
132
@@ -151,7 +151,11 @@ void DomParser::parse_stream(std::istream& in)
151
151
152
152
initialize_context ();
153
153
154
- // TODO: Shouldn't we use a Glib::ustring here, and some alternative to std::getline()?
154
+ // std::string or Glib::ustring?
155
+ // Output from the XML parser is UTF-8 encoded.
156
+ // But the istream "in" is input, i.e. an XML file. It can use any encoding.
157
+ // If it's not UTF-8, the file itself must contain information about which
158
+ // encoding it uses. See the XML specification. Thus use std::string.
155
159
int firstParseError = XML_ERR_OK;
156
160
std::string line;
157
161
while (std::getline (in, line))
@@ -194,13 +198,12 @@ void DomParser::parse_stream(std::istream& in)
194
198
}
195
199
196
200
doc_ = new Document (context_->myDoc );
197
- // This is to indicate to release_underlying that we took the
201
+ // This is to indicate to release_underlying() that we took the
198
202
// ownership on the doc.
199
203
context_->myDoc = nullptr ;
200
204
201
-
202
- // Free the parse context, but keep the document alive so people can navigate the DOM tree:
203
- // TODO: Why not keep the context alive too?
205
+ // Free the parser context because it's not needed anymore,
206
+ // but keep the document alive so people can navigate the DOM tree:
204
207
Parser::release_underlying ();
205
208
}
206
209
0 commit comments