Added GPLv3 headers all over the place.
[fail.git] / src / services / fbf / reader-OBJS.h
blobe6629f75d34ccec8b40409699c919eb27f304d96
1 /*
2 Fail game engine
3 Copyright 2007 Antoine Chavasse <a.chavasse@gmail.com>
5 This file is part of Fail.
7 Fail is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 3
9 as published by the Free Software Foundation.
11 Fail is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef FAIL_FBF_READER_OBJS_H
20 #define FAIL_FBF_READER_OBJS_H
22 #include <vector>
24 namespace fail { namespace fbf
26 template< class EndianessPolicy > GenericPointer BaseReader< EndianessPolicy >::
27 ReadOBJS( buffered_stream_type& Stream )
29 const char objs[] = { 'O', 'B', 'J', 'S' };
30 char chunkid[4];
32 Stream.read( chunkid, sizeof( chunkid ) );
34 while( memcmp( objs, chunkid, sizeof( chunkid ) ) )
36 uint32_t size = Stream.readU32();
37 Stream.seek( Stream.tell() + size );
38 if( Stream.read( chunkid, sizeof( chunkid ) ) != sizeof( chunkid ) )
40 // TODO: throw
41 std::cout << "FBF reader: OBJS chunk not found\n";
45 uint32_t size = Stream.readU32();
47 Impl::ReadContext< buffered_stream_type > rct( Stream );
48 GenericPointer pObj = rct.readObject();
49 rct.postLoad();
50 return pObj;
54 #endif