Enrollment
28.2.0
Theme:
Default
Robot
Toggle main menu visibility
Loading...
Searching...
No Matches
ISOTemplate.h
Go to the documentation of this file.
1
9
10
#pragma once
11
12
#include "
enrollment/Exception/EnrollmentException.h
"
13
#include "enrollment/Export.h"
14
#include "
enrollment/Serialization/Writer.h
"
15
16
// cppcoreguidelines-non-private-member-variables-in-classes,misc-non-private-member-variables-in-classes: This is not a
17
// problem because we are using them only as read only.
18
// cppcoreguidelines-avoid-const-or-ref-data-members: We design te API with const member variables instead of
19
// implementing getter methods. This is nicely transformed in C# to properties. Usually our objects are immutable by
20
// intention to have no problem in multithreaded applications.
21
// NOLINTBEGIN(cppcoreguidelines-non-private-member-variables-in-classes,misc-non-private-member-variables-in-classes,cppcoreguidelines-avoid-const-or-ref-data-members)
22
namespace
inno
23
{
27
*/
28
class
ISOTemplate
:
public
Serializable
29
{
30
public
:
32
const
std::vector<uint8_t>
data
;
33
37
*/
38
explicit
ISOTemplate
(std::vector<uint8_t>&& d) noexcept
39
:
data
(std::move(d))
40
{
41
}
42
46
*/
47
explicit
ISOTemplate
(
const
std::vector<uint8_t>& d)
48
:
data
(d)
49
{
50
}
51
56
*/
57
[[nodiscard]] std::string
GetVersion
()
const
58
{
59
constexpr
ptrdiff_t VersionOffset = 4;
// defined in "ISO_IEC_19794-2_2011 - 8.3.1 Format identifier
60
constexpr
ptrdiff_t VersionSize = 4;
// defined in "ISO_IEC_19794-2_2011 - 8.3.2 Version number"
61
if
(
data
.size() <
static_cast<
std::size_t
>
(VersionOffset + VersionSize))
62
{
63
throw
EnrollmentRuntimeException
(
"Unable to read version from the ISO template"
);
64
}
65
const
auto
*
const
versionBegin =
66
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
67
std::next(
reinterpret_cast<
const
char
*
>
(
data
.data()), VersionOffset);
// version is stored as ASCII string
68
const
auto
*
const
versionEnd = std::next(versionBegin, VersionSize - 1);
// last character is null byte
69
70
const
int
version = std::stoi(std::string{ versionBegin, versionEnd });
71
return
std::to_string(version);
72
}
73
74
void
WriteTo
(
Writer
& writer)
const
final
75
{
76
writer.WriteArray(
"d"
,
data
);
77
}
78
79
ISOTemplate
(
const
ISOTemplate
&) =
default
;
80
ISOTemplate
(
ISOTemplate
&&) =
default
;
81
ISOTemplate
& operator=(
const
ISOTemplate
&) =
delete
;
82
ISOTemplate
& operator=(
ISOTemplate
&&) =
delete
;
83
ISOTemplate
() =
delete
;
84
virtual
~ISOTemplate
() =
default
;
85
};
86
}
// namespace inno
87
// NOLINTEND(cppcoreguidelines-non-private-member-variables-in-classes,misc-non-private-member-variables-in-classes,cppcoreguidelines-avoid-const-or-ref-data-members)
EnrollmentException.h
Writer.h
EnrollmentRuntimeException
Base exception for all enrollment-sdk runtime exceptions.
Definition
EnrollmentException.h:84
ISOTemplate
ISO/IEC 19794-2 print compliant template.
Definition
ISOTemplate.h:28
ISOTemplate::ISOTemplate
ISOTemplate(std::vector< uint8_t > &&d) noexcept
Create ISOTemplate object.
Definition
ISOTemplate.h:37
ISOTemplate::WriteTo
void WriteTo(Writer &writer) const final
Write itself into writer.
Definition
ISOTemplate.h:73
ISOTemplate::GetVersion
std::string GetVersion() const
Provides version information of Innovatrics proprietary algorithm used to create the ISO template.
Definition
ISOTemplate.h:56
ISOTemplate::data
const std::vector< uint8_t > data
Template data.
Definition
ISOTemplate.h:31
ISOTemplate::ISOTemplate
ISOTemplate(const std::vector< uint8_t > &d)
Create ISOTemplate object, copy data to ISO template.
Definition
ISOTemplate.h:46
Writer
Provides interface for serialization of all classes.
Definition
Writer.h:164
Print
ISOTemplate.h
Generated by
1.17.0