Skip to content

Commit ae26c5e

Browse files
committed
partial code modernization
There's still more than enough "old" stuff that could need some more work.
1 parent d6d76cc commit ae26c5e

File tree

9 files changed

+376
-353
lines changed

9 files changed

+376
-353
lines changed

code/MessageDatabase.cpp

Lines changed: 138 additions & 123 deletions
Large diffs are not rendered by default.

code/MessageDatabase.hpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
-------------------------------------------------------------------------------
33
This file is part of the Private Message Database.
4-
Copyright (C) 2012, 2013, 2014, 2015 Dirk Stolle
4+
Copyright (C) 2012, 2013, 2014, 2015, 2025 Dirk Stolle
55
66
This program is free software: you can redistribute it and/or modify
77
it under the terms of the GNU General Public License as published by
@@ -34,11 +34,10 @@ class XMLNode;
3434
class MessageDatabase
3535
{
3636
public:
37-
/* constructor */
3837
MessageDatabase();
3938

4039

41-
/** \brief adds a message to the database
40+
/** \brief Adds a message to the database.
4241
*
4342
* \param pm the message that shall be added
4443
* \return Returns true, if the message was added.
@@ -48,14 +47,14 @@ class MessageDatabase
4847
bool addMessage(PrivateMessage& pm);
4948

5049

51-
/** \brief returns the number of messages that are in the database
50+
/** \brief Returns the number of messages that are in the database.
5251
*
53-
* \return returns the number of messages that are in the database
52+
* \return Returns the number of messages that are in the database.
5453
*/
5554
unsigned int getNumberOfMessages() const;
5655

5756

58-
/** \brief determines whether a given message is in the database.
57+
/** \brief Determines whether a given message is in the database.
5958
*
6059
* \param pm the message
6160
* \return Returns true, if the given message is in the database.
@@ -66,7 +65,7 @@ class MessageDatabase
6665

6766
/** \brief Returns a single message from the database.
6867
*
69-
* \param digest the SHA-256 hash of the required message
68+
* \param digest the SHA-256 hash of the required message
7069
* \return Returns the message with the given digest, if it exists.
7170
* Throws exception otherwise.
7271
*/
@@ -96,27 +95,29 @@ class MessageDatabase
9695
Iterator getEnd() const;
9796

9897

99-
/** \brief tries to save all messages in the database to the given directory
98+
/** \brief Tries to save all messages in the database to the given directory.
10099
*
101100
* \param directory directory where the messages shall be saved
102-
* \param compressed Set this to true to compress PMs with zlib.
101+
* \param compression The type of compression to use when saving the PMs.
103102
* \return Returns true in case of success, or false otherwise.
104103
*/
105-
bool saveMessages(const std::string& directory, const bool compressed) const;
104+
bool saveMessages(const std::string& directory, const Compression compression) const;
106105

107106

108-
/** \brief tries to load all messages in the given directory into the database
107+
/** \brief Tries to load all messages in the given directory into the database.
109108
*
110109
* \param directory the directory from which the messages shall be loaded
111110
* \param readPMs will hold the number of PMs that were read from the file
112111
* \param newPMs will hold the number of new PMs that were stored in the DB
113-
* \param isCompressed Set this to true to indicate that the directory contains only zlib-compressed PMs.
112+
* \param compression The type of (de-)compression to use when loading the
113+
* PMs from the directory. Currently, zlib or none are
114+
* supported.
114115
* \return Returns true in case of success, or false otherwise.
115116
*/
116-
bool loadMessages(const std::string& directory, uint32_t& readPMs, uint32_t& newPMs, const bool isCompressed);
117+
bool loadMessages(const std::string& directory, uint32_t& readPMs, uint32_t& newPMs, const Compression compression);
117118

118119

119-
/** \brief creates index files (HTML) for all message folders
120+
/** \brief Creates index files (HTML) for all message folders.
120121
*
121122
* \param directory path to the directory where the files are saved
122123
* \param index template for index file
@@ -138,11 +139,11 @@ class MessageDatabase
138139
std::map<md_date, std::vector<md_date> > getTextSubsets() const;
139140

140141

141-
/** \brief removes all messages from the database
142+
/** \brief Removes all messages from the database.
142143
*/
143144
void clear();
144145
private:
145-
/** \brief processes a <folder> XML node
146+
/** \brief Processes a <folder> XML node.
146147
*
147148
* \param node the XML node
148149
* \param readPMs will hold the number of PMs that were read from the node
@@ -154,7 +155,7 @@ class MessageDatabase
154155
bool processFolderNode(const XMLNode& node, uint32_t& readPMs, uint32_t& newPMs, FolderMap& fm);
155156

156157

157-
/** \brief processes a <privatemessage> XML node
158+
/** \brief Processes a <privatemessage> XML node.
158159
*
159160
* \param node the XML node
160161
* \param readPMs will hold the number of PMs that were read from the node
@@ -167,6 +168,6 @@ class MessageDatabase
167168
bool processPrivateMessageNode(const XMLNode& node, uint32_t& readPMs, uint32_t& newPMs, const std::string& folder, FolderMap& fm);
168169

169170
std::map<SHA256::MessageDigest, PrivateMessage> m_Messages; /**< map that holds the messages */
170-
};//class
171+
}; // class
171172

172173
#endif // MESSAGEDATABASE_HPP

0 commit comments

Comments
 (0)