From f2577803f6fe4f5a2cc56fc6824ec70f6528f347 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 6 Nov 2020 18:40:22 +0300 Subject: [PATCH] 0031945: Foundation Classes - unique names of alerts of message report in DumpJson # Conflicts: # src/Message/Message_Report.cxx --- src/Message/Message_Report.cxx | 3 ++- src/Standard/Standard_Dump.cxx | 4 ++++ src/Standard/Standard_Dump.hxx | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Message/Message_Report.cxx b/src/Message/Message_Report.cxx index d8ed266198..2b038c1726 100644 --- a/src/Message/Message_Report.cxx +++ b/src/Message/Message_Report.cxx @@ -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::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 27153bf43c..6da4d7ee7f 100644 --- a/src/Standard/Standard_Dump.cxx +++ b/src/Standard/Standard_Dump.cxx @@ -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; diff --git a/src/Standard/Standard_Dump.hxx b/src/Standard/Standard_Dump.hxx index 01a88e43cc..ed6c61be90 100644 --- a/src/Standard/Standard_Dump.hxx +++ b/src/Standard/Standard_Dump.hxx @@ -77,6 +77,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_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. -- 2.39.5