VTK
9.1.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
IO
XMLParser
vtkXMLDataHeaderPrivate.h
Go to the documentation of this file.
1
/*=========================================================================
2
3
Program: Visualization Toolkit
4
Module: vtkXMLDataHeaderPrivate.h
5
6
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7
All rights reserved.
8
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10
This software is distributed WITHOUT ANY WARRANTY; without even
11
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
PURPOSE. See the above copyright notice for more information.
13
14
=========================================================================*/
15
16
#ifndef vtkXMLDataHeaderPrivate_DoNotInclude
17
#error "do not include unless you know what you are doing"
18
#endif
19
20
#ifndef vtkXMLDataHeaderPrivate_h
21
#define vtkXMLDataHeaderPrivate_h
22
23
#include "
vtkType.h
"
24
#include <vector>
25
26
// Abstract interface using type vtkTypeUInt64 to access an array
27
// of either vtkTypeUInt32 or vtkTypeUInt64. Shared by vtkXMLWriter
28
// and vtkXMLDataParser to write/read binary data headers.
29
class
vtkXMLDataHeader
30
{
31
public
:
32
virtual
void
Resize
(
size_t
count) = 0;
33
virtual
vtkTypeUInt64
Get
(
size_t
index
)
const
= 0;
34
virtual
bool
Set
(
size_t
index
, vtkTypeUInt64
value
) = 0;
35
virtual
size_t
WordSize
()
const
= 0;
36
virtual
size_t
WordCount
()
const
= 0;
37
virtual
unsigned
char
*
Data
() = 0;
38
size_t
DataSize
()
const
{
return
this->
WordCount
() * this->
WordSize
(); }
39
virtual
~vtkXMLDataHeader
() =
default
;
40
static
inline
vtkXMLDataHeader
*
New
(
int
width,
size_t
count);
41
};
42
43
template
<
typename
T>
44
class
vtkXMLDataHeaderImpl
:
public
vtkXMLDataHeader
45
{
46
std::vector<T> Header;
47
48
public
:
49
vtkXMLDataHeaderImpl
(
size_t
n)
50
: Header(n, 0)
51
{
52
}
53
void
Resize
(
size_t
count)
override
{ this->Header.resize(count, 0); }
54
vtkTypeUInt64
Get
(
size_t
index
)
const override
{
return
this->Header[
index
]; }
55
bool
Set
(
size_t
index
, vtkTypeUInt64
value
)
override
56
{
57
this->Header[
index
] = T(
value
);
58
return
vtkTypeUInt64(this->Header[
index
]) ==
value
;
59
}
60
size_t
WordSize
()
const override
{
return
sizeof
(T); }
61
size_t
WordCount
()
const override
{
return
this->Header.size(); }
62
unsigned
char
*
Data
()
override
{
return
reinterpret_cast<
unsigned
char
*
>
(&this->Header[0]); }
63
};
64
65
vtkXMLDataHeader
*
vtkXMLDataHeader::New
(
int
width,
size_t
count)
66
{
67
switch
(width)
68
{
69
case
32:
70
return
new
vtkXMLDataHeaderImpl<vtkTypeUInt32>
(count);
71
case
64:
72
return
new
vtkXMLDataHeaderImpl<vtkTypeUInt64>
(count);
73
}
74
return
nullptr
;
75
}
76
77
#endif
78
// VTK-HeaderTest-Exclude: vtkXMLDataHeaderPrivate.h
vtkXMLDataHeaderImpl
Definition:
vtkXMLDataHeaderPrivate.h:45
vtkXMLDataHeaderImpl::vtkXMLDataHeaderImpl
vtkXMLDataHeaderImpl(size_t n)
Definition:
vtkXMLDataHeaderPrivate.h:49
vtkXMLDataHeaderImpl::Set
bool Set(size_t index, vtkTypeUInt64 value) override
Definition:
vtkXMLDataHeaderPrivate.h:55
vtkXMLDataHeaderImpl::WordCount
size_t WordCount() const override
Definition:
vtkXMLDataHeaderPrivate.h:61
vtkXMLDataHeaderImpl::Get
vtkTypeUInt64 Get(size_t index) const override
Definition:
vtkXMLDataHeaderPrivate.h:54
vtkXMLDataHeaderImpl::Data
unsigned char * Data() override
Definition:
vtkXMLDataHeaderPrivate.h:62
vtkXMLDataHeaderImpl::Resize
void Resize(size_t count) override
Definition:
vtkXMLDataHeaderPrivate.h:53
vtkXMLDataHeaderImpl::WordSize
size_t WordSize() const override
Definition:
vtkXMLDataHeaderPrivate.h:60
vtkXMLDataHeader
Definition:
vtkXMLDataHeaderPrivate.h:30
vtkXMLDataHeader::Get
virtual vtkTypeUInt64 Get(size_t index) const =0
vtkXMLDataHeader::New
static vtkXMLDataHeader * New(int width, size_t count)
Definition:
vtkXMLDataHeaderPrivate.h:65
vtkXMLDataHeader::WordCount
virtual size_t WordCount() const =0
vtkXMLDataHeader::Set
virtual bool Set(size_t index, vtkTypeUInt64 value)=0
vtkXMLDataHeader::Data
virtual unsigned char * Data()=0
vtkXMLDataHeader::DataSize
size_t DataSize() const
Definition:
vtkXMLDataHeaderPrivate.h:38
vtkXMLDataHeader::WordSize
virtual size_t WordSize() const =0
vtkXMLDataHeader::Resize
virtual void Resize(size_t count)=0
vtkXMLDataHeader::~vtkXMLDataHeader
virtual ~vtkXMLDataHeader()=default
vtkX3D::value
@ value
Definition:
vtkX3D.h:226
vtkX3D::index
@ index
Definition:
vtkX3D.h:252
vtkType.h
Generated on Sat Feb 25 2023 08:59:35 for VTK by
1.9.4