Teuchos - Trilinos Tools Package
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
remainder
src
Teuchos_Libxml2HandlerAdapter.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_Libxml2HandlerAdapter.hpp
"
11
12
#ifdef HAVE_TEUCHOS_LIBXML2
13
14
#include "
Teuchos_TreeBuildingXMLHandler.hpp
"
15
#include "
Teuchos_ParameterList.hpp
"
16
17
using namespace
Teuchos
;
18
19
void
xmlSAX2StartElement(
void
* handler,
20
const
xmlChar* name,
21
const
xmlChar** attr)
22
{
23
TreeBuildingXMLHandler
* h = (
TreeBuildingXMLHandler
*) handler;
24
25
std::string tag = (
const
char
*) name;
26
Teuchos::map<std::string, std::string> attributes;
27
28
/* the attribute data is stored in a C array of C strings, in order
29
* {key1, val1, key2, val2, ...}. */
30
31
for
(
int
i=0; attr[i] != 0; i+=2)
32
{
33
std::string key = (
const
char
*) attr[i];
34
std::string val = (
const
char
*) attr[i+1];
35
attributes[key] = val;
36
}
37
38
h->
startElement
(tag, attributes);
39
}
40
41
void
xmlSAX2EndElement(
void
* handler,
42
const
xmlChar* name)
43
{
44
TreeBuildingXMLHandler
* h = (
TreeBuildingXMLHandler
*) handler;
45
46
std::string tag = (
const
char
*) name;
47
48
h->
endElement
(tag);
49
}
50
51
void
xmlSAX2CharacterData(
void
* handler,
52
const
xmlChar* s,
53
int
len)
54
{
55
char
* str =
new
char
[len+1];
56
strncpy(str, (
const
char
*) s, len);
57
58
59
str[len] =
'\0'
;
60
std::string chars = str;
61
62
TreeBuildingXMLHandler
* h = (
TreeBuildingXMLHandler
*) handler;
63
h->
characters
(chars);
64
delete
[] str;
65
}
66
67
#endif
Teuchos_Libxml2HandlerAdapter.hpp
libxml2 adapter for the TreeBuildingXMLHandler
Teuchos_ParameterList.hpp
Templated Parameter List class.
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