MultiNodeRapidXMLReader.h
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package ArmarXCore::Core
19 * @author Simon Ottenhaus( simon dot ottenhaus at kit dot edu)
20 * @author Mirko Waechter( mirko dot waechter at kit dot edu)
21 * @date 2017
22 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
23 * GNU General Public License
24 */
25 
26 #pragma once
27 
28 #include <vector>
29 
30 #include "RapidXmlReader.h"
31 
32 namespace armarx
33 {
34  using RapidXmlReaderNodeSeq = std::vector<RapidXmlReaderNode>;
35 
37  {
38  public:
39  MultiNodeRapidXMLReader() = default;
40 
42  {
43  }
44 
46  first_node(const char* name) const
47  {
48  for (const RapidXmlReaderNode& node : nodeSeq)
49  {
50  auto resultNode = node.first_node(name);
51  if (resultNode.is_valid())
52  {
53  return resultNode;
54  }
55  }
57  }
58 
60  nodes(const char* name = nullptr) const
61  {
62  RapidXmlReaderNodeSeq resultSeq;
63  for (const RapidXmlReaderNode& node : nodeSeq)
64  {
65  node.nodes(name, resultSeq);
66  }
67  return resultSeq;
68  }
69 
70  void
72  {
73  nodeSeq.emplace_back(node);
74  }
75 
76  private:
77  RapidXmlReaderNodeSeq nodeSeq;
78  };
79 } // namespace armarx
armarx::RapidXmlReaderNode::NullNode
static RapidXmlReaderNode NullNode()
Definition: RapidXmlReader.h:131
armarx::RapidXmlReaderNodeSeq
std::vector< RapidXmlReaderNode > RapidXmlReaderNodeSeq
Definition: MultiNodeRapidXMLReader.h:34
armarx::MultiNodeRapidXMLReader
Definition: MultiNodeRapidXMLReader.h:36
armarx::MultiNodeRapidXMLReader::addNode
void addNode(const RapidXmlReaderNode &node)
Definition: MultiNodeRapidXMLReader.h:71
armarx::RapidXmlReaderNode
Definition: RapidXmlReader.h:69
armarx::MultiNodeRapidXMLReader::MultiNodeRapidXMLReader
MultiNodeRapidXMLReader(RapidXmlReaderNodeSeq nodes)
Definition: MultiNodeRapidXMLReader.h:41
armarx::MultiNodeRapidXMLReader::nodes
RapidXmlReaderNodeSeq nodes(const char *name=nullptr) const
Definition: MultiNodeRapidXMLReader.h:60
armarx::MultiNodeRapidXMLReader::MultiNodeRapidXMLReader
MultiNodeRapidXMLReader()=default
RapidXmlReader.h
armarx::RapidXmlReaderNode::first_node
RapidXmlReaderNode first_node(const char *name=nullptr) const
Definition: RapidXmlReader.h:156
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::MultiNodeRapidXMLReader::first_node
RapidXmlReaderNode first_node(const char *name) const
Definition: MultiNodeRapidXMLReader.h:46