stream.h
Go to the documentation of this file.
1 #ifndef STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM
2 #define STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM
3 
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
7 
8 
10 #include "yaml-cpp-pm/mark.h"
11 #include <cstddef>
12 #include <deque>
13 #include <ios>
14 #include <iostream>
15 #include <set>
16 #include <string>
17 
18 namespace YAML_PM
19 {
20  class Stream: private noncopyable
21  {
22  public:
23  friend class StreamCharSource;
24 
25  Stream(std::istream& input);
26  ~Stream();
27 
28  operator bool() const;
29  bool operator !() const { return !static_cast <bool>(*this); }
30 
31  char peek() const;
32  char get();
33  std::string get(int n);
34  void eat(int n = 1);
35 
36  static char eof() { return 0x04; }
37 
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; }
43 
44  private:
46 
47  std::istream& m_input;
49 
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;
55 
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;
64  };
65 
66  // CharAt
67  // . Unchecked access
68  inline char Stream::CharAt(size_t i) const {
69  return m_readahead[i];
70  }
71 
72  inline bool Stream::ReadAheadTo(size_t i) const {
73  if(m_readahead.size() > i)
74  return true;
75  return _ReadAheadTo(i);
76  }
77 }
78 
79 #endif // STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM
std::istream & m_input
Definition: stream.h:47
unsigned char *const m_pPrefetched
Definition: stream.h:52
bool ReadAheadTo(size_t i) const
Definition: stream.h:72
void AdvanceCurrent()
Definition: stream.cpp:278
int line() const
Definition: stream.h:40
int line
Definition: mark.h:19
void StreamInUtf8() const
Definition: stream.cpp:310
bool operator!() const
Definition: stream.h:29
std::deque< char > m_readahead
Definition: stream.h:51
unsigned char GetNextByte() const
Definition: stream.cpp:398
::std::string string
Definition: gtest.h:1979
bool _ReadAheadTo(size_t i) const
Definition: stream.cpp:289
void ResetColumn()
Definition: stream.h:42
size_t m_nPrefetchedAvailable
Definition: stream.h:53
size_t m_nPrefetchedUsed
Definition: stream.h:54
Mark m_mark
Definition: stream.h:48
int column
Definition: mark.h:19
char CharAt(size_t i) const
Definition: stream.h:68
void eat(int n=1)
Definition: stream.cpp:272
Stream(std::istream &input)
Definition: stream.cpp:180
int column() const
Definition: stream.h:41
static char eof()
Definition: stream.h:36
int pos
Definition: mark.h:18
void StreamInUtf16() const
Definition: stream.cpp:319
char peek() const
Definition: stream.cpp:228
void StreamInUtf32() const
Definition: stream.cpp:420
CharacterSet m_charSet
Definition: stream.h:50
const Mark mark() const
Definition: stream.h:38
int pos() const
Definition: stream.h:39


libpointmatcher
Author(s):
autogenerated on Sat May 27 2023 02:38:03