QtPass 1.7.0
Multi-platform GUI for pass, the standard unix password manager.
Loading...
Searching...
No Matches
filecontent.h
1// SPDX-FileCopyrightText: 2018 Anne Jan Brouwer
2// SPDX-License-Identifier: GPL-3.0-or-later
3#ifndef SRC_FILECONTENT_H_
4#define SRC_FILECONTENT_H_
5
6#include <QList>
7#include <QString>
8#include <QStringList>
9
14struct NamedValue {
18 QString name;
22 QString value;
23};
24
25inline bool operator==(const NamedValue &a, const NamedValue &b) {
26 return a.name == b.name && a.value == b.value;
27}
28
33class NamedValues : public QList<NamedValue> {
34public:
35 NamedValues();
40 NamedValues(std::initializer_list<NamedValue> values);
41
47 auto takeValue(const QString &name) -> QString;
48};
49
57class FileContent {
58public:
78 static auto parse(const QString &fileContent,
79 const QStringList &templateFields, bool allFields)
80 -> FileContent;
81
85 [[nodiscard]] auto getPassword() const -> QString;
86
91 [[nodiscard]] auto getNamedValues() const -> NamedValues;
92
96 [[nodiscard]] auto getRemainingData() const -> QString;
97
103 [[nodiscard]] auto getRemainingDataForDisplay() const -> QString;
104
105private:
106 FileContent(QString password, NamedValues namedValues, QString remainingData,
107 QString remainingDataDisplay);
108
109 QString password;
110 NamedValues namedValues;
111 QString remainingData, remainingDataDisplay;
112};
113
114#endif // SRC_FILECONTENT_H_
auto getRemainingData() const -> QString
auto getNamedValues() const -> NamedValues
auto getRemainingDataForDisplay() const -> QString
Like getRemainingData but without data that should not be displayed (like a TOTP secret).
auto getPassword() const -> QString
static auto parse(const QString &fileContent, const QStringList &templateFields, bool allFields) -> FileContent
parse parses the given fileContent in a FileContent object. The password is accessible through getPas...
The NamedValues class is mostly a list of NamedValue but also has a method to take a specific NamedVa...
Definition filecontent.h:33
auto takeValue(const QString &name) -> QString
Remove and return the value for the named field.
NamedValues(std::initializer_list< NamedValue > values)
Construct a NamedValues list from an initializer list.
A name/value pair parsed from a password file field.
Definition filecontent.h:14
QString name
Field name (the part before the colon in "name: value").
Definition filecontent.h:18
QString value
Field value (the part after the colon in "name: value").
Definition filecontent.h:22