Teuchos - Trilinos Tools Package
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
parameterlist
src
Teuchos_XMLInputSource.cpp
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
#include "
Teuchos_XMLInputSource.hpp
"
11
#include "
Teuchos_TreeBuildingXMLHandler.hpp
"
12
13
14
#ifdef HAVE_TEUCHOS_EXPAT
15
# include "
Teuchos_ExpatHandlerAdapter.hpp
"
16
# define EXPAT_BUFSIZE 8192
17
#else
18
# include "
Teuchos_XMLParser.hpp
"
19
#endif
20
21
using namespace
Teuchos
;
22
23
XMLObject
XMLInputSource::getObject
()
const
24
{
25
26
#ifdef HAVE_TEUCHOS_EXPAT
27
28
RCP<TreeBuildingXMLHandler>
handler =
rcp
(
new
TreeBuildingXMLHandler
());
29
30
XML_Parser parser = XML_ParserCreate(NULL);
31
32
XML_SetElementHandler(parser, expatStartElementHandler,
33
expatEndElementHandler);
34
35
XML_SetCharacterDataHandler(parser, expatCharacterDataHandler);
36
37
XML_SetUserData(parser, (
void
*) &(*handler));
38
39
RCP<XMLInputStream>
s =
stream
();
40
41
bool
done =
false
;
42
unsigned
int
bufsize = EXPAT_BUFSIZE;
43
unsigned
char
buf[EXPAT_BUFSIZE];
44
45
while
(!done)
46
{
47
unsigned
int
nRead = s->readBytes(buf, bufsize);
48
if
(nRead < bufsize)
49
{
50
done =
true
;
51
}
52
XML_Parse(parser, (
char
*) buf, bufsize, done);
53
}
54
55
return
handler->getObject();
56
57
#else
58
59
XMLParser
parser(
stream
());
60
61
return
parser.parse();
62
63
#endif
64
65
}
66
67
Teuchos_ExpatHandlerAdapter.hpp
Expat adapter for the TreeBuildingXMLHandler.
Teuchos_TreeBuildingXMLHandler.hpp
Defines a class for assembling an XMLObject from XML input.
Teuchos_XMLInputSource.hpp
A base class for defining a source of XML input.
Teuchos_XMLParser.hpp
A class providing a simple XML parser. Methods can be overloaded to exploit external XML parsing libr...
Teuchos::RCP
Smart reference counting pointer class for automatic garbage collection.
Definition
Teuchos_RCPDecl.hpp:397
Teuchos::TreeBuildingXMLHandler
TreeBuildingXMLHandler assembles a XMLObject from your XML input.
Definition
Teuchos_TreeBuildingXMLHandler.hpp:30
Teuchos::XMLInputSource::getObject
XMLObject getObject() const
Get an object by invoking the TreeBuildingXMLHandler on the input data.
Definition
Teuchos_XMLInputSource.cpp:23
Teuchos::XMLInputSource::stream
virtual RCP< XMLInputStream > stream() const =0
Virtual input source interface.
Teuchos::XMLObject
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object,...
Definition
Teuchos_XMLObject.hpp:30
Teuchos::XMLParser
XMLParser consumes characters from an XMLInputStream object, parsing the XML and using a TreeBuilding...
Definition
Teuchos_XMLParser.hpp:39
Teuchos
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
Teuchos::rcp
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
Definition
Teuchos_RCPDecl.hpp:1234
Generated by
1.17.0