Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
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
11
12#ifdef HAVE_TEUCHOS_LIBXML2
13
16
17using namespace Teuchos;
18
20 const xmlChar* name,
21 const xmlChar** attr)
22{
24
25 std::string tag = (const char*) name;
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
41void xmlSAX2EndElement(void* handler,
42 const xmlChar* name)
43{
45
46 std::string tag = (const char*) name;
47
48 h->endElement(tag);
49}
50
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
63 h->characters(chars);
64 delete [] str;
65}
66
67#endif
libxml2 adapter for the TreeBuildingXMLHandler
Templated Parameter List class.
Defines a class for assembling an XMLObject from XML input.
Smart reference counting pointer class for automatic garbage collection.
TreeBuildingXMLHandler assembles a XMLObject from your XML input.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...