ScummVM API documentation
xbuffer.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
22#ifndef WINTERMUTE_XBUFFER_H
23#define WINTERMUTE_XBUFFER_H
24
25#include "common/types.h"
26#include "common/util.h"
27
28namespace Wintermute {
29
30struct DXBuffer {
31private:
32
33 byte *_ptr;
34 uint64 _size;
35
36public:
37
38 DXBuffer() {
39 _ptr = nullptr;
40 _size = 0;
41 }
42
43 DXBuffer(uint64 size) {
44 _ptr = new uint8_t[size];
45 if (_ptr == nullptr) {
46 size = 0;
47 return;
48 }
49 _size = size;
50 }
51
52 DXBuffer(const uint8 *ptr, uint64 size) {
53 _ptr = new uint8[size];
54 if (_ptr == nullptr) {
55 size = 0;
56 return;
57 }
58 memcpy(_ptr, ptr, size);
59 _size = size;
60 }
61
62 void free() {
63 delete[] _ptr;
64 _ptr = nullptr;
65 _size = 0;
66 }
67
68 byte *ptr() const {
69 return _ptr;
70 }
71
72 uint64 size() const {
73 return _size;
74 }
75};
76
77} // namespace Wintermute
78
79#endif
Definition: xbuffer.h:30