make StyledStreamWriter work more like StyledWriter

tests pass
This commit is contained in:
Christopher Dunn 2015-01-23 09:03:00 -06:00
parent 70704b9a70
commit 3efc587fba

View File

@ -628,7 +628,20 @@ void StyledStreamWriter::unindent() {
void StyledStreamWriter::writeCommentBeforeValue(const Value& root) { void StyledStreamWriter::writeCommentBeforeValue(const Value& root) {
if (!root.hasComment(commentBefore)) if (!root.hasComment(commentBefore))
return; return;
*document_ << root.getComment(commentBefore);
*document_ << "\n";
writeIndent();
const std::string& comment = root.getComment(commentBefore);
std::string::const_iterator iter = comment.begin();
while (iter != comment.end()) {
*document_ << *iter;
if (*iter == '\n' &&
(iter != comment.end() && *(iter + 1) == '/'))
writeIndent();
++iter;
}
// Comments are stripped of trailing newlines, so add one here
*document_ << "\n"; *document_ << "\n";
} }