[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r3417: Some minor const and cosmetic cleanups. (vidalia/trunk/src/torcontrol)
Author: edmanm
Date: 2009-01-05 19:55:57 -0500 (Mon, 05 Jan 2009)
New Revision: 3417
Modified:
vidalia/trunk/src/torcontrol/addressmap.cpp
vidalia/trunk/src/torcontrol/addressmap.h
Log:
Some minor const and cosmetic cleanups.
Modified: vidalia/trunk/src/torcontrol/addressmap.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/addressmap.cpp 2009-01-06 00:47:56 UTC (rev 3416)
+++ vidalia/trunk/src/torcontrol/addressmap.cpp 2009-01-06 00:55:57 UTC (rev 3417)
@@ -25,13 +25,14 @@
/** Adds a new address mapping from the address <b>from</b> to the address
* <b>to</b>, that expires at <b>expires</b>. */
void
-AddressMap::add(QString from, QString to, QDateTime expires)
+AddressMap::add(const QString &from, const QString &to,
+ const QDateTime &expires)
{
tc::debug("New address mapping: %1 -> %2 (expires %3)").arg(from)
- .arg(to)
+ .arg(to)
.arg(expires.isValid() ? expires.toString(DATE_FMT)
: "never");
- insert(from, addr_map_entry_t(to, expires));
+ insert(from, AddressMapEntry(to, expires));
}
/** Adds a new address mapping by parsing the fields in <b>mapping</b>, which
@@ -41,7 +42,7 @@
* Expiry = DQUOTE ISOTime DQUOTE / "NEVER"
*/
void
-AddressMap::add(QString mapping)
+AddressMap::add(const QString &mapping)
{
QStringList parts = mapping.split(" ");
if (parts.size() >= 2) {
@@ -61,7 +62,7 @@
/** Returns true if <b>entry</b> is expired; false otherwise. */
bool
-AddressMap::isExpired(addr_map_entry_t entry) const
+AddressMap::isExpired(const AddressMapEntry &entry) const
{
if (entry.second.isValid())
return (entry.second < QDateTime::currentDateTime());
@@ -71,7 +72,7 @@
/** Returns true if there exists a mapping for <b>addr</b> and that mapping is
* not expired. */
bool
-AddressMap::isMapped(QString addr) const
+AddressMap::isMapped(const QString &addr) const
{
return (contains(addr) && !isExpired(value(addr)));
}
@@ -80,9 +81,9 @@
* no mapping for <b>addr</b> (or the mapping is expired), then an empty
* string is returned. */
QString
-AddressMap::mappedTo(QString addr) const
+AddressMap::mappedTo(const QString &addr) const
{
- addr_map_entry_t entry = value(addr);
+ AddressMapEntry entry = value(addr);
return (isExpired(entry) ? QString() : entry.first);
}
@@ -94,7 +95,7 @@
AddressMap reverseMap;
foreach (QString from, keys()) {
/* Flip the "from" and the "to" addresses and retain the expiry time. */
- addr_map_entry_t entry = value(from);
+ AddressMapEntry entry = value(from);
reverseMap.add(entry.first, from, entry.second);
}
return reverseMap;
Modified: vidalia/trunk/src/torcontrol/addressmap.h
===================================================================
--- vidalia/trunk/src/torcontrol/addressmap.h 2009-01-06 00:47:56 UTC (rev 3416)
+++ vidalia/trunk/src/torcontrol/addressmap.h 2009-01-06 00:55:57 UTC (rev 3417)
@@ -23,10 +23,10 @@
/** Defines a type that pairs a mapping's target address with an expiration
* time for that mapping. */
-typedef QPair<QString, QDateTime> addr_map_entry_t;
+typedef QPair<QString, QDateTime> AddressMapEntry;
-class AddressMap : public QHash<QString, addr_map_entry_t>
+class AddressMap : public QHash<QString, AddressMapEntry>
{
public:
/** Types of address mappings. */
@@ -39,31 +39,31 @@
/** Constructor. Creates an empty table for storing address mappinsgs. */
AddressMap()
- : QHash<QString, addr_map_entry_t>() {}
+ : QHash<QString, AddressMapEntry>() {}
/** Adds a new address mapping or updates an existing one for the address
* specified by <b>from</b>. The mapping will remain valid until the date in
* <b>expires</b>. */
- void add(QString from, QString to, QDateTime expires);
+ void add(const QString &from, const QString &to, const QDateTime &expires);
/** Adds a new address mapping or updates an existing one based on fields
* parsed from <b>mapping</b>. */
- void add(QString mapping);
+ void add(const QString &mapping);
/** Returns true if the address map table contains a mapping for <b>addr</b>
* that is not expired. */
- bool isMapped(QString addr) const;
+ bool isMapped(const QString &addr) const;
/** Returns the address to which <b>addr</b> is currently mapped. If there
* is no mapping for <b>addr</b> (or the mapping is expired), then an
* empty string is returned. */
- QString mappedTo(QString addr) const;
+ QString mappedTo(const QString &addr) const;
/** Returns the reverse of this address map. */
AddressMap reverse() const;
private:
/** Returns true if <b>entry</b> is expired; false otherwise. */
- bool isExpired(addr_map_entry_t entry) const;
+ bool isExpired(const AddressMapEntry &entry) const;
};
#endif