Skip to content

Commit

Permalink
rename isTextNode and isCommentNode to remove the node.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickerso committed Jan 18, 2019
1 parent aada9fe commit 9a34b94
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
44 changes: 22 additions & 22 deletions src/parser.cpp
Expand Up @@ -335,7 +335,7 @@ void Parser::ParserImpl::loadModel(const ModelPtr &model, const std::string &inp
}
} else if (childNode->isCellmlElement("connection")) {
connectionNodes.push_back(childNode);
} else if (childNode->isTextNode()) {
} else if (childNode->isText()) {
std::string textNode = childNode->convertToString();
// Ignore whitespace when parsing.
if (hasNonWhitespaceCharacters(textNode)) {
Expand All @@ -346,7 +346,7 @@ void Parser::ParserImpl::loadModel(const ModelPtr &model, const std::string &inp
err->setRule(SpecificationRule::MODEL_CHILD);
mParser->addError(err);
}
} else if (childNode->isCommentNode()) {
} else if (childNode->isComment()) {
// Do nothing.
} else {
ErrorPtr err = std::make_shared<Error>();
Expand Down Expand Up @@ -408,7 +408,7 @@ void Parser::ParserImpl::loadComponent(const ComponentPtr &component, const XmlN
// so math is a valid subdocument.
std::string math = childNode->convertToString();
component->appendMath(math);
} else if (childNode->isTextNode()) {
} else if (childNode->isText()) {
std::string textNode = childNode->convertToString();
// Ignore whitespace when parsing.
if (hasNonWhitespaceCharacters(textNode)) {
Expand All @@ -419,7 +419,7 @@ void Parser::ParserImpl::loadComponent(const ComponentPtr &component, const XmlN
err->setRule(SpecificationRule::COMPONENT_CHILD);
mParser->addError(err);
}
} else if (childNode->isCommentNode()) {
} else if (childNode->isComment()) {
// Do nothing.
} else {
ErrorPtr err = std::make_shared<Error>();
Expand Down Expand Up @@ -454,7 +454,7 @@ void Parser::ParserImpl::loadUnits(const UnitsPtr &units, const XmlNodePtr &node
while (childNode) {
if (childNode->isCellmlElement("unit")) {
loadUnit(units, childNode);
} else if (childNode->isTextNode()) {
} else if (childNode->isText()) {
std::string textNode = childNode->convertToString();
// Ignore whitespace when parsing.
if (hasNonWhitespaceCharacters(textNode)) {
Expand All @@ -465,7 +465,7 @@ void Parser::ParserImpl::loadUnits(const UnitsPtr &units, const XmlNodePtr &node
err->setRule(SpecificationRule::UNITS_CHILD);
mParser->addError(err);
}
} else if (childNode->isCommentNode()) {
} else if (childNode->isComment()) {
// Do nothing.
} else {
ErrorPtr err = std::make_shared<Error>();
Expand All @@ -490,7 +490,7 @@ void Parser::ParserImpl::loadUnit(const UnitsPtr &units, const XmlNodePtr &node)
if (node->getFirstChild()) {
XmlNodePtr childNode = node->getFirstChild();
while (childNode) {
if (childNode->isTextNode()) {
if (childNode->isText()) {
std::string textNode = childNode->convertToString();
// Ignore whitespace when parsing.
if (hasNonWhitespaceCharacters(textNode)) {
Expand All @@ -501,7 +501,7 @@ void Parser::ParserImpl::loadUnit(const UnitsPtr &units, const XmlNodePtr &node)
err->setUnits(units);
mParser->addError(err);
}
} else if (childNode->isCommentNode()) {
} else if (childNode->isComment()) {
// Do nothing.
} else {
ErrorPtr err = std::make_shared<Error>();
Expand Down Expand Up @@ -570,7 +570,7 @@ void Parser::ParserImpl::loadVariable(const VariablePtr &variable, const XmlNode
if (node->getFirstChild()) {
XmlNodePtr childNode = node->getFirstChild();
while (childNode) {
if (childNode->isTextNode()) {
if (childNode->isText()) {
std::string textNode = childNode->convertToString();
// Ignore whitespace when parsing.
if (hasNonWhitespaceCharacters(textNode)) {
Expand All @@ -580,7 +580,7 @@ void Parser::ParserImpl::loadVariable(const VariablePtr &variable, const XmlNode
err->setVariable(variable);
mParser->addError(err);
}
} else if (childNode->isCommentNode()) {
} else if (childNode->isComment()) {
// Do nothing.
} else {
ErrorPtr err = std::make_shared<Error>();
Expand Down Expand Up @@ -712,7 +712,7 @@ void Parser::ParserImpl::loadConnection(const ModelPtr &model, const XmlNodePtr
// Connection map XML nodes should not have further children.
if (childNode->getFirstChild()) {
XmlNodePtr grandchildNode = childNode->getFirstChild();
if (grandchildNode->isTextNode()) {
if (grandchildNode->isText()) {
std::string textNode = grandchildNode->convertToString();
// Ignore whitespace when parsing.
if (hasNonWhitespaceCharacters(textNode)) {
Expand All @@ -723,7 +723,7 @@ void Parser::ParserImpl::loadConnection(const ModelPtr &model, const XmlNodePtr
err->setKind(Error::Kind::CONNECTION);
mParser->addError(err);
}
} else if (childNode->isCommentNode()) {
} else if (childNode->isComment()) {
// Do nothing.
} else {
ErrorPtr err = std::make_shared<Error>();
Expand Down Expand Up @@ -783,7 +783,7 @@ void Parser::ParserImpl::loadConnection(const ModelPtr &model, const XmlNodePtr
variableNameMap.push_back(variableNamePair);
mapVariablesFound = true;

} else if (childNode->isTextNode()) {
} else if (childNode->isText()) {
const std::string textNode = childNode->convertToString();
// Ignore whitespace when parsing.
if (hasNonWhitespaceCharacters(textNode)) {
Expand All @@ -794,7 +794,7 @@ void Parser::ParserImpl::loadConnection(const ModelPtr &model, const XmlNodePtr
err->setKind(Error::Kind::CONNECTION);
mParser->addError(err);
}
} else if (childNode->isCommentNode()) {
} else if (childNode->isComment()) {
// Do nothing.
} else {
ErrorPtr err = std::make_shared<Error>();
Expand Down Expand Up @@ -971,7 +971,7 @@ void Parser::ParserImpl::loadEncapsulation(const ModelPtr &model, const XmlNodeP
} else if (parentComponent) {
parentComponent->setEncapsulationId(encapsulationId);
}
} else if (parentComponentNode->isTextNode()) {
} else if (parentComponentNode->isText()) {
const std::string textNode = parentComponentNode->convertToString();
// Ignore whitespace when parsing.
if (hasNonWhitespaceCharacters(textNode)) {
Expand Down Expand Up @@ -1077,7 +1077,7 @@ void Parser::ParserImpl::loadEncapsulation(const ModelPtr &model, const XmlNodeP
childComponent->setEncapsulationId(childEncapsulationId );
}

} else if (childComponentNode->isTextNode()) {
} else if (childComponentNode->isText()) {
const std::string textNode = childComponentNode->convertToString();
// Ignore whitespace when parsing.
if (hasNonWhitespaceCharacters(textNode)) {
Expand Down Expand Up @@ -1195,7 +1195,7 @@ void Parser::ParserImpl::loadImport(const ImportSourcePtr &importSource, const M
if (!errorOccurred) {
model->addUnits(importedUnits);
}
} else if (childNode->isTextNode()) {
} else if (childNode->isText()) {
const std::string textNode = childNode->convertToString();
// Ignore whitespace when parsing.
if (hasNonWhitespaceCharacters(textNode)) {
Expand All @@ -1206,7 +1206,7 @@ void Parser::ParserImpl::loadImport(const ImportSourcePtr &importSource, const M
err->setRule(SpecificationRule::IMPORT_CHILD);
mParser->addError(err);
}
} else if (childNode->isCommentNode()) {
} else if (childNode->isComment()) {
// Do nothing.
} else {
ErrorPtr err = std::make_shared<Error>();
Expand Down Expand Up @@ -1302,7 +1302,7 @@ void Parser::ParserImpl::loadReset(const ResetPtr &reset, const ComponentPtr &co
WhenPtr when = std::make_shared<When>();
loadWhen(when, reset, childNode);
reset->addWhen(when);
} else if (childNode->isTextNode()) {
} else if (childNode->isText()) {
const std::string textNode = childNode->convertToString();
// Ignore whitespace when parsing.
if (hasNonWhitespaceCharacters(textNode)) {
Expand All @@ -1314,7 +1314,7 @@ void Parser::ParserImpl::loadReset(const ResetPtr &reset, const ComponentPtr &co
err->setRule(SpecificationRule::RESET_CHILD);
mParser->addError(err);
}
} else if (childNode->isCommentNode()) {
} else if (childNode->isComment()) {
// Do nothing.
} else {
ErrorPtr err = std::make_shared<Error>();
Expand Down Expand Up @@ -1396,7 +1396,7 @@ void Parser::ParserImpl::loadWhen(const WhenPtr &when, const ResetPtr &reset, co
err->setRule(SpecificationRule::WHEN_CHILD);
mParser->addError(err);
}
} else if (childNode->isTextNode()) {
} else if (childNode->isText()) {
const std::string textNode = childNode->convertToString();
ErrorPtr err = std::make_shared<Error>();
err->setDescription("When in reset referencing variable '" + referencedVariableName +
Expand All @@ -1405,7 +1405,7 @@ void Parser::ParserImpl::loadWhen(const WhenPtr &when, const ResetPtr &reset, co
err->setWhen(when);
err->setRule(SpecificationRule::WHEN_CHILD);
mParser->addError(err);
} else if (childNode->isCommentNode()) {
} else if (childNode->isComment()) {
// Do nothing.
} else {
ErrorPtr err = std::make_shared<Error>();
Expand Down
8 changes: 4 additions & 4 deletions src/validator.cpp
Expand Up @@ -861,7 +861,7 @@ void Validator::ValidatorImpl::validateAndCleanMathCiCnNodes(XmlNodePtr &node, c
bool cnType = node->isElement("cn", MATHML_NS);
if (ciType || cnType) {
if (childNode) {
if (childNode->isTextNode()) {
if (childNode->isText()) {
textNode = childNode->convertToString();
if (hasNonWhitespaceCharacters(textNode)) {
if (ciType) {
Expand Down Expand Up @@ -978,7 +978,7 @@ void Validator::ValidatorImpl::validateMathMLElements(const XmlNodePtr &node, co
{
XmlNodePtr childNode = node->getFirstChild();
if (childNode) {
if (!childNode->isTextNode() && !isSupportedMathMLElement(childNode)) {
if (!childNode->isText() && !isSupportedMathMLElement(childNode)) {
ErrorPtr err = std::make_shared<Error>();
err->setDescription("Math has a '" + childNode->getName() + "' element" +
" that is not a supported MathML element.");
Expand All @@ -991,7 +991,7 @@ void Validator::ValidatorImpl::validateMathMLElements(const XmlNodePtr &node, co

XmlNodePtr nextNode = node->getNext();
if (nextNode) {
if (!nextNode->isTextNode() && !isSupportedMathMLElement(nextNode)) {
if (!nextNode->isText() && !isSupportedMathMLElement(nextNode)) {
ErrorPtr err = std::make_shared<Error>();
err->setDescription("Math has a '" + nextNode->getName() + "' element" +
" that is not a supported MathML element.");
Expand All @@ -1010,7 +1010,7 @@ void Validator::ValidatorImpl::gatherMathBvarVariableNames(XmlNodePtr &node, std
if ((childNode) && (childNode->isElement("ci", MATHML_NS))) {
XmlNodePtr grandchildNode = childNode->getFirstChild();
if (grandchildNode) {
if (grandchildNode->isTextNode()) {
if (grandchildNode->isText()) {
std::string textNode = grandchildNode->convertToString();
if (hasNonWhitespaceCharacters(textNode)) {
bvarNames.push_back(textNode);
Expand Down
4 changes: 2 additions & 2 deletions src/xmlnode.cpp
Expand Up @@ -77,12 +77,12 @@ bool XmlNode::isCellmlElement(const char *name)
return isElement(name, CELLML_2_0_NS);
}

bool XmlNode::isTextNode()
bool XmlNode::isText()
{
return mPimpl->mXmlNodePtr->type == XML_TEXT_NODE;
}

bool XmlNode::isCommentNode()
bool XmlNode::isComment()
{
return mPimpl->mXmlNodePtr->type == XML_COMMENT_NODE;
}
Expand Down
4 changes: 2 additions & 2 deletions src/xmlnode.h
Expand Up @@ -102,7 +102,7 @@ class XmlNode
*
* @return @c true if this @c XmlNode is a text node and @c false otherwise.
*/
bool isTextNode();
bool isText();

/**
* @brief Check if this @c XmlNode is a comment node.
Expand All @@ -113,7 +113,7 @@ class XmlNode
* @return @c true if this @c XmlNode is a comment node and @c false
* otherwise.
*/
bool isCommentNode();
bool isComment();

/**
* @brief Get the name of the XML element.
Expand Down

0 comments on commit 9a34b94

Please sign in to comment.