Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_TreeBuildingXMLHandler.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef Teuchos_TREEBUILDINGXMLHANDLER_H
11 #define Teuchos_TREEBUILDINGXMLHANDLER_H
12 
17 #include "Teuchos_ConfigDefs.hpp"
18 #include "Teuchos_XMLObject.hpp"
19 #include <list>
20 #include <stack>
21 
22 
23 namespace Teuchos
24 {
25 
30  {
32  public:
35 
37  const XMLObject& getObject() const
38  {
39  // valid XML requires a root object; we will allow empty XML files
41  root_.isEmpty(), EmptyXMLError
42  ,"Error, An empty XML std::string or file was specified!"
43  " The XML specification requires at minimum the presence"
44  " of a root element!" );
45  return root_.getChild(0);
46  }
47 
49  void characters(const std::string& chars);
50 
52  int endElement(const std::string& tag);
53 
55  void startElement(const std::string& tag,
56  const Map& attributes);
57 
58  private:
59  XMLObject root_;
60  XMLObject current_;
61  std::stack<XMLObject> path_;
62  };
63 }
64 
65 
66 #endif
67 
void characters(const std::string &chars)
Process character data.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
Teuchos header file which uses auto-configuration information to include necessary C++ headers...
int endElement(const std::string &tag)
Receive notification of the end of an element.
bool isEmpty() const
Find out if a node is empty.
Thrown when attempting to parse an empty XML std::string.
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object...
void startElement(const std::string &tag, const Map &attributes)
Receive notification of the start of an element.
const XMLObject & getObject() const
Retrieve the entire XML tree.
TreeBuildingXMLHandler assembles a XMLObject from your XML input.
const XMLObject & getChild(int i) const
Return the i-th child node.
An object representation of a subset of XML data.