Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
BlockOutStream.h
1 /*
2  * $Id$
3  * Copyright (c) 2005, IRIT-UPS <casse@irit.fr>
4  *
5  * elm/io/BlockOutStream.h -- BlockOutStream class interface.
6  */
7 #ifndef ELM_IO_BLOCK_OUT_STREAM_H
8 #define ELM_IO_BLOCK_OUT_STREAM_H
9 
10 #include <elm/io/OutStream.h>
11 #include <elm/alloc/DynBlock.h>
12 #include <elm/string/CString.h>
13 #include <elm/string/String.h>
14 
15 namespace elm { namespace io {
16 
17 // BlockOutStream class
18 class BlockOutStream: public OutStream {
19 public:
20  inline BlockOutStream(int size = 4096, int inc = 256): _block(size, inc) { }
21  inline const char *block(void) const { return _block.base(); }
22  inline int size(void) const { return _block.size(); }
23  inline char *detach(void) { return _block.detach(); }
24  inline void clear(void) { _block.reset(); }
25  inline void setSize(int size) { _block.setSize(size); }
26  CString toCString(void);
27  String toString(void);
28 
29  // OutStream overload
30  virtual int write(const char *buffer, int size);
31  virtual int write(char byte);
32  virtual int flush(void);
33 
34 private:
35  block::DynBlock _block;
36 };
37 
38 } } // elm::io
39 
40 #endif // ELM_IO_BLOCK_OUT_STREAM_H
elm::io::BlockOutStream::size
int size(void) const
Definition: BlockOutStream.h:22
elm::io::BlockOutStream::toCString
CString toCString(void)
Definition: io_BlockOutStream.cpp:112
elm::io::BlockOutStream::flush
virtual int flush(void)
Definition: io_BlockOutStream.cpp:101
elm::io::BlockOutStream::write
virtual int write(const char *buffer, int size)
Definition: io_BlockOutStream.cpp:85
elm::io::BlockOutStream::detach
char * detach(void)
Definition: BlockOutStream.h:23
elm::CString
Definition: CString.h:17
elm::block::DynBlock::size
int size(void) const
Definition: DynBlock.h:21
elm
Definition: adapter.h:26
elm::block::DynBlock::detach
char * detach(void)
Definition: DynBlock.h:27
elm::block::DynBlock::base
const char * base(void) const
Definition: DynBlock.h:26
elm::block::DynBlock::setSize
void setSize(int new_size)
Definition: DynBlock.h:24
elm::io::OutStream
Definition: OutStream.h:30
elm::io::BlockOutStream::toString
String toString(void)
Definition: io_BlockOutStream.cpp:122
elm::block::DynBlock::reset
void reset(void)
Definition: DynBlock.h:25
elm::io::BlockOutStream::setSize
void setSize(int size)
Definition: BlockOutStream.h:25
elm::io::BlockOutStream::clear
void clear(void)
Definition: BlockOutStream.h:24
elm::String
Definition: String.h:30
elm::block::DynBlock
Definition: DynBlock.h:13
elm::io::BlockOutStream::BlockOutStream
BlockOutStream(int size=4096, int inc=256)
Definition: BlockOutStream.h:20
elm::io::BlockOutStream::block
const char * block(void) const
Definition: BlockOutStream.h:21
elm::io::BlockOutStream
Definition: BlockOutStream.h:18