]> 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)
committersnn <sergey.nikonov@opencascade.com>
Wed, 17 Mar 2021 12:42:48 +0000 (15:42 +0300)
# Conflicts:
# src/Message/Message_Report.cxx

src/Message/Message_Report.cxx
src/Standard/Standard_Dump.cxx
src/Standard/Standard_Dump.hxx

index d8ed266198c721090fdc82d5ca5bf3c79d7bc36a..2b038c1726c3fe9d741c9b83fa1348ca7117ae54 100644 (file)
@@ -489,10 +489,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<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 27153bf43c2832320c376af6705ee15ac261459a..6da4d7ee7ffbb75a60b816cda4d01357c5ffd572 100644 (file)
@@ -354,6 +354,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 01a88e43cc9065405787ac10233fd23890f515b8..ed6c61be90369b931d37ed8cefd414e5bc6ba1a3 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.