LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
buildtagstree.cpp
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#include "buildtagstree.h"
10#include <QDomDocument>
11
12namespace LC::Util
13{
17 const QString& elementName,
18 const std::function<QString (QDomElement)>& tagGetter,
19 const std::function<void (QDomElement&, QString)>& tagSetter)
20 {
21 if (tags.isEmpty ())
22 return node.toElement ();
23
24 const auto& tag = tags.value (0);
25 tags.removeFirst ();
26
27 auto elements = node.childNodes ();
28 for (int i = 0; i < elements.size (); ++i)
29 {
30 auto elem = elements.at (i).toElement ();
31 if (tagGetter (elem) == tag)
32 return BuildTagsTree (tags, elem,
35 }
36
37 auto result = document.createElement (elementName);
39 node.appendChild (result);
40 return BuildTagsTree (tags, result,
43 }
44}
Container< T > Filter(const Container< T > &c, F f)
Definition prelude.h:118
QDomElement BuildTagsTree(QStringList tags, QDomNode &node, QDomDocument &document, const QString &elementName, const std::function< QString(QDomElement)> &tagGetter, const std::function< void(QDomElement &, QString)> &tagSetter)
Builds a nested sequence of DOM elements representing a list of tags.