Teuchos - Trilinos Tools Package
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
parameterlist
src
Teuchos_XMLObjectImplem.hpp
Go to the documentation of this file.
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
#ifndef TEUCHOS_XMLOBJECTIMPLEM_H
11
#define TEUCHOS_XMLOBJECTIMPLEM_H
12
16
17
#include "
Teuchos_map.hpp
"
18
#include "
Teuchos_Array.hpp
"
19
#include "
Teuchos_RCP.hpp
"
20
21
namespace
Teuchos
22
{
23
24
class
XMLObject
;
25
30
class
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
XMLObjectImplem
31
{
32
typedef
Teuchos::map<std::string, std::string> Map;
33
34
public
:
36
XMLObjectImplem
(
const
std::string& tag);
37
39
XMLObjectImplem
*
deepCopy
()
const
;
40
42
void
addAttribute
(
const
std::string& name,
const
std::string& value);
43
45
void
addChild
(
const
XMLObject
& child);
46
48
void
addContent
(
const
std::string& contentLine);
49
51
const
std::string&
getTag
()
const
{
return
tag_;}
52
54
bool
hasAttribute
(
const
std::string& name)
const
55
{
return
attributes_.find(name) != attributes_.end();}
56
58
const
std::string&
getAttribute
(
const
std::string& name)
const
59
{
return
(*(attributes_.find(name))).second;}
60
62
int
numChildren()
const
;
63
65
const
XMLObject
& getChild(
int
i)
const
;
66
68
int
numContentLines
()
const
{
return
content_.length();}
69
71
const
Map&
getAttributes
()
const
{
return
attributes_;}
72
74
const
std::string&
getContentLine
(
int
i)
const
{
return
content_[i];}
75
77
void
appendContentLine
(
const
size_t
& i,
const
std::string &str) {
78
content_[i].append(str);
79
}
80
82
void
removeContentLine(
const
size_t
& i);
83
85
void
print(std::ostream& os,
int
indent)
const
;
86
88
std::string toString()
const
;
89
91
std::string header(
bool
strictXML =
false
)
const
;
92
94
std::string terminatedHeader(
bool
strictXML =
false
)
const
;
95
97
std::string
footer
()
const
{
return
"</"
+
getTag
() +
">"
;}
98
99
private
:
100
102
void
printContent(std::ostream& os,
int
indent)
const
;
103
105
static
std::string XMLifyAttVal(
const
std::string &attval);
106
107
std::string tag_;
108
Map attributes_;
109
Array<XMLObject>
children_;
110
Array<std::string>
content_;
111
112
};
113
114
}
115
116
#endif
117
Teuchos_Array.hpp
Templated array class derived from the STL std::vector.
Teuchos_RCP.hpp
Reference-counted pointer class and non-member templated function implementations.
Teuchos_map.hpp
Provides std::map class for deficient platforms.
Teuchos::Array
Replacement for std::vector that is compatible with the Teuchos Memory Management classes.
Definition
Teuchos_Array.hpp:163
Teuchos::XMLObject
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object,...
Definition
Teuchos_XMLObject.hpp:30
Teuchos::XMLObjectImplem::getAttribute
const std::string & getAttribute(const std::string &name) const
Look up an attribute by name.
Definition
Teuchos_XMLObjectImplem.hpp:58
Teuchos::XMLObjectImplem::deepCopy
XMLObjectImplem * deepCopy() const
Deep copy.
Definition
Teuchos_XMLObjectImplem.cpp:21
Teuchos::XMLObjectImplem::getTag
const std::string & getTag() const
Return the tag std::string.
Definition
Teuchos_XMLObjectImplem.hpp:51
Teuchos::XMLObjectImplem::getAttributes
const Map & getAttributes() const
Get all attributes.
Definition
Teuchos_XMLObjectImplem.hpp:71
Teuchos::XMLObjectImplem::addAttribute
void addAttribute(const std::string &name, const std::string &value)
Add a [name, value] attribute.
Definition
Teuchos_XMLObjectImplem.cpp:41
Teuchos::XMLObjectImplem::numContentLines
int numContentLines() const
Get the number of content lines.
Definition
Teuchos_XMLObjectImplem.hpp:68
Teuchos::XMLObjectImplem::hasAttribute
bool hasAttribute(const std::string &name) const
Determine whether an attribute exists.
Definition
Teuchos_XMLObjectImplem.hpp:54
Teuchos::XMLObjectImplem::getContentLine
const std::string & getContentLine(int i) const
Look up a content line by index.
Definition
Teuchos_XMLObjectImplem.hpp:74
Teuchos::XMLObjectImplem::addContent
void addContent(const std::string &contentLine)
Add a content line.
Definition
Teuchos_XMLObjectImplem.cpp:52
Teuchos::XMLObjectImplem::XMLObjectImplem
XMLObjectImplem(const std::string &tag)
Construct with a 'tag'.
Definition
Teuchos_XMLObjectImplem.cpp:17
Teuchos::XMLObjectImplem::appendContentLine
void appendContentLine(const size_t &i, const std::string &str)
Add string at the the end of a content line.
Definition
Teuchos_XMLObjectImplem.hpp:77
Teuchos::XMLObjectImplem::addChild
void addChild(const XMLObject &child)
Add a child XMLObject.
Definition
Teuchos_XMLObjectImplem.cpp:47
Teuchos::XMLObjectImplem::footer
std::string footer() const
Write the footer.
Definition
Teuchos_XMLObjectImplem.hpp:97
Teuchos
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
Generated by
1.17.0