ScummVM API documentation
dbase.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  * This file is dual-licensed.
22  * In addition to the GPLv3 license mentioned above, this code is also
23  * licensed under LGPL 2.1. See LICENSES/COPYING.LGPL file for the
24  * full text of the license.
25  *
26  */
27 
28 #ifndef GOB_DBASE_H
29 #define GOB_DBASE_H
30 
31 #include "common/system.h"
32 #include "common/util.h"
33 #include "common/str.h"
34 #include "common/stream.h"
35 #include "common/array.h"
36 
37 namespace Gob {
38 
46 class dBase {
47 public:
48  enum Type {
49  kTypeString = 0x43, // 'C'
50  kTypeDate = 0x44, // 'D'
51  kTypeBool = 0x4C, // 'L'
52  kTypeMemo = 0x4D, // 'M'
53  kTypeNumber = 0x4E // 'N'
54  };
55 
57  struct Field {
59 
60  Type type;
61  uint8 size;
62  uint8 decimals;
63  };
64 
66  struct Record {
67  bool deleted;
69  };
70 
71  dBase();
72  ~dBase();
73 
74  bool load(Common::SeekableReadStream &stream);
75  void clear();
76 
77  byte getVersion() const;
78 
80  TimeDate getLastUpdate() const;
81 
82  const Common::Array<Field> &getFields() const;
83  const Common::Array<Record> &getRecords() const;
84 
86  Common::String getString(const Record &record, int field) const;
87 
88 private:
89  byte _version;
90  bool _hasMemo;
91 
92  TimeDate _lastUpdate;
93 
94  Common::Array<Field> _fields;
95  Common::Array<Record> _records;
96 
97  byte *_recordData;
98 
99  static inline uint32 stringLength(const byte *data, uint32 max);
100  static inline Common::String readString(Common::SeekableReadStream &stream, int n);
101 };
102 
103 } // End of namespace Gob
104 
105 #endif // GOB_DBASE_H
uint8 size
Size of raw field data in bytes.
Definition: dbase.h:61
Definition: system.h:106
Definition: str.h:59
TimeDate getLastUpdate() const
Definition: array.h:52
Definition: dbase.h:66
Common::Array< const byte * > fields
Raw field data.
Definition: dbase.h:68
Definition: stream.h:745
Common::String getString(const Record &record, int field) const
Definition: dbase.h:46
Definition: anifile.h:40
uint8 decimals
Number of decimals the field holds.
Definition: dbase.h:62
Definition: dbase.h:57
Type type
Type of the field.
Definition: dbase.h:60
Common::String name
Name of the field.
Definition: dbase.h:58
bool deleted
Has this record been deleted?
Definition: dbase.h:67