本文整理汇总了C++中ExpectedAttributes::hasAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ ExpectedAttributes::hasAttribute方法的具体用法?C++ ExpectedAttributes::hasAttribute怎么用?C++ ExpectedAttributes::hasAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExpectedAttributes
的用法示例。
在下文中一共展示了ExpectedAttributes::hasAttribute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tripleCharge
/*
* Read values from the given XMLAttributes set into their specific fields.
*/
void
FbcSpeciesPlugin::readAttributes (const XMLAttributes& attributes,
const ExpectedAttributes& expectedAttributes)
{
// dont call this as all it does it log unknown attributes
// SBasePlugin::readAttributes(attributes, expectedAttributes);
for (int i = 0; i < attributes.getLength(); i++)
{
std::string name = attributes.getName(i);
std::string uri = attributes.getURI(i);
if (uri != mURI) continue;
if (!expectedAttributes.hasAttribute(name))
{
getErrorLog()->logPackageError("fbc", FbcSpeciesAllowedL3Attributes,
getPackageVersion(), getLevel(), getVersion());
}
}
if (mSBMLExt->getLevel(mURI) > 2)
{
XMLTriple tripleCharge("charge", mURI, mPrefix);
unsigned int numErrs = getErrorLog()->getNumErrors();
mIsSetCharge = attributes.readInto(tripleCharge, mCharge, getErrorLog(),
false, getLine(), getColumn());
if (mIsSetCharge == false)
{
if (getErrorLog()->getNumErrors() == numErrs + 1 &&
getErrorLog()->contains(XMLAttributeTypeMismatch))
{
getErrorLog()->remove(XMLAttributeTypeMismatch);
getErrorLog()->logPackageError("fbc", FbcSpeciesChargeMustBeInteger,
getPackageVersion(), getLevel(), getVersion());
}
}
XMLTriple tripleChemicalFormula("chemicalFormula", mURI, mPrefix);
bool assigned = attributes.readInto(tripleChemicalFormula, mChemicalFormula);
if (assigned == true)
{
parseChemicalFormula(mChemicalFormula, *(getErrorLog()), getPackageVersion(),
getLevel(), getVersion());
}
}
}
示例2: getLevel
/*
* Subclasses should override this method to read values from the given
* XMLAttributes set into their specific fields.
*/
void
SBasePlugin::readAttributes (const XMLAttributes& attributes,
const ExpectedAttributes& expectedAttributes)
{
if (&attributes == NULL || &expectedAttributes == NULL ) return;
const unsigned int sbmlLevel = getLevel ();
const unsigned int sbmlVersion = getVersion();
const unsigned int pkgVersion = getPackageVersion();
std::string element = (mParent) ? mParent->getElementName() : std::string();
//
// (NOTE)
//
// This function is just used to identify unexpected
// attributes with the prefix of the package.
//
#if 0
std::cout << "[DEBUG] SBasePlugin::readAttributes() " << element << std::endl;
#endif
//
// check that all attributes of this plugin object are expected
//
for (int i = 0; i < attributes.getLength(); i++)
{
std::string name = attributes.getName(i);
std::string uri = attributes.getURI(i);
#if 0
std::cout << "[DEBUG] SBasePlugin::readAttributes() name : " << name
<< " uri " << uri << std::endl;
#endif
if (uri != mURI) continue;
if (!expectedAttributes.hasAttribute(name))
{
logUnknownAttribute(name, sbmlLevel, sbmlVersion, pkgVersion, element);
}
}
}
示例3: if
bool
ASTBase::readAttributes(const XMLAttributes& attributes,
const ExpectedAttributes& expectedAttributes,
XMLInputStream& stream, const XMLToken& element)
{
bool read = true;
//
// check that all attributes are expected
//
for (int i = 0; i < attributes.getLength(); i++)
{
std::string name = attributes.getName(i);
std::string uri = attributes.getURI(i);
std::string prefix = attributes.getPrefix(i);
//
// To allow prefixed attribute whose namespace doesn't belong to
// core or extension package.
//
// (e.g. xsi:type attribute in Curve element in layout extension)
//
if (!prefix.empty())
{
if ( expectedAttributes.hasAttribute(prefix + ":" + name) ) continue;
}
if (!expectedAttributes.hasAttribute(name))
{
std::string message = "The attribute '" + name + "' is not permitted" +
" on a <" + element.getName() + "> element.";
if (name == "type")
{
logError(stream, element, DisallowedMathTypeAttributeUse, message);
}
else if (name == "encoding")
{
logError(stream, element, DisallowedMathMLEncodingUse, message);
}
else if (name == "definitionURL")
{
logError(stream, element, DisallowedDefinitionURLUse, message);
}
else if (name == "units")
{
if (stream.getSBMLNamespaces() != NULL
&& stream.getSBMLNamespaces()->getLevel() > 2)
{
logError(stream, element, DisallowedMathUnitsUse, message);
}
else
{
message = "The 'units' attribute was introduced in SBML Level 3.";
logError(stream, element, InvalidMathMLAttribute, message);
}
}
else
{
logError(stream, element, InvalidMathElement, message);
}
// not sufficient to make the read bad
//return false;
}
}
string id;
string className;
string style;
attributes.readInto( "id" , id );
attributes.readInto( "class" , className );
attributes.readInto( "style" , style );
if (!id.empty())
{
if (setId(id) != LIBSBML_OPERATION_SUCCESS)
{
read = false;
}
}
if (!className.empty())
{
if (setClass(className) != LIBSBML_OPERATION_SUCCESS)
{
read = false;
}
}
if (!style.empty())
{
if (setStyle(style) != LIBSBML_OPERATION_SUCCESS)
{
read = false;
}
}
//.........这里部分代码省略.........