Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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) throw(sys::SystemException);
51  static RandomAccessStream *createFile(const sys::Path& path,
52  access_t access = WRITE) throw(sys::SystemException);
53 };
54 
55 } } // elm::io
56 
57 #endif /*ELM_IO_RANDOMACCESSSTREAM_H_*/
virtual void resetPos(void)
Definition: RandomAccessStream.h:48
Definition: Path.h:31
static RandomAccessStream * openFile(const sys::Path &path, access_t access=READ)
Definition: io_RandomAccessStream.cpp:95
Definition: OutStream.h:30
static const int WRITE
Definition: RandomAccessStream.h:40
virtual pos_t pos(void) const =0
static RandomAccessStream * createFile(const sys::Path &path, access_t access=WRITE)
Definition: io_RandomAccessStream.cpp:111
int access_t
Definition: RandomAccessStream.h:38
virtual bool moveBackward(pos_t pos)=0
virtual bool moveForward(pos_t pos)=0
static const int READ_WRITE
Definition: RandomAccessStream.h:41
Definition: RandomAccessStream.h:34
virtual bool moveTo(pos_t pos)=0
t::uint64 pos_t
Definition: RandomAccessStream.h:36
virtual size_t size(void) const =0
static const int READ
Definition: RandomAccessStream.h:39
Definition: InStream.h:30
t::uint64 size_t
Definition: RandomAccessStream.h:37
uint64_t uint64
Definition: int.h:37