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 <cstdlib>
#include <fstream>
#include <functional>
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<int(int)> 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<std::string> projections;
for (const auto& prj : project)
for (const ProjectionMap::value_type& prj : project)
if (prj.first == NONE)
os <<"\nPure residual error estimates enabled";
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))
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<int>& val)
int utl::getAttribute (const TiXmlElement* xml, const char* att,
std::vector<int>& 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;

View File

@ -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<int>& val);
int getAttribute(const TiXmlElement* xml, const char* att,
std::vector<int>& 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