Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_StandardParameterEntryXMLConverters.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_STANDARDPARAMETERENTRYXMLCONVERTERS_HPP
11 #define TEUCHOS_STANDARDPARAMETERENTRYXMLCONVERTERS_HPP
12 
18 #include "Teuchos_ParameterEntryXMLConverter.hpp"
19 
20 
21 namespace Teuchos {
22 
23 
29 class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT AnyParameterEntryConverter : public ParameterEntryXMLConverter{
30 
31 public:
32 
35 
37  const std::string getTypeAttributeValue() const;
38 
40  const std::string getValueAttributeValue(
41  RCP<const ParameterEntry> entry) const;
42 
44  any getAny(const XMLObject& xmlObj) const;
46 
47 };
48 
49 
54 template<class T>
57 {
58 
59 public:
60 
63 
65  virtual const std::string getTypeAttributeValue() const{
66  return TypeNameTraits<T>::name();
67  }
68 
70  virtual const std::string getValueAttributeValue(
71  RCP<const ParameterEntry> entry) const {
72  return toString(any_cast<T>(entry->getAny(false)));
73  }
74 
76  any getAny(const XMLObject& xmlObj) const{
77  return any(xmlObj.getRequired<T>(getValueAttributeName()));
78  }
79 
81 
82 };
83 
84 
85 
86 } // namespace Teuchos
87 
88 
89 #endif // TEUCHOS_STANDARDPARAMETERENTRYXMLCONVERTERS_HPP
Modified boost::any class, which is a container for a templated value.
A class used to convert parameter entries to xml and vice versa.
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object...
A standard ParameterEntryXMLConverter for most data types.
virtual const std::string getValueAttributeValue(RCP< const ParameterEntry > entry) const
A last resort converter for when no others will do.
Smart reference counting pointer class for automatic garbage collection.
const std::string & getRequired(const std::string &name) const
Get an attribute, throwing an std::exception if it is not found.