2#include <NDEVR/Buffer.h>
3#include <NDEVR/Dictionary.h>
4#include <NDEVR/String.h>
5#include <NDEVR/Pointer.h>
6#include <NDEVR/TypeInfo.h>
7#include <NDEVR/PasswordString.h>
8#define NDEVR_SUPPORTS_ZFP 0
146 template<
class t_type>
153#if NDEVR_SUPPORTS_ZFP
160 if (
sizeof(t_type) == 4)
162 else if (
sizeof(t_type) == 8)
166 if (
sizeof(t_type) / 2 == 4)
168 else if (
sizeof(t_type) / 2 == 8)
172 if (
sizeof(t_type) / 3 == 4)
174 else if (
sizeof(t_type) / 3 == 8)
178 if (
sizeof(t_type) / 4 == 4)
180 else if (
sizeof(t_type) / 4 == 8)
187 return compression_mode;
199 template<
class t_type,
class t_memory_manager>
203 object.buffer_size = data.size();
204 if (
object.buffer_size != 0)
207 object.uncompressed_data = (
uint01*)data.ptr();
208 object.uncompressed_size = data.memSize();
209 switch (
object.compression_mode)
216 compression_data.clear();
217 object.compressed_size = 0;
221 object.compressed_size = data.memSize();
224 object.compressed_data = compression_data.begin();
232 compression_data.clear();
243 template<
class t_memory_manager>
247 locations.setSize(data.size());
248 for (
uint04 i = 0; i < data.size(); i++)
251 locations[i] = info.
index;
253 Compress(
object, compression_data, locations);
266 template<
class t_type,
class t_memory_manager>
271 sizes.setSize(data.size());
272 Buffer<
decltype(t_type::Type())> combined_data;
273 for (
uint04 i = 0; i < data.size(); i++)
275 sizes[i] = data[i].size();
276 combined_data.addAll(data[i]);
278 compression_data.clear();
283 Compress(*sub_obj, temp_compress, sizes);
284 compression_data += temp_compress;
286 Compress(
object, temp_compress, combined_data);
287 compression_data += temp_compress;
A specification of upper and lower bounds in N-dimensions.
The equivelent of std::vector but with a bit more control.
A series of static methods designed to compress objects and reduce their memory consumption or file s...
static CompressionMode PickCompressionMode(CompressionMode compression_mode=e_default_compression)
Selects the most appropriate compression mode for the given type.
static CompressedStringInfo AddString(BinaryCompressionObject &data, const String &string)
Adds a string to the BinaryCompressionObject, returning the Compressed string info.
static sint04 ZLibDecompress(const uint01 *compressed, uint01 *uncompressed, size_t compressed_size, size_t &decompressed_size)
A simple, raw call into zlibs uncompress function.
static std::enable_if< ObjectInfo< t_type >::Buffer >::type Compress(BinaryCompressionObject &object, Buffer< uint01 > &compression_data, const Buffer< t_type, t_memory_manager > &data)
Compresses a buffer of buffer-type elements (nested buffers) by flattening sub-buffer sizes and conte...
static Module ZLibModule()
Returns module information for the version of zlib used in this implementation.
static sint04 ZLibCompress(uint01 *compressed, const uint01 *uncompressed, size_t &compressed_size, size_t decompressed_size)
A simple, raw call into zlibs compress function, except if the compressed size is larger than the unc...
static sint04 ZLibCompressFile(File src, File output, const PasswordString &password=PasswordString())
Compresses a file or folder and writes it to an output.
static std::enable_if<!ObjectInfo< t_type >::Buffer >::type Compress(BinaryCompressionObject &object, Buffer< uint01 > &compression_data, const Buffer< t_type, t_memory_manager > &data)
Compresses a buffer of non-buffer (flat) elements into the given compression object.
static void DecompressData(BinaryCompressionObject &data)
Decompresses the BinaryCompressionObject.
static void CompressString(BinaryCompressionObject &object, Buffer< uint01 > &compression_data, const Buffer< String, t_memory_manager > &data)
Compresses a buffer of strings by adding each to the shared string table and then compressing the res...
static void CompressData(BinaryCompressionObject &data)
Compresses the BinaryCompressionObject.
static char * GetString(BinaryCompressionObject &data, uint04 index)
Retrieves a raw string pointer from the compression object by reference index.
static sint04 ZLibDecompressFile(File src, File output_dir, const PasswordString &password=PasswordString())
Decompresses a file or folder and writes it to an output directory.
static uint04 GetStringLength(BinaryCompressionObject &data, uint04 index)
Returns the length of a stored string identified by its reference index.
static char * GetString(BinaryCompressionObject &data, const Bounds< 1, uint04 > &bounds)
Retrieves a raw string pointer from the compression object using byte offset bounds.
A hash-based key-value store, useful for quick associative lookups.
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
When passwords are used inside the NDEVR engine, we don't want them logged or visible.
The core String class for the NDEVR API.
Stores information about a type, relevant for certain templated functions.
The primary namespace for the NDEVR SDK.
constexpr std::enable_if<!ObjectInfo< t_type >::Buffer, TypeInfo >::type GetTypeInfo()
Constructs a TypeInfo for a non-buffer type at compile time using ObjectInfo traits.
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
CompressionMode
Forward declaration of the Module struct for module metadata.
@ e_default_compression
Uses a sensible default compression strategy.
@ e_floating_point_compression_2_fltp08
2D double-precision floating-point compression.
@ e_best_compression
Optimizes for smallest output at the cost of speed.
@ e_floating_point_compression_1_fltp08
1D double-precision floating-point compression.
@ e_string_compression
Compression mode tailored for string data.
@ e_floating_point_compression_3_fltp08
3D double-precision floating-point compression.
@ e_floating_point_compression_4_fltp04
4D single-precision floating-point compression.
@ e_floating_point_compression
Generic floating-point compression.
@ e_no_compression
No compression is applied; data is stored raw.
@ e_floating_point_compression_1_fltp04
1D single-precision floating-point compression.
@ e_best_speed
Optimizes for fastest compression at the cost of ratio.
@ e_string_reference
Stores strings by reference index into a shared table.
@ e_floating_point_compression_2_fltp04
2D single-precision floating-point compression.
@ e_floating_point_compression_3_fltp04
3D single-precision floating-point compression.
@ e_floating_point_compression_4_fltp08
4D double-precision floating-point compression.
@ e_compression_count
Total number of compression modes; always last.
int32_t sint04
-Defines an alias representing a 4 byte, signed integer.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.
A container for storing compressed data, typically used for File IO operations.
uint08 uncompressed_size
Size in bytes of the uncompressed data.
DynamicPointer< BinaryCompressionObject > compression_link
Linked sub-object used when compressing nested buffers.
uint08 buffer_size
Number of logical elements in the buffer.
TypeInfo object_type
Type information describing the elements being compressed.
CompressionMode compression_mode
The compression algorithm to apply.
uint08 version_number
Version number for serialization compatibility.
Dictionary< String, uint04 > * m_string_reference
Lookup table mapping strings to reference indices.
uint01 * compressed_data
Pointer to the compressed data buffer.
Buffer< Bounds< 1, uint04 > > * m_string_size_info
Per-string byte offset bounds within the combined buffer.
String * m_strings
Pointer to the combined string storage buffer.
uint01 * uncompressed_data
Pointer to the raw uncompressed data buffer.
uint08 compressed_size
Size in bytes of the compressed data.
Contains information for referencing compressed strings.
Bounds< 1, uint04 > bounds
The byte offset bounds within the combined string buffer.
uint04 index
The index into the shared string reference table.
Base class for extensions, typically added as external DLL's that can modify or enhance the behavior ...
Information about the object.