Initial commit, includes Lua with broken Luabind as a backup for branching purposes
[terrastrategy.git] / include / vfs / fstream.h
blobb69958147fc1e9bb9cfcac77823bdd694aa9cb35
1 //
2 // Copyright (C) 2007 by Martin Moracek
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 /**
20 * @file fstream.h
22 * blablabla
25 #pragma once
27 #include <stdarg.h>
28 #include <istream>
30 #include "types.h"
32 namespace tre {
35 * File stream classes
37 * names of public methods follow STL naming convention
39 class FileIStream : public std::istream {
40 public:
41 FileIStream();
42 FileIStream(const std::string & filename,
43 std::ios_base::openmode mode=std::ios_base::binary);
44 ~FileIStream();
46 bool open(const std::string & filename,
47 std::ios_base::openmode mode=std::ios_base::binary);
49 void close(void);
51 bool is_open(void) const;
53 ulong length(void) const;
55 int iformat(const char * fmt, ...);
58 class FileOStream : public std::ostream {
59 public:
60 FileOStream();
61 FileOStream(const std::string & filename,
62 std::ios_base::openmode mode=std::ios_base::binary
63 | std::ios_base::trunc);
64 ~FileOStream();
66 bool open(const std::string & filename,
67 std::ios_base::openmode mode=std::ios_base::binary
68 | std::ios_base::trunc);
70 void close(void);
72 bool is_open(void) const;
74 ulong length(void) const;
76 int oformat(const char * fmt, ...);
79 class FileIOStream : public std::iostream {
80 public:
81 FileIOStream();
82 FileIOStream(const std::string & filename,
83 std::ios_base::openmode mode=std::ios_base::binary
84 | std::ios_base::in);
85 ~FileIOStream();
87 bool open(const std::string & filename,
88 std::ios_base::openmode mode=std::ios_base::binary
89 | std::ios_base::in);
91 void close(void);
93 bool is_open(void) const;
95 ulong length(void) const;
97 int iformat(const char * fmt, ...);
98 int oformat(const char * fmt, ...);
102 * FileBuffer interface
104 class FileBuffer : public std::streambuf {
105 public:
106 virtual ulong GetSize(void) const = 0;
109 } // vfs