void StyledStreamWriter::writeCommentAfterValueOnSameLine(const Value& root) { if (root.hasComment(commentAfterOnSameLine)) *document_ << " " + normalizeEOL(root.getComment(commentAfterOnSameLine)); if (root.hasComment(commentAfter)) { *document_ << "\n"; *document_ << normalizeEOL(root.getComment(commentAfter)); *document_ << "\n"; } }
void StyledWriter::writeCommentAfterValueOnSameLine(const Value& root) { if (root.hasComment(commentAfterOnSameLine)) document_ += " " + normalizeEOL(root.getComment(commentAfterOnSameLine)); if (root.hasComment(commentAfter)) { document_ += "\n"; document_ += normalizeEOL(root.getComment(commentAfter)); document_ += "\n"; } }
void StyledStreamWriter::writeCommentBeforeValue( const Value &root ) { if ( !root.hasComment( commentBefore ) ) return; *document_ << normalizeEOL( root.getComment( commentBefore ) ); *document_ << "\n"; }
void StyledWriter::writeCommentBeforeValue( const Value &root ) { if ( !root.hasComment( commentBefore ) ) return; document_ += normalizeEOL( root.getComment( commentBefore ) ); document_ += "\n"; }
void Reader::addComment(Location begin, Location end, CommentPlacement placement) { assert(collectComments_); const std::string& normalized = normalizeEOL(begin, end); if (placement == commentAfterOnSameLine) { assert(lastValue_ != 0); lastValue_->setComment(normalized, placement); } else { commentsBefore_ += normalized; } }
void StyledWriter::writeCommentBeforeValue(const Value& root) { if (!root.hasComment(commentBefore)) return; document_ += "\n"; writeIndent(); std::string normalizedComment = normalizeEOL(root.getComment(commentBefore)); std::string::const_iterator iter = normalizedComment.begin(); while (iter != normalizedComment.end()) { document_ += *iter; if (*iter == '\n' && *(iter + 1) == '/') writeIndent(); ++iter; } // Comments are stripped of newlines, so add one here document_ += "\n"; }