mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-04-20 16:03:34 +02:00
make StyledStreamWriter work more like StyledWriter
tests pass
This commit is contained in:
parent
70704b9a70
commit
3efc587fba
@ -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";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user