xoreos  0.0.5
archive.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos 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 xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef AURORA_ARCHIVE_H
26 #define AURORA_ARCHIVE_H
27 
28 #include <list>
29 
30 #include <boost/noncopyable.hpp>
31 
32 #include "src/common/types.h"
33 #include "src/common/ustring.h"
34 #include "src/common/hash.h"
35 
36 #include "src/aurora/types.h"
37 
38 namespace Common {
39  class SeekableReadStream;
40 }
41 
42 namespace Aurora {
43 
45 class Archive : boost::noncopyable {
46 public:
48  struct Resource {
53 
54  Resource();
55  };
56 
57  typedef std::list<Resource> ResourceList;
58 
59  Archive();
60  virtual ~Archive();
61 
63  virtual const ResourceList &getResources() const = 0;
64 
66  virtual uint32 getResourceSize(uint32 index) const;
67 
74  virtual Common::SeekableReadStream *getResource(uint32 index, bool tryNoCopy = false) const = 0;
75 
77  virtual Common::HashAlgo getNameHashAlgo() const;
78 
80  uint32 findResource(uint64 hash) const;
82  uint32 findResource(const Common::UString &name, FileType type) const;
83 };
84 
85 } // End of namespace Aurora
86 
87 #endif // AURORA_ARCHIVE_H
uint64 hash
The resource&#39;s hashed name.
Definition: archive.h:50
uint32 findResource(uint64 hash) const
Return the index of the resource matching the hash, or 0xFFFFFFFF if not found.
Definition: archive.cpp:48
Definition: 2dafile.h:39
A class holding an UTF-8 string.
Definition: ustring.h:48
uint64_t uint64
Definition: types.h:206
Common::UString name
The resource&#39;s name.
Definition: archive.h:49
virtual const ResourceList & getResources() const =0
Return the list of resources.
Utility hash functions.
virtual uint32 getResourceSize(uint32 index) const
Return the size of a resource.
Definition: archive.cpp:40
std::list< Resource > ResourceList
Definition: archive.h:57
virtual Common::HashAlgo getNameHashAlgo() const
Return with which algorithm the name is hashed.
Definition: archive.cpp:44
HashAlgo
The algorithm used for hashing.
Definition: hash.h:37
Low-level type definitions to handle fixed width types portably.
A resource within the archive.
Definition: archive.h:48
Unicode string handling.
Basic type definitions to handle files used in BioWare&#39;s Aurora engine.
FileType type
The resource&#39;s type.
Definition: archive.h:51
uint32_t uint32
Definition: types.h:204
virtual Common::SeekableReadStream * getResource(uint32 index, bool tryNoCopy=false) const =0
Return a stream of the resource&#39;s contents.
FileType
Various file types used by the Aurora engine and found in archives.
Definition: types.h:56
virtual ~Archive()
Definition: archive.cpp:37
An abstract file archive.
Definition: archive.h:45
Interface for a seekable & readable data stream.
Definition: readstream.h:265
uint32 index
The resource&#39;s local index within the archive.
Definition: archive.h:52