Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
BlockInStream.h
1 /*
2  * BlockInStream class interface
3  *
4  * This file is part of OTAWA
5  * Copyright (c) 2005-09, 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_IO_BLOCK_IN_STREAM_H
22 #define ELM_IO_BLOCK_IN_STREAM_H
23 
24 #include <elm/string/String.h>
25 #include <elm/string/CString.h>
26 #include <elm/io/InStream.h>
27 
28 namespace elm { namespace io {
29 
30 // BlockInStream class
31 class BlockInStream: public InStream {
32  const char *_block;
33  int _size, off;
34 public:
35 
36  BlockInStream(const void *block, int size);
37  BlockInStream(const char *str);
38  BlockInStream(const CString& str);
39  BlockInStream(const String& str);
40  inline const void *block() const { return _block; }
41  inline int size() const { return _size; }
42  inline int mark() const { return off; }
43  inline void move(int mark) { off = mark; }
44  inline void moveForward(int size) { off += size; }
45  inline void moveBackward(int size) { off -= size; }
46  inline void reset(void) { off = 0; }
47 
48  // InStream overload
49  int read(void *buffer, int size) override;
50  int read() override;
51 };
52 
53 } } // elm::io
54 
55 #endif // ELM_IO_BLOCK_IN_STREAM_H
elm::io::BlockInStream::moveBackward
void moveBackward(int size)
Definition: BlockInStream.h:45
elm::io::BlockInStream::moveForward
void moveForward(int size)
Definition: BlockInStream.h:44
elm::io::BlockInStream::mark
int mark() const
Definition: BlockInStream.h:42
elm::io::BlockInStream::BlockInStream
BlockInStream(const void *block, int size)
Definition: io_BlockInStream.cpp:42
elm::io::BlockInStream
Definition: BlockInStream.h:31
elm::CString
Definition: CString.h:17
elm::io::BlockInStream::size
int size() const
Definition: BlockInStream.h:41
elm::io::BlockInStream::reset
void reset(void)
Definition: BlockInStream.h:46
elm::io::BlockInStream::block
const void * block() const
Definition: BlockInStream.h:40
elm
Definition: adapter.h:26
elm::io::BlockInStream::move
void move(int mark)
Definition: BlockInStream.h:43
elm::String
Definition: String.h:30
elm::str
string str(const char *s)
Definition: String.h:150
elm::io::BlockInStream::read
int read() override
Definition: io_BlockInStream.cpp:139
elm::io::InStream
Definition: InStream.h:29