libkeepass 0.2.0
KeePass key database importer/exporter library
Loading...
Searching...
No Matches
icon.hh
Go to the documentation of this file.
1/*
2 * libkeepass - KeePass key database importer/exporter
3 * Copyright (C) 2014 Christian Kindahl
4 * Copyright (C) 2024 Dominik Krümpelmann
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
22#pragma once
23#include <array>
24#include <ctime>
25#include <optional>
26#include <string>
27#include <vector>
28
29namespace keepass {
30
37class Icon final {
38private:
39 std::array<uint8_t, 16> uuid_;
40 std::vector<uint8_t> data_;
41 std::string name_;
42 std::optional<std::time_t> last_modification_time_;
43
44public:
46 Icon(const std::array<uint8_t, 16>& uuid, std::vector<uint8_t> data)
47 : uuid_(uuid), data_(std::move(data)) {}
48
50 const std::array<uint8_t, 16>& uuid() const { return uuid_; }
51
53 const std::vector<uint8_t>& data() const { return data_; }
54
56 void set_data(const std::vector<uint8_t>& data) { data_ = data; }
57
59 const std::string& name() const { return name_; }
60
62 void set_name(const std::string& name) { name_ = name; }
63
65 const std::optional<std::time_t>& last_modification_time() const {
66 return last_modification_time_;
67 }
68
71 void set_last_modification_time(std::optional<std::time_t> time) {
72 last_modification_time_ = time;
73 }
74
76 bool operator==(const Icon& other) const {
77 return data_ == other.data_ && name_ == other.name_ &&
78 last_modification_time_ == other.last_modification_time_;
79 }
80
82 bool operator!=(const Icon& other) const { return !(*this == other); }
83};
84
85} // namespace keepass
A custom icon stored in the database.
Definition icon.hh:37
bool operator!=(const Icon &other) const
Inequality comparison.
Definition icon.hh:82
void set_last_modification_time(std::optional< std::time_t > time)
Definition icon.hh:71
const std::optional< std::time_t > & last_modification_time() const
Returns the icon last modification time (KDBX 4.1); empty if unset.
Definition icon.hh:65
const std::array< uint8_t, 16 > & uuid() const
Returns the icon UUID.
Definition icon.hh:50
void set_data(const std::vector< uint8_t > &data)
Sets the raw icon data.
Definition icon.hh:56
bool operator==(const Icon &other) const
Equality comparison (based on data).
Definition icon.hh:76
const std::string & name() const
Returns the icon name (KDBX 4.1).
Definition icon.hh:59
Icon(const std::array< uint8_t, 16 > &uuid, std::vector< uint8_t > data)
Creates an icon with the given UUID and raw data.
Definition icon.hh:46
void set_name(const std::string &name)
Sets the icon name (KDBX 4.1).
Definition icon.hh:62
const std::vector< uint8_t > & data() const
Returns the raw icon data.
Definition icon.hh:53