1
#ifndef __MRT_BASEFILE__
2
#define __MRT_BASEFILE__
5
* Copyright (C) 2005-2008 Vladimir Menshakov
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License, or (at your option) any later version.
12
* This library 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 GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this library; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
#include "export_mrt.h"
29
class MRTAPI BaseFile {
33
void read_all(std::string &str) const;
34
void read_all(Chunk &ch) const;
35
void write_all(const Chunk &ch) const;
36
void write_all(const std::string &str) const;
38
virtual void open(const std::string &fname, const std::string &mode) = 0;
39
virtual bool opened() const = 0;
41
virtual void seek(long offset, int whence) const = 0;
42
virtual long tell() const = 0;
43
virtual void write(const Chunk &ch) const = 0;
45
virtual const off_t get_size() const = 0;
46
virtual const size_t read(void *buf, const size_t size) const = 0;
49
virtual bool eof() const = 0;
51
virtual bool readline(std::string &str, const size_t bufsize = 1024) const; //default 1-byte read implementation
53
void readLE16(int &x) const;
54
void readLE32(int &x) const;
55
void readLE16(unsigned int &x) const;
56
void readLE32(unsigned int &x) const;