Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
BufferedInStream.h
1 /*
2  * BufferedInStream class interface
3  *
4  * This file is part of OTAWA
5  * Copyright (c) 2008, IRIT UPS.
6  *
7  * OTAWA is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * OTAWA is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OTAWA; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 #ifndef ELM_BUFFEREDINSTREAM_H_
22 #define ELM_BUFFEREDINSTREAM_H_
23 
24 #include <elm/io.h>
25 #include <elm/io/InStream.h>
26 
27 namespace elm { namespace io {
28 
29 // BufferedInStream class
30 class BufferedInStream: public InStream {
31 public:
32  static const int default_size = 4096;
33 
35  BufferedInStream(InStream *input, bool close = false, int size = default_size);
36  ~BufferedInStream() override;
37 
38  inline InStream& stream() const { return *in; }
39  void setStream(InStream& str);
40  void reset();
41 
42  int read(void *buffer, int size) override;
43  int read(void) override;
44 
45 private:
46  int refill();
47  InStream *in;
48  char *buf;
49  int pos, top, buf_size;
50  bool _close;
51 };
52 
53 } } // elm::io
54 
55 #endif /* ELM_BUFFEREDINSTREAM_H_ */
elm::io::BufferedInStream::~BufferedInStream
~BufferedInStream() override
Definition: io_BufferedInStream.cpp:65
elm::io::BufferedInStream
Definition: BufferedInStream.h:30
elm::io::BufferedInStream::setStream
void setStream(InStream &str)
Definition: io_BufferedInStream.cpp:83
elm
Definition: adapter.h:26
elm::io::BufferedInStream::reset
void reset()
Definition: io_BufferedInStream.cpp:92
elm::t::size
uint64 size
Definition: arch.h:35
elm::io::BufferedInStream::stream
InStream & stream() const
Definition: BufferedInStream.h:38
elm::io::BufferedInStream::default_size
static const int default_size
Definition: BufferedInStream.h:32
elm::str
string str(const char *s)
Definition: String.h:150
elm::io::BufferedInStream::BufferedInStream
BufferedInStream(InStream &input, int size=default_size)
Definition: io_BufferedInStream.cpp:44
elm::io::BufferedInStream::read
int read(void) override
Definition: io_BufferedInStream.cpp:120
elm::io::InStream
Definition: InStream.h:29