BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnIArchiveLibRead.h
Go to the documentation of this file.
1
#pragma once
2
#ifndef BmnIArchiveLibRead_h
3
#define BmnIArchiveLibRead_h
4
5
// headers from this target
6
#include "
BmnFileProcessingFlags.h
"
7
// std:: headers
8
#include <cstddef>
9
#include <string>
10
11
/*
12
* An interface class for all archive libraries that should read (uncompress) data from binary files
13
*/
14
struct
BmnIArchiveLibRead
15
{
16
BmnIArchiveLibRead
() =
default
;
17
virtual
~BmnIArchiveLibRead
() =
default
;
18
19
/*
20
* A method that is called to uncompress compressed data
21
* @param source A pointer to a buffer with the subsequent compressed data that should be uncompressed
22
* @param sourceTotalSize A number of bytes available in the source buffer
23
* @param numberOfReadBytes A number of bytes that were consumed while compressing. This value will be set.
24
* @param output A pointer to a buffer that will be filled with uncompressed data
25
* @param outputTotalSize A number of bytes that may be filled in the output buffer
26
* @param numberOfSetOutputBytes A number of bytes that were set while decompressing. This value will be set.
27
* @return A result status based on the success of this function
28
*/
29
virtual
BmnFileStreamResults
Uncompress
(
const
void
* source,
30
const
size_t
sourceTotalSize,
31
size_t
& numberOfReadBytes,
32
void
* output,
33
const
size_t
outputTotalSize,
34
size_t
& numberOfSetOutputBytes) = 0;
35
36
/*
37
* If an error previously occurred, this method may be called to obtain its description
38
* @return A string describing the last error, or an empty string if no error has occurred
39
*/
40
[[nodiscard]]
virtual
std::string
GetLastUncompressErrorDescription
() const noexcept = 0;
41
42
/*
43
* A method that tells one if the underlying archive library may jump over the source file or not.
44
* If it may not, it should be read sequentially and any "jumps" actually imply that all previous
45
* compressed bytes were uncompressed.
46
* @return Whether the underlying library allow fast jumping over the source data
47
*/
48
[[nodiscard]] virtual
bool
JumpsAllowed
() const noexcept = 0;
49
50
/*
51
* A method that can be called to quickly jump to a specific position in uncompressed data. This method
52
* should be used only if `JumpsAllowed` return 'true'. Otherwise, it will do nothing!
53
* @param value A place in output data to which the reader should jump (if jumps are allowed)
54
*/
55
virtual
void
JumpTo
(
size_t
value) = 0;
56
57
/*
58
* Get the number of currently decompressed bytes. This only includes bytes that are not part of
59
* various headers (actual number of output bytes)
60
* @return The number of currently decompressed bytes
61
*/
62
[[nodiscard]] virtual
size_t
GetNumberOfDecompressedBytes
() const noexcept = 0;
63
64
/*
65
* Some libraries if not all will be able to tell if the end of the stream is reached.
66
* This is important because the used library might cache some data internally, which could result
67
* in data loss. Thus, calling this method to check if we have processed all the data is
68
* advisable.
69
* @return 'true' if the underlying stream has a bad state or empty internal cache, or 'false' otherwise
70
*/
71
[[nodiscard]] virtual
bool
HasReachedTheEndOfStream
() const noexcept = 0;
72
73
/*
74
* This method can help us determine if an error was detected in the past while trying to decompress data
75
* @return 'true' if an underlying decompression stream is in a good state, or 'false' if not
76
*/
77
[[nodiscard]] virtual
bool
IsStreamInGoodState
() const noexcept = 0;
78
};
79
80
#endif
// BmnIArchiveLibRead_h
BmnFileProcessingFlags.h
BmnFileStreamResults
BmnFileStreamResults
Definition
BmnFileProcessingFlags.h:70
BmnIArchiveLibRead::JumpsAllowed
virtual bool JumpsAllowed() const noexcept=0
BmnIArchiveLibRead::BmnIArchiveLibRead
BmnIArchiveLibRead()=default
BmnIArchiveLibRead::Uncompress
virtual BmnFileStreamResults Uncompress(const void *source, const size_t sourceTotalSize, size_t &numberOfReadBytes, void *output, const size_t outputTotalSize, size_t &numberOfSetOutputBytes)=0
BmnIArchiveLibRead::~BmnIArchiveLibRead
virtual ~BmnIArchiveLibRead()=default
BmnIArchiveLibRead::JumpTo
virtual void JumpTo(size_t value)=0
BmnIArchiveLibRead::GetLastUncompressErrorDescription
virtual std::string GetLastUncompressErrorDescription() const noexcept=0
BmnIArchiveLibRead::HasReachedTheEndOfStream
virtual bool HasReachedTheEndOfStream() const noexcept=0
BmnIArchiveLibRead::GetNumberOfDecompressedBytes
virtual size_t GetNumberOfDecompressedBytes() const noexcept=0
BmnIArchiveLibRead::IsStreamInGoodState
virtual bool IsStreamInGoodState() const noexcept=0
compression
include
BmnIArchiveLibRead.h
Generated on
for BmnRoot by
1.17.0