[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r2263: Add a ControlCommand::addArguments() command that adds a QSt (in trunk: . src/torcontrol)
Author: edmanm
Date: 2007-12-27 11:34:19 -0500 (Thu, 27 Dec 2007)
New Revision: 2263
Modified:
trunk/
trunk/src/torcontrol/controlcommand.cpp
trunk/src/torcontrol/controlcommand.h
Log:
r2376@lysithea: edmanm | 2007-12-26 23:22:33 -0500
Add a ControlCommand::addArguments() command that adds a QStringList of
arguments to a control command, instead of adding them individually. Also some
const cleanups.
Property changes on: trunk
___________________________________________________________________
svk:merge ticket from /local/vidalia/trunk [r2376] on 0108964c-5b0b-4c9e-969f-e2288315d100
Modified: trunk/src/torcontrol/controlcommand.cpp
===================================================================
--- trunk/src/torcontrol/controlcommand.cpp 2007-12-27 16:33:50 UTC (rev 2262)
+++ trunk/src/torcontrol/controlcommand.cpp 2007-12-27 16:34:19 UTC (rev 2263)
@@ -34,13 +34,13 @@
}
/** Creates a command using the specified keyword. */
-ControlCommand::ControlCommand(QString keyword)
+ControlCommand::ControlCommand(const QString &keyword)
{
_keyword = keyword;
}
/** Creates a control command using the specified keyword and argument. */
-ControlCommand::ControlCommand(QString keyword, QString arg)
+ControlCommand::ControlCommand(const QString &keyword, const QString &arg)
{
_keyword = keyword;
addArgument(arg);
@@ -48,7 +48,7 @@
/** Creates a control command using the specified keyword and list of
* arguments. */
-ControlCommand::ControlCommand(QString keyword, QStringList args)
+ControlCommand::ControlCommand(const QString &keyword, const QStringList &args)
{
_keyword = keyword;
_arguments = args;
@@ -56,29 +56,39 @@
/** Sets the keyword for this command. */
void
-ControlCommand::setKeyword(QString keyword)
+ControlCommand::setKeyword(const QString &keyword)
{
_keyword = keyword;
}
/** Adds an argument to this command's argument list. */
void
-ControlCommand::addArgument(QString arg)
+ControlCommand::addArgument(const QString &arg)
{
_arguments << arg;
}
+/** Adds all arguments in <b>args</b> to this control command. */
+void
+ControlCommand::addArguments(const QStringList &args)
+{
+ foreach (QString arg, args) {
+ addArgument(arg);
+ }
+}
+
/** Adds data to the end of this command. */
void
-ControlCommand::appendData(QString data)
+ControlCommand::appendData(const QString &data)
{
_data << data;
}
/** Escapes any special characters in this command. */
QString
-ControlCommand::escape(QString str)
+ControlCommand::escape(const QString &unescaped) const
{
+ QString str = unescaped;
if (str.startsWith(".")) {
str.prepend(".");
}
@@ -98,7 +108,7 @@
* Arguments = *(SP / VCHAR)
*/
QString
-ControlCommand::toString()
+ControlCommand::toString() const
{
int i;
QString str;
Modified: trunk/src/torcontrol/controlcommand.h
===================================================================
--- trunk/src/torcontrol/controlcommand.h 2007-12-27 16:33:50 UTC (rev 2262)
+++ trunk/src/torcontrol/controlcommand.h 2007-12-27 16:34:19 UTC (rev 2263)
@@ -35,29 +35,31 @@
{
public:
ControlCommand();
- ControlCommand(QString keyword);
- ControlCommand(QString keyword, QString arg);
- ControlCommand(QString keyword, QStringList args);
+ ControlCommand(const QString &keyword);
+ ControlCommand(const QString &keyword, const QString &arg);
+ ControlCommand(const QString &keyword, const QStringList &args);
/** Returns the keyword for this control command. */
QString keyword() const { return _keyword; }
/** Set the keyword for this control command */
- void setKeyword(QString keyword);
+ void setKeyword(const QString &keyword);
/** Add an argument to this control command */
- void addArgument(QString arg);
-
+ void addArgument(const QString &arg);
+ /** Adds all arguments in <b>args</b> to this control command. */
+ void addArguments(const QStringList &args);
+
/** Append a data line for this control command */
- void appendData(QString data);
+ void appendData(const QString &data);
/** Format this control command into a format conforming to Tor's v1
* protocol specification. */
- QString toString();
+ QString toString() const;
private:
/** Escape special characters in the supplied string */
- QString escape(QString str);
+ QString escape(const QString &str) const;
QString _keyword;
QStringList _arguments;