PxCrypt v0.2.2
Encrypt data within an image
Loading...
Searching...
No Matches
standard_decoder.h
1#ifndef STANDARD_DECODER_H
2#define STANDARD_DECODER_H
3
4// Shared Library Support
5#include "pxcrypt/pxcrypt_codec_export.h"
6
7// Qt Includes
8#include <QImage>
9
10// Qx Includes
11#include <qx/core/qx-abstracterror.h>
12
13// Project Includes
14#include "pxcrypt/codec/decoder.h"
15
16namespace PxCrypt
17{
18
19class StandardDecoderPrivate;
20
21class PXCRYPT_CODEC_EXPORT StandardDecoder final : public Decoder
22{
23 Q_DECLARE_PRIVATE(StandardDecoder);
24//-Inner Classes----------------------------------------------------------------------------------------------
25public:
26 class Error;
27
28//-Constructor---------------------------------------------------------------------------------------------------
29public:
31
32//-Instance Functions----------------------------------------------------------------------------------------------
33public:
34 QString tag() const;
35 Error decode(QByteArray& decoded, const QImage& encoded, const QImage& medium = QImage());
36};
37
38class PXCRYPT_CODEC_EXPORT QX_ERROR_TYPE(StandardDecoder::Error, "PxCrypt::StandardDecoder::Error", 6878)
39{
40//-Class Enums-------------------------------------------------------------
41public:
52
53//-Class Variables-------------------------------------------------------------
54private:
55 static inline const QString PREFIX_STRING = u"Decoding failed."_s;
56 static inline const QHash<Type, QString> ERR_STRINGS{
57 {NoError, u""_s},
58 {InvalidSource, u"The encoded image is invalid."_s},
59 {MissingMedium, u"The encoded image requires a medium to be decoded but none was provided."_s},
60 {DimensionMismatch, u"The required medium image has different dimensions than the encoded image."_s},
61 {NotLargeEnough, u"The provided image is not large enough to be an encoded image."_s},
62 {InvalidMeta, u"The provided image is not encoded."_s},
63 {SkimFailed, u"There was an error while skimming data."_s}
64 };
65
66//-Instance Variables-------------------------------------------------------------
67private:
68 Type mType;
69 QString mSpecific;
70
71//-Constructor-------------------------------------------------------------
72public:
73 Error(Type t = NoError, const QString& s = {});
74
75//-Instance Functions-------------------------------------------------------------
76public:
77 bool isValid() const;
78 Type type() const;
79 QString specific() const;
80 QString errorString() const;
81
82private:
83 quint32 deriveValue() const override;
84 QString derivePrimary() const override;
85 QString deriveSecondary() const override;
86};
87
88}
89
90#endif // STANDARD_DECODER_H
The Encoder class is a base class from which all PxCrypt decoders derive in order to skim and decrypt...
Definition decoder.h:17
The MultiDecoder::Error class is used to report errors during multi-image decoding.
Definition multi_decoder.h:39
The StandardDecoder::Error class is used to report errors during image decoding.
Definition standard_decoder.h:39
Type
Definition standard_decoder.h:43
@ NoError
Definition standard_decoder.h:44
@ DimensionMismatch
Definition standard_decoder.h:47
@ InvalidMeta
Definition standard_decoder.h:49
@ InvalidSource
Definition standard_decoder.h:45
@ MissingMedium
Definition standard_decoder.h:46
@ NotLargeEnough
Definition standard_decoder.h:48
The StandardDecoder class decodes a payload and identifying tag from a single encoded image.
Definition standard_decoder.h:22
The PxCrypt namespace is the main namespace through which all functionality of the PxCrypt library is...
Definition decoder.cpp:6