scide: implement selectionLength for openDocument
[supercollider.git] / external_libraries / yaml-cpp-0.3.0 / src / stream.h
blob87f48dc890ed5b9cb54956fb41fb522445e1bb75
1 #ifndef STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66
2 #define STREAM_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 "yaml-cpp/mark.h"
11 #include <cstddef>
12 #include <deque>
13 #include <ios>
14 #include <iostream>
15 #include <set>
16 #include <string>
18 namespace YAML
20 class Stream: private noncopyable
22 public:
23 friend class StreamCharSource;
25 Stream(std::istream& input);
26 ~Stream();
28 operator bool() const;
29 bool operator !() const { return !static_cast <bool>(*this); }
31 char peek() const;
32 char get();
33 std::string get(int n);
34 void eat(int n = 1);
36 static char eof() { return 0x04; }
38 const Mark mark() const { return m_mark; }
39 int pos() const { return m_mark.pos; }
40 int line() const { return m_mark.line; }
41 int column() const { return m_mark.column; }
42 void ResetColumn() { m_mark.column = 0; }
44 private:
45 enum CharacterSet {utf8, utf16le, utf16be, utf32le, utf32be};
47 std::istream& m_input;
48 Mark m_mark;
50 CharacterSet m_charSet;
51 mutable std::deque<char> m_readahead;
52 unsigned char* const m_pPrefetched;
53 mutable size_t m_nPrefetchedAvailable;
54 mutable size_t m_nPrefetchedUsed;
56 void AdvanceCurrent();
57 char CharAt(size_t i) const;
58 bool ReadAheadTo(size_t i) const;
59 bool _ReadAheadTo(size_t i) const;
60 void StreamInUtf8() const;
61 void StreamInUtf16() const;
62 void StreamInUtf32() const;
63 unsigned char GetNextByte() const;
66 // CharAt
67 // . Unchecked access
68 inline char Stream::CharAt(size_t i) const {
69 return m_readahead[i];
72 inline bool Stream::ReadAheadTo(size_t i) const {
73 if(m_readahead.size() > i)
74 return true;
75 return _ReadAheadTo(i);
79 #endif // STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66