[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r2262: Add a ReplyLine::hasData() method that returns true if Tor's (in trunk: . src/torcontrol)
Author: edmanm
Date: 2007-12-27 11:33:50 -0500 (Thu, 27 Dec 2007)
New Revision: 2262
Modified:
trunk/
trunk/src/torcontrol/replyline.cpp
trunk/src/torcontrol/replyline.h
Log:
r2375@lysithea: edmanm | 2007-12-26 23:21:18 -0500
Add a ReplyLine::hasData() method that returns true if Tor's reply contained a
"." terminated data portion. Also some const cleanups.
Property changes on: trunk
___________________________________________________________________
svk:merge ticket from /local/vidalia/trunk [r2375] on 0108964c-5b0b-4c9e-969f-e2288315d100
Modified: trunk/src/torcontrol/replyline.cpp
===================================================================
--- trunk/src/torcontrol/replyline.cpp 2007-12-26 22:26:35 UTC (rev 2261)
+++ trunk/src/torcontrol/replyline.cpp 2007-12-27 16:33:50 UTC (rev 2262)
@@ -33,14 +33,15 @@
}
/** Constructor */
-ReplyLine::ReplyLine(QString status, QString msg)
+ReplyLine::ReplyLine(const QString &status, const QString &msg)
{
_status = status;
setMessage(msg);
}
/** Constructor */
-ReplyLine::ReplyLine(QString status, QString msg, QString data)
+ReplyLine::ReplyLine(const QString &status, const QString &msg,
+ const QString &data)
{
_status = status;
setMessage(msg);
@@ -50,7 +51,7 @@
/** Set the status code for this reply line. See Tor Control Protocol V1
* specification for a description of status codes. */
void
-ReplyLine::setStatus(QString status)
+ReplyLine::setStatus(const QString &status)
{
_status = status;
}
@@ -64,7 +65,7 @@
/** Sets the ReplyText message this reply line to <b>msg</b>. */
void
-ReplyLine::setMessage(QString msg)
+ReplyLine::setMessage(const QString &msg)
{
_message = unescape(msg);
}
@@ -78,7 +79,7 @@
/** Appends <b>data</b> to this reply line. */
void
-ReplyLine::appendData(QString data)
+ReplyLine::appendData(const QString &data)
{
_data << unescape(data);
}
@@ -93,8 +94,9 @@
/** Unescapes special characters in <b>str</b> and returns the unescaped
* result. */
QString
-ReplyLine::unescape(QString str)
+ReplyLine::unescape(const QString &escaped)
{
+ QString str = escaped;
/* If the line starts with a "." and was escaped, then unescape it */
if (str.startsWith("..")) {
str.remove(0, 1);
Modified: trunk/src/torcontrol/replyline.h
===================================================================
--- trunk/src/torcontrol/replyline.h 2007-12-26 22:26:35 UTC (rev 2261)
+++ trunk/src/torcontrol/replyline.h 2007-12-27 16:33:50 UTC (rev 2262)
@@ -35,24 +35,26 @@
{
public:
ReplyLine();
- ReplyLine(QString status, QString message);
- ReplyLine(QString status, QString message, QString data);
+ ReplyLine(const QString &status, const QString &message);
+ ReplyLine(const QString &status, const QString &message, const QString &data);
/** Set the status code to <b>status</b>. */
- void setStatus(QString status);
+ void setStatus(const QString &status);
/** Returns the status code for this reply line. */
QString getStatus() const;
/** Sets the ReplyText message this reply line to <b>msg</b>. */
- void setMessage(QString msg);
+ void setMessage(const QString &msg);
/** Returns the ReplyText portion of this reply line. */
QString getMessage() const;
/** Appends <b>data</b> to this reply line. */
- void appendData(QString data);
+ void appendData(const QString &data);
/** Returns a QStringList of all data lines for this reply line. */
QStringList getData() const;
-
+ /** Returns true if this reply contained a data portion. */
+ bool hasData() const { return _data.size() > 0; }
+
/** Returns the entire contents of this reply line, including the status,
* message, and any extra data. */
QString toString() const;
@@ -60,7 +62,7 @@
private:
/** Unescapes special characters in <b>str</b> and returns the unescaped
* result. */
- static QString unescape(QString str);
+ static QString unescape(const QString &escaped);
QString _status; /**< Response status code. */
QString _message; /**< ReplyText portion of this reply line. */