From f76ef20b832428aa1090d7f5df749909828f9bd8 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sat, 18 Apr 2020 22:34:49 +0300 Subject: Hostlist: test list parsing --- staging/hostlist/filterlist.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'staging/hostlist/filterlist.cpp') diff --git a/staging/hostlist/filterlist.cpp b/staging/hostlist/filterlist.cpp index 483ba7d..42be349 100644 --- a/staging/hostlist/filterlist.cpp +++ b/staging/hostlist/filterlist.cpp @@ -27,3 +27,23 @@ std::map Filterlist::parseRule(const Q } return r; } + +bool Filterlist::load(QIODevice &from) +{ + if(!from.isReadable() || !from.isTextModeEnabled()) { + return false; + } + + while(from.bytesAvailable() > 0) { + const auto line = from.readLine(512).trimmed(); + if(!line.isEmpty() && line.at(0) != '#') { + auto r = parseRule(line); + if(!r.empty()) { + qDebug("merging in %lu rules", r.size()); + rules.merge(r); + } + } + } + return true; +} + -- cgit v1.2.1