Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
XMLParser_ParseWithoutFailing.cpp
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 
11 #include "Teuchos_XMLParser.hpp"
13 
14 std::string filename;
15 std::string error;
16 
17 namespace Teuchos {
18 
20  {
22  "filename", &filename, "XML file to parse" );
23  }
24 
25  TEUCHOS_UNIT_TEST( XMLParser, IgnoreDeclarations )
26  {
29  XMLParser parser(stream);
30  bool caughtError = false;
31  try {
32  Teuchos::XMLObject obj = parser.parse();
33  out << "Parsed XML object: \n" << obj.toString() << std::endl;
34  }
35  catch (std::runtime_error &err) {
36  caughtError = true;
37  out << "XML Parser caught exception:\n" << err.what() << "\n";
38  }
39  TEST_EQUALITY_CONST(caughtError, false);
40  }
41 
42 } // namespace Teuchos
static CommandLineProcessor & getCLP()
Return the CLP to add options to.
XMLObject parse()
Consume the XMLInputStream to build an XMLObject.
XMLParser consumes characters from an XMLInputStream object, parsing the XML and using a TreeBuilding...
TEUCHOS_UNIT_TEST(ConstNonconstObjectContainer, create)
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
Set a boolean option.
std::string toString() const
Represent this node and its children as a std::string.
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object...
Unit testing support.
#define TEST_EQUALITY_CONST(v1, v2)
Assert the equality of v1 and constant v2.
Instantiation of XMLInputSource class for reading XML from a file.
virtual RCP< XMLInputStream > stream() const
Create a FileInputStream.
std::string error
Definition of XMLInputSource derived class for reading XML from a file.
A class providing a simple XML parser. Methods can be overloaded to exploit external XML parsing libr...