From: nds Date: Fri, 6 Nov 2020 15:40:22 +0000 (+0300) Subject: 0031945: Foundation Classes - unique names of alerts of message report in DumpJson X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=6070750198bb16ec3d44a8360cd38a7abf24862f;p=occt-copy.git 0031945: Foundation Classes - unique names of alerts of message report in DumpJson --- diff --git a/src/Message/Message_CompositeAlerts.cxx b/src/Message/Message_CompositeAlerts.cxx index e0a9cafca9..5c1a267ea3 100644 --- a/src/Message/Message_CompositeAlerts.cxx +++ b/src/Message/Message_CompositeAlerts.cxx @@ -169,15 +169,12 @@ void Message_CompositeAlerts::DumpJson (Standard_OStream& theOStream, { OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream) + Standard_Integer anInc = 1; for (unsigned int i = 0; i < sizeof(myAlerts)/sizeof(myAlerts[0]); ++i) { if (myAlerts[i].IsEmpty()) continue; - Message_Gravity aGravity = (Message_Gravity)i; - OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, aGravity) - - Standard_Integer anInc = 1; for (Message_ListOfAlert::Iterator anIt (myAlerts[i]); anIt.More(); anIt.Next(), anInc++) { const Handle(Message_Alert)& anAlert = anIt.Value(); diff --git a/src/Message/Message_Report.cxx b/src/Message/Message_Report.cxx index d592b03eec..7a58017722 100644 --- a/src/Message/Message_Report.cxx +++ b/src/Message/Message_Report.cxx @@ -479,10 +479,11 @@ void Message_Report::DumpJson (Standard_OStream& theOStream, Standard_Integer th Standard_Integer anAlertLevels = myAlertLevels.Size(); OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, anAlertLevels) + Standard_Integer anInc = 1; for (NCollection_IndexedMap::Iterator anIterator (myActiveMetrics); anIterator.More(); anIterator.Next()) { Message_MetricType anActiveMetric = anIterator.Value(); - OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, anActiveMetric) + OCCT_DUMP_FIELD_VALUE_NUMERICAL_INC (theOStream, anActiveMetric, anInc++) } OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myLimit) diff --git a/src/Standard/Standard_Dump.cxx b/src/Standard/Standard_Dump.cxx index c125ad966a..f6a2fa4621 100644 --- a/src/Standard/Standard_Dump.cxx +++ b/src/Standard/Standard_Dump.cxx @@ -225,6 +225,10 @@ TCollection_AsciiString Standard_Dump::FormatJson (const Standard_SStream& theSt else aText += aSymbol; } + else if (aSymbol == '\n') + { + aText += ""; // json does not support multi-lined values, skip this symbol + } else aText += aSymbol; diff --git a/src/Standard/Standard_Dump.hxx b/src/Standard/Standard_Dump.hxx index 0ef0b74dc9..a026bc8c52 100644 --- a/src/Standard/Standard_Dump.hxx +++ b/src/Standard/Standard_Dump.hxx @@ -75,6 +75,15 @@ theOStream << "\"" << aName << "\": " << theField; \ } +//! @def OCCT_DUMP_FIELD_VALUE_NUMERICAL +//! Append into output value: "Name": Field +#define OCCT_DUMP_FIELD_VALUE_NUMERICAL_INC(theOStream, theField, theIncName) \ +{ \ + TCollection_AsciiString aName = Standard_Dump::DumpFieldToName (#theField) + theIncName; \ + Standard_Dump::AddValuesSeparator (theOStream); \ + theOStream << "\"" << aName << "\": " << theField; \ +} + //! @def OCCT_DUMP_FIELD_VALUE_STRING //! Append into output value: "Name": "Field" #define OCCT_DUMP_FIELD_VALUE_STRING(theOStream, theField) \