Skip to content

Commit

Permalink
Some minor cleaning up.
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Feb 5, 2020
1 parent 776b7f9 commit f6075c3
Showing 1 changed file with 11 additions and 28 deletions.
39 changes: 11 additions & 28 deletions src/plugins/support/CellMLSupport/src/cellmlfile.cpp
Expand Up @@ -146,8 +146,7 @@ void CellmlFile::retrieveImports(const QString &pXmlBase,
{
// Retrieve all the imports of the given model

ObjRef<iface::cellml_api::CellMLImportSet> imports = pModel->imports();
ObjRef<iface::cellml_api::CellMLImportIterator> importsIter = imports->iterateImports();
ObjRef<iface::cellml_api::CellMLImportIterator> importsIter = pModel->imports()->iterateImports();

for (ObjRef<iface::cellml_api::CellMLImport> import = importsIter->nextImport();
import != nullptr; import = importsIter->nextImport()) {
Expand Down Expand Up @@ -211,8 +210,7 @@ bool CellmlFile::fullyInstantiateImports(iface::cellml_api::Model *pModel,
// retrieve the contents of the import ourselves and
// instantiate it from text instead...

ObjRef<iface::cellml_api::URI> xlinkHref = import->xlinkHref();
QString xlinkHrefString = QString::fromStdWString(xlinkHref->asText());
QString xlinkHrefString = QString::fromStdWString(import->xlinkHref()->asText());
QString url = QUrl(importXmlBase).resolved(xlinkHrefString).toString();
bool isLocalFile;
QString fileNameOrUrl;
Expand Down Expand Up @@ -334,8 +332,7 @@ bool CellmlFile::load(const QString &pFileContents,

// Get a bootstrap object and its model loader

ObjRef<iface::cellml_api::CellMLBootstrap> cellmlBootstrap = CreateCellMLBootstrap();
ObjRef<iface::cellml_api::DOMModelLoader> modelLoader = cellmlBootstrap->modelLoader();
ObjRef<iface::cellml_api::DOMModelLoader> modelLoader = CreateCellMLBootstrap()->modelLoader();

// Try to create the model

Expand Down Expand Up @@ -394,8 +391,7 @@ void CellmlFile::retrieveCmetaIdsFromCellmlElement(iface::cellml_api::CellMLElem

// Do the same for all the child elements of the given CellML element

ObjRef<iface::cellml_api::CellMLElementSet> childElements = pElement->childElements();
ObjRef<iface::cellml_api::CellMLElementIterator> childElementsIter = childElements->iterate();
ObjRef<iface::cellml_api::CellMLElementIterator> childElementsIter = pElement->childElements()->iterate();

try {
for (ObjRef<iface::cellml_api::CellMLElement> childElement = childElementsIter->next();
Expand Down Expand Up @@ -464,8 +460,7 @@ bool CellmlFile::load()

if (mRdfApiRepresentation != nullptr) {
mRdfDataSource = mRdfApiRepresentation->source();
ObjRef<iface::rdf_api::TripleSet> rdfTriples = mRdfDataSource->getAllTriples();
ObjRef<iface::rdf_api::TripleEnumerator> rdfTriplesEnumerator = rdfTriples->enumerateTriples();
ObjRef<iface::rdf_api::TripleEnumerator> rdfTriplesEnumerator = mRdfDataSource->getAllTriples()->enumerateTriples();

for (ObjRef<iface::rdf_api::Triple> rdfTriple = rdfTriplesEnumerator->getNextTriple();
rdfTriple != nullptr; rdfTriple = rdfTriplesEnumerator->getNextTriple()) {
Expand Down Expand Up @@ -621,9 +616,7 @@ bool CellmlFile::isValid(iface::cellml_api::Model *pModel,
// We are dealing with a CellML representation issue, so determine
// its line and column

ObjRef<iface::dom::Node> errorNode = cellmlRepresentationValidityError->errorNode();

line = vacssService->getPositionInXML(errorNode,
line = vacssService->getPositionInXML(cellmlRepresentationValidityError->errorNode(),
cellmlRepresentationValidityError->errorNodalOffset(),
&column);
} else {
Expand All @@ -639,9 +632,7 @@ bool CellmlFile::isValid(iface::cellml_api::Model *pModel,
ObjRef<iface::cellml_api::CellMLElement> cellmlElement = cellmlSemanticValidityError->errorElement();
ObjRef<iface::cellml_api::CellMLDOMElement> cellmlDomElement = QueryInterface(cellmlElement);

ObjRef<iface::dom::Element> domElement = cellmlDomElement->domElement();

line = vacssService->getPositionInXML(domElement, 0, &column);
line = vacssService->getPositionInXML(cellmlDomElement->domElement(), 0, &column);

// Also determine its imported file, if any

Expand All @@ -661,9 +652,7 @@ bool CellmlFile::isValid(iface::cellml_api::Model *pModel,
ObjRef<iface::cellml_api::CellMLImport> importCellmlElement = QueryInterface(importedCellmlElement);

if (importCellmlElement != nullptr) {
ObjRef<iface::cellml_api::URI> xlinkHref = importCellmlElement->xlinkHref();

importedFileInfo = QString::fromStdWString(xlinkHref->asText());
importedFileInfo = QString::fromStdWString(importCellmlElement->xlinkHref()->asText());
importedFileName = Core::canonicalFileName(QFileInfo(mFileName).path()+"/"+importedFileInfo);
}
}
Expand Down Expand Up @@ -1014,9 +1003,7 @@ QString CellmlFile::xmlBase()
// Return our base URI

if (load()) {
ObjRef<iface::cellml_api::URI> baseUri = mModel->xmlBase();

return QString::fromStdWString(baseUri->asText());
return QString::fromStdWString(mModel->xmlBase()->asText());
}

return {};
Expand Down Expand Up @@ -1188,12 +1175,10 @@ CellmlFile::Version CellmlFile::fileVersion(const QString &pFileName)
{
// Return the version of the given CellML file

ObjRef<iface::cellml_api::CellMLBootstrap> cellmlBootstrap = CreateCellMLBootstrap();
ObjRef<iface::cellml_api::DOMModelLoader> modelLoader = cellmlBootstrap->modelLoader();
ObjRef<iface::cellml_api::Model> model;

try {
model = modelLoader->loadFromURL(QUrl::fromPercentEncoding(QUrl::fromLocalFile(pFileName).toEncoded()).toStdWString());
model = CreateCellMLBootstrap()->modelLoader()->loadFromURL(QUrl::fromPercentEncoding(QUrl::fromLocalFile(pFileName).toEncoded()).toStdWString());
} catch (...) {
return Version::Unknown;
}
Expand All @@ -1207,12 +1192,10 @@ CellmlFile::Version CellmlFile::fileContentsVersion(const QString &pFileContents
{
// Return the version of the given CellML file contents

ObjRef<iface::cellml_api::CellMLBootstrap> cellmlBootstrap = CreateCellMLBootstrap();
ObjRef<iface::cellml_api::DOMModelLoader> modelLoader = cellmlBootstrap->modelLoader();
ObjRef<iface::cellml_api::Model> model;

try {
model = modelLoader->createFromText(pFileContents.toStdWString());
model = CreateCellMLBootstrap()->modelLoader()->createFromText(pFileContents.toStdWString());
} catch (...) {
return Version::Unknown;
}
Expand Down

0 comments on commit f6075c3

Please sign in to comment.