stream.h
Go to the documentation of this file.
00001 #ifndef STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM
00002 #define STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM
00003 
00004 #if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
00005 #pragma once
00006 #endif
00007 
00008 
00009 #include "yaml-cpp-pm/noncopyable.h"
00010 #include "yaml-cpp-pm/mark.h"
00011 #include <cstddef>
00012 #include <deque>
00013 #include <ios>
00014 #include <iostream>
00015 #include <set>
00016 #include <string>
00017 
00018 namespace YAML_PM
00019 {
00020         class Stream: private noncopyable
00021         {
00022         public:
00023                 friend class StreamCharSource;
00024                 
00025                 Stream(std::istream& input);
00026                 ~Stream();
00027 
00028                 operator bool() const;
00029                 bool operator !() const { return !static_cast <bool>(*this); }
00030 
00031                 char peek() const;
00032                 char get();
00033                 std::string get(int n);
00034                 void eat(int n = 1);
00035 
00036                 static char eof() { return 0x04; }
00037                 
00038                 const Mark mark() const { return m_mark; }
00039                 int pos() const { return m_mark.pos; }
00040                 int line() const { return m_mark.line; }
00041                 int column() const { return m_mark.column; }
00042                 void ResetColumn() { m_mark.column = 0; }
00043 
00044         private:
00045                 enum CharacterSet {utf8, utf16le, utf16be, utf32le, utf32be};
00046 
00047                 std::istream& m_input;
00048                 Mark m_mark;
00049                 
00050                 CharacterSet m_charSet;
00051                 mutable std::deque<char> m_readahead;
00052                 unsigned char* const m_pPrefetched;
00053                 mutable size_t m_nPrefetchedAvailable;
00054                 mutable size_t m_nPrefetchedUsed;
00055                 
00056                 void AdvanceCurrent();
00057                 char CharAt(size_t i) const;
00058                 bool ReadAheadTo(size_t i) const;
00059                 bool _ReadAheadTo(size_t i) const;
00060                 void StreamInUtf8() const;
00061                 void StreamInUtf16() const;
00062                 void StreamInUtf32() const;
00063                 unsigned char GetNextByte() const;
00064         };
00065 
00066         // CharAt
00067         // . Unchecked access
00068         inline char Stream::CharAt(size_t i) const {
00069                 return m_readahead[i];
00070         }
00071         
00072         inline bool Stream::ReadAheadTo(size_t i) const {
00073                 if(m_readahead.size() > i)
00074                         return true;
00075                 return _ReadAheadTo(i);
00076         }       
00077 }
00078 
00079 #endif // STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM


libpointmatcher
Author(s):
autogenerated on Mon Sep 14 2015 02:59:06