From d89c31558f2d077ac99241e15bd5ca9b00733e10 Mon Sep 17 00:00:00 2001 From: Knut Morten Okstad Date: Tue, 10 Jan 2023 12:46:01 +0100 Subject: [PATCH] Changed: Return int instead of bool such the bitwise or can be used on the result without warning for newer compilers --- src/SIM/SIMoptions.C | 5 +++-- src/Utility/Utilities.C | 24 ++++++++++++------------ src/Utility/Utilities.h | 24 ++++++++++++------------ 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/SIM/SIMoptions.C b/src/SIM/SIMoptions.C index 5eca3081..d70c0d6c 100644 --- a/src/SIM/SIMoptions.C +++ b/src/SIM/SIMoptions.C @@ -24,6 +24,7 @@ #include #include #include +#include SIMoptions::SIMoptions () @@ -404,7 +405,7 @@ utl::LogStream& SIMoptions::print (utl::LogStream& os, bool addBlankLine) const <<"\nShift value: "<< shift; // Lambda function to print proper interpretation of nGauss - auto printG = [&os](int n) + std::function printG = [&os](int n) -> int { if (n > 0 && n <= 10) { @@ -443,7 +444,7 @@ utl::LogStream& SIMoptions::print (utl::LogStream& os, bool addBlankLine) const } std::vector projections; - for (const auto& prj : project) + for (const ProjectionMap::value_type& prj : project) if (prj.first == NONE) os <<"\nPure residual error estimates enabled"; else diff --git a/src/Utility/Utilities.C b/src/Utility/Utilities.C index 9a5b2819..a1d5b1b8 100644 --- a/src/Utility/Utilities.C +++ b/src/Utility/Utilities.C @@ -167,7 +167,7 @@ bool utl::ignoreComments (std::istream& is) } -bool utl::getAttribute (const TiXmlElement* xml, const char* att, bool& val) +int utl::getAttribute (const TiXmlElement* xml, const char* att, bool& val) { if (!xml || !xml->Attribute(att)) return false; @@ -188,7 +188,7 @@ bool utl::getAttribute (const TiXmlElement* xml, const char* att, bool& val) } -bool utl::getAttribute (const TiXmlElement* xml, const char* att, int& val) +int utl::getAttribute (const TiXmlElement* xml, const char* att, int& val) { if (xml && xml->Attribute(att)) val = atoi(xml->Attribute(att)); @@ -199,8 +199,8 @@ bool utl::getAttribute (const TiXmlElement* xml, const char* att, int& val) } -bool utl::getAttribute (const TiXmlElement* xml, const char* att, char& val, - bool useIntValue) +int utl::getAttribute (const TiXmlElement* xml, const char* att, char& val, + bool useIntValue) { if (xml && xml->Attribute(att)) val = useIntValue ? atoi(xml->Attribute(att)) : xml->Attribute(att)[0]; @@ -211,7 +211,7 @@ bool utl::getAttribute (const TiXmlElement* xml, const char* att, char& val, } -bool utl::getAttribute (const TiXmlElement* xml, const char* att, size_t& val) +int utl::getAttribute (const TiXmlElement* xml, const char* att, size_t& val) { if (xml && xml->Attribute(att)) val = atoi(xml->Attribute(att)); @@ -222,7 +222,7 @@ bool utl::getAttribute (const TiXmlElement* xml, const char* att, size_t& val) } -bool utl::getAttribute (const TiXmlElement* xml, const char* att, Real& val) +int utl::getAttribute (const TiXmlElement* xml, const char* att, Real& val) { if (xml && xml->Attribute(att)) val = atof(xml->Attribute(att)); @@ -238,8 +238,8 @@ bool utl::getAttribute (const TiXmlElement* xml, const char* att, Real& val) If \a ncomp is zero, use the value zero for the missing components, if any. */ -bool utl::getAttribute (const TiXmlElement* xml, const char* att, - Vec3& val, int ncomp) +int utl::getAttribute (const TiXmlElement* xml, const char* att, + Vec3& val, int ncomp) { if (!xml || !xml->Attribute(att)) return false; @@ -260,8 +260,8 @@ bool utl::getAttribute (const TiXmlElement* xml, const char* att, } -bool utl::getAttribute (const TiXmlElement* xml, const char* att, - std::vector& val) +int utl::getAttribute (const TiXmlElement* xml, const char* att, + std::vector& val) { if (xml && xml->Attribute(att)) parseIntegers(val,xml->Attribute(att)); @@ -272,8 +272,8 @@ bool utl::getAttribute (const TiXmlElement* xml, const char* att, } -bool utl::getAttribute (const TiXmlElement* xml, const char* att, - std::string& val, bool toLower) +int utl::getAttribute (const TiXmlElement* xml, const char* att, + std::string& val, bool toLower) { if (!xml || !xml->Attribute(att)) return false; diff --git a/src/Utility/Utilities.h b/src/Utility/Utilities.h index 250059a1..a9c858c9 100644 --- a/src/Utility/Utilities.h +++ b/src/Utility/Utilities.h @@ -61,14 +61,14 @@ namespace utl //! \param[out] val The attribute value //! \return \e true if the attribute \a att is found in \a xml, //! otherwise \e false - bool getAttribute(const TiXmlElement* xml, const char* att, bool& val); + int getAttribute(const TiXmlElement* xml, const char* att, bool& val); //! \brief Extracts an integer attribute value from the specified XML-element. //! \param[in] xml Pointer to XML-element to extract from //! \param[in] att The attribute tag //! \param[out] val The attribute value //! \return \e true if the attribute \a att is found in \a xml, //! otherwise \e false - bool getAttribute(const TiXmlElement* xml, const char* att, int& val); + int getAttribute(const TiXmlElement* xml, const char* att, int& val); //! \brief Extracts a char attribute value from the specified XML-element. //! \param[in] xml Pointer to XML-element to extract from //! \param[in] att The attribute tag @@ -76,22 +76,22 @@ namespace utl //! \param[in] useIntValue If \e true, convert the value to an integer //! \return \e true if the attribute \a att is found in \a xml, //! otherwise \e false - bool getAttribute(const TiXmlElement* xml, const char* att, char& val, - bool useIntValue = true); + int getAttribute(const TiXmlElement* xml, const char* att, char& val, + bool useIntValue = true); //! \brief Extracts a size_t attribute value from the specified XML-element. //! \param[in] xml Pointer to XML-element to extract from //! \param[in] att The attribute tag //! \param[out] val The attribute value //! \return \e true if the attribute \a att is found in \a xml, //! otherwise \e false - bool getAttribute(const TiXmlElement* xml, const char* att, size_t& val); + int getAttribute(const TiXmlElement* xml, const char* att, size_t& val); //! \brief Extracts a real attribute value from the specified XML-element. //! \param[in] xml Pointer to XML-element to extract from //! \param[in] att The attribute tag //! \param[out] val The attribute value //! \return \e true if the attribute \a att is found in \a xml, //! otherwise \e false - bool getAttribute(const TiXmlElement* xml, const char* att, Real& val); + int getAttribute(const TiXmlElement* xml, const char* att, Real& val); //! \brief Extracts a vector attribute value from the specified XML-element. //! \param[in] xml Pointer to XML-element to extract from //! \param[in] att The attribute tag @@ -99,16 +99,16 @@ namespace utl //! \param[in] ncomp Maximum number of components to read //! \return \e true if the attribute \a att is found in \a xml, //! otherwise \e false - bool getAttribute(const TiXmlElement* xml, const char* att, Vec3& val, - int ncomp = 0); + int getAttribute(const TiXmlElement* xml, const char* att, Vec3& val, + int ncomp = 0); //! \brief Extracts an integer vector attribute from specified XML-element. //! \param[in] xml Pointer to XML-element to extract from //! \param[in] att The attribute tag //! \param[out] val The attribute value //! \return \e true if the attribute \a att is found in \a xml, //! otherwise \e false - bool getAttribute(const TiXmlElement* xml, const char* att, - std::vector& val); + int getAttribute(const TiXmlElement* xml, const char* att, + std::vector& val); //! \brief Extracts a string attribute value from the specified XML-element. //! \param[in] xml Pointer to XML-element to extract from @@ -117,8 +117,8 @@ namespace utl //! \param[in] toLower If \e true, convert return string to lower case //! \return \e true if the attribute \a att is found in \a xml, //! otherwise \e false - bool getAttribute(const TiXmlElement* xml, const char* att, std::string& val, - bool toLower = false); + int getAttribute(const TiXmlElement* xml, const char* att, std::string& val, + bool toLower = false); //! \brief Returns the value (if any) of the specified XML-node. //! \param[in] xml Pointer to XML-node to extract the value from //! \param[in] tag The name of the XML-element to extract the value from