Cupt
file.hpp
Go to the documentation of this file.
1 /**************************************************************************
2 * Copyright (C) 2010 by Eugene V. Lyubimkin *
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 *
6 * (version 3 or above) as published by the Free Software Foundation. *
7 * *
8 * This program is distributed in the hope that it will be useful, *
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
11 * GNU General Public License for more details. *
12 * *
13 * You should have received a copy of the GNU GPL *
14 * along with this program; if not, write to the *
15 * Free Software Foundation, Inc., *
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA *
17 **************************************************************************/
18 #ifndef CUPT_FILE_SEEN
19 #define CUPT_FILE_SEEN
20 
22 
23 #include <functional>
24 
25 #include <cupt/common.hpp>
26 
27 namespace cupt {
28 
29 namespace internal {
30 
31 struct FileImpl;
32 
33 }
34 
36 class CUPT_API File
37 {
38  internal::FileImpl* __impl;
39  public:
41 
52  File(const string& path, const char* mode, string& error);
54  virtual ~File();
56 
67  File& rawGetLine(const char*& buffer, size_t& size);
69 
88  File& getLine(string& line);
90 
103  File& getRecord(string& record);
105 
111  File& getBlock(char* buffer, size_t& size);
113 
118  void getFile(string& block);
120 
123  void put(const string& data);
125 
129  void put(const char* data, size_t size);
131  void unbufferedPut(const char* data, size_t size);
133 
134 
136  bool eof() const;
138 
144  void seek(size_t newPosition);
146  size_t tell() const;
147 
149 
152  void lock(int flags);
153 };
154 
155 } // namespace
156 
157 #endif
158