From c708682e565b4f38cd267b06e0917302bd727f01 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Mon, 23 Jan 2012 03:36:42 +0000 Subject: [PATCH] Removed 'using namespace std' from all header files --- Cantera/clib/src/ctfunc.cpp | 4 +-- Cantera/clib/src/ctreactor.cpp | 2 +- Cantera/cxx/demos/kinetics1/example_utils.h | 1 - Cantera/cxx/include/zerodim.h | 2 -- Cantera/matlab/src/ctmatutils.h | 1 - Cantera/matlab/src/mllogger.h | 1 - Cantera/python/src/pylogger.h | 2 -- Cantera/src/converters/CKParser.h | 13 ++++---- Cantera/src/converters/CKReader.h | 1 - Cantera/src/converters/Constituent.h | 3 +- Cantera/src/converters/Element.h | 14 ++++----- Cantera/src/converters/Reaction.cpp | 10 +++---- Cantera/src/converters/Reaction.h | 32 +++++++------------- Cantera/src/converters/RxnSpecies.h | 8 ++--- Cantera/src/converters/Species.h | 17 +++++------ Cantera/src/converters/ckr_defs.h | 1 - Cantera/src/converters/ckr_utils.h | 33 +++++++-------------- Cantera/src/converters/writelog.h | 3 +- Cantera/src/kinetics/Group.h | 1 - Cantera/src/numerics/Func1.h | 1 - Cantera/src/thermo/PureFluidPhase.cpp | 8 +++-- Cantera/src/transport/AqueousTransport.h | 10 +++---- Cantera/src/transport/LiquidTransport.h | 4 +-- Cantera/src/transport/MixTransport.h | 18 +++++------ Cantera/src/transport/SimpleTransport.h | 2 -- Cantera/src/transport/WaterTransport.h | 2 -- apps/bvp/BoundaryValueProblem.h | 1 - ext/tpx/CarbonDioxide.cpp | 4 +-- ext/tpx/Sub.cpp | 2 ++ ext/tpx/Sub.h | 13 ++++---- ext/tpx/utils.cpp | 2 ++ test_problems/cxx_ex/equil_example1.cpp | 22 +++++++------- test_problems/cxx_ex/example_utils.h | 6 ++-- test_problems/cxx_ex/kinetics_example2.cpp | 22 +++++++------- test_problems/cxx_ex/kinetics_example3.cpp | 6 ++-- test_problems/cxx_ex/rxnpath_example1.cpp | 10 ++++--- test_problems/cxx_ex/transport_example1.cpp | 12 ++++---- test_problems/cxx_ex/transport_example2.cpp | 12 ++++---- 38 files changed, 135 insertions(+), 171 deletions(-) diff --git a/Cantera/clib/src/ctfunc.cpp b/Cantera/clib/src/ctfunc.cpp index a1144556e..a3951163b 100755 --- a/Cantera/clib/src/ctfunc.cpp +++ b/Cantera/clib/src/ctfunc.cpp @@ -142,8 +142,8 @@ extern "C" { int DLL_EXPORT func_write(int i, size_t lennm, const char* arg, char* nm) { try { - string a = string(arg); - string w = _func(i)->write(a); + std::string a = std::string(arg); + std::string w = _func(i)->write(a); size_t ws = w.size(); size_t lout = (lennm > ws ? ws : lennm); std::copy(w.c_str(), w.c_str() + lout, nm); diff --git a/Cantera/clib/src/ctreactor.cpp b/Cantera/clib/src/ctreactor.cpp index 985e59acc..3a42371ff 100755 --- a/Cantera/clib/src/ctreactor.cpp +++ b/Cantera/clib/src/ctreactor.cpp @@ -177,7 +177,7 @@ extern "C" { if (r->type() >= ReactorType) return ((Reactor*)r)->nSensParams(); else { - cout << "type problem..." << r->type() << endl; + std::cout << "type problem..." << r->type() << std::endl; return 0; } } diff --git a/Cantera/cxx/demos/kinetics1/example_utils.h b/Cantera/cxx/demos/kinetics1/example_utils.h index 236dff6d8..6a3100510 100644 --- a/Cantera/cxx/demos/kinetics1/example_utils.h +++ b/Cantera/cxx/demos/kinetics1/example_utils.h @@ -5,7 +5,6 @@ #include using namespace Cantera; -using namespace std; // Save the temperature, density, pressure, and mole fractions at one // time diff --git a/Cantera/cxx/include/zerodim.h b/Cantera/cxx/include/zerodim.h index 68c6e760b..4351d6f36 100644 --- a/Cantera/cxx/include/zerodim.h +++ b/Cantera/cxx/include/zerodim.h @@ -8,7 +8,5 @@ #include "kernel/FlowReactor.h" #include "kernel/ConstPressureReactor.h" -using namespace CanteraZeroD; - #endif diff --git a/Cantera/matlab/src/ctmatutils.h b/Cantera/matlab/src/ctmatutils.h index ba872b62a..5ad3e6c55 100755 --- a/Cantera/matlab/src/ctmatutils.h +++ b/Cantera/matlab/src/ctmatutils.h @@ -2,7 +2,6 @@ const double Undef = -999.123; //const double DERR = -999.999; #include -using namespace std; void reportError(); diff --git a/Cantera/matlab/src/mllogger.h b/Cantera/matlab/src/mllogger.h index 67470aeca..a0205b9bc 100644 --- a/Cantera/matlab/src/mllogger.h +++ b/Cantera/matlab/src/mllogger.h @@ -9,7 +9,6 @@ #include "cantera/kernel/logger.h" #include -//using namespace std; static std::string ss = "disp(' "; diff --git a/Cantera/python/src/pylogger.h b/Cantera/python/src/pylogger.h index 9a84139cb..62d33c94c 100644 --- a/Cantera/python/src/pylogger.h +++ b/Cantera/python/src/pylogger.h @@ -5,8 +5,6 @@ #include #include "cantera/kernel/logger.h" -using namespace std; - static std::string ss = "print \"\"\" "; namespace Cantera { diff --git a/Cantera/src/converters/CKParser.h b/Cantera/src/converters/CKParser.h index a34b7bde2..140345f1d 100755 --- a/Cantera/src/converters/CKParser.h +++ b/Cantera/src/converters/CKParser.h @@ -11,7 +11,6 @@ #include #include #include -//using namespace std; #include "ckr_defs.h" #include "Element.h" @@ -53,17 +52,17 @@ namespace ckr { bool readElementSection(elementList& elements); bool readSpeciesSection(speciesList& species); - bool readThermoSection(vector& names, - speciesTable& speciesData, vector_fp& temp, - int& optionFlag, ostream& log); - bool readReactionSection(const vector& speciesNames, - vector& elementNames, + bool readThermoSection(std::vector& names, + speciesTable& speciesData, vector_fp& temp, + int& optionFlag, std::ostream& log); + bool readReactionSection(const std::vector& speciesNames, + std::vector& elementNames, reactionList& reactions, ReactionUnits& units); bool advanceToKeyword(const std::string& kw, const std::string& stop); bool verbose; bool debug; - bool readNASA9ThermoSection(std::vector& names, + bool readNASA9ThermoSection(std::vector& names, speciesTable& species, vector_fp& temp, int& optionFlag, std::ostream& log); diff --git a/Cantera/src/converters/CKReader.h b/Cantera/src/converters/CKReader.h index 56515423a..64c87933d 100755 --- a/Cantera/src/converters/CKReader.h +++ b/Cantera/src/converters/CKReader.h @@ -18,7 +18,6 @@ #include #include -using namespace std; namespace ckr { diff --git a/Cantera/src/converters/Constituent.h b/Cantera/src/converters/Constituent.h index d8daf5d06..c81773045 100755 --- a/Cantera/src/converters/Constituent.h +++ b/Cantera/src/converters/Constituent.h @@ -11,7 +11,6 @@ #include #include -using namespace std; namespace ckr { @@ -22,7 +21,7 @@ namespace ckr { */ class Constituent { public: - string name; //!< The name of the object. + std::string name; //!< The name of the object. double number; //!< The number of units (molecules, etc.). }; diff --git a/Cantera/src/converters/Element.h b/Cantera/src/converters/Element.h index 5ba352502..25aeb5f95 100755 --- a/Cantera/src/converters/Element.h +++ b/Cantera/src/converters/Element.h @@ -12,8 +12,6 @@ #include #include -using namespace std; - namespace ckr { /** @@ -41,7 +39,7 @@ public: /// Construct a new empty Element object - Element(const string& nm, double wt) : + Element(const std::string& nm, double wt) : name(nm), atomicWeight(wt), valid(0), @@ -54,12 +52,12 @@ public: /// Destructor ~Element() {} - string name; //!< Element name + std::string name; //!< Element name double atomicWeight; //!< Atomic weight in amu int valid; //!< flag returned by validation routines int index; //!< index number bool weightFromDB; //!< true if atomic weight is not specified - string comment; //!< comment in input file + std::string comment; //!< comment in input file /** @@ -72,11 +70,11 @@ public: bool operator!=(const Element& e) const { return !(*this == e); } - friend ostream& operator<<(ostream& s, const Element& e) { + friend std::ostream& operator<<(std::ostream& s, const Element& e) { s << e.name; if (!e.weightFromDB) s << "/" << e.atomicWeight << "/"; if (e.comment != "") - s << " !" << e.comment << endl; + s << " !" << e.comment << std::endl; else s << " "; return s; @@ -84,7 +82,7 @@ public: }; /// a list (vector) of Elements -typedef vector elementList; +typedef std::vector elementList; } diff --git a/Cantera/src/converters/Reaction.cpp b/Cantera/src/converters/Reaction.cpp index d7c26c81f..e7a1050f8 100755 --- a/Cantera/src/converters/Reaction.cpp +++ b/Cantera/src/converters/Reaction.cpp @@ -59,10 +59,10 @@ namespace ckr { return *this; } - void Reaction::write(ostream& s) const { + void Reaction::write(std::ostream& s) const { int nl = static_cast(lines.size()); for (int nn = 0; nn < nl; nn++) { - s << lines[nn] << endl; + s << lines[nn] << std::endl; } // int nr = reactants.size(); // int np = products.size(); @@ -126,8 +126,8 @@ bool Reaction::operator==(const Reaction& r) const { if (int(r.reactants.size()) != nr || int(r.products.size()) != np || r.thirdBody != thirdBody) return false; - string nm; - map coeffs; + std::string nm; + std::map coeffs; for (int ir = 0; ir < nr; ir++) { coeffs[reactants[ir].name] = -reactants[ir].number; } @@ -145,7 +145,7 @@ bool Reaction::operator==(const Reaction& r) const { coeffs[nm] /= products[jp].number; } int nc = static_cast(coeffs.size()); - vector ratios; + std::vector ratios; getMapValues(coeffs, ratios); if (!isReversible && ratios[0] < 0.0) return false; diff --git a/Cantera/src/converters/Reaction.h b/Cantera/src/converters/Reaction.h index c626ea87e..1333bae4f 100755 --- a/Cantera/src/converters/Reaction.h +++ b/Cantera/src/converters/Reaction.h @@ -12,13 +12,11 @@ #include #include #include -using namespace std; #include "ckr_defs.h" #include "ckr_utils.h" #include "RxnSpecies.h" - namespace ckr { @@ -183,7 +181,7 @@ namespace ckr { * third body collision partners, or a species name if only * one species does. */ - string thirdBody; + std::string thirdBody; /// Reaction number. int number; @@ -192,21 +190,21 @@ namespace ckr { * list of species that participate as reactants, * and their stoichiometric coefficients */ - vector reactants; + std::vector reactants; - mutable map fwdOrder; + mutable std::map fwdOrder; /** * list of species that participate as products, * and their stoichiometric coefficients */ - vector products; + std::vector products; /** * map from species names to enhanced third-body collision efficiencies */ - mutable map e3b; + mutable std::map e3b; /** * Forward rate coefficient. For falloff reactions, this is the @@ -231,39 +229,31 @@ namespace ckr { /** * auxiliary data not handled elsewhere. */ - mutable map otherAuxData; + mutable std::map otherAuxData; /** * input file lines */ - vector lines; + std::vector lines; /** * comments */ - vector comment; + std::vector comment; // methods - double stoichCoefficient(const string& s) const; + double stoichCoefficient(const std::string& s) const; bool operator==(const Reaction& r) const; - void write(ostream& s) const; + void write(std::ostream& s) const; }; /// a list of Reaction objects - typedef vector reactionList; + typedef std::vector reactionList; Reaction forwardReaction(const Reaction& rxn); Reaction reverseReaction(const Reaction& rxn); } - - - #endif - - - - - diff --git a/Cantera/src/converters/RxnSpecies.h b/Cantera/src/converters/RxnSpecies.h index e49b46a79..1cc31878b 100755 --- a/Cantera/src/converters/RxnSpecies.h +++ b/Cantera/src/converters/RxnSpecies.h @@ -13,12 +13,10 @@ #include //#include "Cantera.h" -using namespace std; - namespace ckr { - typedef vector_int group_t; - typedef vector grouplist_t; + typedef vector_int group_t; + typedef std::vector grouplist_t; /** @@ -29,7 +27,7 @@ class RxnSpecies { public: RxnSpecies() : number(0) {} - string name; //!< The name of the object. + std::string name; //!< The name of the object. double number; //!< The number of units (molecules, etc.). grouplist_t groups; }; diff --git a/Cantera/src/converters/Species.h b/Cantera/src/converters/Species.h index ca5d9b24e..e4ddf9ad3 100755 --- a/Cantera/src/converters/Species.h +++ b/Cantera/src/converters/Species.h @@ -55,19 +55,18 @@ namespace ckr { int thermoFormatType; //! Species Name - string name; - string id; //!< ID tag from 'date' field in input - string phase; //!< Phase string. Usually "G", "L", or "S". + std::string name; + std::string id; //!< ID tag from 'date' field in input + std::string phase; //!< Phase string. Usually "G", "L", or "S". double tlow; //!< Min temperature for thermo data fit double tmid; //!< Mid temperature for thermo data fit double thigh; //!< Max temperature for thermo data fit - /// list of Constituent objects defining elemental composition - vector elements; + std::vector elements; /// map from element symbols to atom numbers - mutable map comp; + mutable std::map comp; /// polynomial coefficients for the lower temperature range vector_fp lowCoeffs; @@ -88,7 +87,7 @@ namespace ckr { /// position in the list of species in the input file int index; - string m_commentsRef; + std::string m_commentsRef; private: //! Delete private data @@ -96,10 +95,10 @@ namespace ckr { }; //! Shorthand for a list of Species - typedef vector speciesList; + typedef std::vector speciesList; //! A map from species names to Species objects - typedef map speciesTable; + typedef std::map speciesTable; } #endif diff --git a/Cantera/src/converters/ckr_defs.h b/Cantera/src/converters/ckr_defs.h index 8138974f7..0240bfd50 100755 --- a/Cantera/src/converters/ckr_defs.h +++ b/Cantera/src/converters/ckr_defs.h @@ -14,7 +14,6 @@ #include #include #include -//using namespace std; //#include "../ctvector.h" diff --git a/Cantera/src/converters/ckr_utils.h b/Cantera/src/converters/ckr_utils.h index ed4dbcef8..8df7de900 100755 --- a/Cantera/src/converters/ckr_utils.h +++ b/Cantera/src/converters/ckr_utils.h @@ -13,39 +13,30 @@ #include #include -using namespace std; - namespace ckr { /** - * * Fill vector 'keys' with the keys of map 'mp' - * */ - template -void getMapKeys(const map& mp, vector& keys) { +void getMapKeys(const std::map& mp, std::vector& keys) { keys.clear(); - typename map::const_iterator i = mp.begin(); + typename std::map::const_iterator i = mp.begin(); for (; i != mp.end(); ++i) keys.push_back(i->first); } /** - * * Fill vector 'values' with the values of map 'mp' - * */ - template -void getMapValues(const map& mp, vector& values) { +void getMapValues(const std::map& mp, std::vector& values) { values.clear(); - typename map::const_iterator i = mp.begin(); + typename std::map::const_iterator i = mp.begin(); for (; i != mp.end(); ++i) values.push_back(i->second); } - /** * * Template to compare two objects a and b, possibly of different @@ -109,10 +100,10 @@ inline bool valid(L& list) { /// Remove all white space from string s. -void removeWhiteSpace(string& s); +void removeWhiteSpace(std::string& s); -void getTokens(string& begin, - int n, vector& toks, char delim=' '); +void getTokens(std::string& begin, + int n, std::vector& toks, char delim=' '); /** @@ -123,15 +114,13 @@ void getTokens(string& begin, * in string s2 matches any character at that position. * * Example: if s1 = "elements", then match(s1, "ELEM") would return true. - * */ - -bool match(const string& s1, const string& s2); +bool match(const std::string& s1, const std::string& s2); /** * Check whether string 'word' begins with a Chemkin keyword. */ -inline bool isKeyword(string word) +inline bool isKeyword(std::string word) { return (match(word, "ELEM") || match(word, "SPEC") || @@ -141,8 +130,8 @@ inline bool isKeyword(string word) } -bool extractSlashData(string& s, string& name, string& data); -string capitalize(const string& word); +bool extractSlashData(std::string& s, std::string& name, std::string& data); +std::string capitalize(const std::string& word); } diff --git a/Cantera/src/converters/writelog.h b/Cantera/src/converters/writelog.h index b079d90bf..b8e436486 100755 --- a/Cantera/src/converters/writelog.h +++ b/Cantera/src/converters/writelog.h @@ -12,7 +12,6 @@ #include #include #include -//using namespace std; #include "Species.h" #include "Reaction.h" @@ -20,7 +19,7 @@ //#include "Cantera.h" namespace ckr { - std::string newTask(string msg); + std::string newTask(std::string msg); bool writeFalloff(int type, const vector_fp& c, std::ostream& log); bool writeRateCoeff(const RateCoeff& k, std::ostream& log); void printReactionEquation(std::ostream& f, const Reaction& r); diff --git a/Cantera/src/kinetics/Group.h b/Cantera/src/kinetics/Group.h index 32dd6b15d..55fc6c0bf 100644 --- a/Cantera/src/kinetics/Group.h +++ b/Cantera/src/kinetics/Group.h @@ -9,7 +9,6 @@ #include "ct_defs.h" -//using namespace std; namespace Cantera { /** diff --git a/Cantera/src/numerics/Func1.h b/Cantera/src/numerics/Func1.h index 14aaee763..8f0eb335f 100644 --- a/Cantera/src/numerics/Func1.h +++ b/Cantera/src/numerics/Func1.h @@ -13,7 +13,6 @@ #include #include -using namespace std; namespace Cantera { diff --git a/Cantera/src/thermo/PureFluidPhase.cpp b/Cantera/src/thermo/PureFluidPhase.cpp index 4e1df5968..22c1e7a61 100644 --- a/Cantera/src/thermo/PureFluidPhase.cpp +++ b/Cantera/src/thermo/PureFluidPhase.cpp @@ -16,6 +16,10 @@ #include #include +using std::string; +using std::endl; +using std::setw; + namespace Cantera { // Base Constructor @@ -470,8 +474,8 @@ namespace Cantera { std::vector ubar(kk, 0.0); std::vector cpbar(kk, 0.0); std::vector vbar(kk, 0.0); - vector pNames; - vector data; + std::vector pNames; + std::vector data; getMoleFractions(DATA_PTR(x)); pNames.push_back("X"); diff --git a/Cantera/src/transport/AqueousTransport.h b/Cantera/src/transport/AqueousTransport.h index 1eb47ed51..886c15a56 100644 --- a/Cantera/src/transport/AqueousTransport.h +++ b/Cantera/src/transport/AqueousTransport.h @@ -8,8 +8,6 @@ #ifndef CT_AQUEOUSTRAN_H #define CT_AQUEOUSTRAN_H -using namespace std; - // Cantera includes #include "TransportBase.h" #include "DenseMatrix.h" @@ -342,21 +340,21 @@ namespace Cantera { vector_fp m_mw; // polynomial fits - vector > m_poly; + std::vector > m_poly; //! Polynomial coefficients of the viscosity /*! * These express the temperature dependendence of the pures * species viscosities. */ - vector m_visccoeffs; + std::vector m_visccoeffs; //! Polynomial coefficients of the conductivities /*! * These express the temperature dependendence of the pures * species conductivities */ - vector m_condcoeffs; + std::vector m_condcoeffs; //! Polynomial coefficients of the binary diffusion coefficients /*! @@ -364,7 +362,7 @@ namespace Cantera { * binary diffusivities. An overall pressure dependence is then * added. */ - vector m_diffcoeffs; + std::vector m_diffcoeffs; //! Internal value of the gradient of the mole fraction vector diff --git a/Cantera/src/transport/LiquidTransport.h b/Cantera/src/transport/LiquidTransport.h index 546f73003..467f8b588 100644 --- a/Cantera/src/transport/LiquidTransport.h +++ b/Cantera/src/transport/LiquidTransport.h @@ -15,8 +15,6 @@ #include #include -using namespace std; - // Cantera includes #include "TransportBase.h" #include "DenseMatrix.h" @@ -422,7 +420,7 @@ namespace Cantera { * binary diffusivities. An overall pressure dependence is then * added. */ - vector m_diffcoeffs; + std::vector m_diffcoeffs; //! Internal value of the gradient of the mole fraction vector /*! diff --git a/Cantera/src/transport/MixTransport.h b/Cantera/src/transport/MixTransport.h index 2ad4159ca..93c3501d1 100644 --- a/Cantera/src/transport/MixTransport.h +++ b/Cantera/src/transport/MixTransport.h @@ -14,8 +14,6 @@ #include #include -using namespace std; - // Cantera includes #include "TransportBase.h" #include "DenseMatrix.h" @@ -138,9 +136,9 @@ namespace Cantera { vector_fp m_mw; // polynomial fits - vector m_visccoeffs; - vector m_condcoeffs; - vector m_diffcoeffs; + std::vector m_visccoeffs; + std::vector m_condcoeffs; + std::vector m_diffcoeffs; vector_fp m_polytempvec; // property values @@ -151,11 +149,11 @@ namespace Cantera { array_fp m_molefracs; - vector > m_poly; - vector m_astar_poly; - vector m_bstar_poly; - vector m_cstar_poly; - vector m_om22_poly; + std::vector > m_poly; + std::vector m_astar_poly; + std::vector m_bstar_poly; + std::vector m_cstar_poly; + std::vector m_om22_poly; DenseMatrix m_astar; DenseMatrix m_bstar; DenseMatrix m_cstar; diff --git a/Cantera/src/transport/SimpleTransport.h b/Cantera/src/transport/SimpleTransport.h index 6e2bd46cb..43b0de2ff 100644 --- a/Cantera/src/transport/SimpleTransport.h +++ b/Cantera/src/transport/SimpleTransport.h @@ -15,8 +15,6 @@ #include #include -using namespace std; - // Cantera includes #include "TransportBase.h" #include "DenseMatrix.h" diff --git a/Cantera/src/transport/WaterTransport.h b/Cantera/src/transport/WaterTransport.h index 999cc41c1..4d72b35f9 100644 --- a/Cantera/src/transport/WaterTransport.h +++ b/Cantera/src/transport/WaterTransport.h @@ -15,8 +15,6 @@ #include #include -using namespace std; - // Cantera includes #include "TransportBase.h" #include "DenseMatrix.h" diff --git a/apps/bvp/BoundaryValueProblem.h b/apps/bvp/BoundaryValueProblem.h index 106aabc4b..6083fd42f 100644 --- a/apps/bvp/BoundaryValueProblem.h +++ b/apps/bvp/BoundaryValueProblem.h @@ -8,7 +8,6 @@ #include #include using namespace Cantera; -using namespace std; /// Namespace for the boundary value problem package. namespace BVP { diff --git a/ext/tpx/CarbonDioxide.cpp b/ext/tpx/CarbonDioxide.cpp index d0859aa06..21a990b03 100755 --- a/ext/tpx/CarbonDioxide.cpp +++ b/ext/tpx/CarbonDioxide.cpp @@ -311,7 +311,7 @@ double CarbonDioxide::Psat(){ double log, sum=0,P; if ((T < Tmn) || (T > Tc)) { - cout << " error in Psat " << TempError << endl; + std::cout << " error in Psat " << TempError << std::endl; set_Err(TempError); // Error("CarbonDioxide::Psat",TempError,T); } for (int i=1;i<=8;i++) @@ -332,7 +332,7 @@ double CarbonDioxide::Psat(){ double CarbonDioxide::ldens() { double xx=1-(T/Tc), sum=0; if ((T < Tmn) || (T > Tc)) { - cout << " error in ldens " << TempError << endl; + std::cout << " error in ldens " << TempError << std::endl; set_Err(TempError); } for(int i=1;i<=6;i++) diff --git a/ext/tpx/Sub.cpp b/ext/tpx/Sub.cpp index dda02e7ab..e36c2aeac 100755 --- a/ext/tpx/Sub.cpp +++ b/ext/tpx/Sub.cpp @@ -7,6 +7,8 @@ #include #include +using std::string; + namespace tpx { static string fp2str(double x, string fmt="%g") { diff --git a/ext/tpx/Sub.h b/ext/tpx/Sub.h index 3fd40eef8..f2e48c696 100755 --- a/ext/tpx/Sub.h +++ b/ext/tpx/Sub.h @@ -21,19 +21,18 @@ #include #include -using namespace std; namespace tpx { class TPX_Error { public: - TPX_Error(string p, string e) { + TPX_Error(std::string p, std::string e) { ErrorMessage = e; ErrorProcedure = p; } virtual ~TPX_Error(){} - static string ErrorMessage; - static string ErrorProcedure; + static std::string ErrorMessage; + static std::string ErrorProcedure; }; @@ -70,7 +69,7 @@ namespace tpx { const double Undef = 999.1234; - string errorMsg(int flag); + std::string errorMsg(int flag); class Substance { public: @@ -200,8 +199,8 @@ namespace tpx { int Err; double m_energy_offset; double m_entropy_offset; - string m_name; - string m_formula; + std::string m_name; + std::string m_formula; // virtual double Xm(int k) { return 1.0;} //virtual int Species() { return 1;} diff --git a/ext/tpx/utils.cpp b/ext/tpx/utils.cpp index be81b09ac..d75a44cdf 100755 --- a/ext/tpx/utils.cpp +++ b/ext/tpx/utils.cpp @@ -1,6 +1,8 @@ #include "subs.h" #include "utils.h" +using std::string; + namespace tpx { static string lowercase(string s) { diff --git a/test_problems/cxx_ex/equil_example1.cpp b/test_problems/cxx_ex/equil_example1.cpp index e8a2f77fd..9794cb0fc 100755 --- a/test_problems/cxx_ex/equil_example1.cpp +++ b/test_problems/cxx_ex/equil_example1.cpp @@ -27,9 +27,9 @@ void makeEquilDataLabels(const G& gas, V& names) { } template -void plotEquilSoln(string fname, string fmt, string title, const G& gas, - const A& soln) { - vector names; +void plotEquilSoln(std::string fname, std::string fmt, std::string title, + const G& gas, const A& soln) { + std::vector names; makeEquilDataLabels(gas, names); writePlotFile(fname, fmt, title, names, soln); } @@ -46,10 +46,10 @@ void plotEquilSoln(string fname, string fmt, string title, const G& gas, int equil_example1(int job) { - cout << "Chemical equilibrium." << endl; + std::cout << "Chemical equilibrium." << std::endl; if (job > 0) { - cout << "Equilibrium composition and pressure for a " - << "range of temperatures at constant density." << endl; + std::cout << "Equilibrium composition and pressure for a " + << "range of temperatures at constant density." << std::endl; } if (job <= 1) return 0; @@ -82,14 +82,14 @@ int equil_example1(int job) { } // make a Tecplot data file and an Excel spreadsheet - string plotTitle = "equilibrium example 1: " - "chemical equilibrium"; + std::string plotTitle = "equilibrium example 1: " + "chemical equilibrium"; plotEquilSoln("eq1.dat", "TEC", plotTitle, gas, output); plotEquilSoln("eq1.csv", "XL", plotTitle, gas, output); - cout << "Output files:" << endl - << " eq1.csv (Excel CSV file)" << endl - << " eq1.dat (Tecplot data file)" << endl; + std::cout << "Output files:" << std::endl + << " eq1.csv (Excel CSV file)" << std::endl + << " eq1.dat (Tecplot data file)" << std::endl; return 0; diff --git a/test_problems/cxx_ex/example_utils.h b/test_problems/cxx_ex/example_utils.h index 91281f050..616969705 100755 --- a/test_problems/cxx_ex/example_utils.h +++ b/test_problems/cxx_ex/example_utils.h @@ -5,7 +5,6 @@ #include using namespace Cantera; -using namespace std; // Save the temperature, density, pressure, and mole fractions at one // time @@ -45,8 +44,9 @@ void makeDataLabels(const G& gas, V& names) { } template -void plotSoln(string fname, string fmt, string title, const G& gas, const A& soln) { - vector names; +void plotSoln(std::string fname, std::string fmt, std::string title, + const G& gas, const A& soln) { + std::vector names; makeDataLabels(gas, names); writePlotFile(fname, fmt, title, names, soln); } diff --git a/test_problems/cxx_ex/kinetics_example2.cpp b/test_problems/cxx_ex/kinetics_example2.cpp index 6cfef41a8..833652eba 100755 --- a/test_problems/cxx_ex/kinetics_example2.cpp +++ b/test_problems/cxx_ex/kinetics_example2.cpp @@ -24,12 +24,12 @@ int kinetics_example2(int job) { try { - cout << "Ignition simulation using class GRI30." << endl; + std::cout << "Ignition simulation using class GRI30." << std::endl; if (job >= 1) { - cout << "Constant-pressure ignition of a " - << "hydrogen/oxygen/nitrogen" - " mixture \nbeginning at T = 1001 K and P = 1 atm." << endl; + std::cout << + "Constant-pressure ignition of a hydrogen/oxygen/nitrogen" + " mixture \nbeginning at T = 1001 K and P = 1 atm." << std::endl; } if (job < 2) return 0; @@ -83,24 +83,24 @@ int kinetics_example2(int job) { } // make a Tecplot data file and an Excel spreadsheet - string plotTitle = "kinetics example 2: constant-pressure ignition"; + std::string plotTitle = "kinetics example 2: constant-pressure ignition"; plotSoln("kin2.dat", "TEC", plotTitle, gas, soln); plotSoln("kin2.csv", "XL", plotTitle, gas, soln); // print final temperature - cout << " Tfinal = " << r.temperature() << endl; - cout << "Output files:" << endl - << " kin2.csv (Excel CSV file)" << endl - << " kin2.dat (Tecplot data file)" << endl; + std::cout << " Tfinal = " << r.temperature() << std::endl; + std::cout << "Output files:" << std::endl + << " kin2.csv (Excel CSV file)" << std::endl + << " kin2.dat (Tecplot data file)" << std::endl; return 0; } // handle exceptions thrown by Cantera catch (CanteraError) { - showErrors(cout); - cout << " terminating... " << endl; + showErrors(std::cout); + std::cout << " terminating... " << std::endl; appdelete(); return -1; } diff --git a/test_problems/cxx_ex/kinetics_example3.cpp b/test_problems/cxx_ex/kinetics_example3.cpp index a107724bd..085542130 100644 --- a/test_problems/cxx_ex/kinetics_example3.cpp +++ b/test_problems/cxx_ex/kinetics_example3.cpp @@ -12,6 +12,8 @@ #include "example_utils.h" using namespace Cantera; +using std::cout; +using std::endl; // Kinetics example. This is written as a function so that one // driver program can run multiple examples. @@ -29,7 +31,7 @@ int kinetics_example3(int job) { try { cout << "Ignition simulation using class IdealGasMix " - << "with file gri30.cti." + << "with file gri30.cti." << endl; if (job >= 1) { @@ -88,7 +90,7 @@ int kinetics_example3(int job) { } // make a Tecplot data file and an Excel spreadsheet - string plotTitle = "kinetics example 3: constant-pressure ignition"; + std::string plotTitle = "kinetics example 3: constant-pressure ignition"; plotSoln("kin3.dat", "TEC", plotTitle, gas, soln); plotSoln("kin3.csv", "XL", plotTitle, gas, soln); diff --git a/test_problems/cxx_ex/rxnpath_example1.cpp b/test_problems/cxx_ex/rxnpath_example1.cpp index 6e7bf56da..6755806d1 100755 --- a/test_problems/cxx_ex/rxnpath_example1.cpp +++ b/test_problems/cxx_ex/rxnpath_example1.cpp @@ -13,11 +13,13 @@ #include // #include -// using namespace std; + using namespace Cantera; +using std::cout; +using std::endl; void writeRxnPathDiagram(double time, ReactionPathBuilder& b, - IdealGasMix& gas, ostream& logfile, ostream& outfile) { + IdealGasMix& gas, std::ostream& logfile, std::ostream& outfile) { // create a new empty diagram ReactionPathDiagram d; @@ -122,8 +124,8 @@ int rxnpath_example1(int job) { // create a reaction path diagram builder ReactionPathBuilder b; - ofstream rplog("rp1.log"); // log file - ofstream rplot("rp1.dot"); // output file + std::ofstream rplog("rp1.log"); // log file + std::ofstream rplot("rp1.dot"); // output file b.init(rplog, gas); // initialize // main loop diff --git a/test_problems/cxx_ex/transport_example1.cpp b/test_problems/cxx_ex/transport_example1.cpp index 7b4087e78..f872296b0 100755 --- a/test_problems/cxx_ex/transport_example1.cpp +++ b/test_problems/cxx_ex/transport_example1.cpp @@ -12,6 +12,8 @@ #include using namespace Cantera; +using std::cout; +using std::endl; template void makeTransportDataLabels(const G& gas, V& names) { @@ -25,9 +27,9 @@ void makeTransportDataLabels(const G& gas, V& names) { } template -void plotTransportSoln(string fname, string fmt, string title, const G& gas, - const A& soln) { - vector names; +void plotTransportSoln(std::string fname, std::string fmt, std::string title, + const G& gas, const A& soln) { + std::vector names; makeTransportDataLabels(gas, names); writePlotFile(fname, fmt, title, names, soln); } @@ -75,8 +77,8 @@ int transport_example1(int job) { } // make a Tecplot data file and an Excel spreadsheet - string plotTitle = "transport example 1: " - "mixture-averaged transport properties"; + std::string plotTitle = "transport example 1: " + "mixture-averaged transport properties"; plotTransportSoln("tr1.dat", "TEC", plotTitle, gas, output); plotTransportSoln("tr1.csv", "XL", plotTitle, gas, output); diff --git a/test_problems/cxx_ex/transport_example2.cpp b/test_problems/cxx_ex/transport_example2.cpp index 5b422b8cc..da1ac107b 100755 --- a/test_problems/cxx_ex/transport_example2.cpp +++ b/test_problems/cxx_ex/transport_example2.cpp @@ -13,6 +13,8 @@ #include using namespace Cantera; +using std::cout; +using std::endl; template void makeTransportDataLabels(const G& gas, V& names) { @@ -26,9 +28,9 @@ void makeTransportDataLabels(const G& gas, V& names) { } template -void plotTransportSoln(string fname, string fmt, string title, const G& gas, - const A& soln) { - vector names; +void plotTransportSoln(std::string fname, std::string fmt, std::string title, + const G& gas, const A& soln) { + std::vector names; makeTransportDataLabels(gas, names); writePlotFile(fname, fmt, title, names, soln); } @@ -77,8 +79,8 @@ int transport_example2(int job) { } // make a Tecplot data file and an Excel spreadsheet - string plotTitle = "transport example 2: " - "multicomponent transport properties"; + std::string plotTitle = "transport example 2: " + "multicomponent transport properties"; plotTransportSoln("tr2.dat", "TEC", plotTitle, gas, output); plotTransportSoln("tr2.csv", "XL", plotTitle, gas, output);