Maemo: Polish class interface.

This commit is contained in:
ck
2010-08-12 19:46:58 +02:00
parent 77941ddf9d
commit 47562aa1e8
2 changed files with 7 additions and 4 deletions

View File

@@ -139,14 +139,14 @@ private:
{ {
const int startPort = parsePort(); const int startPort = parsePort();
if (atEnd() || nextChar() != '-') { if (atEnd() || nextChar() != '-') {
m_portList.addRange(MaemoPortList::Range(startPort, startPort)); m_portList.addPort(startPort);
return; return;
} }
++m_pos; ++m_pos;
const int endPort = parsePort(); const int endPort = parsePort();
if (endPort < startPort) if (endPort < startPort)
throw ParseException("Invalid range (end < start)."); throw ParseException("Invalid range (end < start).");
m_portList.addRange(MaemoPortList::Range(startPort, endPort)); m_portList.addRange(startPort, endPort);
} }
int parsePort() int parsePort()

View File

@@ -51,9 +51,12 @@ namespace Internal {
class MaemoPortList class MaemoPortList
{ {
public:
typedef QPair<int, int> Range; typedef QPair<int, int> Range;
void addRange(const Range &range) { m_ranges << range; } public:
void addPort(int port) { addRange(port, port); }
void addRange(int startPort, int endPort) {
m_ranges << Range(startPort, endPort);
}
bool hasMore() const { return !m_ranges.isEmpty(); } bool hasMore() const { return !m_ranges.isEmpty(); }
int count() const { int count() const {
int n = 0; int n = 0;