SerUt  1.1.1 (development version)
fileserializer.h
Go to the documentation of this file.
1 /*
2 
3  This file is a part of SerUt, a library containing some serialization
4  utilities.
5 
6  Copyright (C) 2008-2018 Jori Liesenborgs
7 
8  Contact: jori.liesenborgs@gmail.com
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Lesser General Public
12  License as published by the Free Software Foundation; either
13  version 2.1 of the License, or (at your option) any later version.
14 
15  This library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public
21  License along with this library; if not, write to the Free Software
22  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23  USA
24 
25 */
26 
31 #ifndef SERUT_FILESERIALIZER_H
32 
33 #define SERUT_FILESERIALIZER_H
34 
35 #include "serutconfig.h"
36 #include "serializationinterface.h"
37 #include <stdio.h>
38 #include <string>
39 
40 namespace serut
41 {
42 
44 class SERUT_IMPORTEXPORT FileSerializer : public SerializationInterface
45 {
46 public:
48  enum OpenMode
49  {
55  ReadWrite
56  };
57 
59  ~FileSerializer();
60 
66  bool open(const std::string &filename, OpenMode m);
67 
69  bool close();
70 
71  bool readBytes(void *pBuffer, size_t amount);
72  bool writeBytes(const void *pBuffer, size_t amount);
73 private:
74  FILE *m_pFile;
75  OpenMode m_mode;
76 };
77 
78 } // end namespace
79 
80 #endif // SERUT_FILESERIALIZER_H
81 
A serializer for writing to and reading from files.
Definition: fileserializer.h:45
OpenMode
Specifies the mode in which a file can be opened.
Definition: fileserializer.h:49
@ ReadOnly
Read-only mode.
Definition: fileserializer.h:51
@ WriteOnly
Write-only mode.
Definition: fileserializer.h:53
bool open(const std::string &filename, OpenMode m)
Open a file.
bool close()
Close a previously opened file.
Generic serialization interface.
Definition: serializationinterface.h:58