Arcane  v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
XmlNodeIterator.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 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-2018 */
9/* */
10/* Iterator sur les noeuds d'un arbre DOM. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_XMLNODEITERATOR_H
13#define ARCANE_XMLNODEITERATOR_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/XmlNode.h"
18
19#include <iterator>
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24ARCANE_BEGIN_NAMESPACE
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29class IRessourceMng;
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
35{
36 public:
37 typedef std::bidirectional_iterator_tag iterator_category;
38 typedef XmlNode value_type;
39 typedef int difference_type;
40 typedef XmlNode* pointer;
41 typedef XmlNode& reference;
42 public:
43 XmlNodeConstIterator(const XmlNode& node)
44 : m_node(node) {}
46 : m_node() {}
47 public:
48 void operator++() { ++m_node; }
49 void operator--() { --m_node; }
50 const XmlNode& operator* () const { return m_node; }
51 const XmlNode* operator->() const { return &m_node; }
52 protected:
53 XmlNode m_node;
54};
55
58{
59 public:
60 XmlNodeIterator(const XmlNode& node)
61 : XmlNodeConstIterator(node) {}
63 public:
64 const XmlNode& operator* () const { return m_node; }
65 const XmlNode* operator->() const { return &m_node; }
66 XmlNode& operator* () { return m_node; }
67 XmlNode* operator->() { return &m_node; }
68};
69
70/*---------------------------------------------------------------------------*/
71/*---------------------------------------------------------------------------*/
72
73inline bool
74operator==(const XmlNodeConstIterator& n1,const XmlNodeConstIterator& n2)
75{
76 return *n1==*n2;
77}
78
79inline bool
80operator!=(const XmlNodeConstIterator& n1,const XmlNodeConstIterator& n2)
81{
82 return *n1!=*n2;
83}
84
85/*---------------------------------------------------------------------------*/
86/*---------------------------------------------------------------------------*/
87
88inline XmlNodeIterator XmlNode::
89begin()
90{
91 return XmlNode(m_rm,m_node.firstChild());
92}
93
94inline XmlNodeIterator XmlNode::
95end()
96{
97 return XmlNode(m_rm);
98}
99
100inline XmlNodeConstIterator XmlNode::
101begin() const
102{
103 return XmlNode(m_rm,m_node.firstChild());
104}
105
106inline XmlNodeConstIterator XmlNode::
107end() const
108{
109 return XmlNode(m_rm);
110}
111
112/*---------------------------------------------------------------------------*/
113/*---------------------------------------------------------------------------*/
114/*!
115 * \brief Itérateur sur les fils d'un noeud \a from de nom \a ref_name.
116 */
118{
119 public:
120 XmlNodeNameIterator(const XmlNode& from,const String& ref_name);
121 XmlNodeNameIterator(const XmlNode& from,const char* ref_name);
122 bool operator()() const { return !m_current.null(); }
123 void operator++() { _findNextValid(false); }
124 const XmlNode& operator*() const { return m_current; }
125 const XmlNode* operator->() const { return &m_current; }
126 XmlNode& operator*() { return m_current; }
127 XmlNode* operator->() { return &m_current; }
128 private:
129 XmlNode m_parent;
130 XmlNode m_current;
131 String m_ref_name;
132 private:
133 void _findNextValid(bool is_init);
134};
135
136/*---------------------------------------------------------------------------*/
137/*---------------------------------------------------------------------------*/
138
139ARCANE_END_NAMESPACE
140
141/*---------------------------------------------------------------------------*/
142/*---------------------------------------------------------------------------*/
143
144#endif
145
Itérateur sur les fils d'un noeud from de nom ref_name.
Noeud d'un arbre DOM.
Definition XmlNode.h:51
Chaîne de caractères unicode.
Real2 operator*(Real sca, const Real2Proxy &vec)
Multiplication par un scalaire.
Definition Real2Proxy.h:241