]> OCCT Git - occt-copy.git/commitdiff
0031362: Inspectors - MessageView plugin for message alerts
authornds <nds@opencascade.com>
Fri, 6 Nov 2020 15:40:22 +0000 (18:40 +0300)
committernds <nds@opencascade.com>
Thu, 12 Nov 2020 08:39:39 +0000 (11:39 +0300)
- avoid '\n' in json report, Unique name of composite alerts

(cherry picked from commit c2c6db031c23578c4ca5403fd4ecc1ece8758886)

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

index e0a9cafca909d3465050e4ec9aead5d7f758f48e..5c1a267ea354f66beb8410ef55ddae2c8b5ccdcb 100644 (file)
@@ -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();
index 3a88c7bdd5964dc8a317b4968c20b2c98fc75336..4c09657ffb17e747fe7b48fc1bf9b9d34941f45f 100644 (file)
@@ -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<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 c065dab3ddd83aaa8bdfe0dada3487d3481ebe6b..3bdc2f55d51b6d24728420115c502f560342d322 100644 (file)
@@ -384,6 +384,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 fffedf4ffdb5ee8d2d08d87fa3df0e39fafce4f4..a84ec5a5325394b96866581c31d8759d61743d5f 100644 (file)
@@ -74,6 +74,15 @@ class Standard_DumpSentry;
   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_NUMERICAL
 //! 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.