-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOperations.h
More file actions
60 lines (50 loc) · 2.62 KB
/
Operations.h
File metadata and controls
60 lines (50 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <vector>
#include "Passwords.h"
/**
* This structure provides functions for operations of passwords inside files.
*/
struct Operations{
/**
* @brief Adds a password to a vector of passwords.
* This function creates a password based on parameters provided by the user,
* and adds it to the provided vector of passwords.
* @param passwords The vector of passwords to which the new password will be added.
*/
static void addPassword(std::vector<Password> &passwords);
/**
* @brief Removes passwords from a vector of passwords.
* This function asks the user to choose passwords from the provided
* vector of passwords and removes them
* @param passwords The vector of passwords from which a password should be removed
* @return true if the password was successfully removed, false otherwise.
*/
static void removePasswords(std::vector<Password> &passwords, const std::vector<Password> &toRemove);
/**
* @brief Comparator function for sorting passwords based on specified parameters.
* @param one The first Password object to compare
* @param another The second Password object to compare
* @param parameters The vector of parameters used for comparison
* @return true if "one" is considered less than "another" based on the specified parameters, false otherwise.
* @note The "parameters" vector should contain only parameters, which are Password member functions,
* e.g. name, password, category, login or website
*/
static bool comparatorByParameters(const Password &one, const Password &another,
const std::vector<std::string> ¶meters);
/**
* @brief Finds password that match specified parameters.
* @param passwords The vector of Password objects to search within.
* @param parameters The map of parameters and their corresponding values to match against.
* @return A vector of const Password pointers that represent the matching passwords.
*/
static std::vector<const Password*> findMatches(const std::vector<Password> &passwords,
const std::map<std::string, std::string> ¶meters);
static int generateKeyForEncoding(const std::string &password);
/**
* Encodes or decode the provided string.
* @param data The string to be encoded or decoded.
* @param key The key used for decoding or encoding
* @param encode Indicates whether the data should encoded or decoded.
* true if it should be decoded, false otherwise.
*/
static void encodeOrDecode(std::string &data, int key, bool encode);
};