diff --git a/include/yaml-cpp/emitter.h b/include/yaml-cpp/emitter.h index 43101da..28ece0a 100644 --- a/include/yaml-cpp/emitter.h +++ b/include/yaml-cpp/emitter.h @@ -10,9 +10,9 @@ #include "yaml-cpp/binary.h" #include "yaml-cpp/emitterdef.h" #include "yaml-cpp/emittermanip.h" -#include "yaml-cpp/ostream.h" #include "yaml-cpp/noncopyable.h" #include "yaml-cpp/null.h" +#include "yaml-cpp/ostream_wrapper.h" #include #include #include @@ -114,8 +114,8 @@ namespace YAML bool CanEmitNewline() const; private: - ostream m_stream; - std::auto_ptr m_pState; + ostream_wrapper m_stream; + std::auto_ptr m_pState; }; template diff --git a/include/yaml-cpp/ostream.h b/include/yaml-cpp/ostream_wrapper.h similarity index 59% rename from include/yaml-cpp/ostream.h rename to include/yaml-cpp/ostream_wrapper.h index 5f11ce6..8d33a3b 100644 --- a/include/yaml-cpp/ostream.h +++ b/include/yaml-cpp/ostream_wrapper.h @@ -1,5 +1,5 @@ -#ifndef OSTREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define OSTREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#ifndef OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once @@ -10,11 +10,11 @@ namespace YAML { - class ostream + class ostream_wrapper { public: - ostream(); - ~ostream(); + ostream_wrapper(); + ~ostream_wrapper(); void reserve(unsigned size); void put(char ch); @@ -35,9 +35,9 @@ namespace YAML bool m_comment; }; - ostream& operator << (ostream& out, const char *str); - ostream& operator << (ostream& out, const std::string& str); - ostream& operator << (ostream& out, char ch); + ostream_wrapper& operator << (ostream_wrapper& out, const char *str); + ostream_wrapper& operator << (ostream_wrapper& out, const std::string& str); + ostream_wrapper& operator << (ostream_wrapper& out, char ch); } -#endif // OSTREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#endif // OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/emitterutils.cpp b/src/emitterutils.cpp index 5dfaec9..0f2800c 100644 --- a/src/emitterutils.cpp +++ b/src/emitterutils.cpp @@ -107,7 +107,7 @@ namespace YAML return true; } - void WriteCodePoint(ostream& out, int codePoint) { + void WriteCodePoint(ostream_wrapper& out, int codePoint) { if (codePoint < 0 || codePoint > 0x10FFFF) { codePoint = REPLACEMENT_CHARACTER; } @@ -185,7 +185,7 @@ namespace YAML return true; } - void WriteDoubleQuoteEscapeSequence(ostream& out, int codePoint) { + void WriteDoubleQuoteEscapeSequence(ostream_wrapper& out, int codePoint) { static const char hexDigits[] = "0123456789abcdef"; char escSeq[] = "\\U00000000"; @@ -208,7 +208,7 @@ namespace YAML out << escSeq; } - bool WriteAliasName(ostream& out, const std::string& str) { + bool WriteAliasName(ostream_wrapper& out, const std::string& str) { int codePoint; for(std::string::const_iterator i = str.begin(); GetNextCodePointAndAdvance(codePoint, i, str.end()); @@ -247,7 +247,7 @@ namespace YAML return StringFormat::DoubleQuoted; } - bool WriteSingleQuotedString(ostream& out, const std::string& str) + bool WriteSingleQuotedString(ostream_wrapper& out, const std::string& str) { out << "'"; int codePoint; @@ -267,7 +267,7 @@ namespace YAML return true; } - bool WriteDoubleQuotedString(ostream& out, const std::string& str, bool escapeNonAscii) + bool WriteDoubleQuotedString(ostream_wrapper& out, const std::string& str, bool escapeNonAscii) { out << "\""; int codePoint; @@ -297,7 +297,7 @@ namespace YAML return true; } - bool WriteLiteralString(ostream& out, const std::string& str, int indent) + bool WriteLiteralString(ostream_wrapper& out, const std::string& str, int indent) { out << "|\n"; out << IndentTo(indent); @@ -314,7 +314,7 @@ namespace YAML return true; } - bool WriteChar(ostream& out, char ch) + bool WriteChar(ostream_wrapper& out, char ch) { if(('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z')) out << ch; @@ -334,7 +334,7 @@ namespace YAML return true; } - bool WriteComment(ostream& out, const std::string& str, int postCommentIndent) + bool WriteComment(ostream_wrapper& out, const std::string& str, int postCommentIndent) { const unsigned curIndent = out.col(); out << "#" << Indentation(postCommentIndent); @@ -354,19 +354,19 @@ namespace YAML return true; } - bool WriteAlias(ostream& out, const std::string& str) + bool WriteAlias(ostream_wrapper& out, const std::string& str) { out << "*"; return WriteAliasName(out, str); } - bool WriteAnchor(ostream& out, const std::string& str) + bool WriteAnchor(ostream_wrapper& out, const std::string& str) { out << "&"; return WriteAliasName(out, str); } - bool WriteTag(ostream& out, const std::string& str, bool verbatim) + bool WriteTag(ostream_wrapper& out, const std::string& str, bool verbatim) { out << (verbatim ? "!<" : "!"); StringCharSource buffer(str.c_str(), str.size()); @@ -386,7 +386,7 @@ namespace YAML return true; } - bool WriteTagWithPrefix(ostream& out, const std::string& prefix, const std::string& tag) + bool WriteTagWithPrefix(ostream_wrapper& out, const std::string& prefix, const std::string& tag) { out << "!"; StringCharSource prefixBuffer(prefix.c_str(), prefix.size()); @@ -416,7 +416,7 @@ namespace YAML return true; } - bool WriteBinary(ostream& out, const Binary& binary) + bool WriteBinary(ostream_wrapper& out, const Binary& binary) { WriteDoubleQuotedString(out, EncodeBase64(binary.data(), binary.size()), false); return true; diff --git a/src/emitterutils.h b/src/emitterutils.h index 67200f8..50b37f0 100644 --- a/src/emitterutils.h +++ b/src/emitterutils.h @@ -7,7 +7,7 @@ #include "emitterstate.h" -#include "yaml-cpp/ostream.h" +#include "yaml-cpp/ostream_wrapper.h" #include namespace YAML @@ -20,16 +20,16 @@ namespace YAML { StringFormat::value ComputeStringFormat(const std::string& str, EMITTER_MANIP strFormat, FlowType::value flowType, bool escapeNonAscii); - bool WriteSingleQuotedString(ostream& out, const std::string& str); - bool WriteDoubleQuotedString(ostream& out, const std::string& str, bool escapeNonAscii); - bool WriteLiteralString(ostream& out, const std::string& str, int indent); - bool WriteChar(ostream& out, char ch); - bool WriteComment(ostream& out, const std::string& str, int postCommentIndent); - bool WriteAlias(ostream& out, const std::string& str); - bool WriteAnchor(ostream& out, const std::string& str); - bool WriteTag(ostream& out, const std::string& str, bool verbatim); - bool WriteTagWithPrefix(ostream& out, const std::string& prefix, const std::string& tag); - bool WriteBinary(ostream& out, const Binary& binary); + bool WriteSingleQuotedString(ostream_wrapper& out, const std::string& str); + bool WriteDoubleQuotedString(ostream_wrapper& out, const std::string& str, bool escapeNonAscii); + bool WriteLiteralString(ostream_wrapper& out, const std::string& str, int indent); + bool WriteChar(ostream_wrapper& out, char ch); + bool WriteComment(ostream_wrapper& out, const std::string& str, int postCommentIndent); + bool WriteAlias(ostream_wrapper& out, const std::string& str); + bool WriteAnchor(ostream_wrapper& out, const std::string& str); + bool WriteTag(ostream_wrapper& out, const std::string& str, bool verbatim); + bool WriteTagWithPrefix(ostream_wrapper& out, const std::string& prefix, const std::string& tag); + bool WriteBinary(ostream_wrapper& out, const Binary& binary); } } diff --git a/src/indentation.h b/src/indentation.h index 25f684f..426fcb5 100644 --- a/src/indentation.h +++ b/src/indentation.h @@ -6,7 +6,7 @@ #endif -#include "yaml-cpp/ostream.h" +#include "yaml-cpp/ostream_wrapper.h" #include namespace YAML @@ -16,7 +16,7 @@ namespace YAML unsigned n; }; - inline ostream& operator << (ostream& out, const Indentation& indent) { + inline ostream_wrapper& operator << (ostream_wrapper& out, const Indentation& indent) { for(unsigned i=0;i namespace YAML { - ostream::ostream(): m_buffer(0), m_pos(0), m_size(0), m_row(0), m_col(0), m_comment(false) + ostream_wrapper::ostream_wrapper(): m_buffer(0), m_pos(0), m_size(0), m_row(0), m_col(0), m_comment(false) { reserve(1024); } - ostream::~ostream() + ostream_wrapper::~ostream_wrapper() { delete [] m_buffer; } - void ostream::reserve(unsigned size) + void ostream_wrapper::reserve(unsigned size) { if(size <= m_size) return; @@ -26,7 +26,7 @@ namespace YAML m_size = size; } - void ostream::put(char ch) + void ostream_wrapper::put(char ch) { if(m_pos >= m_size - 1) // an extra space for the NULL terminator reserve(m_size * 2); @@ -42,7 +42,7 @@ namespace YAML m_col++; } - ostream& operator << (ostream& out, const char *str) + ostream_wrapper& operator << (ostream_wrapper& out, const char *str) { std::size_t length = std::strlen(str); for(std::size_t i=0;i