Renamed ostream -> ostream_wrapper

This commit is contained in:
Jesse Beder
2012-05-25 17:28:35 -05:00
parent 2dd1cf4596
commit 1602f78974
6 changed files with 47 additions and 47 deletions

View File

@@ -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;

View File

@@ -7,7 +7,7 @@
#include "emitterstate.h"
#include "yaml-cpp/ostream.h"
#include "yaml-cpp/ostream_wrapper.h"
#include <string>
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);
}
}

View File

@@ -6,7 +6,7 @@
#endif
#include "yaml-cpp/ostream.h"
#include "yaml-cpp/ostream_wrapper.h"
#include <iostream>
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<indent.n;i++)
out << ' ';
return out;
@@ -27,7 +27,7 @@ namespace YAML
unsigned n;
};
inline ostream& operator << (ostream& out, const IndentTo& indent) {
inline ostream_wrapper& operator << (ostream_wrapper& out, const IndentTo& indent) {
while(out.col() < indent.n)
out << ' ';
return out;

View File

@@ -1,19 +1,19 @@
#include "yaml-cpp/ostream.h"
#include "yaml-cpp/ostream_wrapper.h"
#include <cstring>
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<length;i++)
@@ -50,13 +50,13 @@ namespace YAML
return out;
}
ostream& operator << (ostream& out, const std::string& str)
ostream_wrapper& operator << (ostream_wrapper& out, const std::string& str)
{
out << str.c_str();
return out;
}
ostream& operator << (ostream& out, char ch)
ostream_wrapper& operator << (ostream_wrapper& out, char ch)
{
out.put(ch);
return out;