Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
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
11
12#ifdef HAVE_TEUCHOS_EXPAT
13
15
16using namespace Teuchos;
17
19 const XML_Char* name,
20 const XML_Char** attr)
21{
23
24 std::string tag = name;
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
41 const XML_Char* name)
42{
44
45 std::string tag = name;
46
47 h->endElement(tag);
48}
49
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
62 h->characters(chars);
63 delete [] str;
64}
65
66#endif // HAVE_TEUCHOS_EXPAT
Expat adapter for the TreeBuildingXMLHandler.
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,...