44 bool protected_ =
false;
55 protect(
const T& val,
bool prot) : value_(val), protected_(prot) {}
62 protect(T&& val,
bool prot) : value_(std::move(val)), protected_(prot) {}
69 value_ = other.value_;
70 protected_ = other.protected_;
78 value_ = std::move(other.value_);
79 protected_ = other.protected_;
98 const T&
value()
const {
return value_; }
119 value_ = std::move(other.value_);
120 protected_ = other.protected_;
128 explicit operator const T&()
const {
return value_; }
148 return value_ == other.value_ && protected_ == other.protected_;
Wrapper that marks a value as sensitive and tracks the protection flag of a KeePass field.
Definition security.hh:41
bool operator!=(const protect< T > &other) const
Inequality comparison of two protected wrappers.
Definition security.hh:156
const T * operator->() const
Arrow operator forwarding to the stored value.
Definition security.hh:134
protect< T > & operator=(protect< T > &&other) noexcept
Move-assigns from another protected wrapper.
Definition security.hh:118
protect()=default
Default-constructs an empty protected wrapper.
protect(protect< T > &&other) noexcept
Move-constructs from another protected wrapper.
Definition security.hh:77
protect(const T &val, bool prot)
Constructs a protected wrapper with an explicit protection flag.
Definition security.hh:55
const T & operator*() const
Dereference operator forwarding to the stored value.
Definition security.hh:140
const T & value() const
Returns a const reference to the stored value.
Definition security.hh:98
bool operator==(const protect< T > &other) const
Equality comparison of two protected wrappers.
Definition security.hh:147
void set_value(const T &val)
Replaces the stored value.
Definition security.hh:104
bool is_protected() const
Returns whether the value is marked as sensitive.
Definition security.hh:86
protect< T > & operator=(const protect< T > &)=default
Copy-assigns from another protected wrapper.
protect(const protect< T > &other)
Copy-constructs from another protected wrapper.
Definition security.hh:68
protect(T &&val, bool prot)
Constructs a protected wrapper by moving a value in.
Definition security.hh:62
void set_protected(bool prot)
Sets the protection flag.
Definition security.hh:92