libnick 2025.9.1
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
keyring.h
Go to the documentation of this file.
1
22
23#ifndef KEYRING_H
24#define KEYRING_H
25
26#include <memory>
27#include <mutex>
28#include <optional>
29#include <string>
30#include <vector>
31#include "credential.h"
33
34namespace Nickvision::Keyring
35{
40 class Keyring
41 {
42 public:
49 Keyring(const std::string& name);
50 Keyring(const Keyring&) = delete;
55 Keyring(Keyring&& other) noexcept;
60 const std::string& getName() const noexcept;
65 bool isSavingToDisk() const noexcept;
70 const std::vector<Credential>& getAll() const noexcept;
76 std::optional<Credential> get(const std::string& name) noexcept;
82 bool add(const Credential& credential) noexcept;
88 bool update(const Credential& credential) noexcept;
94 bool remove(const std::string& name) noexcept;
101 bool destroy() noexcept;
102 Keyring& operator=(const Keyring&) = delete;
107 Keyring& operator=(Keyring&& other) noexcept;
108
109 private:
110 mutable std::mutex m_mutex;
111 std::string m_name;
112 std::unique_ptr<Database::SqliteDatabase> m_database;
113 std::vector<Credential> m_credentials;
114 };
115}
116
117#endif //KEYRING_H
A model of a credential stored in a keyring.
Definition credential.h:34
const std::string & getName() const noexcept
Gets the name of the keyring.
bool update(const Credential &credential) noexcept
Updates a credential in the keyring.
std::optional< Credential > get(const std::string &name) noexcept
Gets the credential matching the provided name.
Keyring(const Keyring &)=delete
Keyring(const std::string &name)
Constructs a Keyring.
const std::vector< Credential > & getAll() const noexcept
Gets all credentials in the keyring.
bool destroy() noexcept
Destroys the keyring.
Keyring(Keyring &&other) noexcept
Constructs a Keyring via move.
bool add(const Credential &credential) noexcept
Adds a credential to the keyring.
bool isSavingToDisk() const noexcept
Gets whether the keyring is saving data to disk.
bool remove(const std::string &name) noexcept
Deletes a credential from the keyring.
Definition sqlite.h:40
Definition credential.h:29