TPIE

2362a60
stdio.h
Go to the documentation of this file.
1 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
2 // vi:set ts=4 sts=4 sw=4 noet :
3 // Copyright 2009, 2010, The TPIE development team
4 //
5 // This file is part of TPIE.
6 //
7 // TPIE is free software: you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the
9 // Free Software Foundation, either version 3 of the License, or (at your
10 // option) any later version.
11 //
12 // TPIE is distributed in the hope that it will be useful, but WITHOUT ANY
13 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with TPIE. If not, see <http://www.gnu.org/licenses/>
19 
23 
24 #ifndef _TPIE_FILE_ACCESSOR_STDIO_H
25 #define _TPIE_FILE_ACCESSOR_STDIO_H
26 
27 #include <tpie/file_accessor/file_accessor_crtp.h>
28 
29 namespace tpie {
30 namespace file_accessor {
31 
35 
36 class stdio: public file_accessor_crtp<stdio> {
37 private:
38  FILE * m_f;
39  bool m_write;
40 
41  friend class file_accessor_crtp<stdio>;
42 
43  inline void read_i(void * data, memory_size_type size);
44  inline void write_i(const void * data, memory_size_type size);
45  inline void seek_i(stream_size_type size);
46 public:
47  inline stdio();
48  inline void open(const std::string & path,
49  bool read,
50  bool write,
51  memory_size_type itemSize,
52  memory_size_type blockSize,
53  memory_size_type userDataSize);
54  inline void close();
55  inline void truncate(stream_size_type size);
56  inline ~stdio() {close();}
57 };
58 
59 }
60 }
61 
62 #include <tpie/file_accessor/stdio.inl>
63 
64 #endif //_TPIE_FILE_ACCESSOR_STDIO_H
stdio.h-style file accessor.
Definition: stdio.h:36