本文整理汇总了C++中ParameterList::currentParametersString方法的典型用法代码示例。如果您正苦于以下问题:C++ ParameterList::currentParametersString方法的具体用法?C++ ParameterList::currentParametersString怎么用?C++ ParameterList::currentParametersString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParameterList
的用法示例。
在下文中一共展示了ParameterList::currentParametersString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: validateParametersAndSetDefaults
void ParameterList::validateParametersAndSetDefaults(
ParameterList const& validParamList,
int const depth
)
{
typedef std::deque<ListPlusValidList> sublist_list_t;
#ifdef TEUCHOS_PARAMETER_LIST_SHOW_TRACE
RCP<FancyOStream> out = VerboseObjectBase::getDefaultOStream();
OSTab tab(out);
*out << "\n*** Entering ParameterList::validateParametersAndSetDefaults(...) "
"for this->name()=\""<<this->name()<<"\"...\n";
#endif
//
// A) loop through and validate the parameters at this level.
//
// Here we generate a list of sublists that we will search next
//
sublist_list_t sublist_list;
{
Iterator itr;
for (itr = this->nonconstBegin(); itr != this->nonconstEnd(); ++itr) {
const std::string &entryName = this->name(itr);
ParameterEntry &theEntry = this->nonconstEntry(itr);
#ifdef TEUCHOS_PARAMETER_LIST_SHOW_TRACE
OSTab tab(out);
*out << "\nentryName=\""<<entryName<<"\"\n";
#endif
const ParameterEntry *validEntry = validParamList.getEntryPtr(entryName);
TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(
!validEntry, Exceptions::InvalidParameterName
,"Error, the parameter {name=\""<<entryName<<"\","
"type=\""<<theEntry.getAny(false).typeName()<<"\""
",value=\""<<filterValueToString(theEntry)<<"\"}"
"\nin the parameter (sub)list \""<<this->name()<<"\""
"\nwas not found in the list of valid parameters!"
"\n\nThe valid parameters and types are:\n"
<<validParamList.currentParametersString()
);
RCP<const ParameterEntryValidator> validator;
if (nonnull(validator=validEntry->validator())) {
validator->validateAndModify(entryName, this->name(), &theEntry);
theEntry.setValidator(validator);
}
else {
const bool validType =
( validEntry!=NULL
? theEntry.getAny(false).type() == validEntry->getAny(false).type()
: false
);
TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(
!validType, Exceptions::InvalidParameterType
,"Error, the parameter {name=\""<<entryName<<"\","
"type=\""<<theEntry.getAny(false).typeName()<<"\""
",value=\""<<filterValueToString(theEntry)<<"\"}"
"\nin the parameter (sub)list \""<<this->name()<<"\""
"\nexists in the list of valid parameters but has the wrong type."
"\n\nThe correct type is \""
<< validEntry->getAny(false).typeName() << "\"."
);
// Note: If there is no validator for this item, then we can not
// validate the value of the parameter, only its type!
}
if( theEntry.isList() && depth > 0 ) {
sublist_list.push_back(
ListPlusValidList(
&getValue<ParameterList>(theEntry),
&getValue<ParameterList>(*validEntry)
)
);
}
}
}
//
// B) Loop through the valid parameters at this level that are not set in
// *this, and set their defaults.
//
{
ConstIterator itr;
for (itr = validParamList.begin(); itr != validParamList.end(); ++itr) {
const std::string &validEntryName = validParamList.name(itr);
const ParameterEntry &validEntry = validParamList.entry(itr);
const ParameterEntry *theEntry = this->getEntryPtr(validEntryName);
if (!theEntry) {
// This entry does not exist, so add it. Here we will only set the
// value of the entry and its validator and and leave off the
// documentation. The reason that the validator is set is so that it
// can be used to extract and validate entries in the transformed list
// *this without having to refer back to the valid parameter list.
ParameterEntry newEntry;
newEntry.setAnyValue(
validEntry.getAny(),
true // isDefault
);
newEntry.setValidator(validEntry.validator());
this->setEntry(validEntryName,newEntry);
}
}
}
//
// C) Loop through the sublists and validate their parameters and set their
//.........这里部分代码省略.........
示例2: validateParameters
void ParameterList::validateParameters(
ParameterList const& validParamList,
int const depth,
EValidateUsed const validateUsed,
EValidateDefaults const validateDefaults
) const
{
typedef std::deque<ListPlusValidList> sublist_list_t;
#ifdef TEUCHOS_PARAMETER_LIST_SHOW_TRACE
RCP<FancyOStream> out = VerboseObjectBase::getDefaultOStream();
OSTab tab(out);
*out << "\n*** Entering ParameterList::validateParameters(...) for "
"this->name()=\""<<this->name()<<"\"...\n";
#endif
//
// First loop through and validate the parameters at this level.
//
// Here we generate a list of sublists that we will search next
//
sublist_list_t sublist_list;
ConstIterator itr;
for (itr = this->begin(); itr != this->end(); ++itr) {
const std::string &entryName = this->name(itr);
const ParameterEntry &theEntry = this->entry(itr);
#ifdef TEUCHOS_PARAMETER_LIST_SHOW_TRACE
OSTab tab(out);
*out << "\nentryName=\""<<entryName<<"\"\n";
#endif
if(
( theEntry.isUsed() && validateUsed!=VALIDATE_USED_ENABLED )
||
( theEntry.isDefault() && validateDefaults!=VALIDATE_DEFAULTS_ENABLED )
)
{
continue;
}
const ParameterEntry *validEntry = validParamList.getEntryPtr(entryName);
TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(
!validEntry, Exceptions::InvalidParameterName
,"Error, the parameter {name=\""<<entryName<<"\","
"type=\""<<theEntry.getAny(false).typeName()<<"\""
",value=\""<<filterValueToString(theEntry)<<"\"}"
"\nin the parameter (sub)list \""<<this->name()<<"\""
"\nwas not found in the list of valid parameters!"
"\n\nThe valid parameters and types are:\n"
<<validParamList.currentParametersString()
);
RCP<const ParameterEntryValidator> validator;
if (nonnull(validator=validEntry->validator())) {
validator->validate(theEntry, entryName, this->name());
}
else {
const bool validType =
( validEntry!=NULL
? theEntry.getAny(false).type() == validEntry->getAny(false).type()
: false
);
TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(
!validType, Exceptions::InvalidParameterType
,"Error, the parameter {name=\""<<entryName<<"\","
"type=\""<<theEntry.getAny(false).typeName()<<"\""
",value=\""<<filterValueToString(theEntry)<<"\"}"
"\nin the parameter (sub)list \""<<this->name()<<"\""
"\nexists in the list of valid parameters but has the wrong type."
"\n\nThe correct type is \""
<< validEntry->getAny(false).typeName() << "\"."
);
}
if( theEntry.isList() && depth > 0 ) {
sublist_list.push_back(
ListPlusValidList(
&getValue<ParameterList>(theEntry),&getValue<ParameterList>(*validEntry)
)
);
}
}
//
// Now loop through the sublists and validate their parameters
//
for(
sublist_list_t::const_iterator sl_itr = sublist_list.begin();
sl_itr != sublist_list.end();
++sl_itr
)
{
if (!sl_itr->validList->disableRecursiveValidation_) {
sl_itr->list->validateParameters(
*sl_itr->validList
,depth-1
,validateUsed
,validateDefaults
);
}
}
#ifdef TEUCHOS_PARAMETER_LIST_SHOW_TRACE
*out << "\n*** Existing ParameterList::validateParameters(...) for "
"this->name()=\""<<this->name()<<"\"...\n";
#endif
}