Debian Codegraph @

src/LibBGCode/core/core.hpp

raw symbols SCIP
1 #cxx . . $ `<file>/src/LibBGCode/core/core.hpp`/ifndef BGCODE_CORE_HPP
2 #define BGCODE_CORE_HPPcxx . . $ `src/LibBGCode/core/core.hpp:2:9`!
3
4 #include "core/export.h"cxx . . $ `<file>/build/core/export.h`/
5
6 #include <cstdio>
7 #include <cstdint>
8 #include <cstddef>
9 #include <climits>
10 #include <array>
11 #include <vector>
12 #include <string>
13 #include <string_view>
14
15 namespace bgcodecxx . . $ bgcode/ { namespace corecxx . . $ bgcode/core/ {
16
17 enum class EResultcxx . . $ bgcode/core/EResult# : uint16_tcxx . . $ uint16_t#
18 {
19 Successcxx . . $ bgcode/core/EResult#Success.,
20 ReadErrorcxx . . $ bgcode/core/EResult#ReadError.,
21 WriteErrorcxx . . $ bgcode/core/EResult#WriteError.,
22 InvalidMagicNumbercxx . . $ bgcode/core/EResult#InvalidMagicNumber.,
23 InvalidVersionNumbercxx . . $ bgcode/core/EResult#InvalidVersionNumber.,
24 InvalidChecksumTypecxx . . $ bgcode/core/EResult#InvalidChecksumType.,
25 InvalidBlockTypecxx . . $ bgcode/core/EResult#InvalidBlockType.,
26 InvalidCompressionTypecxx . . $ bgcode/core/EResult#InvalidCompressionType.,
27 InvalidMetadataEncodingTypecxx . . $ bgcode/core/EResult#InvalidMetadataEncodingType.,
28 InvalidGCodeEncodingTypecxx . . $ bgcode/core/EResult#InvalidGCodeEncodingType.,
29 DataCompressionErrorcxx . . $ bgcode/core/EResult#DataCompressionError.,
30 DataUncompressionErrorcxx . . $ bgcode/core/EResult#DataUncompressionError.,
31 MetadataEncodingErrorcxx . . $ bgcode/core/EResult#MetadataEncodingError.,
32 MetadataDecodingErrorcxx . . $ bgcode/core/EResult#MetadataDecodingError.,
33 GCodeEncodingErrorcxx . . $ bgcode/core/EResult#GCodeEncodingError.,
34 GCodeDecodingErrorcxx . . $ bgcode/core/EResult#GCodeDecodingError.,
35 BlockNotFoundcxx . . $ bgcode/core/EResult#BlockNotFound.,
36 InvalidChecksumcxx . . $ bgcode/core/EResult#InvalidChecksum.,
37 InvalidThumbnailFormatcxx . . $ bgcode/core/EResult#InvalidThumbnailFormat.,
38 InvalidThumbnailWidthcxx . . $ bgcode/core/EResult#InvalidThumbnailWidth.,
39 InvalidThumbnailHeightcxx . . $ bgcode/core/EResult#InvalidThumbnailHeight.,
40 InvalidThumbnailDataSizecxx . . $ bgcode/core/EResult#InvalidThumbnailDataSize.,
41 InvalidBinaryGCodeFilecxx . . $ bgcode/core/EResult#InvalidBinaryGCodeFile.,
42 InvalidAsciiGCodeFilecxx . . $ bgcode/core/EResult#InvalidAsciiGCodeFile.,
43 InvalidSequenceOfBlockscxx . . $ bgcode/core/EResult#InvalidSequenceOfBlocks.,
44 InvalidBuffercxx . . $ bgcode/core/EResult#InvalidBuffer.,
45 AlreadyBinarizedcxx . . $ bgcode/core/EResult#AlreadyBinarized.,
46 MissingPrinterMetadatacxx . . $ bgcode/core/EResult#MissingPrinterMetadata.,
47 MissingPrintMetadatacxx . . $ bgcode/core/EResult#MissingPrintMetadata.,
48 MissingSlicerMetadatacxx . . $ bgcode/core/EResult#MissingSlicerMetadata.,
49 };
50
51 enum class EChecksumTypecxx . . $ bgcode/core/EChecksumType# : uint16_tcxx . . $ uint16_t#
52 {
53 Nonecxx . . $ bgcode/core/EChecksumType#None.,
54 CRC32cxx . . $ bgcode/core/EChecksumType#CRC32.
55 };
56
57 enum class EBlockTypecxx . . $ bgcode/core/EBlockType# : uint16_tcxx . . $ uint16_t#
58 {
59 FileMetadatacxx . . $ bgcode/core/EBlockType#FileMetadata.,
60 GCodecxx . . $ bgcode/core/EBlockType#GCode.,
61 SlicerMetadatacxx . . $ bgcode/core/EBlockType#SlicerMetadata.,
62 PrinterMetadatacxx . . $ bgcode/core/EBlockType#PrinterMetadata.,
63 PrintMetadatacxx . . $ bgcode/core/EBlockType#PrintMetadata.,
64 Thumbnailcxx . . $ bgcode/core/EBlockType#Thumbnail.
65 };
66
67 enum class ECompressionTypecxx . . $ bgcode/core/ECompressionType# : uint16_tcxx . . $ uint16_t#
68 {
69 Nonecxx . . $ bgcode/core/ECompressionType#None.,
70 Deflatecxx . . $ bgcode/core/ECompressionType#Deflate.,
71 Heatshrink_11_4cxx . . $ bgcode/core/ECompressionType#Heatshrink_11_4.,
72 Heatshrink_12_4cxx . . $ bgcode/core/ECompressionType#Heatshrink_12_4.
73 };
74
75 enum class EMetadataEncodingTypecxx . . $ bgcode/core/EMetadataEncodingType# : uint16_tcxx . . $ uint16_t#
76 {
77 INIcxx . . $ bgcode/core/EMetadataEncodingType#INI.,
78 JSONcxx . . $ bgcode/core/EMetadataEncodingType#JSON.
79 };
80
81 enum class EGCodeEncodingTypecxx . . $ bgcode/core/EGCodeEncodingType# : uint16_tcxx . . $ uint16_t#
82 {
83 Nonecxx . . $ bgcode/core/EGCodeEncodingType#None.,
84 MeatPackcxx . . $ bgcode/core/EGCodeEncodingType#MeatPack.,
85 MeatPackCommentscxx . . $ bgcode/core/EGCodeEncodingType#MeatPackComments.
86 };
87
88 enum class EThumbnailFormatcxx . . $ bgcode/core/EThumbnailFormat# : uint16_tcxx . . $ uint16_t#
89 {
90 PNGcxx . . $ bgcode/core/EThumbnailFormat#PNG.,
91 JPGcxx . . $ bgcode/core/EThumbnailFormat#JPG.,
92 QOIcxx . . $ bgcode/core/EThumbnailFormat#QOI.
93 };
94
95 struct BGCODE_CORE_EXPORTcxx . . $ `build/core/export.h:15:15`! FileHeadercxx . . $ bgcode/core/FileHeader#
96 {
97 uint32_tcxx . . $ uint32_t# magiccxx . . $ bgcode/core/FileHeader#magic.;
98 uint32_tcxx . . $ uint32_t# versioncxx . . $ bgcode/core/FileHeader#version.;
99 uint16_tcxx . . $ uint16_t# checksum_typecxx . . $ bgcode/core/FileHeader#checksum_type.;
100
101 FileHeadercxx . . $ bgcode/core/FileHeader#FileHeader(49f6e7a06ebc5aa8).();
102 FileHeadercxx . . $ bgcode/core/FileHeader#FileHeader(b1624636d8f2829d).(uint32_tcxx . . $ uint32_t# mg, uint32_tcxx . . $ uint32_t# ver, uint16_tcxx . . $ uint16_t# chk_type);
103
104 EResultcxx . . $ bgcode/core/EResult# writecxx . . $ bgcode/core/FileHeader#write(fe8a7317264494e8).(FILEcxx . . $ FILE#& file) const;
105 EResultcxx . . $ bgcode/core/EResult# readcxx . . $ bgcode/core/FileHeader#read(c22f737ea54cd81b).(FILEcxx . . $ FILE#& file, const uint32_tcxx . . $ uint32_t#* const max_version);
106 };
107
108 struct BGCODE_CORE_EXPORTcxx . . $ `build/core/export.h:15:15`! BlockHeadercxx . . $ bgcode/core/BlockHeader#
109 {
110 uint16_tcxx . . $ uint16_t# typecxx . . $ bgcode/core/BlockHeader#type.{ 0 };
111 uint16_tcxx . . $ uint16_t# compressioncxx . . $ bgcode/core/BlockHeader#compression.{ 0 };
112 uint32_tcxx . . $ uint32_t# uncompressed_sizecxx . . $ bgcode/core/BlockHeader#uncompressed_size.{ 0 };
113 uint32_tcxx . . $ uint32_t# compressed_sizecxx . . $ bgcode/core/BlockHeader#compressed_size.{ 0 };
114
115 BlockHeadercxx . . $ bgcode/core/BlockHeader#BlockHeader(49f6e7a06ebc5aa8).() = default;
116 BlockHeadercxx . . $ bgcode/core/BlockHeader#BlockHeader(7274fabe54ccb4a8).(uint16_tcxx . . $ uint16_t# type, uint16_tcxx . . $ uint16_t# compression, uint32_tcxx . . $ uint32_t# uncompressed_size, uint32_tcxx . . $ uint32_t# compressed_size = 0);
117
118 // Returns the position of this block in the file.
119 // Position is set by calling write() and read() methods.
120 long get_positioncxx . . $ bgcode/core/BlockHeader#get_position(57a65ae535d7db84).() const;
121
122 EResultcxx . . $ bgcode/core/EResult# writecxx . . $ bgcode/core/BlockHeader#write(b597d3acafec750f).(FILEcxx . . $ FILE#& file);
123 EResultcxx . . $ bgcode/core/EResult# readcxx . . $ bgcode/core/BlockHeader#read(b597d3acafec750f).(FILEcxx . . $ FILE#& file);
124
125 // Returs the size of this BlockHeader, in bytes
126 size_tcxx . . $ size_t# get_sizecxx . . $ bgcode/core/BlockHeader#get_size(fe4d2d262d4164a8).() const;
127
128 private:
129 long m_positioncxx . . $ bgcode/core/BlockHeader#m_position.{ 0 };
130 };
131
132 struct BGCODE_CORE_EXPORTcxx . . $ `build/core/export.h:15:15`! ThumbnailParamscxx . . $ bgcode/core/ThumbnailParams#
133 {
134 uint16_tcxx . . $ uint16_t# formatcxx . . $ bgcode/core/ThumbnailParams#format.;
135 uint16_tcxx . . $ uint16_t# widthcxx . . $ bgcode/core/ThumbnailParams#width.;
136 uint16_tcxx . . $ uint16_t# heightcxx . . $ bgcode/core/ThumbnailParams#height.;
137
138 EResultcxx . . $ bgcode/core/EResult# writecxx . . $ bgcode/core/ThumbnailParams#write(fe8a7317264494e8).(FILEcxx . . $ FILE#& file) const;
139 EResultcxx . . $ bgcode/core/EResult# readcxx . . $ bgcode/core/ThumbnailParams#read(b597d3acafec750f).(FILEcxx . . $ FILE#& file);
140 };
141
142 // Returns a string description of the given result
143 extern BGCODE_CORE_EXPORTcxx . . $ `build/core/export.h:15:15`! stdcxx . . $ std/::string_viewcxx . . $ std/string_view# translate_resultcxx . . $ bgcode/core/translate_result(a668d56a003f646e).(EResultcxx . . $ bgcode/core/EResult# result);
144
145 // Returns EResult::Success if the given file is a valid binary gcode
146 // If check_contents is set to true, the order of the blocks is checked
147 // Does not modify the file position
148 // Caller is responsible for providing buffer for checksum calculation, if needed.
149 extern BGCODE_CORE_EXPORTcxx . . $ `build/core/export.h:15:15`! EResultcxx . . $ bgcode/core/EResult# is_valid_binary_gcodecxx . . $ bgcode/core/is_valid_binary_gcode(73bc5f1c782bc347).(FILEcxx . . $ FILE#& file, bool check_contents = false, stdcxx . . $ std/::byte* cs_buffer = nullptr,
150 size_tcxx . . $ size_t# cs_buffer_size = 0);
151
152 // Reads the file header.
153 // If max_version is not null, version is checked against the passed value.
154 // If return == EResult::Success:
155 // - header will contain the file header.
156 // - file position will be set at the start of the 1st block header.
157 extern BGCODE_CORE_EXPORTcxx . . $ `build/core/export.h:15:15`! EResultcxx . . $ bgcode/core/EResult# read_headercxx . . $ bgcode/core/read_header(9cf9b3ef17676c3e).(FILEcxx . . $ FILE#& file, FileHeadercxx . . $ bgcode/core/FileHeader#& header, const uint32_tcxx . . $ uint32_t#* const max_version);
158
159 // Reads next block header from the current file position.
160 // File position must be at the start of a block header.
161 // If return == EResult::Success:
162 // - block_header will contain the header of the block.
163 // - file position will be set at the start of the block parameters data.
164 // Caller is responsible for providing buffer for checksum calculation, if needed.
165 extern BGCODE_CORE_EXPORTcxx . . $ `build/core/export.h:15:15`! EResultcxx . . $ bgcode/core/EResult# read_next_block_headercxx . . $ bgcode/core/read_next_block_header(5e0f4149a99be637).(FILEcxx . . $ FILE#& file, const FileHeadercxx . . $ bgcode/core/FileHeader#& file_header, BlockHeadercxx . . $ bgcode/core/BlockHeader#& block_header,
166 stdcxx . . $ std/::byte* cs_buffer = nullptr, size_tcxx . . $ size_t# cs_buffer_size = 0);
167
168 // Searches and reads next block header with the given type from the current file position.
169 // File position must be at the start of a block header.
170 // If return == EResult::Success:
171 // - block_header will contain the header of the block with the required type.
172 // - file position will be set at the start of the block parameters data.
173 // otherwise:
174 // - file position will keep the current value.
175 // Caller is responsible for providing buffer for checksum calculation, if needed.
176 extern BGCODE_CORE_EXPORTcxx . . $ `build/core/export.h:15:15`! EResultcxx . . $ bgcode/core/EResult# read_next_block_headercxx . . $ bgcode/core/read_next_block_header(c3c0ee3d65db6cab).(FILEcxx . . $ FILE#& file, const FileHeadercxx . . $ bgcode/core/FileHeader#& file_header, BlockHeadercxx . . $ bgcode/core/BlockHeader#& block_header, EBlockTypecxx . . $ bgcode/core/EBlockType# type,
177 stdcxx . . $ std/::byte* cs_buffer = nullptr, size_tcxx . . $ size_t# cs_buffer_size = 0);
178
179 // Calculates block checksum and verify it against checksum stored in file.
180 // Caller is responsible for providing buffer for checksum calculation, bigger buffer means faster calculation and vice versa.
181 // If return == EResult::Success:
182 // - file position will be set at the start of the next block header.
183 extern BGCODE_CORE_EXPORTcxx . . $ `build/core/export.h:15:15`! EResultcxx . . $ bgcode/core/EResult# verify_block_checksumcxx . . $ bgcode/core/verify_block_checksum(a783147db604bed3).(FILEcxx . . $ FILE#& file, const FileHeadercxx . . $ bgcode/core/FileHeader#& file_header, const BlockHeadercxx . . $ bgcode/core/BlockHeader#& block_header, stdcxx . . $ std/::byte* buffer,
184 size_tcxx . . $ size_t# buffer_size);
185
186 // Skips the content (parameters + data + checksum) of the block with the given block header.
187 // File position must be at the start of the block parameters.
188 // If return == EResult::Success:
189 // - file position will be set at the start of the next block header.
190 extern BGCODE_CORE_EXPORTcxx . . $ `build/core/export.h:15:15`! EResultcxx . . $ bgcode/core/EResult# skip_block_contentcxx . . $ bgcode/core/skip_block_content(3ea66fc514e22a37).(FILEcxx . . $ FILE#& file, const FileHeadercxx . . $ bgcode/core/FileHeader#& file_header, const BlockHeadercxx . . $ bgcode/core/BlockHeader#& block_header);
191
192 // Skips the block with the given block header.
193 // File position must be set by a previous call to BlockHeader::write() or BlockHeader::read().
194 // If return == EResult::Success:
195 // - file position will be set at the start of the next block header.
196 extern BGCODE_CORE_EXPORTcxx . . $ `build/core/export.h:15:15`! EResultcxx . . $ bgcode/core/EResult# skip_blockcxx . . $ bgcode/core/skip_block(3ea66fc514e22a37).(FILEcxx . . $ FILE#& file, const FileHeadercxx . . $ bgcode/core/FileHeader#& file_header, const BlockHeadercxx . . $ bgcode/core/BlockHeader#& block_header);
197
198 // Returns the size of the parameters of the given block type, in bytes.
199 extern BGCODE_CORE_EXPORTcxx . . $ `build/core/export.h:15:15`! size_tcxx . . $ size_t# block_parameters_sizecxx . . $ bgcode/core/block_parameters_size(de9915921fd84698).(EBlockTypecxx . . $ bgcode/core/EBlockType# type);
200
201 // Returns the size of the payload (parameters + data) of the block with the given header, in bytes.
202 extern BGCODE_CORE_EXPORTcxx . . $ `build/core/export.h:15:15`! size_tcxx . . $ size_t# block_payload_sizecxx . . $ bgcode/core/block_payload_size(275042c486b7286c).(const BlockHeadercxx . . $ bgcode/core/BlockHeader#& block_header);
203
204 // Returns the size of the checksum of the given type, in bytes.
205 extern BGCODE_CORE_EXPORTcxx . . $ `build/core/export.h:15:15`! size_tcxx . . $ size_t# checksum_sizecxx . . $ bgcode/core/checksum_size(c35f3928edf924e0).(EChecksumTypecxx . . $ bgcode/core/EChecksumType# type);
206
207 // Returns the size of the content (parameters + data + checksum) of the block with the given header, in bytes.
208 extern BGCODE_CORE_EXPORTcxx . . $ `build/core/export.h:15:15`! size_tcxx . . $ size_t# block_content_sizecxx . . $ bgcode/core/block_content_size(c2d5e52d7c3d4bcd).(const FileHeadercxx . . $ bgcode/core/FileHeader#& file_header, const BlockHeadercxx . . $ bgcode/core/BlockHeader#& block_header);
209
210 // Highest version of the binary format supported by this library instance
211 extern BGCODE_CORE_EXPORTcxx . . $ `build/core/export.h:15:15`! uint32_tcxx . . $ uint32_t# bgcode_versioncxx . . $ bgcode/core/bgcode_version(2658d6455debfaef).() noexcept;
212
213 // Version of the library
214 extern BGCODE_CORE_EXPORTcxx . . $ `build/core/export.h:15:15`! const char* versioncxx . . $ bgcode/core/version(a90adccc7a50142).() noexcept;
215
216 }} // bgcode::core
217
218 #endif // BGCODE_CORE_HPP