37 const std::string&
msg() const noexcept {
return _msg; }
38 explicit operator bool() const noexcept {
return _type !=
Type::None; }
45 Error(
const char* file,
short line,
Type type, std::string
msg = {}) : _msg(std::move(
msg)), _file(file), _line(line), _type(
type) {}
53 return _type == o._type && _msg == o._msg && _file == o._file && _line == o._line;
60 const char* _file =
nullptr;
67inline bool operator==(
const Error& e,
Error::Type t)
noexcept {
return e.type() == t; }
68inline bool operator!=(
const Error& e,
Error::Type t)
noexcept {
return !(e == t); }
69inline bool operator==(
Error::Type t,
const Error& e)
noexcept {
return e.type() == t; }
70inline bool operator!=(
Error::Type t,
const Error& e)
noexcept {
return !(t == e); }
72#define FormatError(...) Error(__FILE__, __LINE__, Error::Format, std::string(__VA_ARGS__))
73#define ChecksumError(...) Error(__FILE__, __LINE__, Error::Checksum, std::string(__VA_ARGS__))
74#define UnsupportedError(...) Error(__FILE__, __LINE__, Error::Unsupported, std::string(__VA_ARGS__))
The Error class is a value type for the error() member of Barcode.
Definition Error.h:27
bool operator!=(const Error &o) const noexcept
Definition Error.h:55
Type
Definition Error.h:30
@ Format
Format error (i.e. the decoded data is not valid for the detected symbology).
Definition Error.h:32
@ None
No error.
Definition Error.h:31
@ Checksum
Checksum error (i.e. the decoded data does not pass the checksum validation).
Definition Error.h:33
@ Unsupported
Unsupported error (i.e. a particular feature detected is not supported by zxing-cpp).
Definition Error.h:34
static constexpr auto Unsupported
Definition Error.h:49
bool operator==(const Error &o) const noexcept
Definition Error.h:51
Error(Type type, std::string msg={})
Definition Error.h:44
const std::string & msg() const noexcept
Definition Error.h:37
Error(const char *file, short line, Type type, std::string msg={})
Definition Error.h:45
static constexpr auto Format
Definition Error.h:47
static constexpr auto Checksum
Definition Error.h:48
std::string location() const
The source code location where the error was detected (if available).
Type type() const noexcept
Definition Error.h:36
std::string ToString(BarcodeFormat format)