scide: implement selectionLength for openDocument
[supercollider.git] / external_libraries / yaml-cpp-0.3.0 / src / streamcharsource.h
blob21fae4e1f561aafda4907166e9595a022c28cf5a
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
5 #pragma once
6 #endif
9 #include "yaml-cpp/noncopyable.h"
10 #include <cstddef>
12 namespace YAML
14 class StreamCharSource
16 public:
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;
27 private:
28 std::size_t m_offset;
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)
41 source.m_offset += i;
42 else
43 source.m_offset = 0;
44 return source;
48 #endif // STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66