Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
RandomAccessStream.h
1 /*
2  * $Id$
3  * RandomAccessStream class interface
4  *
5  * This file is part of OTAWA
6  * Copyright (c) 2008, IRIT UPS.
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_RANDOMACCESSSTREAM_H_
23 #define ELM_IO_RANDOMACCESSSTREAM_H_
24 
25 #include <elm/types.h>
26 #include <elm/io/InStream.h>
27 #include <elm/io/OutStream.h>
28 #include <elm/sys/Path.h>
29 #include <elm/sys/SystemException.h>
30 
31 namespace elm { namespace io {
32 
33 // RandomAccessStream class
34 class RandomAccessStream: public InStream, public OutStream {
35 public:
36  typedef t::uint64 pos_t;
37  typedef t::uint64 size_t;
38  typedef int access_t;
39  static const int READ = 1;
40  static const int WRITE = 2;
41  static const int READ_WRITE = READ | WRITE;
42 
43  virtual pos_t pos(void) const = 0;
44  virtual size_t size(void) const = 0;
45  virtual bool moveTo(pos_t pos) = 0;
46  virtual bool moveForward(pos_t pos) = 0;
47  virtual bool moveBackward(pos_t pos) = 0;
48  virtual void resetPos(void) { moveTo(0); }
49  static RandomAccessStream *openFile(const sys::Path& path,
50  access_t access = READ);
51  static RandomAccessStream *createFile(const sys::Path& path,
52  access_t access = WRITE);
53 };
54 
55 } } // elm::io
56 
57 #endif /*ELM_IO_RANDOMACCESSSTREAM_H_*/
elm::io::RandomAccessStream::pos
virtual pos_t pos(void) const =0
elm::io::RandomAccessStream::moveForward
virtual bool moveForward(pos_t pos)=0
elm::sys::Path
Definition: Path.h:33
elm::io::RandomAccessStream
Definition: RandomAccessStream.h:34
elm::io::RandomAccessStream::pos_t
t::uint64 pos_t
Definition: RandomAccessStream.h:36
elm::io::RandomAccessStream::WRITE
static const int WRITE
Definition: RandomAccessStream.h:40
elm::io::RandomAccessStream::access_t
int access_t
Definition: RandomAccessStream.h:38
elm::io::RandomAccessStream::READ
static const int READ
Definition: RandomAccessStream.h:39
elm::io::RandomAccessStream::createFile
static RandomAccessStream * createFile(const sys::Path &path, access_t access=WRITE)
Definition: io_RandomAccessStream.cpp:110
elm
Definition: adapter.h:26
elm::io::RandomAccessStream::READ_WRITE
static const int READ_WRITE
Definition: RandomAccessStream.h:41
elm::t::uint64
unsigned long uint64
Definition: arch.h:33
elm::io::RandomAccessStream::size
virtual size_t size(void) const =0
elm::io::OutStream
Definition: OutStream.h:30
elm::io::RandomAccessStream::resetPos
virtual void resetPos(void)
Definition: RandomAccessStream.h:48
elm::io::RandomAccessStream::moveTo
virtual bool moveTo(pos_t pos)=0
elm::io::RandomAccessStream::openFile
static RandomAccessStream * openFile(const sys::Path &path, access_t access=READ)
Definition: io_RandomAccessStream.cpp:95
elm::io::RandomAccessStream::size_t
t::uint64 size_t
Definition: RandomAccessStream.h:37
elm::io::InStream
Definition: InStream.h:29
elm::io::RandomAccessStream::moveBackward
virtual bool moveBackward(pos_t pos)=0