From b113c3781902bc8427ccc16d7053d6ddf83a814f Mon Sep 17 00:00:00 2001 From: Jesse Beder Date: Fri, 10 Jul 2009 03:20:16 +0000 Subject: [PATCH] Clarified some copy/assignment issues with the stream/streamcharsource. --- src/stream.h | 3 ++- src/streamcharsource.h | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/stream.h b/src/stream.h index 05fb29c..697e1b9 100644 --- a/src/stream.h +++ b/src/stream.h @@ -1,5 +1,6 @@ #pragma once +#include "noncopyable.h" #include #include #include @@ -10,7 +11,7 @@ namespace YAML { static const size_t MAX_PARSER_PUSHBACK = 8; - class Stream + class Stream: private noncopyable { public: friend class StreamCharSource; diff --git a/src/streamcharsource.h b/src/streamcharsource.h index 4a1122c..d8368ac 100644 --- a/src/streamcharsource.h +++ b/src/streamcharsource.h @@ -1,5 +1,6 @@ #pragma once +#include "noncopyable.h" #include namespace YAML @@ -7,9 +8,10 @@ namespace YAML class StreamCharSource { public: - StreamCharSource(const Stream& stream); + StreamCharSource(const Stream& stream): m_offset(0), m_stream(stream) {} + StreamCharSource(const StreamCharSource& source): m_offset(source.m_offset), m_stream(source.m_stream) {} ~StreamCharSource() {} - + operator bool() const; char operator [] (std::size_t i) const { return m_stream.CharAt(m_offset + i); } bool operator !() const { return !static_cast(*this); } @@ -19,11 +21,10 @@ namespace YAML private: std::size_t m_offset; const Stream& m_stream; + + StreamCharSource& operator = (const StreamCharSource&); // non-assignable }; - inline StreamCharSource::StreamCharSource(const Stream& stream): m_offset(0), m_stream(stream) { - } - inline StreamCharSource::operator bool() const { return m_stream.ReadAheadTo(m_offset); }