Switched the stream << for c-strings to take a templated array param (since we never stream user-built c-strings, only string literals). For this, refactored the escape character display

This commit is contained in:
Jesse Beder
2012-05-25 19:33:34 -05:00
parent 772969270d
commit bc3f72b565
2 changed files with 16 additions and 17 deletions

View File

@@ -25,9 +25,9 @@ namespace YAML
const char *str() const {
if(m_pStream) {
return NULL;
return 0;
} else {
m_buffer[m_pos] = NULL;
m_buffer[m_pos] = '\0';
return &m_buffer[0];
}
}
@@ -49,8 +49,9 @@ namespace YAML
bool m_comment;
};
inline ostream_wrapper& operator << (ostream_wrapper& stream, const char *str) {
stream.write(str, std::strlen(str));
template<std::size_t N>
inline ostream_wrapper& operator << (ostream_wrapper& stream, const char (&str)[N]) {
stream.write(str, N-1);
return stream;
}