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 "RapidXmlReader.h"
29 #include <vector>
30 
31 namespace armarx
32 {
33  using RapidXmlReaderNodeSeq = std::vector<RapidXmlReaderNode>;
35  {
36  public:
37  MultiNodeRapidXMLReader() = default;
39 
40  RapidXmlReaderNode first_node(const char* name) const
41  {
42  for (const RapidXmlReaderNode& node : nodeSeq)
43  {
44  auto resultNode = node.first_node(name);
45  if (resultNode.is_valid())
46  {
47  return resultNode;
48  }
49  }
51  }
52 
53  RapidXmlReaderNodeSeq nodes(const char* name = nullptr) const
54  {
55  RapidXmlReaderNodeSeq resultSeq;
56  for (const RapidXmlReaderNode& node : nodeSeq)
57  {
58  node.nodes(name, resultSeq);
59  }
60  return resultSeq;
61  }
62 
63  void addNode(const RapidXmlReaderNode& node)
64  {
65  nodeSeq.emplace_back(node);
66  }
67 
68  private:
69  RapidXmlReaderNodeSeq nodeSeq;
70  };
71 }
72 
armarx::RapidXmlReaderNode::NullNode
static RapidXmlReaderNode NullNode()
Definition: RapidXmlReader.h:119
armarx::RapidXmlReaderNodeSeq
std::vector< RapidXmlReaderNode > RapidXmlReaderNodeSeq
Definition: MultiNodeRapidXMLReader.h:33
armarx::MultiNodeRapidXMLReader
Definition: MultiNodeRapidXMLReader.h:34
armarx::MultiNodeRapidXMLReader::addNode
void addNode(const RapidXmlReaderNode &node)
Definition: MultiNodeRapidXMLReader.h:63
armarx::RapidXmlReaderNode
Definition: RapidXmlReader.h:68
armarx::MultiNodeRapidXMLReader::MultiNodeRapidXMLReader
MultiNodeRapidXMLReader(RapidXmlReaderNodeSeq nodes)
Definition: MultiNodeRapidXMLReader.h:38
armarx::MultiNodeRapidXMLReader::nodes
RapidXmlReaderNodeSeq nodes(const char *name=nullptr) const
Definition: MultiNodeRapidXMLReader.h:53
armarx::MultiNodeRapidXMLReader::MultiNodeRapidXMLReader
MultiNodeRapidXMLReader()=default
RapidXmlReader.h
armarx::RapidXmlReaderNode::first_node
RapidXmlReaderNode first_node(const char *name=nullptr) const
Definition: RapidXmlReader.h:140
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::MultiNodeRapidXMLReader::first_node
RapidXmlReaderNode first_node(const char *name) const
Definition: MultiNodeRapidXMLReader.h:40