]> OCCT Git - occt-copy.git/commitdiff
0031945: Foundation Classes - unique names of alerts of message report in DumpJson
authornds <nds@opencascade.com>
Fri, 6 Nov 2020 15:40:22 +0000 (18:40 +0300)
committernds <nds@opencascade.com>
Thu, 19 Nov 2020 07:03:27 +0000 (10:03 +0300)
src/Message/Message_CompositeAlerts.cxx
src/Message/Message_Report.cxx
src/Standard/Standard_Dump.cxx
src/Standard/Standard_Dump.hxx

index 5d315f3e8cf9beed6403c62a4ca9cf6a07a6cf6a..c9daf6dc44e64392e9199344eeb5d2c6d0f2ed22 100644 (file)
@@ -164,15 +164,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();
index 70de6b011ac83bd329677a5fa7975dc6549d961b..41c64accfa901f5e91709cc1e62d44e25a7008cc 100644 (file)
@@ -488,10 +488,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_Map<Message_MetricType>::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)
index a56292f912f93f754d99d7a9d26f16b7d269d07d..4d594bf61e69cac7b27fadc7dd31211a456d2e50 100644 (file)
@@ -358,6 +358,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;
   
index e0333c03e457c76a47dc2d7de5e1af4d74bdecbf..d3afcac4d8f728c53b03c6817d8aa7846e244292 100644 (file)
   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_INIT_FIELD_VALUE_REAL
 //! Append vector values into output value: "Name": [value_1, value_2, ...]
 //! This macro is intended to have only one row for dumped object in Json.