Teuchos - Trilinos Tools Package
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
parameterlist
src
Teuchos_ExpatHandlerAdapter.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_ExpatHandlerAdapter.hpp
"
11
12
#ifdef HAVE_TEUCHOS_EXPAT
13
14
#include "
Teuchos_TreeBuildingXMLHandler.hpp
"
15
16
using namespace
Teuchos
;
17
18
void
expatStartElementHandler(
void
* handler,
19
const
XML_Char* name,
20
const
XML_Char** attr)
21
{
22
TreeBuildingXMLHandler
* h = (
TreeBuildingXMLHandler
*) handler;
23
24
std::string tag = name;
25
Teuchos::map<std::string, std::string> attributes;
26
27
/* the attribute data is stored in a C array of C strings, in order
28
* {key1, val1, key2, val2, ...}. */
29
30
for
(
int
i=0; attr[i] != 0; i+=2)
31
{
32
std::string key = attr[i];
33
std::string val = attr[i+1];
34
attributes[key] = val;
35
}
36
37
h->
startElement
(tag, attributes);
38
}
39
40
void
expatEndElementHandler(
void
* handler,
41
const
XML_Char* name)
42
{
43
TreeBuildingXMLHandler
* h = (
TreeBuildingXMLHandler
*) handler;
44
45
std::string tag = name;
46
47
h->
endElement
(tag);
48
}
49
50
void
expatCharacterDataHandler(
void
* handler,
51
const
XML_Char* s,
52
int
len)
53
{
54
char
* str =
new
char
[len+1];
55
strncpy(str, s, len);
56
57
58
str[len] =
'\0'
;
59
std::string chars = str;
60
61
TreeBuildingXMLHandler
* h = (
TreeBuildingXMLHandler
*) handler;
62
h->
characters
(chars);
63
delete
[] str;
64
}
65
66
#endif
// HAVE_TEUCHOS_EXPAT
Teuchos_ExpatHandlerAdapter.hpp
Expat adapter for the TreeBuildingXMLHandler.
Teuchos_TreeBuildingXMLHandler.hpp
Defines a class for assembling an XMLObject from XML input.
Teuchos::TreeBuildingXMLHandler
TreeBuildingXMLHandler assembles a XMLObject from your XML input.
Definition
Teuchos_TreeBuildingXMLHandler.hpp:30
Teuchos::TreeBuildingXMLHandler::characters
void characters(const std::string &chars)
Process character data.
Definition
Teuchos_TreeBuildingXMLHandler.cpp:22
Teuchos::TreeBuildingXMLHandler::startElement
void startElement(const std::string &tag, const Map &attributes)
Receive notification of the start of an element.
Definition
Teuchos_TreeBuildingXMLHandler.cpp:45
Teuchos::TreeBuildingXMLHandler::endElement
int endElement(const std::string &tag)
Receive notification of the end of an element.
Definition
Teuchos_TreeBuildingXMLHandler.cpp:68
Teuchos
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
Generated by
1.17.0