libkeepass 0.2.0
KeePass key database importer/exporter library
Loading...
Searching...
No Matches
visitor.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
25#pragma once
26#include <iosfwd>
27
28#include "libkeepass/export.hh"
29
30namespace keepass {
31
32class Entry;
33class Group;
34
43public:
44 virtual ~Visitor() = default;
45
47 virtual void Visit(Group& group);
48
50 virtual void Visit(Entry& entry);
51};
52
57public:
59 explicit PrintVisitor(std::ostream& os) : os_(os) {}
60
61 void Visit(Group& group) override;
62 void Visit(Entry& entry) override;
63
64private:
65 std::ostream& os_;
66};
67
69
73LIBKEEPASS_API void Visit(Group& group, Visitor& visitor);
74
75} // namespace keepass
A single KeePass entry (a username/password record).
Definition entry.hh:55
A KeePass group (a folder) that contains entries and subgroups.
Definition group.hh:45
Visitor that prints the path of every group and entry to a stream.
Definition visitor.hh:56
void Visit(Group &group) override
Called for every group during traversal.
void Visit(Entry &entry) override
Called for every entry during traversal.
PrintVisitor(std::ostream &os)
Creates a visitor that writes to the given output stream.
Definition visitor.hh:59
Visitor pattern over a KeePass group/entry tree.
Definition visitor.hh:42
virtual void Visit(Entry &entry)
Called for every entry during traversal.
virtual void Visit(Group &group)
Called for every group during traversal.
Visibility/export macro for the shared library.
#define LIBKEEPASS_API
Marks a class, function or variable as part of the public ABI.
Definition export.hh:43
LIBKEEPASS_API void Visit(Group &group, Visitor &visitor)
Traverses the tree rooted at the given group, visiting every group and entry.