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
YAML_PM::Stream::CharAt
char CharAt(size_t i) const
Definition: stream.h:68
YAML_PM::Stream::m_charSet
CharacterSet m_charSet
Definition: stream.h:50
YAML_PM::Stream::m_readahead
std::deque< char > m_readahead
Definition: stream.h:51
YAML_PM::Stream::peek
char peek() const
Definition: stream.cpp:228
YAML_PM::Stream::column
int column() const
Definition: stream.h:41
YAML_PM::Stream::StreamInUtf8
void StreamInUtf8() const
Definition: stream.cpp:310
YAML_PM::Stream::m_pPrefetched
unsigned char *const m_pPrefetched
Definition: stream.h:52
YAML_PM
Definition: aliasmanager.h:11
YAML_PM::StreamCharSource
Definition: streamcharsource.h:14
YAML_PM::Stream::AdvanceCurrent
void AdvanceCurrent()
Definition: stream.cpp:278
YAML_PM::Stream::StreamInUtf32
void StreamInUtf32() const
Definition: stream.cpp:420
YAML_PM::Stream::pos
int pos() const
Definition: stream.h:39
YAML_PM::Stream::CharacterSet
CharacterSet
Definition: stream.h:45
YAML_PM::Stream::ResetColumn
void ResetColumn()
Definition: stream.h:42
YAML_PM::Stream::GetNextByte
unsigned char GetNextByte() const
Definition: stream.cpp:398
YAML_PM::Mark::line
int line
Definition: mark.h:19
YAML_PM::Stream::get
char get()
Definition: stream.cpp:245
YAML_PM::Stream::StreamInUtf16
void StreamInUtf16() const
Definition: stream.cpp:319
YAML_PM::Stream::utf32be
@ utf32be
Definition: stream.h:45
testing::internal::string
::std::string string
Definition: gtest.h:1979
YAML_PM::Stream::operator!
bool operator!() const
Definition: stream.h:29
YAML_PM::Stream::utf16be
@ utf16be
Definition: stream.h:45
YAML_PM::Stream::ReadAheadTo
bool ReadAheadTo(size_t i) const
Definition: stream.h:72
YAML_PM::Stream::utf8
@ utf8
Definition: stream.h:45
YAML_PM::Stream::line
int line() const
Definition: stream.h:40
YAML_PM::Stream::m_nPrefetchedUsed
size_t m_nPrefetchedUsed
Definition: stream.h:54
YAML_PM::Mark::column
int column
Definition: mark.h:19
YAML_PM::Stream::utf32le
@ utf32le
Definition: stream.h:45
YAML_PM::Mark::pos
int pos
Definition: mark.h:18
YAML_PM::Stream::_ReadAheadTo
bool _ReadAheadTo(size_t i) const
Definition: stream.cpp:289
YAML_PM::Stream::~Stream
~Stream()
Definition: stream.cpp:223
YAML_PM::Stream::m_nPrefetchedAvailable
size_t m_nPrefetchedAvailable
Definition: stream.h:53
noncopyable.h
YAML_PM::Mark
Definition: mark.h:13
YAML_PM::Stream::eof
static char eof()
Definition: stream.h:36
YAML_PM::Stream
Definition: stream.h:20
YAML_PM::Stream::Stream
Stream(std::istream &input)
Definition: stream.cpp:180
YAML_PM::Stream::m_input
std::istream & m_input
Definition: stream.h:47
YAML_PM::Stream::utf16le
@ utf16le
Definition: stream.h:45
YAML_PM::Stream::mark
const Mark mark() const
Definition: stream.h:38
YAML_PM::Stream::eat
void eat(int n=1)
Definition: stream.cpp:272
mark.h
YAML_PM::Stream::m_mark
Mark m_mark
Definition: stream.h:48
YAML_PM::noncopyable
Definition: noncopyable.h:13


mp2p_icp
Author(s):
autogenerated on Fri Dec 20 2024 03:46:00