47 mutable std::mutex mutex_;
49 mutable bool loaded_ =
true;
50 bool protected_ =
false;
51 bool compress_ =
false;
52 std::size_t size_ = 0;
53 std::shared_ptr<const detail::BinarySource> source_;
66 Binary(std::shared_ptr<const detail::BinarySource> source,
bool protected_data,
67 bool compress =
false);
94 bool is_lazy()
const {
return source_ !=
nullptr; }
Lazy backing store for binary attachment payloads.
A binary blob (e.g. an attachment payload) with an optional compression flag.
Definition binary.hh:45
bool Empty() const
Returns whether the binary data is empty.
Binary & operator=(const Binary &other)
Copy-assigns the payload/source state.
bool is_loaded() const
Returns whether the payload is currently materialized in memory.
Definition binary.hh:91
void load() const
Loads a lazy payload into secure memory (no-op for materialized data).
Binary(const Binary &other)
Copy-constructs the payload/source state.
Binary(std::shared_ptr< const detail::BinarySource > source, bool protected_data, bool compress=false)
Creates a lazy binary backed by a shared source.
bool operator!=(const Binary &other) const
Inequality comparison.
Definition binary.hh:112
Binary(const protect< secure_string > &data)
Creates a binary from the given protected data.
bool operator==(const Binary &other) const
Equality comparison (materializes lazy payloads).
std::size_t Size() const
Returns the size in bytes of the binary data.
void set_compress(bool compress)
Sets whether the binary is stored compressed.
Definition binary.hh:106
const protect< secure_string > & data() const
Returns the binary data, loading it first if necessary.
bool is_protected() const
Returns whether the payload was stored with the protected flag.
Definition binary.hh:97
bool compress() const
Returns whether the binary is stored compressed.
Definition binary.hh:103
bool is_lazy() const
Returns whether the payload is backed by a lazy source.
Definition binary.hh:94
void set_data(const protect< secure_string > &data)
Sets the binary data, replacing any lazy source.
void WriteTo(std::ostream &dst) const
Writes the payload to dst, streaming it when it is still lazy.
Wrapper that marks a value as sensitive and tracks the protection flag of a KeePass field.
Definition security.hh:41
#define LIBKEEPASS_API
Marks a class, function or variable as part of the public ABI.
Definition export.hh:43
Secure memory handling: zeroization, locked allocations and sensitive value containers.
Wrapper type for protecting sensitive KeePass field values.