From 7fab7f3cd3deec74e649a522b37e10efdf238e79 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Tue, 1 Aug 2017 23:45:12 -0400 Subject: [PATCH] Add boolean and integer types to AnyMap --- include/cantera/base/AnyMap.h | 24 ++++++++++++++++++++++++ test/thermo/phaseConstructors.cpp | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/cantera/base/AnyMap.h b/include/cantera/base/AnyMap.h index 3a28312d3..2357e0b98 100644 --- a/include/cantera/base/AnyMap.h +++ b/include/cantera/base/AnyMap.h @@ -85,6 +85,10 @@ public: m_value = value; return *this; } + AnyValue& operator=(const char* value) { + m_value = std::string(value); + return *this; + } const std::string& asString() const { return as(); } @@ -97,6 +101,26 @@ public: return as(); } + AnyValue& operator=(bool value) { + m_value = value; + return *this; + } + bool asBool() const { + return as(); + } + + AnyValue& operator=(long int value) { + m_value = value; + return *this; + } + AnyValue& operator=(int value) { + m_value = static_cast(value); + return *this; + } + long int asInt() const { + return as(); + } + template AnyValue& operator=(const std::vector& value) { m_value = value; diff --git a/test/thermo/phaseConstructors.cpp b/test/thermo/phaseConstructors.cpp index 7094775fa..3cb539141 100644 --- a/test/thermo/phaseConstructors.cpp +++ b/test/thermo/phaseConstructors.cpp @@ -386,7 +386,7 @@ TEST(DebyeHuckel, fromScratch) sOH->extra["ionic_radius"] = 3.5e-10; auto sNaCl = make_species("NaCl(aq)", "Na:1, Cl:1", -96.03e6*4.184, 298.15, -174.5057463, 333.15, -174.5057463); - sNaCl->extra["weak_acid_charge"] = -1; + sNaCl->extra["weak_acid_charge"] = -1.0; sNaCl->extra["electrolyte_species_type"] = "weakAcidAssociated"; for (auto& s : {sH2O, sNa, sCl, sH, sOH, sNaCl}) { p.addSpecies(s);