Added single character emitting

This commit is contained in:
Jesse Beder
2011-11-14 16:23:14 -06:00
parent 6f4608ce05
commit 3099d51ba4
5 changed files with 52 additions and 1 deletions

View File

@@ -268,6 +268,26 @@ namespace YAML
return true;
}
bool WriteChar(ostream& out, char ch)
{
if(('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z'))
out << ch;
else if((0x20 <= ch && ch <= 0x7e) || ch == ' ')
out << "\"" << ch << "\"";
else if(ch == '\t')
out << "\"\\t\"";
else if(ch == '\n')
out << "\"\\n\"";
else if(ch == '\b')
out << "\"\\b\"";
else {
out << "\"";
WriteDoubleQuoteEscapeSequence(out, ch);
out << "\"";
}
return true;
}
bool WriteComment(ostream& out, const std::string& str, int postCommentIndent)
{
const unsigned curIndent = out.col();