Teuchos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Teuchos_StandardValidatorXMLConverters.cpp
Go to the documentation of this file.
1// @HEADER
2// ***********************************************************************
3//
4// Teuchos: Common Tools Package
5// Copyright (2004) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38//
39// ***********************************************************************
40// @HEADER
41
43#include "Teuchos_RCP.hpp"
44
49namespace Teuchos {
50
52 const XMLObject& /* xmlObj */,
53 const IDtoValidatorMap& /*validatorIDsMap*/) const
54{
55 return boolParameterEntryValidator();
56}
57
58
60 const RCP<const ParameterEntryValidator> /* validator */,
61 XMLObject& /* xmlObj */,
62 const ValidatortoIDMap& /*validatorIDsMap*/) const
63{
64 //RCP<const AnyNumberParameterEntryValidator> castedValidator =
65 // rcp_dynamic_cast<const AnyNumberParameterEntryValidator>(validator, true);
66
67 // currently no action
68}
69
70#ifdef HAVE_TEUCHOS_DEBUG
72BoolValidatorXMLConverter::getDummyValidator() const{
74}
75#endif
76
93
94
98 const ValidatortoIDMap& /*validatorIDsMap*/) const
99{
102 xmlObj.addBool(
103 getAllowIntAttributeName(), castedValidator->isIntAllowed());
104 xmlObj.addBool(
105 getAllowDoubleAttributeName(), castedValidator->isDoubleAllowed());
106 xmlObj.addBool(
107 getAllowStringAttributeName(), castedValidator->isStringAllowed());
109 castedValidator->getPrefferedTypeString(
110 castedValidator->getPreferredType()));
111}
112
113#ifdef HAVE_TEUCHOS_DEBUG
115AnyNumberValidatorXMLConverter::getDummyValidator() const{
117}
118#endif
119
121 const XMLObject& xmlObj,
122 const IDtoValidatorMap& /*validatorIDsMap*/) const
123{
124 return rcp(
126 xmlObj.getWithDefault<bool>(
129 )
130 )
131 );
132}
133
134
145
146
147#ifdef HAVE_TEUCHOS_DEBUG
149FileNameValidatorXMLConverter::getDummyValidator() const{
151}
152#endif
153
154
156 const XMLObject& xmlObj,
157 const IDtoValidatorMap& /*validatorIDsMap*/) const
158{
159 Array<std::string> strings(xmlObj.numChildren());
160 if(xmlObj.numChildren()!=0){
161 for(int i=0; i<xmlObj.numChildren(); ++i){
162 XMLObject currentChild = xmlObj.getChild(i);
165 "Error converting xmlObject to StringValidator." << std::endl <<
166 "Unrecognized tag: " << currentChild.getTag());
168 }
169 }
170 return rcp(new StringValidator(strings));
171}
172
173
177 const ValidatortoIDMap& /*validatorIDsMap*/) const
178{
181
182 if(!is_null(validator->validStringValues())){
184 validator->validStringValues()->begin();
185 for(; it != validator->validStringValues()->end(); ++it){
187 stringTag.addAttribute(getStringValueAttributeName(), *it);
188 xmlObj.addChild(stringTag);
189 }
190 }
191}
192
193
194#ifdef HAVE_TEUCHOS_DEBUG
196StringValidatorXMLConverter::getDummyValidator() const{
198}
199#endif
200
201} // namespace Teuchos
202
Reference-counted pointer class and non-member templated function implementations.
A collection of standard ValidatorXMLConverters.
static EPreferredType getPrefferedTypeStringEnum(const std::string &enumString)
Gets the preferred type enum associated with a give string.
RCP< ParameterEntryValidator > convertXML(const XMLObject &xmlObj, const IDtoValidatorMap &validatorIDsMap) const
void convertValidator(const RCP< const ParameterEntryValidator > validator, XMLObject &xmlObj, const ValidatortoIDMap &validatorIDsMap) const
std::vector< T >::const_iterator const_iterator
The type of a const forward iterator.
Thrown when xml tag is encountered that is either unrecognized or inappropriate for a given context.
void convertValidator(const RCP< const ParameterEntryValidator > validator, XMLObject &xmlObj, const ValidatortoIDMap &validatorIDsMap) const
RCP< ParameterEntryValidator > convertXML(const XMLObject &xmlObj, const IDtoValidatorMap &validatorIDsMap) const
static RCP< T > getDummyObject()
Retrieves a dummy object of type T.
RCP< ParameterEntryValidator > convertXML(const XMLObject &xmlObj, const IDtoValidatorMap &validatorIDsMap) const
void convertValidator(const RCP< const ParameterEntryValidator > validator, XMLObject &xmlObj, const ValidatortoIDMap &validatorIDsMap) const
static bool mustAlreadyExistDefault()
The default value of the mustAlreadyExist parameter in the constructor.
Maps Validators to integers.
Concrete serial communicator subclass.
int getTag() const
The current tag.
void convertValidator(const RCP< const ParameterEntryValidator > validator, XMLObject &xmlObj, const ValidatortoIDMap &validatorIDsMap) const
RCP< ParameterEntryValidator > convertXML(const XMLObject &xmlObj, const IDtoValidatorMap &validatorIDsMap) const
A simple validator that only allows certain string values to be choosen or simply enforces that a par...
A class for mapping validators to integers.
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object,...
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
bool is_null(const std::shared_ptr< T > &p)
Returns true if p.get()==NULL.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.