Arcane
4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
XmlNodeIterator.h
1
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2
//-----------------------------------------------------------------------------
3
// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4
// See the top-level COPYRIGHT file for details.
5
// SPDX-License-Identifier: Apache-2.0
6
//-----------------------------------------------------------------------------
7
/*---------------------------------------------------------------------------*/
8
/* XmlNodeIterator.h (C) 2000-2025 */
9
/* */
10
/* Iterator over the nodes of a DOM tree. */
11
/*---------------------------------------------------------------------------*/
12
#ifndef ARCANE_CORE_XMLNODEITERATOR_H
13
#define ARCANE_CORE_XMLNODEITERATOR_H
14
/*---------------------------------------------------------------------------*/
15
/*---------------------------------------------------------------------------*/
16
17
#include "arcane/core/XmlNode.h"
18
19
#include <iterator>
20
21
/*---------------------------------------------------------------------------*/
22
/*---------------------------------------------------------------------------*/
23
24
namespace
Arcane
25
{
26
27
/*---------------------------------------------------------------------------*/
28
/*---------------------------------------------------------------------------*/
29
30
class
XmlNodeConstIterator
31
{
32
public
:
33
34
typedef
std::bidirectional_iterator_tag iterator_category;
35
typedef
XmlNode
value_type;
36
typedef
int
difference_type;
37
typedef
XmlNode
* pointer;
38
typedef
XmlNode
& reference;
39
40
public
:
41
42
XmlNodeConstIterator(
const
XmlNode
& node)
43
: m_node(node)
44
{}
45
XmlNodeConstIterator()
46
: m_node()
47
{}
48
49
public
:
50
51
void
operator++() { ++m_node; }
52
void
operator--() { --m_node; }
53
const
XmlNode
& operator*()
const
{
return
m_node; }
54
const
XmlNode
* operator->()
const
{
return
&m_node; }
55
56
protected
:
57
58
XmlNode
m_node;
59
};
60
61
/*---------------------------------------------------------------------------*/
62
/*---------------------------------------------------------------------------*/
63
64
class
XmlNodeIterator
65
:
public
XmlNodeConstIterator
66
{
67
public
:
68
69
XmlNodeIterator(
const
XmlNode
& node)
70
: XmlNodeConstIterator(node)
71
{}
72
XmlNodeIterator() {}
73
74
public
:
75
76
const
XmlNode
& operator*()
const
{
return
m_node; }
77
const
XmlNode
* operator->()
const
{
return
&m_node; }
78
XmlNode
& operator*() {
return
m_node; }
79
XmlNode
* operator->() {
return
&m_node; }
80
};
81
82
/*---------------------------------------------------------------------------*/
83
/*---------------------------------------------------------------------------*/
84
85
inline
bool
86
operator==(
const
XmlNodeConstIterator
& n1,
const
XmlNodeConstIterator
& n2)
87
{
88
return
*n1 == *n2;
89
}
90
91
inline
bool
92
operator!=(
const
XmlNodeConstIterator& n1,
const
XmlNodeConstIterator& n2)
93
{
94
return
*n1 != *n2;
95
}
96
97
/*---------------------------------------------------------------------------*/
98
/*---------------------------------------------------------------------------*/
99
100
inline
XmlNodeIterator
XmlNode::
101
begin
()
102
{
103
return
XmlNode(m_rm, m_node.firstChild());
104
}
105
106
inline
XmlNodeIterator
XmlNode::
107
end
()
108
{
109
return
XmlNode(m_rm);
110
}
111
112
inline
XmlNodeConstIterator
XmlNode::
113
begin
()
const
114
{
115
return
XmlNode(m_rm, m_node.firstChild());
116
}
117
118
inline
XmlNodeConstIterator
XmlNode::
119
end
()
const
120
{
121
return
XmlNode(m_rm);
122
}
123
124
/*---------------------------------------------------------------------------*/
125
/*---------------------------------------------------------------------------*/
126
130
class
XmlNodeNameIterator
131
{
132
public
:
133
134
XmlNodeNameIterator(
const
XmlNode
& from,
const
String
& ref_name);
135
XmlNodeNameIterator(
const
XmlNode
& from,
const
char
* ref_name);
136
bool
operator()()
const
{
return
!m_current.null(); }
137
void
operator++() { _findNextValid(
false
); }
138
const
XmlNode
& operator*()
const
{
return
m_current; }
139
const
XmlNode
* operator->()
const
{
return
&m_current; }
140
XmlNode
& operator*() {
return
m_current; }
141
XmlNode
* operator->() {
return
&m_current; }
142
143
private
:
144
145
XmlNode
m_parent;
146
XmlNode
m_current;
147
String
m_ref_name;
148
149
private
:
150
151
void
_findNextValid(
bool
is_init);
152
};
153
154
/*---------------------------------------------------------------------------*/
155
/*---------------------------------------------------------------------------*/
156
157
}
// namespace Arcane
158
159
/*---------------------------------------------------------------------------*/
160
/*---------------------------------------------------------------------------*/
161
162
#endif
Arcane::String
Unicode character string.
Definition
arccore/src/base/arccore/base/String.h:70
Arcane::XmlNodeConstIterator
Definition
XmlNodeIterator.h:31
Arcane::XmlNodeIterator
Definition
XmlNodeIterator.h:66
Arcane::XmlNode
Node of a DOM tree.
Definition
XmlNode.h:51
Arcane::XmlNode::end
iterator end()
Returns an iterator over the first element after the end of the array.
Definition
XmlNodeIterator.h:107
Arcane::XmlNode::begin
iterator begin()
Returns an iterator over the first element of the array.
Definition
XmlNodeIterator.h:101
Arcane
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition
arcane/src/arcane/accelerator/AcceleratorGlobal.h:37
arcane
core
XmlNodeIterator.h
Generated on
for Arcane by
1.16.1