Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-21 09:18:28

0001 // Copyright (c) 2019 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _Standard_Dump_HeaderFile
0015 #define _Standard_Dump_HeaderFile
0016 
0017 #include <NCollection_IndexedDataMap.hxx>
0018 #include <NCollection_List.hxx>
0019 #include <Standard_OStream.hxx>
0020 #include <Standard_SStream.hxx>
0021 #include <TCollection_AsciiString.hxx>
0022 
0023 //!@file
0024 //! The file contains interface to prepare dump output for OCCT objects. Format of the dump is JSON.
0025 //!
0026 //! To prepare this output, implement method DumpJson in the object and use macro functions from
0027 //! this file. Macros have one parameter for both, key and the value. It is a field of the current
0028 //! class. Macro has internal analyzer that uses the variable name to generate key. If the parameter
0029 //! has prefix symbols "&", "*" and "my", it is cut.
0030 //!
0031 //! - OCCT_DUMP_FIELD_VALUE_NUMERICAL. Use it for fields of numerical C++ types, like int, float,
0032 //! double. It creates a pair "key", "value",
0033 //! - OCCT_DUMP_FIELD_VALUE_NUMERICAL_INC. Use it for fields of numerical C++ types, like int,
0034 //! float, double.
0035 //!     It creates a pair "key_inc", "value",
0036 //! - OCCT_DUMP_FIELD_VALUE_STRING. Use it for char* type. It creates a pair "key", "value",
0037 //! - OCCT_DUMP_FIELD_VALUE_POINTER. Use it for pointer fields. It creates a pair "key", "value",
0038 //! where the value is the pointer address,
0039 //! - OCCT_DUMP_FIELD_VALUES_DUMPED. Use it for fields that has own Dump implementation. It expects
0040 //! the pointer to the class instance.
0041 //!     It creates "key": { result of dump of the field }
0042 //! - OCCT_DUMP_FIELD_VALUES_DUMPED_INC. Use it for fields that has own Dump implementation. It
0043 //! expects the pointer to the class instance.
0044 //!     It creates "key_inc": { result of dump of the field }
0045 //! - OCCT_DUMP_STREAM_VALUE_DUMPED. Use it for Standard_SStream. It creates "key": { text of stream
0046 //! }
0047 //! - OCCT_DUMP_FIELD_VALUES_NUMERICAL. Use it for unlimited list of fields of C++ double type.
0048 //!     It creates massive of values [value_1, value_2, ...]
0049 //! - OCCT_DUMP_FIELD_VALUES_STRING. Use it for unlimited list of fields of TCollection_AsciiString
0050 //! types.
0051 //!     It creates massive of values ["value_1", "value_2", ...]
0052 //! - OCCT_DUMP_BASE_CLASS. Use if Dump implementation of the class is virtual, to perform
0053 //! ClassName::Dump() of the parent class,
0054 //!     expected parameter is the parent class name.
0055 //!     It creates "key": { result of dump of the field }
0056 //! - OCCT_DUMP_VECTOR_CLASS. Use it as a single row in some object dump to have one row in output.
0057 //!     It's possible to use it without necessity of OCCT_DUMP_CLASS_BEGIN call.
0058 //!     It creates massive of values [value_1, value_2, ...]
0059 //!
0060 //! The Dump result prepared by these macros is an output stream, it is not arranged with spaces and
0061 //! line feed. To have output in a more readable way, use ConvertToAlignedString method for obtained
0062 //! stream.
0063 
0064 //! Converts the class type into a string value
0065 #define OCCT_CLASS_NAME(theClass) #theClass
0066 
0067 //! @def OCCT_DUMP_CLASS_BEGIN
0068 //! Creates an instance of Sentry to cover the current Dump implementation with keys of start and
0069 //! end. This row should be inserted before other macros. The end key will be added by the sentry
0070 //! remove, (exit of the method).
0071 #define OCCT_DUMP_CLASS_BEGIN(theOStream, theField)                                                \
0072   {                                                                                                \
0073     const char* className = OCCT_CLASS_NAME(theField);                                             \
0074     OCCT_DUMP_FIELD_VALUE_STRING(theOStream, className)                                            \
0075   }
0076 
0077 //! @def OCCT_DUMP_TRANSIENT_CLASS_BEGIN
0078 //! Creates an instance of Sentry to cover the current Dump implementation with keys of start and
0079 //! end. This row should be inserted before other macros. The end key will be added by the sentry
0080 //! remove, (exit of the method).
0081 #define OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)                                                \
0082   {                                                                                                \
0083     const char* className = get_type_name();                                                       \
0084     OCCT_DUMP_FIELD_VALUE_STRING(theOStream, className)                                            \
0085   }
0086 
0087 //! @def OCCT_DUMP_FIELD_VALUE_NUMERICAL
0088 //! Append into output value: "Name": Field
0089 #define OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, theField)                                      \
0090   {                                                                                                \
0091     TCollection_AsciiString aName = Standard_Dump::DumpFieldToName(#theField);                     \
0092     Standard_Dump::AddValuesSeparator(theOStream);                                                 \
0093     theOStream << "\"" << aName << "\": " << theField;                                             \
0094   }
0095 
0096 //! @def OCCT_DUMP_FIELD_VALUE_NUMERICAL
0097 //! Append into output value: "Name": Field
0098 //! Inc name value added to the key to provide unique keys
0099 #define OCCT_DUMP_FIELD_VALUE_NUMERICAL_INC(theOStream, theField, theIncName)                      \
0100   {                                                                                                \
0101     TCollection_AsciiString aName = Standard_Dump::DumpFieldToName(#theField) + theIncName;        \
0102     Standard_Dump::AddValuesSeparator(theOStream);                                                 \
0103     theOStream << "\"" << aName << "\": " << theField;                                             \
0104   }
0105 
0106 //! @def OCCT_INIT_FIELD_VALUE_REAL
0107 //! Append vector values into output value: "Name": [value_1, value_2, ...]
0108 //! This macro is intended to have only one row for dumped object in Json.
0109 //! It's possible to use it without necessity of OCCT_DUMP_CLASS_BEGIN call, but pay attention that
0110 //! it should be only one row in the object dump.
0111 #define OCCT_INIT_FIELD_VALUE_REAL(theOStream, theStreamPos, theField)                             \
0112   {                                                                                                \
0113     int aStreamPos = theStreamPos;                                                                 \
0114     if (!Standard_Dump::ProcessFieldName(theOStream, #theField, aStreamPos))                       \
0115       return false;                                                                                \
0116     TCollection_AsciiString aValueText;                                                            \
0117     if (!Standard_Dump::InitValue(theOStream, aStreamPos, aValueText)                              \
0118         || !aValueText.IsRealValue())                                                              \
0119       return false;                                                                                \
0120     theField     = aValueText.RealValue();                                                         \
0121     theStreamPos = aStreamPos;                                                                     \
0122   }
0123 
0124 //! @def OCCT_INIT_FIELD_VALUE_NUMERICAL
0125 //! Append vector values into output value: "Name": [value_1, value_2, ...]
0126 //! This macro is intended to have only one row for dumped object in Json.
0127 //! It's possible to use it without necessity of OCCT_DUMP_CLASS_BEGIN call, but pay attention that
0128 //! it should be only one row in the object dump.
0129 #define OCCT_INIT_FIELD_VALUE_INTEGER(theOStream, theStreamPos, theField)                          \
0130   {                                                                                                \
0131     int aStreamPos = theStreamPos;                                                                 \
0132     if (!Standard_Dump::ProcessFieldName(theOStream, #theField, aStreamPos))                       \
0133       return false;                                                                                \
0134     TCollection_AsciiString aValueText;                                                            \
0135     if (!Standard_Dump::InitValue(theOStream, aStreamPos, aValueText)                              \
0136         || !aValueText.IsIntegerValue())                                                           \
0137       return false;                                                                                \
0138     theField     = aValueText.IntegerValue();                                                      \
0139     theStreamPos = aStreamPos;                                                                     \
0140   }
0141 
0142 //! @def OCCT_DUMP_FIELD_VALUE_STRING
0143 //! Append into output value: "Name": "Field"
0144 #define OCCT_DUMP_FIELD_VALUE_STRING(theOStream, theField)                                         \
0145   {                                                                                                \
0146     TCollection_AsciiString aName = Standard_Dump::DumpFieldToName(#theField);                     \
0147     Standard_Dump::AddValuesSeparator(theOStream);                                                 \
0148     theOStream << "\"" << aName << "\": \"" << theField << "\"";                                   \
0149   }
0150 
0151 //! @def OCCT_DUMP_FIELD_VALUE_POINTER
0152 //! Append into output value: "Name": "address of the pointer"
0153 #define OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, theField)                                        \
0154   {                                                                                                \
0155     TCollection_AsciiString aName = Standard_Dump::DumpFieldToName(#theField);                     \
0156     Standard_Dump::AddValuesSeparator(theOStream);                                                 \
0157     theOStream << "\"" << aName << "\": \"" << Standard_Dump::GetPointerInfo(theField) << "\"";    \
0158   }
0159 
0160 //! @def OCCT_DUMP_FIELD_VALUE_STRING
0161 //! Append into output value: "Name": "Field"
0162 #define OCCT_DUMP_FIELD_VALUE_GUID(theOStream, theField)                                           \
0163   {                                                                                                \
0164     TCollection_AsciiString aName = Standard_Dump::DumpFieldToName(#theField);                     \
0165     Standard_Dump::AddValuesSeparator(theOStream);                                                 \
0166     char aStr[Standard_GUID_SIZE_ALLOC];                                                           \
0167     theField.ToCString(aStr);                                                                      \
0168     theOStream << "\"" << aName << "\": \"" << aStr << "\"";                                       \
0169   }
0170 
0171 //! @def OCCT_DUMP_FIELD_VALUES_DUMPED
0172 //! Append into output value: "Name": { field dumped values }
0173 //! It computes Dump of the fields. The expected field is a pointer.
0174 //! Use this macro for fields of the dumped class which has own Dump implementation.
0175 //! The macros is recursive. Recursion is stopped when the depth value becomes equal to zero.
0176 //! Depth = -1 is the default value, dump here is unlimited.
0177 #define OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, theField)                              \
0178   {                                                                                                \
0179     if (theDepth != 0 && (void*)(theField) != NULL)                                                \
0180     {                                                                                              \
0181       Standard_SStream aFieldStream;                                                               \
0182       (theField)->DumpJson(aFieldStream, theDepth - 1);                                            \
0183       TCollection_AsciiString aName = Standard_Dump::DumpFieldToName(#theField);                   \
0184       Standard_Dump::DumpKeyToClass(theOStream, aName, Standard_Dump::Text(aFieldStream));         \
0185     }                                                                                              \
0186   }
0187 
0188 //! @def OCCT_DUMP_FIELD_VALUES_DUMPED_INC
0189 //! Append into output value: "Name": { field dumped values }
0190 //! It computes Dump of the fields. The expected field is a pointer.
0191 //! Use this macro for fields of the dumped class which has own Dump implementation.
0192 //! The macros is recursive. Recursion is stopped when the depth value becomes equal to zero.
0193 //! Depth = -1 is the default value, dump here is unlimited.
0194 //! Inc name value added to the key to provide unique keys
0195 #define OCCT_DUMP_FIELD_VALUES_DUMPED_INC(theOStream, theDepth, theField, theIncName)              \
0196   {                                                                                                \
0197     if (theDepth != 0 && (void*)(theField) != NULL)                                                \
0198     {                                                                                              \
0199       Standard_SStream aFieldStream;                                                               \
0200       (theField)->DumpJson(aFieldStream, theDepth - 1);                                            \
0201       TCollection_AsciiString aName = Standard_Dump::DumpFieldToName(#theField) + theIncName;      \
0202       Standard_Dump::DumpKeyToClass(theOStream, aName, Standard_Dump::Text(aFieldStream));         \
0203     }                                                                                              \
0204   }
0205 
0206 //! @def OCCT_INIT_FIELD_VALUES_DUMPED
0207 //! Append into output value: "Name": { field dumped values }
0208 //! It computes Dump of the fields. The expected field is a pointer.
0209 //! Use this macro for fields of the dumped class which has own Dump implementation.
0210 //! The macros is recursive. Recursion is stopped when the depth value becomes equal to zero.
0211 //! Depth = -1 is the default value, dump here is unlimited.
0212 #define OCCT_INIT_FIELD_VALUES_DUMPED(theSStream, theStreamPos, theField)                          \
0213   {                                                                                                \
0214     if ((theField) == NULL || !(theField)->InitFromJson(theSStream, theStreamPos))                 \
0215       return false;                                                                                \
0216   }
0217 
0218 //! @def OCCT_DUMP_STREAM_VALUE_DUMPED
0219 //! Append into output value: "Name": { stream text }
0220 //! It computes Dump of the fields. The expected field is a pointer.
0221 //! Use this macro for Standard_SStream field.
0222 #define OCCT_DUMP_STREAM_VALUE_DUMPED(theOStream, theField)                                        \
0223   {                                                                                                \
0224     TCollection_AsciiString aName = Standard_Dump::DumpFieldToName(#theField);                     \
0225     Standard_Dump::DumpKeyToClass(theOStream, aName, Standard_Dump::Text(theField));               \
0226   }
0227 
0228 //! @def OCCT_DUMP_FIELD_VALUES_NUMERICAL
0229 //! Append real values into output values in an order: [value_1, value_2, ...]
0230 //! It computes Dump of the parent. The expected field is a parent class name to call
0231 //! ClassName::Dump.
0232 #define OCCT_DUMP_FIELD_VALUES_NUMERICAL(theOStream, theName, theCount, ...)                       \
0233   {                                                                                                \
0234     Standard_Dump::AddValuesSeparator(theOStream);                                                 \
0235     theOStream << "\"" << theName << "\": [";                                                      \
0236     Standard_Dump::DumpRealValues(theOStream, theCount, __VA_ARGS__);                              \
0237     theOStream << "]";                                                                             \
0238   }
0239 
0240 //! @def OCCT_DUMP_FIELD_VALUES_STRING
0241 //! Append real values into output values in an order: ["value_1", "value_2", ...]
0242 //! It computes Dump of the parent. The expected field is a parent class name to call
0243 //! ClassName::Dump.
0244 #define OCCT_DUMP_FIELD_VALUES_STRING(theOStream, theName, theCount, ...)                          \
0245   {                                                                                                \
0246     Standard_Dump::AddValuesSeparator(theOStream);                                                 \
0247     theOStream << "\"" << theName << "\": [";                                                      \
0248     Standard_Dump::DumpCharacterValues(theOStream, theCount, __VA_ARGS__);                         \
0249     theOStream << "]";                                                                             \
0250   }
0251 
0252 //! @def OCCT_DUMP_BASE_CLASS
0253 //! Append into output value: "Name": { field dumped values }
0254 //! It computes Dump of the parent. The expected field is a parent class name to call
0255 //! ClassName::Dump. Use this macro for parent of the current class. The macros is recursive.
0256 //! Recursive is stopped when the depth value becomes equal to zero. Depth = -1 is the default
0257 //! value, dump here is unlimited.
0258 #define OCCT_DUMP_BASE_CLASS(theOStream, theDepth, theField)                                       \
0259   {                                                                                                \
0260     if (theDepth != 0)                                                                             \
0261     {                                                                                              \
0262       Standard_Dump::AddValuesSeparator(theOStream);                                               \
0263       theField::DumpJson(theOStream, theDepth - 1);                                                \
0264     }                                                                                              \
0265   }
0266 
0267 //! @def OCCT_DUMP_VECTOR_CLASS
0268 //! Append vector values into output value: "Name": [value_1, value_2, ...]
0269 //! This macro is intended to have only one row for dumped object in Json.
0270 //! It's possible to use it without necessity of OCCT_DUMP_CLASS_BEGIN call, but pay attention that
0271 //! it should be only one row in the object dump.
0272 #define OCCT_DUMP_VECTOR_CLASS(theOStream, theName, theCount, ...)                                 \
0273   {                                                                                                \
0274     Standard_Dump::AddValuesSeparator(theOStream);                                                 \
0275     theOStream << "\"" << theName << "\": [";                                                      \
0276     Standard_Dump::DumpRealValues(theOStream, theCount, __VA_ARGS__);                              \
0277     theOStream << "]";                                                                             \
0278   }
0279 
0280 //! @def OCCT_INIT_VECTOR_CLASS
0281 //! Append vector values into output value: "Name": [value_1, value_2, ...]
0282 //! This macro is intended to have only one row for dumped object in Json.
0283 //! It's possible to use it without necessity of OCCT_DUMP_CLASS_BEGIN call, but pay attention that
0284 //! it should be only one row in the object dump.
0285 #define OCCT_INIT_VECTOR_CLASS(theOStream, theName, theStreamPos, theCount, ...)                   \
0286   {                                                                                                \
0287     int aStreamPos = theStreamPos;                                                                 \
0288     if (!Standard_Dump::ProcessStreamName(theOStream, theName, aStreamPos))                        \
0289       return false;                                                                                \
0290     if (!Standard_Dump::InitRealValues(theOStream, aStreamPos, theCount, __VA_ARGS__))             \
0291       return false;                                                                                \
0292     theStreamPos = aStreamPos;                                                                     \
0293   }
0294 
0295 //! Kind of key in Json string
0296 enum Standard_JsonKey
0297 {
0298   Standard_JsonKey_None,                 //!< no key
0299   Standard_JsonKey_OpenChild,            //!< "{"
0300   Standard_JsonKey_CloseChild,           //!< "}"
0301   Standard_JsonKey_OpenContainer,        //!< "["
0302   Standard_JsonKey_CloseContainer,       //!< "]"
0303   Standard_JsonKey_Quote,                //!< "\""
0304   Standard_JsonKey_SeparatorKeyToValue,  //!< ": "
0305   Standard_JsonKey_SeparatorValueToValue //!< ", "
0306 };
0307 
0308 //! Type for storing a dump value with the stream position
0309 struct Standard_DumpValue
0310 {
0311   Standard_DumpValue()
0312       : myStartPosition(0)
0313   {
0314   }
0315 
0316   Standard_DumpValue(const TCollection_AsciiString& theValue, const int theStartPos)
0317       : myValue(theValue),
0318         myStartPosition(theStartPos)
0319   {
0320   }
0321 
0322   TCollection_AsciiString myValue;         //!< current string value
0323   int                     myStartPosition; //!< position of the value first char in the whole stream
0324 };
0325 
0326 //! This interface has some tool methods for stream (in JSON format) processing.
0327 class Standard_Dump
0328 {
0329 public:
0330   //! Converts stream value to string value. The result is original stream value.
0331   //! @param theStream source value
0332   //! @return text presentation
0333   Standard_EXPORT static TCollection_AsciiString Text(const Standard_SStream& theStream);
0334 
0335   //! Converts stream value to string value. Improves the text presentation with the following
0336   //! cases:
0337   //! - for '{' append after '\n' and indent to the next value, increment current indent value
0338   //! - for '}' append '\n' and current indent before it, decrement indent value
0339   //! - for ',' append after '\n' and indent to the next value. If the current symbol is in massive
0340   //! container [], do nothing Covers result with opened and closed brackets on the top level, if it
0341   //! has no symbols there.
0342   //! @param theStream source value
0343   //! @param theIndent count of ' ' symbols to apply hierarchical indent of the text values
0344   //! @return text presentation
0345   Standard_EXPORT static TCollection_AsciiString FormatJson(const Standard_SStream& theStream,
0346                                                             const int               theIndent = 3);
0347 
0348   //! Converts stream into map of values.
0349   //!
0350   //! The one level stream example: 'key_1: value_1, key_2: value_2'
0351   //! In output: values contain 'key_1: value_1' and 'key_2: value_2'.
0352   //!
0353   //! The two level stream example: 'key_1: value_1, key_2: value_2, key_3: {sublevel_key_1:
0354   //! sublevel_value_1}, key_4: value_4' In output values contain 'key_1: value_1', 'key_2:
0355   //! value_2', 'key_3: {sublevel_key_1: sublevel_value_1}' and 'key_4: value_4'. The sublevel value
0356   //! might be processed later using the same method.
0357   //!
0358   //! @param theStreamStr stream value
0359   //! @param[out] theKeyToValues  container of split values. It contains key to value and position
0360   //! of the value in the stream text
0361   Standard_EXPORT static bool SplitJson(
0362     const TCollection_AsciiString&                                           theStreamStr,
0363     NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue>& theKeyToValues);
0364 
0365   //! Returns container of indices in values, that has hierarchical value
0366   Standard_EXPORT static NCollection_List<int> HierarchicalValueIndices(
0367     const NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString>& theValues);
0368 
0369   //! Returns true if the value has bracket key
0370   Standard_EXPORT static bool HasChildKey(const TCollection_AsciiString& theSourceValue);
0371 
0372   //! Returns key value for enum type
0373   Standard_EXPORT static const char* JsonKeyToString(const Standard_JsonKey theKey);
0374 
0375   //! Returns length value for enum type
0376   Standard_EXPORT static int JsonKeyLength(const Standard_JsonKey theKey);
0377 
0378   //! @param theOStream source value
0379   static Standard_EXPORT void AddValuesSeparator(Standard_OStream& theOStream);
0380 
0381   //! Returns default prefix added for each pointer info string if short presentation of pointer
0382   //! used
0383   static TCollection_AsciiString GetPointerPrefix() { return "0x"; }
0384 
0385   //! Convert handle pointer to address of the pointer. If the handle is NULL, the result is an
0386   //! empty string.
0387   //! @param thePointer a pointer
0388   //! @param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
0389   //! @return the string value
0390   Standard_EXPORT static TCollection_AsciiString GetPointerInfo(
0391     const occ::handle<Standard_Transient>& thePointer,
0392     const bool                             isShortInfo = true);
0393 
0394   //! Convert pointer to address of the pointer. If the handle is NULL, the result is an empty
0395   //! string.
0396   //! @param thePointer a pointer
0397   //! @param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
0398   //! @return the string value
0399   Standard_EXPORT static TCollection_AsciiString GetPointerInfo(const void* thePointer,
0400                                                                 const bool  isShortInfo = true);
0401 
0402   //! Append into output value: "Name": { Field }
0403   //! @param[out] theOStream  stream to be fill with values
0404   //! @param theKey a source value
0405   //! @param theField stream value
0406   Standard_EXPORT static void DumpKeyToClass(Standard_OStream&              theOStream,
0407                                              const TCollection_AsciiString& theKey,
0408                                              const TCollection_AsciiString& theField);
0409 
0410   //! Unite values in one value using template: "value_1", "value_2", ..., "value_n"
0411   //! @param[out] theOStream  stream to be fill with values
0412   //! @param[in] theCount     number of values
0413   Standard_EXPORT static void DumpCharacterValues(Standard_OStream& theOStream, int theCount, ...);
0414 
0415   //! Unite values in one value using template: value_1, value_2, ..., value_n
0416   //! @param[out] theOStream  stream to be fill with values
0417   //! @param[in] theCount     number of values
0418   Standard_EXPORT static void DumpRealValues(Standard_OStream& theOStream, int theCount, ...);
0419 
0420   //! Check whether the parameter name is equal to the name in the stream at position
0421   //! @param[in]  theStreamStr stream with values
0422   //! @param[in]  theName      stream key value
0423   //! @param[out] theStreamPos current position in the stream
0424   Standard_EXPORT static bool ProcessStreamName(const TCollection_AsciiString& theStreamStr,
0425                                                 const TCollection_AsciiString& theName,
0426                                                 int&                           theStreamPos);
0427 
0428   //! Check whether the field name is equal to the name in the stream at position
0429   //! @param[in]  theStreamStr stream with values
0430   //! @param[in]  theName      stream key field value
0431   //! @param[out] theStreamPos current position in the stream
0432   Standard_EXPORT static bool ProcessFieldName(const TCollection_AsciiString& theStreamStr,
0433                                                const TCollection_AsciiString& theName,
0434                                                int&                           theStreamPos);
0435 
0436   //! Unite values in one value using template: value_1, value_2, ..., value_n
0437   //! @param[in]  theStreamStr stream with values
0438   //! @param[out] theStreamPos current position in the stream
0439   //! @param[in]  theCount     number of values
0440   Standard_EXPORT static bool InitRealValues(const TCollection_AsciiString& theStreamStr,
0441                                              int&                           theStreamPos,
0442                                              int                            theCount,
0443                                              ...);
0444 
0445   //! Returns real value
0446   //! @param[in]  theStreamStr stream with values
0447   //! @param[out] theStreamPos current position in the stream
0448   //! @param[out] theValue     stream value
0449   Standard_EXPORT static bool InitValue(const TCollection_AsciiString& theStreamStr,
0450                                         int&                           theStreamPos,
0451                                         TCollection_AsciiString&       theValue);
0452 
0453   //! Convert field name into dump text value, removes "&" and "my" prefixes
0454   //! An example, for field myValue, theName is Value, for &myCLass, the name is Class
0455   //! @param theField a source value
0456   Standard_EXPORT static TCollection_AsciiString DumpFieldToName(
0457     const TCollection_AsciiString& theField);
0458 
0459 private:
0460   //! Extracts from the string value a pair (key, value), add it into output container, update index
0461   //! value Example: stream string starting the index position contains: ..."key": <value>... a pair
0462   //! key, value will be added into theValues at beginning theIndex is the position of the quota
0463   //! before <key>, after the index is the next position after the value splitDumped(aString) gives
0464   //! theSplitValue = "abc", theTailValue = "defg", theKey = "key"
0465   Standard_EXPORT static bool splitKeyToValue(
0466     const TCollection_AsciiString&                                           theStreamStr,
0467     int                                                                      theStartIndex,
0468     int&                                                                     theNextIndex,
0469     NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue>& theValues);
0470 
0471   //! Returns key of json in the index position. Increment the index position to the next symbol in
0472   //! the row
0473   Standard_EXPORT static bool jsonKey(const TCollection_AsciiString& theStreamStr,
0474                                       int                            theStartIndex,
0475                                       int&                           theNextIndex,
0476                                       Standard_JsonKey&              theKey);
0477 
0478   //! Find position in the source string of the symbol close after the start position.
0479   //! Ignore combination <symbol open> ... <symbol close> between the close symbol.
0480   //! Example, for case ... { ... { ... } ...} ... } it returns the position of the forth brace
0481   Standard_EXPORT static int nextClosePosition(const TCollection_AsciiString& theSourceValue,
0482                                                const int                      theStartPosition,
0483                                                const Standard_JsonKey         theCloseKey,
0484                                                const Standard_JsonKey         theOpenKey);
0485 };
0486 
0487 #endif // _Standard_Dump_HeaderFile