Vidalia  0.3.1
ReplyLine.h
Go to the documentation of this file.
1 /*
2 ** This file is part of Vidalia, and is subject to the license terms in the
3 ** LICENSE file, found in the top level directory of this distribution. If
4 ** you did not receive the LICENSE file with this file, you may obtain it
5 ** from the Vidalia source package distributed by the Vidalia Project at
6 ** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7 ** including this file, may be copied, modified, propagated, or distributed
8 ** except according to the terms described in the LICENSE file.
9 */
10 
11 /*
12 ** \file ReplyLine.h
13 ** \brief Reply from a previous control command sent to Tor
14 */
15 
16 #ifndef _REPLYLINE_H
17 #define _REPLYLINE_H
18 
19 #include <QStringList>
20 
21 
22 class ReplyLine
23 {
24 public:
25  ReplyLine();
26  ReplyLine(const QString &status, const QString &message);
27  ReplyLine(const QString &status, const QString &message, const QString &data);
28 
29  /** Set the status code to <b>status</b>. */
30  void setStatus(const QString &status);
31  /** Returns the status code for this reply line. */
32  QString getStatus() const;
33 
34  /** Sets the ReplyText message this reply line to <b>msg</b>. */
35  void setMessage(const QString &msg);
36  /** Returns the ReplyText portion of this reply line. */
37  QString getMessage() const;
38 
39  /** Appends <b>data</b> to this reply line. */
40  void appendData(const QString &data);
41  /** Returns a QStringList of all data lines for this reply line. */
42  QStringList getData() const;
43  /** Returns true if this reply contained a data portion. */
44  bool hasData() const { return _data.size() > 0; }
45 
46  /** Returns the entire contents of this reply line, including the status,
47  * message, and any extra data. */
48  QString toString() const;
49 
50 private:
51  /** Unescapes special characters in <b>str</b> and returns the unescaped
52  * result. */
53  static QString unescape(const QString &escaped);
54 
55  QString _status; /**< Response status code. */
56  QString _message; /**< ReplyText portion of this reply line. */
57  QStringList _data; /**< Contents of any DataReplyLines in this line. */
58 };
59 
60 #endif
61