xoreos  0.0.5
talktable.cpp
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 #include "src/common/util.h"
26 #include "src/common/scopedptr.h"
27 #include "src/common/readstream.h"
28 
29 #include "src/aurora/aurorafile.h"
30 #include "src/aurora/talktable.h"
33 
34 static const uint32 kTLKID = MKTAG('T', 'L', 'K', ' ');
35 static const uint32 kGFFID = MKTAG('G', 'F', 'F', ' ');
36 
37 namespace Aurora {
38 
39 TalkTable::TalkTable(Common::Encoding encoding) : _encoding(encoding) {
40 }
41 
43 }
44 
47  if (!tlkStream)
48  return 0;
49 
50  size_t pos = tlkStream->pos();
51 
52  uint32 id, version;
53  bool utf16le;
54 
55  AuroraFile::readHeader(*tlkStream, id, version, utf16le);
56 
57  tlkStream->seek(pos);
58 
59  if (id == kTLKID)
60  return new TalkTable_TLK(tlkStream.release(), encoding);
61 
62  if (id == kGFFID)
63  return new TalkTable_GFF(tlkStream.release(), encoding);
64 
65  return 0;
66 }
67 
68 } // End of namespace Aurora
#define MKTAG(a0, a1, a2, a3)
A wrapper macro used around four character constants, like &#39;DATA&#39;, to ensure portability.
Definition: endianness.h:140
virtual ~TalkTable()
Definition: talktable.cpp:42
PointerType release()
Returns the plain pointer value and releases ScopedPtr.
Definition: scopedptr.h:103
Base class for BioWare&#39;s talk tables.
Definition: talktable.h:52
Loading BioWare&#39;s GFF&#39;d talk tables.
Definition: talktable_gff.h:60
static void readHeader(Common::ReadStream &stream, uint32 &id, uint32 &version, bool &utf16le)
Read the header out of a stream.
Definition: aurorafile.cpp:53
A simple scoped smart pointer template.
static TalkTable * load(Common::SeekableReadStream *tlk, Common::Encoding encoding)
Take over this stream and read a talk table (of either format) out of it.
Definition: talktable.cpp:45
Utility templates and functions.
Base for BioWare&#39;s Aurora engine files.
Encoding
Definition: encoding.h:37
Base class for BioWare&#39;s talk tables.
Handling BioWare&#39;s TLK talk tables.
Basic reading stream interfaces.
static const uint32 kTLKID
Definition: talktable.cpp:34
TalkTable(Common::Encoding encoding)
Definition: talktable.cpp:39
Loading BioWare&#39;s TLK talk tables.
Definition: talktable_tlk.h:53
uint32_t uint32
Definition: types.h:204
Interface for a seekable & readable data stream.
Definition: readstream.h:265
Handling BioWare&#39;s GFF&#39;d talk tables.
static const uint32 kGFFID
Definition: talktable.cpp:35