本文整理汇总了C++中XMLToken类的典型用法代码示例。如果您正苦于以下问题:C++ XMLToken类的具体用法?C++ XMLToken怎么用?C++ XMLToken使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XMLToken类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addExpectedAttributes
bool
ASTCnBase::read(XMLInputStream& stream, const std::string& )
{
bool read = false;
const XMLToken element = stream.next ();
ExpectedAttributes expectedAttributes;
addExpectedAttributes(expectedAttributes, stream);
read = readAttributes(element.getAttributes(), expectedAttributes,
stream, element);
string prefix;
if (isSetUnits() == true)
{
prefix = element.getAttrPrefix(
element.getAttrIndex("units", stream.getSBMLNamespaces()->getURI()));
setUnitsPrefix(prefix);
}
//return ASTBase::read(stream, reqd_prefix);
return read;
}
示例2: addExpectedAttributes
bool
ASTCiNumberNode::read(XMLInputStream& stream, const std::string& reqd_prefix)
{
bool read = false;
const XMLToken element = stream.next ();
const string& nameE = element.getName();
ASTBase::checkPrefix(stream, reqd_prefix, element);
if (nameE != "ci")
{
#if 0
cout << "HELP\n";
#endif
return read;
}
ExpectedAttributes expectedAttributes;
addExpectedAttributes(expectedAttributes, stream);
read = readAttributes(element.getAttributes(), expectedAttributes,
stream, element);
const string name = trim( stream.next().getCharacters() );
setName((name));
ASTBase::setType(AST_NAME);
if (read == true)
stream.skipPastEnd(element);
return read;
}
示例3: setTypeCI
/**
* Sets the type of an ASTNode based on the given MathML <ci> element.
* Errors will be logged in the stream's SBMLErrorLog object.
*/
static void
setTypeCI (ASTNode& node, const XMLToken& element, XMLInputStream& stream)
{
if (element.getName() == "csymbol")
{
string url;
element.getAttributes().readInto("definitionURL", url);
if ( url == URL_DELAY ) node.setType(AST_FUNCTION_DELAY);
else if ( url == URL_TIME ) node.setType(AST_NAME_TIME);
else if ( url == URL_AVOGADRO ) node.setType(AST_NAME_AVOGADRO);
else
{
static_cast <SBMLErrorLog*>
(stream.getErrorLog())->logError(BadCsymbolDefinitionURLValue,
stream.getSBMLNamespaces()->getLevel(),
stream.getSBMLNamespaces()->getVersion());
}
}
else if (element.getName() == "ci")
{
node.setDefinitionURL(element.getAttributes());
}
const string name = trim( stream.next().getCharacters() );
node.setName( name.c_str() );
}
示例4: determineNumChildren
bool
ArraysASTPlugin::readMatrixRow(XMLInputStream& stream, const std::string& reqd_prefix,
const XMLToken& currentElement)
{
bool read = false;
stream.skipText();
const XMLToken nextElement = stream.peek();
const string& nextName = nextElement.getName();
unsigned int numChildren = determineNumChildren(stream, "matrixrow");
mVector = new ASTArraysVectorFunctionNode(AST_LINEAR_ALGEBRA_MATRIXROW_CONSTRUCTOR);
mVector->setExpectedNumChildren(numChildren);
// read attributes on this element here since we have already consumed
// the element
ExpectedAttributes expectedAttributes;
mVector->addExpectedAttributes(expectedAttributes, stream);
read = mVector->ASTBase::readAttributes(currentElement.getAttributes(),
expectedAttributes, stream, currentElement);
if (read == false)
{
mVector = NULL;
}
else
{
read = mVector->read(stream, reqd_prefix);
}
return read;
}
示例5:
void
ASTBase::logError (XMLInputStream& stream, const XMLToken& element, SBMLErrorCode_t code,
const std::string& msg)
{
SBMLNamespaces* ns = stream.getSBMLNamespaces();
if (ns != NULL)
{
static_cast <SBMLErrorLog*>
(stream.getErrorLog())->logError(
code,
ns->getLevel(),
ns->getVersion(),
msg,
element.getLine(),
element.getColumn());
}
else
{
static_cast <SBMLErrorLog*>
(stream.getErrorLog())->logError(
code,
SBML_DEFAULT_LEVEL,
SBML_DEFAULT_VERSION,
msg,
element.getLine(),
element.getColumn());
}
}
示例6: setTypeCN
/**
* Sets the type of an ASTNode based on the given MathML <cn> element.
* Errors will be logged in the stream's SBMLErrorLog object.
*/
static void
setTypeCN (ASTNode& node, const XMLToken& element, XMLInputStream& stream)
{
string type = "real";
element.getAttributes().readInto("type", type);
// here is the only place we might encounter the sbml:units attribute
string units = "";
element.getAttributes().readInto("units", units);
if (type == "real")
{
double value = 0;
istringstream isreal;
isreal.str( stream.next().getCharacters() );
isreal >> value;
node.setValue(value);
if (isreal.fail()
|| node.isInfinity()
|| node.isNegInfinity()
)
{
static_cast <SBMLErrorLog*>
(stream.getErrorLog())->logError(FailedMathMLReadOfDouble,
stream.getSBMLNamespaces()->getLevel(),
stream.getSBMLNamespaces()->getVersion());
}
}
示例7: setType
bool
ASTUnaryFunctionNode::read(XMLInputStream& stream, const std::string& reqd_prefix)
{
bool read = false;
ASTBase * child = NULL;
const XMLToken element = stream.peek ();
ASTBase::checkPrefix(stream, reqd_prefix, element);
const char* name = element.getName().c_str();
setType(getTypeFromName(name));
ASTBase::read(stream, reqd_prefix);
unsigned int numChildrenAdded = 0;
if (getExpectedNumChildren() > 0)
{
while (stream.isGood() && numChildrenAdded < getExpectedNumChildren())
{
stream.skipText();
name = stream.peek().getName().c_str();
if (representsNumber(ASTBase::getTypeFromName(name)) == true)
{
child = new ASTNumber();
}
else
{
child = new ASTFunction();
}
read = child->read(stream, reqd_prefix);
stream.skipText();
if (read == true && addChild(child) == LIBSBML_OPERATION_SUCCESS)
{
numChildrenAdded++;
}
else
{
delete child;
child = NULL;
read = false;
break;
}
}
}
else
{
stream.skipPastEnd(element);
read = true;
}
return read;
}
示例8: isEnd
/*
* @return @c true if this XMLToken is an XML end element for the given XML
* start element, false otherwise.
*/
bool
XMLToken::isEndFor (const XMLToken& element) const
{
return
isEnd() &&
!isStart() &&
element.isStart() &&
element.getName() == getName() &&
element.getURI () == getURI ();
}
示例9: addExpectedAttributes
bool
ASTBase::read(XMLInputStream& stream, const std::string& )
{
ExpectedAttributes expectedAttributes;
addExpectedAttributes(expectedAttributes, stream);
const XMLToken element = stream.next ();
return readAttributes(element.getAttributes(), expectedAttributes,
stream, element);
}
示例10: while
bool
XMLTokenizer::containsChild(bool & valid,
const std::string& qualifier,
const std::string& container)
{
valid = false;
//unsigned int numQualifiers = 0;
size_t size = mTokens.size();
if (size < 2)
{
return false;
}
unsigned int index = 0;
//unsigned int depth = 0;
std::string name;
XMLToken next = mTokens.at(index);
name = next.getName();
while (index < size-2)
{
// skip any text elements
while(next.isText() == true && index < size-1)
{
index++;
next = mTokens.at(index);
}
if (next.getName() == qualifier)
{
valid = true;
return true;
}
index++;
if (index < size)
{
next = mTokens.at(index);
}
}
// we might have hit the end of the loop and the end of the correct tag
if (valid == false && index >= size-2)
{
valid = true;
}
return false;
}
示例11: if
bool
ArraysASTPlugin::read(XMLInputStream& stream, const std::string& reqd_prefix,
const XMLToken& currentElement)
{
bool read = false;
stream.skipText();
const string& currentName = currentElement.getName();
//ASTBase::checkPrefix(stream, reqd_prefix, currentElement);
// create appropriate sub class
if (currentName == "vector")
{
read = readVector(stream, reqd_prefix, currentElement);
}
#if (0)
else if (currentName == "matrix")
{
read = readMatrix(stream, reqd_prefix, currentElement);
}
else if (currentName == "matrixrow")
{
read = readMatrixRow(stream, reqd_prefix, currentElement);
}
#endif
return read;
}
示例12: logError
void
ASTBase::checkPrefix(XMLInputStream &stream, const std::string& reqd_prefix,
const XMLToken& element)
{
if (!reqd_prefix.empty())
{
std::string prefix = element.getPrefix();
if (prefix != reqd_prefix)
{
const string message = "Element <" + element.getName()
+ "> should have prefix \"" + reqd_prefix + "\".";
logError(stream, element, InvalidMathElement, message);
}
}
}
示例13: while
/*
* Consume zero or more XMLTokens up to and including the corresponding
* end XML element or EOF.
*/
void
XMLInputStream::skipPastEnd (const XMLToken& element)
{
if ( element.isEnd() ) return;
while ( isGood() && !peek().isEndFor(element) ) next();
next();
}
示例14: setReal
bool
ASTCnRealNode::read(XMLInputStream& stream, const std::string& reqd_prefix)
{
bool read = false;
const XMLToken element = stream.peek ();
const string& name = element.getName();
ASTBase::checkPrefix(stream, reqd_prefix, element);
if (name != "cn")
{
#if 0
cout << "HELP\n";
#endif
return read;
}
ASTCnBase::read(stream, reqd_prefix);
std::string type = "real";
element.getAttributes().readInto("type", type);
if (type == "real")
{
double value = 0;
istringstream isreal;
isreal.str( stream.next().getCharacters() );
isreal >> value;
setReal(value);
ASTBase::setType(AST_REAL);
if (isreal.fail()
|| (util_isInf(getValue()) > 0)
|| (util_isInf(getValue()) < 0)
)
{
logError(stream, element, FailedMathMLReadOfDouble);
}
read = true;
}
示例15: logError
LIBSBML_CPP_NAMESPACE_BEGIN
#ifdef __cplusplus
/**
* logs the given erroron the error log of the stream.
*
* @param stream the stream to log the error on
* @param element the element to log the error for
* @param code the error code to log
* @param msg optional message
*/
static void
logError (XMLInputStream* stream, const XMLToken& element, SBMLErrorCode_t code,
const std::string& msg = "")
{
if (&element == NULL || stream == NULL) return;
SBMLNamespaces* ns = stream->getSBMLNamespaces();
if (ns != NULL)
{
static_cast <SBMLErrorLog*>
(stream->getErrorLog())->logError(
code,
ns->getLevel(),
ns->getVersion(),
msg,
element.getLine(),
element.getColumn());
}
else
{
static_cast <SBMLErrorLog*>
(stream->getErrorLog())->logError(
code,
SBML_DEFAULT_LEVEL,
SBML_DEFAULT_VERSION,
msg,
element.getLine(),
element.getColumn());
}
}