0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / Standard / Standard_Dump.hxx
CommitLineData
0904aa63 1// Copyright (c) 2019 OPEN CASCADE SAS
2//
3// This file is part of Open CASCADE Technology software library.
4//
5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Lesser General Public License version 2.1 as published
7// by the Free Software Foundation, with special exception defined in the file
8// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9// distribution for complete text of the license and disclaimer of any warranty.
10//
11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
13
14#ifndef _Standard_Dump_HeaderFile
15#define _Standard_Dump_HeaderFile
16
bc73b006 17#include <NCollection_IndexedDataMap.hxx>
18#include <NCollection_List.hxx>
a2af24d1 19#include <Standard_OStream.hxx>
0904aa63 20#include <Standard_SStream.hxx>
21#include <TCollection_AsciiString.hxx>
22
64e68ea6 23//!@file
0904aa63 24//! The file contains interface to prepare dump output for OCCT objects. Format of the dump is JSON.
64e68ea6 25//!
3de0f784 26//! To prepare this output, implement method DumpJson in the object and use macro functions from this file.
0904aa63 27//! Macros have one parameter for both, key and the value. It is a field of the current class. Macro has internal analyzer that
28//! uses the variable name to generate key. If the parameter has prefix symbols "&", "*" and "my", it is cut.
29//!
3de0f784 30//! - OCCT_DUMP_FIELD_VALUE_NUMERICAL. Use it for fields of numerical C++ types, like int, float, double. It creates a pair "key", "value",
04114fd2 31//! - OCCT_DUMP_FIELD_VALUE_NUMERICAL_INC. Use it for fields of numerical C++ types, like int, float, double.
32//! It creates a pair "key_inc", "value",
3de0f784 33//! - OCCT_DUMP_FIELD_VALUE_STRING. Use it for char* type. It creates a pair "key", "value",
34//! - OCCT_DUMP_FIELD_VALUE_POINTER. Use it for pointer fields. It creates a pair "key", "value", where the value is the pointer address,
35//! - OCCT_DUMP_FIELD_VALUES_DUMPED. Use it for fields that has own Dump implementation. It expects the pointer to the class instance.
0904aa63 36//! It creates "key": { result of dump of the field }
04114fd2 37//! - OCCT_DUMP_FIELD_VALUES_DUMPED_INC. Use it for fields that has own Dump implementation. It expects the pointer to the class instance.
38//! It creates "key_inc": { result of dump of the field }
39//! - OCCT_DUMP_STREAM_VALUE_DUMPED. Use it for Standard_SStream. It creates "key": { text of stream }
3de0f784 40//! - OCCT_DUMP_FIELD_VALUES_NUMERICAL. Use it for unlimited list of fields of C++ double type.
0904aa63 41//! It creates massive of values [value_1, value_2, ...]
3de0f784 42//! - OCCT_DUMP_FIELD_VALUES_STRING. Use it for unlimited list of fields of TCollection_AsciiString types.
0904aa63 43//! It creates massive of values ["value_1", "value_2", ...]
3de0f784 44//! - OCCT_DUMP_BASE_CLASS. Use if Dump implementation of the class is virtual, to perform ClassName::Dump() of the parent class,
0904aa63 45//! expected parameter is the parent class name.
46//! It creates "key": { result of dump of the field }
3de0f784 47//! - OCCT_DUMP_VECTOR_CLASS. Use it as a single row in some object dump to have one row in output.
48//! It's possible to use it without necessity of OCCT_DUMP_CLASS_BEGIN call.
0904aa63 49//! It creates massive of values [value_1, value_2, ...]
50//!
51//! The Dump result prepared by these macros is an output stream, it is not arranged with spaces and line feed.
52//! To have output in a more readable way, use ConvertToAlignedString method for obtained stream.
53
54//! Converts the class type into a string value
3de0f784 55#define OCCT_CLASS_NAME(theClass) #theClass
0904aa63 56
3de0f784 57//! @def OCCT_DUMP_CLASS_BEGIN
0904aa63 58//! Creates an instance of Sentry to cover the current Dump implementation with keys of start and end.
59//! This row should be inserted before other macros. The end key will be added by the sentry remove,
60//! (exit of the method).
bc73b006 61#define OCCT_DUMP_CLASS_BEGIN(theOStream, theField) \
62{ \
63 const char* className = OCCT_CLASS_NAME(theField); \
64 OCCT_DUMP_FIELD_VALUE_STRING (theOStream, className) \
65}
66
67//! @def OCCT_DUMP_TRANSIENT_CLASS_BEGIN
68//! Creates an instance of Sentry to cover the current Dump implementation with keys of start and end.
69//! This row should be inserted before other macros. The end key will be added by the sentry remove,
70//! (exit of the method).
71#define OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream) \
72{ \
73 const char* className = get_type_name(); \
74 OCCT_DUMP_FIELD_VALUE_STRING (theOStream, className) \
75}
0904aa63 76
3de0f784 77//! @def OCCT_DUMP_FIELD_VALUE_NUMERICAL
0904aa63 78//! Append into output value: "Name": Field
3de0f784 79#define OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, theField) \
0904aa63 80{ \
bc73b006 81 TCollection_AsciiString aName = Standard_Dump::DumpFieldToName (#theField); \
3de0f784 82 Standard_Dump::AddValuesSeparator (theOStream); \
0904aa63 83 theOStream << "\"" << aName << "\": " << theField; \
84}
85
04114fd2 86//! @def OCCT_DUMP_FIELD_VALUE_NUMERICAL
87//! Append into output value: "Name": Field
88//! Inc name value added to the key to provide unique keys
89#define OCCT_DUMP_FIELD_VALUE_NUMERICAL_INC(theOStream, theField, theIncName) \
90{ \
91 TCollection_AsciiString aName = Standard_Dump::DumpFieldToName (#theField) + theIncName; \
92 Standard_Dump::AddValuesSeparator (theOStream); \
93 theOStream << "\"" << aName << "\": " << theField; \
94}
95
6b63dc83 96//! @def OCCT_INIT_FIELD_VALUE_REAL
97//! Append vector values into output value: "Name": [value_1, value_2, ...]
98//! This macro is intended to have only one row for dumped object in Json.
99//! It's possible to use it without necessity of OCCT_DUMP_CLASS_BEGIN call, but pay attention that it should be only one row in the object dump.
100#define OCCT_INIT_FIELD_VALUE_REAL(theOStream, theStreamPos, theField) \
101{ \
102 Standard_Integer aStreamPos = theStreamPos; \
103 if (!Standard_Dump::ProcessFieldName (theOStream, #theField, aStreamPos)) \
104 return Standard_False; \
105 TCollection_AsciiString aValueText; \
106 if (!Standard_Dump::InitValue (theOStream, aStreamPos, aValueText) || !aValueText.IsRealValue()) \
107 return Standard_False; \
108 theField = aValueText.RealValue(); \
109 theStreamPos = aStreamPos; \
110}
111
112//! @def OCCT_INIT_FIELD_VALUE_NUMERICAL
113//! Append vector values into output value: "Name": [value_1, value_2, ...]
114//! This macro is intended to have only one row for dumped object in Json.
115//! It's possible to use it without necessity of OCCT_DUMP_CLASS_BEGIN call, but pay attention that it should be only one row in the object dump.
116#define OCCT_INIT_FIELD_VALUE_INTEGER(theOStream, theStreamPos, theField) \
117{ \
118 Standard_Integer aStreamPos = theStreamPos; \
119 if (!Standard_Dump::ProcessFieldName (theOStream, #theField, aStreamPos)) \
120 return Standard_False; \
121 TCollection_AsciiString aValueText; \
122 if (!Standard_Dump::InitValue (theOStream, aStreamPos, aValueText) || !aValueText.IsIntegerValue()) \
123 return Standard_False; \
124 theField = aValueText.IntegerValue(); \
125 theStreamPos = aStreamPos; \
126}
127
3de0f784 128//! @def OCCT_DUMP_FIELD_VALUE_STRING
0904aa63 129//! Append into output value: "Name": "Field"
3de0f784 130#define OCCT_DUMP_FIELD_VALUE_STRING(theOStream, theField) \
0904aa63 131{ \
bc73b006 132 TCollection_AsciiString aName = Standard_Dump::DumpFieldToName (#theField); \
3de0f784 133 Standard_Dump::AddValuesSeparator (theOStream); \
0904aa63 134 theOStream << "\"" << aName << "\": \"" << theField << "\""; \
135}
136
3de0f784 137//! @def OCCT_DUMP_FIELD_VALUE_POINTER
0904aa63 138//! Append into output value: "Name": "address of the pointer"
3de0f784 139#define OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, theField) \
0904aa63 140{ \
bc73b006 141 TCollection_AsciiString aName = Standard_Dump::DumpFieldToName (#theField); \
3de0f784 142 Standard_Dump::AddValuesSeparator (theOStream); \
0904aa63 143 theOStream << "\"" << aName << "\": \"" << Standard_Dump::GetPointerInfo (theField) << "\""; \
144}
145
bc73b006 146//! @def OCCT_DUMP_FIELD_VALUE_STRING
147//! Append into output value: "Name": "Field"
148#define OCCT_DUMP_FIELD_VALUE_GUID(theOStream, theField) \
149{ \
150 TCollection_AsciiString aName = Standard_Dump::DumpFieldToName (#theField); \
151 Standard_Dump::AddValuesSeparator (theOStream); \
152 char aStr[Standard_GUID_SIZE_ALLOC]; \
153 theField.ToCString (aStr); \
154 theOStream << "\"" << aName << "\": \"" << aStr << "\""; \
155}
156
3de0f784 157//! @def OCCT_DUMP_FIELD_VALUES_DUMPED
0904aa63 158//! Append into output value: "Name": { field dumped values }
159//! It computes Dump of the fields. The expected field is a pointer.
160//! Use this macro for fields of the dumped class which has own Dump implementation.
161//! The macros is recursive. Recursion is stopped when the depth value becomes equal to zero.
162//! Depth = -1 is the default value, dump here is unlimited.
3de0f784 163#define OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, theField) \
0904aa63 164{ \
bc73b006 165 if (theDepth != 0 && (void*)(theField) != NULL) \
0904aa63 166 { \
167 Standard_SStream aFieldStream; \
bc73b006 168 (theField)->DumpJson (aFieldStream, theDepth - 1); \
169 TCollection_AsciiString aName = Standard_Dump::DumpFieldToName (#theField); \
0904aa63 170 Standard_Dump::DumpKeyToClass (theOStream, aName, Standard_Dump::Text (aFieldStream)); \
171 } \
172}
173
04114fd2 174//! @def OCCT_DUMP_FIELD_VALUES_DUMPED_INC
175//! Append into output value: "Name": { field dumped values }
176//! It computes Dump of the fields. The expected field is a pointer.
177//! Use this macro for fields of the dumped class which has own Dump implementation.
178//! The macros is recursive. Recursion is stopped when the depth value becomes equal to zero.
179//! Depth = -1 is the default value, dump here is unlimited.
180//! Inc name value added to the key to provide unique keys
181#define OCCT_DUMP_FIELD_VALUES_DUMPED_INC(theOStream, theDepth, theField, theIncName) \
182{ \
183 if (theDepth != 0 && (void*)(theField) != NULL) \
184 { \
185 Standard_SStream aFieldStream; \
186 (theField)->DumpJson (aFieldStream, theDepth - 1); \
187 TCollection_AsciiString aName = Standard_Dump::DumpFieldToName (#theField) + theIncName; \
188 Standard_Dump::DumpKeyToClass (theOStream, aName, Standard_Dump::Text (aFieldStream)); \
189 } \
190}
191
6b63dc83 192//! @def OCCT_INIT_FIELD_VALUES_DUMPED
193//! Append into output value: "Name": { field dumped values }
194//! It computes Dump of the fields. The expected field is a pointer.
195//! Use this macro for fields of the dumped class which has own Dump implementation.
196//! The macros is recursive. Recursion is stopped when the depth value becomes equal to zero.
197//! Depth = -1 is the default value, dump here is unlimited.
198#define OCCT_INIT_FIELD_VALUES_DUMPED(theSStream, theStreamPos, theField) \
199{ \
200 if ((theField) == NULL || !(theField)->InitFromJson (theSStream, theStreamPos)) \
201 return Standard_False; \
202}
203
04114fd2 204//! @def OCCT_DUMP_STREAM_VALUE_DUMPED
205//! Append into output value: "Name": { stream text }
206//! It computes Dump of the fields. The expected field is a pointer.
207//! Use this macro for Standard_SStream field.
208#define OCCT_DUMP_STREAM_VALUE_DUMPED(theOStream, theField) \
209{ \
210 TCollection_AsciiString aName = Standard_Dump::DumpFieldToName (#theField); \
211 Standard_Dump::DumpKeyToClass (theOStream, aName, Standard_Dump::Text (theField)); \
212}
213
3de0f784 214//! @def OCCT_DUMP_FIELD_VALUES_NUMERICAL
0904aa63 215//! Append real values into output values in an order: [value_1, value_2, ...]
216//! It computes Dump of the parent. The expected field is a parent class name to call ClassName::Dump.
3de0f784 217#define OCCT_DUMP_FIELD_VALUES_NUMERICAL(theOStream, theName, theCount, ...) \
0904aa63 218{ \
3de0f784 219 Standard_Dump::AddValuesSeparator (theOStream); \
0904aa63 220 theOStream << "\"" << theName << "\": ["; \
221 Standard_Dump::DumpRealValues (theOStream, theCount, __VA_ARGS__);\
222 theOStream << "]"; \
223}
224
3de0f784 225//! @def OCCT_DUMP_FIELD_VALUES_STRING
0904aa63 226//! Append real values into output values in an order: ["value_1", "value_2", ...]
227//! It computes Dump of the parent. The expected field is a parent class name to call ClassName::Dump.
3de0f784 228#define OCCT_DUMP_FIELD_VALUES_STRING(theOStream, theName, theCount, ...) \
0904aa63 229{ \
3de0f784 230 Standard_Dump::AddValuesSeparator (theOStream); \
0904aa63 231 theOStream << "\"" << theName << "\": ["; \
232 Standard_Dump::DumpCharacterValues (theOStream, theCount, __VA_ARGS__);\
233 theOStream << "]"; \
234}
235
3de0f784 236//! @def OCCT_DUMP_BASE_CLASS
0904aa63 237//! Append into output value: "Name": { field dumped values }
238//! It computes Dump of the parent. The expected field is a parent class name to call ClassName::Dump.
239//! Use this macro for parent of the current class.
316ea293 240//! The macros is recursive. Recursive is stopped when the depth value becomes equal to zero.
0904aa63 241//! Depth = -1 is the default value, dump here is unlimited.
3de0f784 242#define OCCT_DUMP_BASE_CLASS(theOStream, theDepth, theField) \
0904aa63 243{ \
244 if (theDepth != 0) \
245 { \
bc73b006 246 Standard_Dump::AddValuesSeparator (theOStream); \
247 theField::DumpJson (theOStream, theDepth - 1); \
0904aa63 248 } \
249}
250
3de0f784 251//! @def OCCT_DUMP_VECTOR_CLASS
0904aa63 252//! Append vector values into output value: "Name": [value_1, value_2, ...]
253//! This macro is intended to have only one row for dumped object in Json.
3de0f784 254//! It's possible to use it without necessity of OCCT_DUMP_CLASS_BEGIN call, but pay attention that it should be only one row in the object dump.
255#define OCCT_DUMP_VECTOR_CLASS(theOStream, theName, theCount, ...) \
0904aa63 256{ \
bc73b006 257 Standard_Dump::AddValuesSeparator (theOStream); \
258 theOStream << "\"" << theName << "\": ["; \
0904aa63 259 Standard_Dump::DumpRealValues (theOStream, theCount, __VA_ARGS__);\
260 theOStream << "]"; \
261}
262
6b63dc83 263//! @def OCCT_INIT_VECTOR_CLASS
264//! Append vector values into output value: "Name": [value_1, value_2, ...]
265//! This macro is intended to have only one row for dumped object in Json.
266//! It's possible to use it without necessity of OCCT_DUMP_CLASS_BEGIN call, but pay attention that it should be only one row in the object dump.
267#define OCCT_INIT_VECTOR_CLASS(theOStream, theName, theStreamPos, theCount, ...) \
268{ \
269 Standard_Integer aStreamPos = theStreamPos; \
270 if (!Standard_Dump::ProcessStreamName (theOStream, theName, aStreamPos)) \
271 return Standard_False; \
272 if (!Standard_Dump::InitRealValues (theOStream, aStreamPos, theCount, __VA_ARGS__)) \
273 return Standard_False; \
274 theStreamPos = aStreamPos; \
275}
276
bc73b006 277//! Kind of key in Json string
278enum Standard_JsonKey
0904aa63 279{
bc73b006 280 Standard_JsonKey_None, //!< no key
281 Standard_JsonKey_OpenChild, //!< "{"
282 Standard_JsonKey_CloseChild, //!< "}"
283 Standard_JsonKey_OpenContainer, //!< "["
284 Standard_JsonKey_CloseContainer, //!< "]"
285 Standard_JsonKey_Quote, //!< "\""
286 Standard_JsonKey_SeparatorKeyToValue, //!< ": "
287 Standard_JsonKey_SeparatorValueToValue //!< ", "
288};
0904aa63 289
bc73b006 290//! Type for storing a dump value with the stream position
291struct Standard_DumpValue
292{
293 Standard_DumpValue() : myStartPosition (0) {}
294 Standard_DumpValue (const TCollection_AsciiString& theValue, const Standard_Integer theStartPos)
295 : myValue (theValue), myStartPosition (theStartPos) {}
0904aa63 296
bc73b006 297 TCollection_AsciiString myValue; //!< current string value
298 Standard_Integer myStartPosition; //!< position of the value first char in the whole stream
0904aa63 299};
300
301//! This interface has some tool methods for stream (in JSON format) processing.
302class Standard_Dump
303{
304public:
305 //! Converts stream value to string value. The result is original stream value.
306 //! @param theStream source value
307 //! @return text presentation
308 Standard_EXPORT static TCollection_AsciiString Text (const Standard_SStream& theStream);
309
310 //! Converts stream value to string value. Improves the text presentation with the following cases:
311 //! - for '{' append after '\n' and indent to the next value, increment current indent value
312 //! - for '}' append '\n' and current indent before it, decrement indent value
313 //! - for ',' append after '\n' and indent to the next value. If the current symbol is in massive container [], do nothing
04114fd2 314 //! Covers result with opened and closed brackets on the top level, if it has no symbols there.
0904aa63 315 //! @param theStream source value
316 //! @param theIndent count of ' ' symbols to apply hierarchical indent of the text values
317 //! @return text presentation
318 Standard_EXPORT static TCollection_AsciiString FormatJson (const Standard_SStream& theStream, const Standard_Integer theIndent = 3);
319
0950253c 320 //! Converts stream into map of values.
bc73b006 321 //!
0950253c 322 //! The one level stream example: 'key_1: value_1, key_2: value_2'
323 //! In output: values contain 'key_1: value_1' and 'key_2: value_2'.
bc73b006 324 //!
0950253c 325 //! The two level stream example: 'key_1: value_1, key_2: value_2, key_3: {sublevel_key_1: sublevel_value_1}, key_4: value_4'
326 //! In output values contain 'key_1: value_1', 'key_2: value_2', 'key_3: {sublevel_key_1: sublevel_value_1}' and 'key_4: value_4'.
327 //! The sublevel value might be processed later using the same method.
bc73b006 328 //!
0950253c 329 //! @param theStreamStr stream value
330 //! @param theKeyToValues [out] container of split values. It contains key to value and position of the value in the stream text
bc73b006 331 Standard_EXPORT static Standard_Boolean SplitJson (const TCollection_AsciiString& theStreamStr,
332 NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue>& theKeyToValues);
333
334 //! Returns container of indices in values, that has hierarchical value
335 Standard_EXPORT static NCollection_List<Standard_Integer> HierarchicalValueIndices (
336 const NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString>& theValues);
337
338 //! Returns true if the value has bracket key
339 Standard_EXPORT static Standard_Boolean HasChildKey (const TCollection_AsciiString& theSourceValue);
340
341 //! Returns key value for enum type
342 Standard_EXPORT static Standard_CString JsonKeyToString (const Standard_JsonKey theKey);
343
344 //! Returns length value for enum type
345 Standard_EXPORT static Standard_Integer JsonKeyLength (const Standard_JsonKey theKey);
346
64e68ea6 347 //! @param theOStream source value
3de0f784 348 static Standard_EXPORT void AddValuesSeparator (Standard_OStream& theOStream);
0904aa63 349
350 //! Returns default prefix added for each pointer info string if short presentation of pointer used
bc73b006 351 static TCollection_AsciiString GetPointerPrefix() { return "0x"; }
0904aa63 352
353 //! Convert handle pointer to address of the pointer. If the handle is NULL, the result is an empty string.
354 //! @param thePointer a pointer
355 //! @param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
356 //! @return the string value
357 Standard_EXPORT static TCollection_AsciiString GetPointerInfo (const Handle(Standard_Transient)& thePointer,
358 const bool isShortInfo = true);
359
360 //! Convert pointer to address of the pointer. If the handle is NULL, the result is an empty string.
361 //! @param thePointer a pointer
362 //! @param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
363 //! @return the string value
364 Standard_EXPORT static TCollection_AsciiString GetPointerInfo (const void* thePointer,
365 const bool isShortInfo = true);
366
367 //! Append into output value: "Name": { Field }
368 //! @param theOStream [out] stream to be fill with values
369 //! @param theKey a source value
370 //! @param theField stream value
371 Standard_EXPORT static void DumpKeyToClass (Standard_OStream& theOStream,
bc73b006 372 const TCollection_AsciiString& theKey,
0904aa63 373 const TCollection_AsciiString& theField);
374
375 //! Unite values in one value using template: "value_1", "value_2", ..., "value_n"
376 //! @param theOStream [out] stream to be fill with values
6b63dc83 377 //! @param theCount [in] number of values
0904aa63 378 Standard_EXPORT static void DumpCharacterValues (Standard_OStream& theOStream, int theCount, ...);
379
380 //! Unite values in one value using template: value_1, value_2, ..., value_n
381 //! @param theOStream [out] stream to be fill with values
6b63dc83 382 //! @param theCount [in] number of values
0904aa63 383 Standard_EXPORT static void DumpRealValues (Standard_OStream& theOStream, int theCount, ...);
384
6b63dc83 385 //! Check whether the parameter name is equal to the name in the stream at position
f291ad25 386 //! @param[in] theStreamStr stream with values
387 //! @param[in] theName stream key value
388 //! @param[out] theStreamPos current position in the stream
6b63dc83 389 Standard_EXPORT static Standard_Boolean ProcessStreamName (const TCollection_AsciiString& theStreamStr,
390 const TCollection_AsciiString& theName,
391 Standard_Integer& theStreamPos);
392
393 //! Check whether the field name is equal to the name in the stream at position
f291ad25 394 //! @param[in] theStreamStr stream with values
395 //! @param[in] theName stream key field value
396 //! @param[out] theStreamPos current position in the stream
6b63dc83 397 Standard_EXPORT static Standard_Boolean ProcessFieldName (const TCollection_AsciiString& theStreamStr,
398 const TCollection_AsciiString& theName,
399 Standard_Integer& theStreamPos);
400
401 //! Unite values in one value using template: value_1, value_2, ..., value_n
f291ad25 402 //! @param[in] theStreamStr stream with values
403 //! @param[out] theStreamPos current position in the stream
404 //! @param[in] theCount number of values
6b63dc83 405 Standard_EXPORT static Standard_Boolean InitRealValues (const TCollection_AsciiString& theStreamStr,
406 Standard_Integer& theStreamPos,
407 int theCount, ...);
408
409 //! Returns real value
f291ad25 410 //! @param[in] theStreamStr stream with values
411 //! @param[out] theStreamPos current position in the stream
412 //! @param[out] theValue stream value
6b63dc83 413 Standard_EXPORT static Standard_Boolean InitValue (const TCollection_AsciiString& theStreamStr,
414 Standard_Integer& theStreamPos,
415 TCollection_AsciiString& theValue);
416
0904aa63 417 //! Convert field name into dump text value, removes "&" and "my" prefixes
418 //! An example, for field myValue, theName is Value, for &myCLass, the name is Class
419 //! @param theField a source value
bc73b006 420 Standard_EXPORT static TCollection_AsciiString DumpFieldToName (const TCollection_AsciiString& theField);
421
422private:
423 //! Extracts from the string value a pair (key, value), add it into output container, update index value
424 //! Example:
425 //! stream string starting the index position contains: ..."key": <value>...
426 //! a pair key, value will be added into theValues
427 //! at beginning theIndex is the position of the quota before <key>, after the index is the next position after the value
428 //! splitDumped(aString) gives theSplitValue = "abc", theTailValue = "defg", theKey = "key"
429 Standard_EXPORT static Standard_Boolean splitKeyToValue (const TCollection_AsciiString& theStreamStr,
430 Standard_Integer theStartIndex,
431 Standard_Integer& theNextIndex,
432 NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue>& theValues);
433
434
435 //! Returns key of json in the index position. Incement the index position to the next symbol in the row
436 Standard_EXPORT static Standard_Boolean jsonKey (const TCollection_AsciiString& theStreamStr,
437 Standard_Integer theStartIndex,
438 Standard_Integer& theNextIndex,
439 Standard_JsonKey& theKey);
440
441 //! Find position in the source string of the symbol close after the start position.
442 //! Ignore combination <symbol open> ... <symbol close> between the close symbol.
443 //! Example, for case ... { ... { ... } ...} ... } it returns the position of the forth brace
444 Standard_EXPORT static Standard_Integer nextClosePosition (const TCollection_AsciiString& theSourceValue,
445 const Standard_Integer theStartPosition,
446 const Standard_JsonKey theCloseKey,
447 const Standard_JsonKey theOpenKey);
448
0904aa63 449};
450
451#endif // _Standard_Dump_HeaderFile