本文整理汇总了C++中pacc::xml::ConstIterator::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstIterator::getAttribute方法的具体用法?C++ ConstIterator::getAttribute怎么用?C++ ConstIterator::getAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pacc::xml::ConstIterator
的用法示例。
在下文中一共展示了ConstIterator::getAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readWithSystem
/*!
* \brief Read object from XML using system.
* \param inIter XML iterator of input document.
* \param ioSystem A reference to the system.
* \throw SCHNAPS::Core::IOException if a wrong tag is encountered.
* \throw SCHNAPS::Core::IOException if inProbabilities attribute is missing.
* \throw SCHNAPS::Core::RunTimeException if the primitive is undefined for the specific probabilities source.
*/
void BranchMulti::readWithSystem(PACC::XML::ConstIterator inIter, Core::System& ioSystem) {
schnaps_StackTraceBeginM();
if (inIter->getType() != PACC::XML::eData) {
throw schnaps_IOExceptionNodeM(*inIter, "tag expected!");
}
if (inIter->getValue() != getName()) {
std::ostringstream lOSS;
lOSS << "tag <" << getName() << "> expected, but ";
lOSS << "got tag <" << inIter->getValue() << "> instead!";
throw schnaps_IOExceptionNodeM(*inIter, lOSS.str());
}
// retrieve probabilities of executing each branch
if (inIter->getAttribute("inProbabilities").empty()) {
throw schnaps_IOExceptionNodeM(*inIter, "probabilities of executing each branch expected!");
}
mProbabilities_Ref.assign(inIter->getAttribute("inProbabilities"));
switch (mProbabilities_Ref[0]) {
case '@':
// individual variable value
case '#':
// environment variable value
case '%':
// local variable value
throw schnaps_RunTimeExceptionM("The primitive is undefined for the specific probabilities source!");
break;
case '$':
// parameter value
mProbabilities = Core::castHandleT<Core::Vector>(ioSystem.getParameters().getParameterHandle(mProbabilities_Ref.substr(1)));
break;
default: {
// direct value
std::stringstream lISS(mProbabilities_Ref);
PACC::Tokenizer lTokenizer(lISS);
lTokenizer.setDelimiters("|", "");
std::string lProbability;
double lSum = 0;
mProbabilities = new Core::Vector();
while (lTokenizer.getNextToken(lProbability)) {
mProbabilities->push_back(new Core::Double(SCHNAPS::str2dbl(lProbability)));
lSum += SCHNAPS::str2dbl(lProbability);
}
#ifndef SCHNAPS_NDEBUG
if (lSum != 1) {
std::cout << "Warning: multi branches probabilities must sum to 1 (current sum: " << lSum << "!";
std::cout << "\tIn: void SCHNAPS::Plugins::Control::BranchMulti::readWithSystem(PACC::XML::ConstIterator, SCHNAPS::Core::System&)\n";
}
#endif
break; }
}
setNumberArguments(mProbabilities->size());
schnaps_StackTraceEndM("void SCHNAPS::Plugins::Control::BranchMulti::readWithSystem(PACC::XML::ConstIterator, SCHNAPS::Core::System&)");
}
示例2: Beagle_IOExceptionNodeM
/*!
* \brief Read a linear GP mutation operator from XML tree.
* \param inNode XML node to use to read mutation operator.
* \param ioSystem Evolutionary system.
*/
void LinGP::MutationOp::readWithSystem(PACC::XML::ConstIterator inIter, System& ioSystem)
{
if((inIter->getType() != PACC::XML::eData) || (inIter->getValue() != getName())) {
std::ostringstream lOSS;
lOSS << "tag <" << getName() << "> expected!" << std::flush;
throw Beagle_IOExceptionNodeM(*inIter, lOSS.str());
}
std::string lMutationPbReadName = inIter->getAttribute("mutationpb");
if(lMutationPbReadName.empty() == false) mMutationPbName = lMutationPbReadName;
std::string lInstructMutatePbReadName = inIter->getAttribute("mutinstructpb");
if(lInstructMutatePbReadName.empty() == false) mInstructMutatePbName = lInstructMutatePbReadName;
}
示例3: Beagle_IOExceptionNodeM
/*!
* \brief Read a mutation operator from XML subtree.
* \param inIter XML iterator to use to read crossover operator.
* \param ioSystem Evolutionary system.
*/
void GP::MutationSwapSubtreeOp::readWithSystem(PACC::XML::ConstIterator inIter, System& ioSystem)
{
Beagle_StackTraceBeginM();
if((inIter->getType()!=PACC::XML::eData) || (inIter->getValue()!=getName())) {
std::ostringstream lOSS;
lOSS << "tag <" << getName() << "> expected!" << std::flush;
throw Beagle_IOExceptionNodeM(*inIter, lOSS.str());
}
std::string mMutationPbReadName = inIter->getAttribute("mutationpb");
if(mMutationPbReadName.empty() == false) mMutationPbName = mMutationPbReadName;
std::string mDistribPbReadName = inIter->getAttribute("distrpb");
if(mDistribPbReadName.empty() == false) mDistribPbName = mDistribPbReadName;
Beagle_StackTraceEndM();
}
示例4: Beagle_IOExceptionNodeM
/*!
* \brief Read a bit flip mutation operator from XML subtree.
* \param inIter XML iterator to use to read mutation operator.
* \param ioSystem Evolutionary system.
*/
void BitStr::MutationFlipBitOp::readWithSystem(PACC::XML::ConstIterator inIter, System& ioSystem)
{
Beagle_StackTraceBeginM();
if((inIter->getType()!=PACC::XML::eData) || (inIter->getValue()!=getName())) {
std::ostringstream lOSS;
lOSS << "tag <" << getName() << "> expected!" << std::flush;
throw Beagle_IOExceptionNodeM(*inIter, lOSS.str());
}
std::string lMutationPbReadName = inIter->getAttribute("mutationpb");
if(lMutationPbReadName.empty() == false) mMutationPbName = lMutationPbReadName;
std::string lBitMutatePbReadName = inIter->getAttribute("mutbitpb");
if(lBitMutatePbReadName.empty() == false) mBitMutatePbName = lBitMutatePbReadName;
Beagle_StackTraceEndM();
}
示例5: readWithSystem
/*!
* \brief Read a recombination operator from XML tree.
* \param inIter XML iterator to use to read recombination operator.
* \param ioSystem Evolutionary system.
*/
void RecombinationOp::readWithSystem(PACC::XML::ConstIterator inIter, System& ioSystem)
{
Beagle_StackTraceBeginM();
if((inIter->getType()!=PACC::XML::eData) || (inIter->getValue()!=getName())) {
std::ostringstream lOSS;
lOSS << "tag <" << getName() << "> expected!" << std::flush;
throw Beagle_IOExceptionNodeM(*inIter, lOSS.str());
}
std::string lRecombProbaReadName = inIter->getAttribute("recombpb");
if(lRecombProbaReadName.empty()==false) mRecombProbaName = lRecombProbaReadName;
std::string lNumberRecombReadName = inIter->getAttribute("nbrindrecomb");
if(lNumberRecombReadName.empty()==false) mNumberRecombName = lNumberRecombReadName;
Beagle_StackTraceEndM();
}
示例6: Beagle_IOExceptionNodeM
void Beagle::GP::MutationEphemeralOpT<T>::readWithSystem(PACC::XML::ConstIterator inIter,
Beagle::System& ioSystem)
{
Beagle_StackTraceBeginM();
if((inIter->getType()!=PACC::XML::eData) || (inIter->getValue()!=getName())) {
std::ostringstream lOSS;
lOSS << "tag <" << getName() << "> expected!" << std::flush;
throw Beagle_IOExceptionNodeM(*inIter, lOSS.str());
}
std::string lMutationPbReadName = inIter->getAttribute("mutationpb");
if(lMutationPbReadName.empty() == false) mMutationPbName = lMutationPbReadName;
std::string lEphemeralNameParamName = inIter->getAttribute("primitname");
if(lEphemeralNameParamName.empty() == false) mEphemeralNameParamName = lEphemeralNameParamName;
Beagle_StackTraceEndM("void GP::MutationEphemeralOpT<T>::readWithSystem(PACC::XML::ConstIterator, System&)");
}
示例7: Beagle_IOExceptionNodeM
/*!
* \brief Read an ES vector from a XML subtree.
* \param inIter XML iterator from which the ES vector is read.
* \param ioContext Evolutionary context.
* \throw IOException If a reading error occured (generally bad file format)!
*/
void GA::ESVector::readWithContext(PACC::XML::ConstIterator inIter, Context& ioContext)
{
Beagle_StackTraceBeginM();
if((inIter->getType() != PACC::XML::eData) || (inIter->getValue() != "Genotype")) {
throw Beagle_IOExceptionNodeM(*inIter, "tag <Genotype> expected!");
}
std::string lGenotypeType = inIter->getAttribute("type");
if((lGenotypeType.empty() == false) && (lGenotypeType != getType())) {
std::ostringstream lOSS;
lOSS << "type given '" << lGenotypeType << "' mismatch type of the genotype '";
lOSS << getType() << "'!";
throw Beagle_IOExceptionNodeM(*inIter, lOSS.str());
}
PACC::XML::ConstIterator lChild = inIter->getFirstChild();
if((!lChild) || (lChild->getType()!=PACC::XML::eString)) {
throw Beagle_IOExceptionNodeM(*lChild, "expected content for the ES vector!");
}
clear();
std::istringstream lISS(lChild->getValue());
do {
char lC1='\0', lC2='\0', lC3='\0';
double lValue=DBL_MAX, lStrategy=DBL_MAX;
lISS >> lC1 >> lValue >> lC2 >> lStrategy >> lC3;
if((lC1!='(') || (lC2!=',') || (lC3!=')'))
throw Beagle_IOExceptionNodeM(*lChild, "bad format of ES vector!");
if((lValue==DBL_MAX) || (lStrategy==DBL_MAX))
throw Beagle_IOExceptionNodeM(*lChild, "bad format of ES vector!");
push_back(ESPair(lValue, lStrategy));
} while(lISS.get()==int('/'));
Beagle_StackTraceEndM("void GA::ESVector::readWithContext(PACC::XML::ConstIterator,Context&)");
}
示例8: readWithSystem
/*!
* \brief Read object from XML using system.
* \param inIter XML iterator of input document.
* \param ioSystem A reference to the system.
* \throw SCHNAPS::Core::IOException if a wrong tag is encountered.
*/
void PrimitiveTree::readWithSystem(PACC::XML::ConstIterator inIter, System& ioSystem) {
schnaps_StackTraceBeginM();
if (inIter) {
if (inIter->getType() != PACC::XML::eData) {
throw schnaps_IOExceptionNodeM(*inIter, "tag expected!");
}
if (inIter->getValue() != getName()) {
std::ostringstream lOSS;
lOSS << "tag <" << getName() << "> expected, but ";
lOSS << "got tag <" << inIter->getValue() << "> instead!";
throw schnaps_IOExceptionNodeM(*inIter, lOSS.str());
}
// Get size attribute and reserve size accordingly
std::string lSizeText = inIter->getAttribute("size");
if (lSizeText.empty() == false) {
reserve(str2uint(lSizeText));
}
PACC::XML::ConstIterator lChild = inIter->getFirstChild();
if ((!lChild) || (lChild->getType() != PACC::XML::eData)) {
throw schnaps_IOExceptionNodeM(*lChild, "expected a XML tag for the primitive tree!");
}
clear();
readSubTree(lChild, ioSystem);
}
schnaps_StackTraceEndM("void SCHNAPS::Core::PrimitiveTree::readWithSystem(PACC::XML::ConstIterator, SCHNAPS::Core::System&)");
}
示例9: Beagle_IOExceptionNodeM
/*!
* \brief Read a float vector from a XML subtree.
* \param inIter XML iterator from which the float vector is read.
* \param ioContext Evolutionary context.
* \throw Beagle::IOException If a reading error occured (generally bad file format)!
*/
void GA::IntegerVector::readWithContext(PACC::XML::ConstIterator inIter, Context& ioContext)
{
Beagle_StackTraceBeginM();
if((inIter->getType() != PACC::XML::eData) || (inIter->getValue() != "Genotype")) {
throw Beagle_IOExceptionNodeM(*inIter, "tag <Genotype> expected!");
}
std::string lGenotypeType = inIter->getAttribute("type");
if((lGenotypeType.empty() == false) && (lGenotypeType != getType())) {
std::ostringstream lOSS;
lOSS << "type given '" << lGenotypeType << "' mismatch type of the genotype '";
lOSS << getType() << "'!";
throw Beagle_IOExceptionNodeM(*inIter, lOSS.str());
}
PACC::XML::ConstIterator lChild = inIter->getFirstChild();
if((!lChild) || (lChild->getType()!=PACC::XML::eString))
throw Beagle_IOExceptionNodeM(*lChild, "expected content for the float vector!");
clear();
std::istringstream lISS(lChild->getValue());
while(lISS.good()) {
int lValue=INT_MAX;
lISS >> lValue;
push_back(lValue);
if(lISS.good()==false) break;
int lDelim=lISS.get();
if((lISS.good()==false) || (lDelim==-1)) break;
}
Beagle_StackTraceEndM("void GA::IntegerVector::readWithContext(PACC::XML::ConstIterator,Context&)");
}
示例10: Beagle_IOExceptionNodeM
/*!
* \brief Read a Gaussian mutation operator from a XML subtree.
* \param inIter XML iterator to use to read mutation operator.
* \param ioSystem Evolutionary system.
*/
void FltVec::MutationGaussianOp::readWithSystem(PACC::XML::ConstIterator inIter, System& ioSystem)
{
Beagle_StackTraceBeginM();
if((inIter->getType()!=PACC::XML::eData) || (inIter->getValue()!=getName())) {
std::ostringstream lOSS;
lOSS << "tag <" << getName() << "> expected!" << std::flush;
throw Beagle_IOExceptionNodeM(*inIter, lOSS.str());
}
string lMutationPbReadName = inIter->getAttribute("mutationpb");
if(lMutationPbReadName.empty() == false) mMutationPbName = lMutationPbReadName;
string lMutateFloatPbReadName = inIter->getAttribute("mutfloatpb");
if(lMutateFloatPbReadName.empty() == false) mMutateFloatPbName = lMutateFloatPbReadName;
string lMutateGaussMuReadName = inIter->getAttribute("mutgaussmu");
if(lMutateGaussMuReadName.empty() == false) mMutateGaussMuName = lMutateGaussMuReadName;
string lMutateGaussSigmaReadName = inIter->getAttribute("mutgausssigma");
if(lMutateGaussSigmaReadName.empty() == false) mMutateGaussSigmaName = lMutateGaussSigmaReadName;
Beagle_StackTraceEndM();
}
示例11:
/*!
* \brief Read an argument primitive from XML subtree.
* \param inIter XML iterator to read primitive from.
* \param ioContext Evolutionary context.
*/
void GP::Argument::readWithContext(PACC::XML::ConstIterator inIter, GP::Context& ioContext)
{
Beagle_StackTraceBeginM();
GP::Primitive::readWithContext(inIter, ioContext);
std::string lIndexValue = inIter->getAttribute("id");
if(lIndexValue.empty()==false) {
mIndex = str2uint(lIndexValue);
Beagle_AssertM(mIndex < ioContext.getGenotype().getNumberArguments());
}
Beagle_StackTraceEndM();
}
示例12: readWithSystem
/*!
* \brief Read a initialization operator from a XML subtree.
* \param inIter XML iterator to use to read initialization operator.
* \param ioSystem Evolutionary system.
*/
void InitializationOp::readWithSystem(PACC::XML::ConstIterator inIter, System& ioSystem)
{
Beagle_StackTraceBeginM();
if((inIter->getType()!=PACC::XML::eData) || (inIter->getValue()!=getName())) {
std::ostringstream lOSS;
lOSS << "tag <" << getName() << "> expected!" << std::flush;
throw Beagle_IOExceptionNodeM(*inIter, lOSS.str());
}
std::string mReproProbaReadName = inIter->getAttribute("repropb");
if(mReproProbaReadName.empty() == false) mReproProbaName = mReproProbaReadName;
Beagle_StackTraceEndM();
}
示例13: readWithSystem
/*!
* \brief Read object from XML using system.
* \param inIter XML iterator of input document.
* \param ioSystem A reference to the system.
* \throw SCHNAPS::Core::IOException if a wrong tag is encountered.
* \throw SCHNAPS::Core::IOException if inProbability attribute is missing.
*/
void Branch::readWithSystem(PACC::XML::ConstIterator inIter, Core::System& ioSystem) {
schnaps_StackTraceBeginM();
if (inIter->getType() != PACC::XML::eData) {
throw schnaps_IOExceptionNodeM(*inIter, "tag expected!");
}
if (inIter->getValue() != getName()) {
std::ostringstream lOSS;
lOSS << "tag <" << getName() << "> expected, but ";
lOSS << "got tag <" << inIter->getValue() << "> instead!";
throw schnaps_IOExceptionNodeM(*inIter, lOSS.str());
}
// retrieve probability of executing the first branch
if (inIter->getAttribute("inProbability").empty()) {
throw schnaps_IOExceptionNodeM(*inIter, "probability of executing first branch expected!");
}
mProbability_Ref = inIter->getAttribute("inProbability");
switch (mProbability_Ref[0]) {
case '@':
// individual variable value
case '#':
// environment variable value
case '%':
// local variable value
mProbability = NULL;
break;
case '$':
// parameter value
mProbability = Core::castHandleT<Core::Double>(ioSystem.getParameters().getParameterHandle(mProbability_Ref.substr(1)));
break;
default:
// direct value
mProbability = new Core::Double();
mProbability->readStr(mProbability_Ref);
break;
}
schnaps_StackTraceEndM("void SCHNAPS::Plugins::Control::Branch::readWithSystem(PACC::XML::ConstIterator, SCHNAPS::Core::System&)");
}
示例14: read
/*!
* \brief Read a multiobjective fitness from a XML subtree.
* \param inIter XML iterator to use to read the fitness value.
*/
void FitnessMultiObj::read(PACC::XML::ConstIterator inIter)
{
Beagle_StackTraceBeginM();
if((inIter->getType()!=PACC::XML::eData) || (inIter->getValue()!="Fitness"))
throw Beagle_IOExceptionNodeM(*inIter, "tag <Fitness> expected!");
const std::string& lValid = inIter->getAttribute("valid");
if(lValid.empty() || (lValid == "yes")) {
// Check type of fitness read
const std::string& lType = inIter->getAttribute("type");
if((lType.empty() == false) && (lType != getType())) {
std::ostringstream lOSS;
lOSS << "type given '" << lType << "' mismatch type of the fitness '";
lOSS << getType() << "'!";
throw Beagle_IOExceptionNodeM(*inIter, lOSS.str());
}
// Read objective values
clear();
for(PACC::XML::ConstIterator lChild=inIter->getFirstChild(); lChild; ++lChild) {
if((lChild->getType() != PACC::XML::eData) || (lChild->getValue() != "Obj")) continue;
PACC::XML::ConstIterator lChild2 = lChild->getFirstChild();
if(!lChild2) throw Beagle_IOExceptionNodeM(*lChild, "needed a double value in the <Obj> tag!");
if(lChild2->getType() != PACC::XML::eString)
throw Beagle_IOExceptionNodeM(*lChild2, "needed a double value in the <Obj> tag!");
push_back(str2dbl(lChild2->getValue()));
}
setValid();
} else if(lValid == "no") {
clear();
setInvalid();
}
else {
throw Beagle_IOExceptionNodeM(*inIter, "bad fitness validity value!");
}
Beagle_StackTraceEndM();
}
示例15:
/*!
* \brief Read invoker primitive from XML subtree.
* \param inIter XML iterator to read the primitive from.
* \param ioContext Evolutionary context.
*/
void GP::Invoker::readWithContext(PACC::XML::ConstIterator inIter, GP::Context& ioContext)
{
Beagle_StackTraceBeginM();
GP::Primitive::readWithContext(inIter, ioContext);
std::string lIndexValue = inIter->getAttribute("id");
if(lIndexValue.empty()==false) mIndex = str2uint(lIndexValue);
unsigned int lArgsCount = 0;
for(PACC::XML::ConstIterator lChild=inIter->getFirstChild(); lChild; ++lChild) {
if(lChild->getType()==PACC::XML::eData) ++lArgsCount;
}
setNumberArguments(lArgsCount);
Beagle_StackTraceEndM("void GP::Invoker::readWithContext(PACC::XML::ConstIterator inIter, GP::Context& ioContext)");
}