ScummVM API documentation
database.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program 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
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef DATABASE_H
23 #define DATABASE_H
24 
25 #include "common/hash-str.h"
26 #include "common/hashmap.h"
27 #include "common/scummsys.h"
28 #include "common/str.h"
29 #include "common/stream.h"
30 
31 namespace AGDS {
32 
33 class Database {
34 private:
35  struct Entry {
36  uint32 offset;
37  uint32 size;
38 
39  Entry() : offset(), size() {}
40  Entry(uint32 o, uint32 s) : offset(o), size(s) {}
41  };
42 
44 
45  Common::String _filename;
46  bool _writeable;
47  uint32 _totalEntries;
48  uint32 _usedEntries;
49  uint32 _maxNameSize;
50 
51  EntriesType _entries;
52 
53 private:
54  static uint32 getDataOffset(uint32 maxNameSize, uint32 totalEntries);
55 
56 public:
57  bool open(const Common::String &filename);
58  bool open(const Common::String &filename, Common::SeekableReadStream &stream);
59  Common::Array<Common::String> getEntries() const;
60 
61  Common::SeekableReadStream *getEntry(const Common::String &name) const;
62  Common::SeekableReadStream *getEntry(Common::SeekableReadStream &parent, const Common::String &name) const;
63 
64  static void write(Common::WriteStream &stream, const Common::HashMap<Common::String, Common::Array<uint8>> &entries);
65 };
66 
67 } // End of namespace AGDS
68 
69 #endif /* AGDS_DATABASE_H */
Definition: str.h:59
Definition: stream.h:77
Definition: stream.h:745
Definition: database.h:33
Definition: agds.h:58