OpenXcom  1.0
Open-source clone of the original X-Com
CatFile.h
1 #pragma once
2 /*
3  * Copyright 2010-2016 OpenXcom Developers.
4  *
5  * This file is part of OpenXcom.
6  *
7  * OpenXcom 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  * OpenXcom 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 OpenXcom. If not, see <http://www.gnu.org/licenses/>.
19  */
20 #include <fstream>
21 
22 namespace OpenXcom
23 {
24 
28 class CatFile : protected std::ifstream
29 {
30 private:
31  unsigned int _amount, *_offset, *_size;
32 public:
34  CatFile(const char *path);
36  ~CatFile();
38  bool operator !() const
39  {
40  return std::ifstream::operator!();
41  }
43  int getAmount() const
44  {
45  return _amount;
46  }
48  unsigned int getObjectSize(unsigned int i) const
49  {
50  return (i < _amount) ? _size[i] : 0;
51  }
53  char *load(unsigned int i, bool name = false);
54 };
55 
56 }
bool operator!() const
Inherit operator.
Definition: CatFile.h:38
CatFile(const char *path)
Creates a CAT file stream.
Definition: CatFile.cpp:32
int getAmount() const
Get amount of objects.
Definition: CatFile.h:43
char * load(unsigned int i, bool name=false)
Load an object into memory.
Definition: CatFile.cpp:72
unsigned int getObjectSize(unsigned int i) const
Get object size.
Definition: CatFile.h:48
Subclass of std::ifstream to handle CAT files.
Definition: CatFile.h:28
Definition: BaseInfoState.cpp:40
~CatFile()
Cleans up the stream.
Definition: CatFile.cpp:58