Use XML_Node::attrib when it is more clear than using operator[]

This commit is contained in:
Ray Speth 2014-11-15 00:47:31 +00:00
parent de3d212062
commit ced2d20dd8
14 changed files with 27 additions and 27 deletions

View file

@ -154,7 +154,7 @@ void getString(const Cantera::XML_Node& node, const std::string& titleString, st
XML_Node* s = getByTitle(node, titleString);
if (s && s->name() == "string") {
valueString = s->value();
typeString = (*s)["type"];
typeString = s->attrib("type");
} else {
valueString = "";
typeString = "";
@ -174,8 +174,8 @@ void getNamedStringValue(const Cantera::XML_Node& node, const std::string& nameS
} else {
XML_Node* s = getByTitle(node, nameString);
if (s && s->name() == "string") {
valueString = (*s).value();
typeString = (*s)["type"];
valueString = s->value();
typeString = s->attrib("type");
}
}
}

View file

@ -646,7 +646,7 @@ bool installReactionArrays(const XML_Node& p, Kinetics& kin,
const XML_Node* r = allrxns[i];
string rxid;
if (r) {
rxid = (*r)["id"];
rxid = r->attrib("id");
if (iwild != string::npos) {
rxid = rxid.substr(0,iwild);
}

View file

@ -253,7 +253,7 @@ void MineralEQ3::initThermoXML(XML_Node& phaseNode, const std::string& id_)
"no standard state mode");
}
doublereal volVal = 0.0;
string smodel = (*aStandardState)["model"];
string smodel = aStandardState->attrib("model");
if (smodel != "constantVolume") {
throw CanteraError("MineralEQ3::initThermoXML",
"wrong standard state mode");

View file

@ -151,7 +151,7 @@ Mu0Poly* newMu0ThermoFromXML(const std::string& speciesName,
* form. If they were, then the assumed temperature needs to be
* adjusted from the assumed T = 273.15
*/
string uuu = (*valNode_ptr)["units"];
string uuu = valNode_ptr->attrib("units");
if (uuu == "Dimensionless") {
dimensionlessMu0Values = true;
}

View file

@ -84,7 +84,7 @@ void PDSS_ConstVol::constructPDSSXML(VPStandardStateTP* tp, size_t spindex,
throw CanteraError("PDSS_ConstVol::constructPDSSXML",
"no standardState Node for species " + speciesNode.name());
}
std::string model = (*ss)["model"];
std::string model = ss->attrib("model");
if (model != "constant_incompressible") {
throw CanteraError("PDSS_ConstVol::initThermoXML",
"standardState model for species isn't constant_incompressible: " + speciesNode.name());

View file

@ -575,7 +575,7 @@ void PDSS_HKFT::constructPDSSXML(VPStandardStateTP* tp, size_t spindex,
throw CanteraError("PDSS_HKFT::constructPDSSXML",
"no thermo Node for species " + speciesNode.name());
}
std::string model = lowercase((*tn)["model"]);
std::string model = lowercase(tn->attrib("model"));
if (model != "hkft") {
throw CanteraError("PDSS_HKFT::initThermoXML",
"thermo model for species isn't hkft: "
@ -589,17 +589,17 @@ void PDSS_HKFT::constructPDSSXML(VPStandardStateTP* tp, size_t spindex,
// go get the attributes
m_p0 = OneAtm;
std::string p0string = (*hh)["Pref"];
std::string p0string = hh->attrib("Pref");
if (p0string != "") {
m_p0 = strSItoDbl(p0string);
}
std::string minTstring = (*hh)["Tmin"];
std::string minTstring = hh->attrib("Tmin");
if (minTstring != "") {
m_minTemp = fpValueCheck(minTstring);
}
std::string maxTstring = (*hh)["Tmax"];
std::string maxTstring = hh->attrib("Tmax");
if (maxTstring != "") {
m_maxTemp = fpValueCheck(maxTstring);
}
@ -627,7 +627,7 @@ void PDSS_HKFT::constructPDSSXML(VPStandardStateTP* tp, size_t spindex,
throw CanteraError("PDSS_HKFT::constructPDSSXML",
"no standardState Node for species " + speciesNode.name());
}
model = lowercase((*ss)["model"]);
model = lowercase(ss->attrib("model"));
if (model != "hkft") {
throw CanteraError("PDSS_HKFT::initThermoXML",
"standardState model for species isn't hkft: "

View file

@ -119,7 +119,7 @@ void PDSS_IonsFromNeutral::constructPDSSXML(VPStandardStateTP* tp, size_t spinde
throw CanteraError("PDSS_IonsFromNeutral::constructPDSSXML",
"no thermo Node for species " + speciesNode.name());
}
std::string model = lowercase((*tn)["model"]);
std::string model = lowercase(tn->attrib("model"));
if (model != "ionfromneutral") {
throw CanteraError("PDSS_IonsFromNeutral::constructPDSSXML",
"thermo model for species isn't IonsFromNeutral: "

View file

@ -98,7 +98,7 @@ void PDSS_SSVol::constructPDSSXML(VPStandardStateTP* tp, size_t spindex,
throw CanteraError("PDSS_SSVol::constructPDSSXML",
"no standardState Node for species " + speciesNode.name());
}
std::string model = (*ss)["model"];
std::string model = ss->attrib("model");
if (model == "constant_incompressible" || model == "constant") {
volumeModel_ = cSSVOLUME_CONSTANT;
m_constMolarVolume = ctml::getFloat(*ss, "molarVolume", "toSI");

View file

@ -117,7 +117,7 @@ VPSSMgr_ConstVol::initThermoXML(XML_Node& phaseNode, const std::string& id)
throw CanteraError("VPSSMgr_ConstVol::initThermoXML",
"no standardState Node for species " + s->attrib("name"));
}
std::string model = (*ss)["model"];
std::string model = ss->attrib("model");
if (model != "constant_incompressible" && model != "constantVolume") {
throw CanteraError("VPSSMgr_ConstVol::initThermoXML",
"standardState model for species isn't constant_incompressible: " + s->attrib("name"));
@ -135,7 +135,7 @@ VPSSMgr_ConstVol::createInstallPDSS(size_t k, const XML_Node& speciesNode,
throw CanteraError("VPSSMgr_ConstVol::createInstallPDSS",
"no standardState Node for species " + speciesNode["name"]);
}
std::string model = (*ss)["model"];
std::string model = ss->attrib("model");
if (model != "constant_incompressible" && model != "constantVolume") {
throw CanteraError("VPSSMgr_ConstVol::createInstallPDSS",
"standardState model for species isn't "

View file

@ -156,7 +156,7 @@ VPSSMgr_General::returnPDSS_ptr(size_t k, const XML_Node& speciesNode,
kPDSS = new PDSS_IdealGas(m_vptp_ptr, k, speciesNode, *phaseNode_ptr, true);
return kPDSS;
}
std::string model = (*ss)["model"];
std::string model = ss->attrib("model");
if (model == "constant_incompressible") {
VPSSMgr::installSTSpecies(k, speciesNode, phaseNode_ptr);
kPDSS = new PDSS_ConstVol(m_vptp_ptr, k, speciesNode, *phaseNode_ptr, true);

View file

@ -93,7 +93,7 @@ VPSSMgr_IdealGas::createInstallPDSS(size_t k, const XML_Node& speciesNode,
{
const XML_Node* ss = speciesNode.findByName("standardState");
if (ss) {
std::string model = (*ss)["model"];
std::string model = ss->attrib("model");
if (model != "ideal_gas") {
throw CanteraError("VPSSMgr_IdealGas::createInstallPDSS",
"standardState model for species isn't "

View file

@ -231,13 +231,13 @@ VPSSMgr_Water_ConstVol::initThermoXML(XML_Node& phaseNode, const std::string& id
}
const XML_Node* ss = s->findByName("standardState");
if (!ss) {
std::string sName = s->operator[]("name");
std::string sName = s->attrib("name");
throw CanteraError("VPSSMgr_Water_ConstVol::initThermoXML",
"no standardState Node for species " + sName);
}
std::string model = (*ss)["model"];
std::string model = ss->attrib("model");
if (model != "constant_incompressible") {
std::string sName = s->operator[]("name");
std::string sName = s->attrib("name");
throw CanteraError("VPSSMgr_Water_ConstVol::initThermoXML",
"standardState model for species isn't "
"constant_incompressible: " + sName);
@ -261,7 +261,7 @@ VPSSMgr_Water_ConstVol::createInstallPDSS(size_t k, const XML_Node& speciesNode,
"h2o wrong name: " + xn);
}
const XML_Node* ss = speciesNode.findByName("standardState");
std::string model = (*ss)["model"];
std::string model = ss->attrib("model");
if (model != "waterIAPWS" && model != "waterPDSS") {
throw CanteraError("VPSSMgr_Water_ConstVol::installSpecies",
"wrong SS mode: " + model);
@ -284,7 +284,7 @@ VPSSMgr_Water_ConstVol::createInstallPDSS(size_t k, const XML_Node& speciesNode,
throw CanteraError("VPSSMgr_Water_ConstVol::installSpecies",
"no standardState Node for species " + speciesNode.name());
}
std::string model = (*ss)["model"];
std::string model = ss->attrib("model");
if (model != "constant_incompressible") {
throw CanteraError("VPSSMgr_Water_ConstVol::initThermoXML",
"standardState model for species isn't "

View file

@ -232,7 +232,7 @@ VPSSMgr_Water_HKFT::initThermoXML(XML_Node& phaseNode, const std::string& id)
throw CanteraError("VPSSMgr_Water_HKFT::initThermoXML",
"No standardState Node for species " + sss[k]);
}
std::string model = lowercase((*ss)["model"]);
std::string model = lowercase(ss->attrib("model"));
if (model != "hkft") {
throw CanteraError("VPSSMgr_Water_HKFT::initThermoXML",
"Standard state model for a solute species isn't "
@ -263,7 +263,7 @@ VPSSMgr_Water_HKFT::createInstallPDSS(size_t k, const XML_Node& speciesNode,
"h2o wrong name: " + xn);
}
std::string model = (*ss)["model"];
std::string model = ss->attrib("model");
if (model != "waterIAPWS" && model != "waterPDSS") {
throw CanteraError("VPSSMgr_Water_HKFT::installSpecies",
"wrong SS mode: " + model);
@ -281,7 +281,7 @@ VPSSMgr_Water_HKFT::createInstallPDSS(size_t k, const XML_Node& speciesNode,
kPDSS = m_waterSS;
} else {
std::string model = (*ss)["model"];
std::string model = ss->attrib("model");
if (model != "HKFT") {
std::string sName = speciesNode["name"];
throw CanteraError("VPSSMgr_Water_HKFT::initThermoXML",

View file

@ -955,7 +955,7 @@ void TransportFactory::getLiquidInteractionsTransportData(const XML_Node& transp
throw CanteraError("TransportFactory::getLiquidInteractionsTransportData",
"Unknown compositionDependence string: " + modelName);
} else {
trParam.compositionDepTypeDefault_ = (*it).second;
trParam.compositionDepTypeDefault_ = it->second;
}
} else {
if (tranTypeNode.hasChild("compositionDependence")) {