LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
domchildrenrange.h
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#pragma once
10
11#include <QDomElement>
12#include <QString>
13#include "sllconfig.h"
14
15namespace LC::Util
16{
45 inline auto DomChildren (const QDomNode& parent, const QString& tag)
46 {
47 struct Iterator
48 {
49 using difference_type = ptrdiff_t;
50 using value_type = QDomElement;
51 using reference = QDomElement&;
52 using iterator_category = std::forward_iterator_tag;
53
54 QDomElement Elem_;
55 const QString Tag_;
56
57 bool operator== (const Iterator& other) const
58 {
59 return Elem_ == other.Elem_;
60 }
61
62 Iterator& operator++ ()
63 {
64 Elem_ = Elem_.nextSiblingElement (Tag_);
65 return *this;
66 }
67
68 QDomElement& operator* ()
69 {
70 return Elem_;
71 }
72 };
73
74 struct Range
75 {
76 const Iterator Begin_;
77
78 auto begin () const { return Begin_; }
79 auto end () const { return Iterator {}; }
80 };
81
82 auto firstChild = parent.firstChildElement (tag);
83 return Range { { firstChild, tag } };
84 }
85
98 UTIL_SLL_API QVector<QDomElement> DomDescendants (const QDomElement& parent, const QString& tag);
99}
auto operator==(const T &left, const T &right)
Definition common.h:38
Container< T > Filter(const Container< T > &c, F f)
Definition prelude.h:118
auto DomChildren(const QDomNode &parent, const QString &tag)
Creates a range iterating over direct children named tag.
QVector< QDomElement > DomDescendants(const QDomElement &parent, const QString &tag)
Creates a vector with all descendants of parent named tag.
#define UTIL_SLL_API
Definition sllconfig.h:16