载入中...
搜索中...
未找到
DataView.cpp
浏览该文件的文档.
1
2
3#include "DataView.h"
4#include "common/Exception.h"
5#include <cstdint>
6
7namespace eve
8{
9namespace data
10{
11
12
13DataView::DataView(Data *data, size_t offset, size_t size)
14 : data(data)
15 , offset(offset)
16 , size(size)
17{
18 if (offset >= data->getSize() || size > data->getSize() || offset > data->getSize() - size)
19 throw eve::Exception("Offset and size of Data View must fit within the original Data's size.");
20
21 if (size == 0)
22 throw eve::Exception("DataView size must be greater than 0.");
23}
24
26 : data(d.data)
27 , offset(d.offset)
28 , size(d.size)
29{
30}
31
35
37{
38 return new DataView(*this);
39}
40
41void *DataView::getData() const
42{
43 return (uint8_t *) data->getData() + offset;
44}
45
46size_t DataView::getSize() const
47{
48 return size;
49}
50
51} // data
52} // eve
Light2D::Data * data
int d
virtual void * getData() const =0
Gets a pointer to the data. This pointer will obviously not be valid if the Data object is destroyed.
Contains a reference to a subsection of an existing Data object.
Definition DataView.h:16
DataView(Data *data, size_t offset, size_t size)
Definition DataView.cpp:13
DataView * clone() const override
Creates a duplicate of Data derived class instance.
Definition DataView.cpp:36
size_t getSize() const override
Gets the size of the Data in bytes.
Definition DataView.cpp:46
virtual ~DataView()
Definition DataView.cpp:32
void * getData() const override
Gets a pointer to the data. This pointer will obviously not be valid if the Data object is destroyed.
Definition DataView.cpp:41
Definition Build.cpp:11