From 111f2903f064fe50514c28769023bffa0e80df7a Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <github@naumov.de> Date: Tue, 15 Aug 2023 10:24:11 +0200 Subject: [PATCH] [BL] Add to string conversion for iostate The debug output with boolean conversion is incorrect with newer compiler/stdlib versions. It seems the iostate became a new type and is no longer an unsigned int. --- BaseLib/PrjProcessing.cpp | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/BaseLib/PrjProcessing.cpp b/BaseLib/PrjProcessing.cpp index 1796fe02123..5a0d898dca3 100644 --- a/BaseLib/PrjProcessing.cpp +++ b/BaseLib/PrjProcessing.cpp @@ -10,6 +10,7 @@ #include "PrjProcessing.h" +#include <fmt/core.h> #include <libxml/globals.h> #include <libxml/parser.h> #include <libxml/xmlstring.h> @@ -24,6 +25,40 @@ #include "FileTools.h" #include "Logging.h" +namespace +{ +std::string iostateToString(std::ios_base::iostate const state) +{ + std::string result; + + if (state == std::ios_base::goodbit) + { + result = "goodbit"; + } + else + { + if (state & std::ios_base::eofbit) + { + result += "eofbit "; + } + if (state & std::ios_base::failbit) + { + result += "failbit "; + } + if (state & std::ios_base::badbit) + { + result += "badbit"; + } + // Remove trailing space if there is one + if (!result.empty() && result.back() == ' ') + { + result.pop_back(); + } + } + return result; +} +} // namespace + namespace BaseLib { void traverseIncludes(xmlDoc* doc, xmlNode* node, @@ -274,7 +309,7 @@ void readAndPatchPrj(std::stringstream& prj_stream, std::string& prj_file, { ERR("File {:s} does not exist.", prj_file); } - DBUG("Stream state flags: {:b}.", file.rdstate()); + DBUG("Stream state flags: {:s}.", iostateToString(file.rdstate())); OGS_FATAL("Could not open project file '{:s}' for reading.", prj_file); } -- GitLab