From 2fc09337c08bab0340e2300ba6d9ac205cd86268 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Mon, 15 Sep 2014 18:04:57 +0000 Subject: [PATCH] Deprecate XML_Node::operator() --- include/cantera/base/xml.h | 1 + src/base/ctml.cpp | 14 +++++++------- src/base/xml.cpp | 3 +++ src/kinetics/importKinetics.cpp | 10 +++++----- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/include/cantera/base/xml.h b/include/cantera/base/xml.h index a7deca896..f5a127155 100644 --- a/include/cantera/base/xml.h +++ b/include/cantera/base/xml.h @@ -225,6 +225,7 @@ public: //! Overloaded parenthesis operator returns the value of the Node /*! * @return Returns the value of the node as a string. + * @deprecated Use value() instead. */ std::string operator()() const; diff --git a/src/base/ctml.cpp b/src/base/ctml.cpp index 5eb80ff8d..02f7ed9ad 100644 --- a/src/base/ctml.cpp +++ b/src/base/ctml.cpp @@ -201,7 +201,7 @@ void getIntegers(const Cantera::XML_Node& node, for (size_t i = 0; i < f.size(); i++) { const XML_Node& fi = *f[i]; if (fi["min"] != "" && fi["max"] != "") { - v[fi["title"]] = intValue(fi()); + v[fi["title"]] = fi.int_value(); } } } @@ -222,16 +222,16 @@ doublereal getFloatCurrent(const Cantera::XML_Node& node, const std::string& type) { doublereal fctr = 1.0; - doublereal x = fpValue(node()); + doublereal x = node.fp_value(); const string& units = node["units"]; const string& vmin = node["min"]; const string& vmax = node["max"]; if (vmin != "" && x < fpValue(vmin) - Tiny) { - writelog("\nWarning: value "+node()+" is below lower limit of " + writelog("\nWarning: value "+node.value()+" is below lower limit of " +vmin+".\n"); } if (node["max"] != "" && x > fpValue(vmax) + Tiny) { - writelog("\nWarning: value "+node()+" is above upper limit of " + writelog("\nWarning: value "+node.value()+" is above upper limit of " +vmax+".\n"); } // Note, most types of converters default to toSI() type atm. @@ -322,15 +322,15 @@ int getInteger(const Cantera::XML_Node& parent, const std::string& name) "no child XML element named " + name); } const XML_Node& node = parent.child(name); - int x = intValue(node()); + int x = node.int_value(); const string& vmin = node["min"]; const string& vmax = node["max"]; if (vmin != "" && x < intValue(vmin)) { - writelog("\nWarning: value "+node()+" is below lower limit of " + writelog("\nWarning: value "+node.value()+" is below lower limit of " +vmin+".\n"); } if (node["max"] != "" && x > intValue(vmax)) { - writelog("\nWarning: value "+node()+" is above upper limit of " + writelog("\nWarning: value "+node.value()+" is above upper limit of " +vmax+".\n"); } return x; diff --git a/src/base/xml.cpp b/src/base/xml.cpp index 791ddd75b..f147ca1e5 100644 --- a/src/base/xml.cpp +++ b/src/base/xml.cpp @@ -8,6 +8,7 @@ #include "cantera/base/xml.h" #include "cantera/base/stringUtils.h" +#include "cantera/base/global.h" #include @@ -464,6 +465,8 @@ std::string XML_Node::value() const std::string XML_Node::operator()() const { + warn_deprecated("XML_Node::operator()", + "To be removed after Cantera 2.2. Use XML_Node::value()."); return m_value; } diff --git a/src/kinetics/importKinetics.cpp b/src/kinetics/importKinetics.cpp index b35f50fa1..4a30e1091 100644 --- a/src/kinetics/importKinetics.cpp +++ b/src/kinetics/importKinetics.cpp @@ -217,7 +217,7 @@ bool getReagents(const XML_Node& rxn, Kinetics& kin, int rp, throw CanteraError("getReagents", "reaction order specified for non-reactant: " +sp); - forder = fpValue(oo()); + forder = oo.fp_value(); if (forder < 0.0) { throw CanteraError("getReagents", "reaction order must be non-negative"); @@ -311,7 +311,7 @@ bool getOrders(const XML_Node& rxnNode, Kinetics& kin, doublereal forder; for (size_t nn = 0; nn < ord.size(); nn++) { const XML_Node& oo = *ord[nn]; - forder = fpValue(oo()); + forder = oo.fp_value(); std::string spName = oo["species"]; size_t k = kin.kineticsSpeciesIndex(spName); if (k == npos) { @@ -483,11 +483,11 @@ bool getRxnFormulation(const XML_Node& rxnNode, Kinetics& kin, if (rfNode.hasChild("affinityPower")) { XML_Node& fNode = rxnNode.child("affinityPower"); - affinityPower = fpValueCheck( fNode() ); + affinityPower = fNode.fp_value(); } if (rfNode.hasChild("equilibriumConstantPower")) { XML_Node& eNode = rxnNode.child("equilibriumConstantPower"); - equilibriumConstantPower = fpValueCheck( eNode() ); + equilibriumConstantPower = eNode.fp_value(); } } return true; @@ -1003,7 +1003,7 @@ bool rxninfo::installReaction(int iRxn, const XML_Node& rxnNode, Kinetics& kin, // if (rxnNode.hasChild("filmResistivity")) { XML_Node& fNode = rxnNode.child("filmResistivity"); - rdata.filmResistivity = fpValueCheck( fNode() ); + rdata.filmResistivity = fNode.fp_value(); } } //