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