Changed: Return int instead of bool such the bitwise or

can be used on the result without warning for newer compilers
This commit is contained in:
Knut Morten Okstad 2023-01-10 12:46:01 +01:00
parent 4ea903be4f
commit d89c31558f
3 changed files with 27 additions and 26 deletions

View File

@ -24,6 +24,7 @@
#include <cstring> #include <cstring>
#include <cstdlib> #include <cstdlib>
#include <fstream> #include <fstream>
#include <functional>
SIMoptions::SIMoptions () SIMoptions::SIMoptions ()
@ -404,7 +405,7 @@ utl::LogStream& SIMoptions::print (utl::LogStream& os, bool addBlankLine) const
<<"\nShift value: "<< shift; <<"\nShift value: "<< shift;
// Lambda function to print proper interpretation of nGauss // Lambda function to print proper interpretation of nGauss
auto printG = [&os](int n) std::function<int(int)> printG = [&os](int n) -> int
{ {
if (n > 0 && n <= 10) if (n > 0 && n <= 10)
{ {
@ -443,7 +444,7 @@ utl::LogStream& SIMoptions::print (utl::LogStream& os, bool addBlankLine) const
} }
std::vector<std::string> projections; std::vector<std::string> projections;
for (const auto& prj : project) for (const ProjectionMap::value_type& prj : project)
if (prj.first == NONE) if (prj.first == NONE)
os <<"\nPure residual error estimates enabled"; os <<"\nPure residual error estimates enabled";
else else

View File

@ -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)) if (!xml || !xml->Attribute(att))
return false; 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)) if (xml && xml->Attribute(att))
val = atoi(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, int utl::getAttribute (const TiXmlElement* xml, const char* att, char& val,
bool useIntValue) bool useIntValue)
{ {
if (xml && xml->Attribute(att)) if (xml && xml->Attribute(att))
val = useIntValue ? atoi(xml->Attribute(att)) : xml->Attribute(att)[0]; 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)) if (xml && xml->Attribute(att))
val = atoi(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)) if (xml && xml->Attribute(att))
val = atof(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. If \a ncomp is zero, use the value zero for the missing components, if any.
*/ */
bool utl::getAttribute (const TiXmlElement* xml, const char* att, int utl::getAttribute (const TiXmlElement* xml, const char* att,
Vec3& val, int ncomp) Vec3& val, int ncomp)
{ {
if (!xml || !xml->Attribute(att)) if (!xml || !xml->Attribute(att))
return false; return false;
@ -260,8 +260,8 @@ bool utl::getAttribute (const TiXmlElement* xml, const char* att,
} }
bool utl::getAttribute (const TiXmlElement* xml, const char* att, int utl::getAttribute (const TiXmlElement* xml, const char* att,
std::vector<int>& val) std::vector<int>& val)
{ {
if (xml && xml->Attribute(att)) if (xml && xml->Attribute(att))
parseIntegers(val,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, int utl::getAttribute (const TiXmlElement* xml, const char* att,
std::string& val, bool toLower) std::string& val, bool toLower)
{ {
if (!xml || !xml->Attribute(att)) if (!xml || !xml->Attribute(att))
return false; return false;

View File

@ -61,14 +61,14 @@ namespace utl
//! \param[out] val The attribute value //! \param[out] val The attribute value
//! \return \e true if the attribute \a att is found in \a xml, //! \return \e true if the attribute \a att is found in \a xml,
//! otherwise \e false //! 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. //! \brief Extracts an integer attribute value from the specified XML-element.
//! \param[in] xml Pointer to XML-element to extract from //! \param[in] xml Pointer to XML-element to extract from
//! \param[in] att The attribute tag //! \param[in] att The attribute tag
//! \param[out] val The attribute value //! \param[out] val The attribute value
//! \return \e true if the attribute \a att is found in \a xml, //! \return \e true if the attribute \a att is found in \a xml,
//! otherwise \e false //! 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. //! \brief Extracts a char attribute value from the specified XML-element.
//! \param[in] xml Pointer to XML-element to extract from //! \param[in] xml Pointer to XML-element to extract from
//! \param[in] att The attribute tag //! \param[in] att The attribute tag
@ -76,22 +76,22 @@ namespace utl
//! \param[in] useIntValue If \e true, convert the value to an integer //! \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, //! \return \e true if the attribute \a att is found in \a xml,
//! otherwise \e false //! otherwise \e false
bool getAttribute(const TiXmlElement* xml, const char* att, char& val, int getAttribute(const TiXmlElement* xml, const char* att, char& val,
bool useIntValue = true); bool useIntValue = true);
//! \brief Extracts a size_t attribute value from the specified XML-element. //! \brief Extracts a size_t attribute value from the specified XML-element.
//! \param[in] xml Pointer to XML-element to extract from //! \param[in] xml Pointer to XML-element to extract from
//! \param[in] att The attribute tag //! \param[in] att The attribute tag
//! \param[out] val The attribute value //! \param[out] val The attribute value
//! \return \e true if the attribute \a att is found in \a xml, //! \return \e true if the attribute \a att is found in \a xml,
//! otherwise \e false //! 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. //! \brief Extracts a real attribute value from the specified XML-element.
//! \param[in] xml Pointer to XML-element to extract from //! \param[in] xml Pointer to XML-element to extract from
//! \param[in] att The attribute tag //! \param[in] att The attribute tag
//! \param[out] val The attribute value //! \param[out] val The attribute value
//! \return \e true if the attribute \a att is found in \a xml, //! \return \e true if the attribute \a att is found in \a xml,
//! otherwise \e false //! 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. //! \brief Extracts a vector attribute value from the specified XML-element.
//! \param[in] xml Pointer to XML-element to extract from //! \param[in] xml Pointer to XML-element to extract from
//! \param[in] att The attribute tag //! \param[in] att The attribute tag
@ -99,16 +99,16 @@ namespace utl
//! \param[in] ncomp Maximum number of components to read //! \param[in] ncomp Maximum number of components to read
//! \return \e true if the attribute \a att is found in \a xml, //! \return \e true if the attribute \a att is found in \a xml,
//! otherwise \e false //! otherwise \e false
bool getAttribute(const TiXmlElement* xml, const char* att, Vec3& val, int getAttribute(const TiXmlElement* xml, const char* att, Vec3& val,
int ncomp = 0); int ncomp = 0);
//! \brief Extracts an integer vector attribute from specified XML-element. //! \brief Extracts an integer vector attribute from specified XML-element.
//! \param[in] xml Pointer to XML-element to extract from //! \param[in] xml Pointer to XML-element to extract from
//! \param[in] att The attribute tag //! \param[in] att The attribute tag
//! \param[out] val The attribute value //! \param[out] val The attribute value
//! \return \e true if the attribute \a att is found in \a xml, //! \return \e true if the attribute \a att is found in \a xml,
//! otherwise \e false //! otherwise \e false
bool getAttribute(const TiXmlElement* xml, const char* att, int getAttribute(const TiXmlElement* xml, const char* att,
std::vector<int>& val); std::vector<int>& val);
//! \brief Extracts a string attribute value from the specified XML-element. //! \brief Extracts a string attribute value from the specified XML-element.
//! \param[in] xml Pointer to XML-element to extract from //! \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 //! \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, //! \return \e true if the attribute \a att is found in \a xml,
//! otherwise \e false //! otherwise \e false
bool getAttribute(const TiXmlElement* xml, const char* att, std::string& val, int getAttribute(const TiXmlElement* xml, const char* att, std::string& val,
bool toLower = false); bool toLower = false);
//! \brief Returns the value (if any) of the specified XML-node. //! \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] xml Pointer to XML-node to extract the value from
//! \param[in] tag The name of the XML-element to extract the value from //! \param[in] tag The name of the XML-element to extract the value from