本文整理汇总了C++中XMLAttributes::getPrefix方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLAttributes::getPrefix方法的具体用法?C++ XMLAttributes::getPrefix怎么用?C++ XMLAttributes::getPrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLAttributes
的用法示例。
在下文中一共展示了XMLAttributes::getPrefix方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getLevel
/*
* Subclasses should override this method to read values from the given
* XMLAttributes set into their specific fields. Be sure to call your
* parents implementation of this method as well.
*/
void
Delay::readL3Attributes (const XMLAttributes& attributes)
{
const unsigned int level = getLevel();
const unsigned int version = getVersion();
std::vector<std::string> expectedAttributes;
expectedAttributes.clear();
expectedAttributes.push_back("metaid");
expectedAttributes.push_back("sboTerm");
// check that all attributes are expected
for (int i = 0; i < attributes.getLength(); i++)
{
std::vector<std::string>::const_iterator end = expectedAttributes.end();
std::vector<std::string>::const_iterator begin = expectedAttributes.begin();
std::string name = attributes.getName(i);
std::string prefix = attributes.getPrefix(i);
// only check attributes in the sbml namespace
if (prefix.empty() || prefix == "sbml")
{
if (std::find(begin, end, name) == end)
{
logUnknownAttribute(name, level, version, "<delay>");
}
}
}
//
// sboTerm: SBOTerm { use="optional" } (L2v3 ->)
//
mSBOTerm = SBO::readTerm(attributes, this->getErrorLog(), level, version);
}
示例2: getLevel
/*
* Subclasses should override this method to read values from the given
* XMLAttributes set into their specific fields. Be sure to call your
* parents implementation of this method as well.
*/
void
InitialAssignment::readL2Attributes (const XMLAttributes& attributes)
{
SBase::readAttributes(attributes);
const unsigned int level = getLevel ();
const unsigned int version = getVersion();
if (version == 1)
{
logError(NotSchemaConformant, getLevel(), getVersion(),
"InitialAssignment is not a valid component for this level/version.");
return;
}
std::vector<std::string> expectedAttributes;
expectedAttributes.clear();
expectedAttributes.push_back("metaid");
expectedAttributes.push_back("symbol");
expectedAttributes.push_back("sboTerm");
// check that all attributes are expected
for (int i = 0; i < attributes.getLength(); i++)
{
std::vector<std::string>::const_iterator end = expectedAttributes.end();
std::vector<std::string>::const_iterator begin = expectedAttributes.begin();
std::string name = attributes.getName(i);
std::string prefix = attributes.getPrefix(i);
// only check attributes in the sbml namespace
if (prefix.empty() || prefix == "sbml")
{
if (std::find(begin, end, name) == end)
{
logUnknownAttribute(name, level, version, "<initialAssignment>");
}
}
}
//
// symbol: SId { use="required" } (L2v2 -> )
//
bool assigned = attributes.readInto("symbol", mSymbol, getErrorLog(), true);
if (assigned && mSymbol.size() == 0)
{
logEmptyString("symbol", level, version, "<initialAssignment>");
}
if (!SyntaxChecker::isValidSBMLSId(mSymbol)) logError(InvalidIdSyntax);
//
// sboTerm: SBOTerm { use="optional" } (L2v2 ->)
//
mSBOTerm = SBO::readTerm(attributes, this->getErrorLog(), level, version);
}
示例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;
}
}
//.........这里部分代码省略.........