载入中...
搜索中...
未找到
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
size_t offset
float d
float size
Definition TreeMesh.cpp:156
Data public API.
Definition Data.h:8
virtual void * getData() const =0
Gets a pointer to the data. This pointer will obviously not be valid if the Data object is destroyed.
EVENGINE_API_FOUNDATION public API.
Definition Exception.h:13
Contains a reference to a subsection of an existing Data object.
Definition DataView.h:16
DataView(Data *data, size_t offset, size_t size)
Data view.
Definition DataView.cpp:13
DataView * clone() const override
Deep copy. @ownership Caller deletes.
Definition DataView.cpp:36
size_t getSize() const override
Returns the size.
Definition DataView.cpp:46
virtual ~DataView()
Data view.
Definition DataView.cpp:32
void * getData() const override
Returns the data.
Definition DataView.cpp:41
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16