1 #ifndef STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
2 #define STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
4 #if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
9 #include "yaml-cpp/noncopyable.h"
14 class StreamCharSource
17 StreamCharSource(const Stream
& stream
): m_offset(0), m_stream(stream
) {}
18 StreamCharSource(const StreamCharSource
& source
): m_offset(source
.m_offset
), m_stream(source
.m_stream
) {}
19 ~StreamCharSource() {}
21 operator bool() const;
22 char operator [] (std::size_t i
) const { return m_stream
.CharAt(m_offset
+ i
); }
23 bool operator !() const { return !static_cast<bool>(*this); }
25 const StreamCharSource
operator + (int i
) const;
29 const Stream
& m_stream
;
31 StreamCharSource
& operator = (const StreamCharSource
&); // non-assignable
34 inline StreamCharSource::operator bool() const {
35 return m_stream
.ReadAheadTo(m_offset
);
38 inline const StreamCharSource
StreamCharSource::operator + (int i
) const {
39 StreamCharSource
source(*this);
40 if(static_cast<int> (source
.m_offset
) + i
>= 0)
48 #endif // STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66