Open CASCADE Technology 7.8.2.dev
Standard_Dump.hxx File Reference

The file contains interface to prepare dump output for OCCT objects. Format of the dump is JSON. More...

Data Structures

struct  Standard_DumpValue
 Type for storing a dump value with the stream position. More...
 
class  Standard_Dump
 This interface has some tool methods for stream (in JSON format) processing. More...
 

Macros

#define OCCT_CLASS_NAME(theClass)
 Converts the class type into a string value.
 
#define OCCT_DUMP_CLASS_BEGIN(theOStream, theField)
 Creates an instance of Sentry to cover the current Dump implementation with keys of start and end. This row should be inserted before other macros. The end key will be added by the sentry remove, (exit of the method).
 
#define OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
 Creates an instance of Sentry to cover the current Dump implementation with keys of start and end. This row should be inserted before other macros. The end key will be added by the sentry remove, (exit of the method).
 
#define OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, theField)
 Append into output value: "Name": Field.
 
#define OCCT_DUMP_FIELD_VALUE_NUMERICAL_INC(theOStream, theField, theIncName)
 
#define OCCT_INIT_FIELD_VALUE_REAL(theOStream, theStreamPos, theField)
 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. 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.
 
#define OCCT_INIT_FIELD_VALUE_INTEGER(theOStream, theStreamPos, theField)
 
#define OCCT_DUMP_FIELD_VALUE_STRING(theOStream, theField)
 Append into output value: "Name": "Field".
 
#define OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, theField)
 Append into output value: "Name": "address of the pointer".
 
#define OCCT_DUMP_FIELD_VALUE_GUID(theOStream, theField)
 
#define OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, theField)
 Append into output value: "Name": { field dumped values } It computes Dump of the fields. The expected field is a pointer. Use this macro for fields of the dumped class which has own Dump implementation. The macros is recursive. Recursion is stopped when the depth value becomes equal to zero. Depth = -1 is the default value, dump here is unlimited.
 
#define OCCT_DUMP_FIELD_VALUES_DUMPED_INC(theOStream, theDepth, theField, theIncName)
 Append into output value: "Name": { field dumped values } It computes Dump of the fields. The expected field is a pointer. Use this macro for fields of the dumped class which has own Dump implementation. The macros is recursive. Recursion is stopped when the depth value becomes equal to zero. Depth = -1 is the default value, dump here is unlimited. Inc name value added to the key to provide unique keys.
 
#define OCCT_INIT_FIELD_VALUES_DUMPED(theSStream, theStreamPos, theField)
 Append into output value: "Name": { field dumped values } It computes Dump of the fields. The expected field is a pointer. Use this macro for fields of the dumped class which has own Dump implementation. The macros is recursive. Recursion is stopped when the depth value becomes equal to zero. Depth = -1 is the default value, dump here is unlimited.
 
#define OCCT_DUMP_STREAM_VALUE_DUMPED(theOStream, theField)
 Append into output value: "Name": { stream text } It computes Dump of the fields. The expected field is a pointer. Use this macro for Standard_SStream field.
 
#define OCCT_DUMP_FIELD_VALUES_NUMERICAL(theOStream, theName, theCount, ...)
 Append real values into output values in an order: [value_1, value_2, ...] It computes Dump of the parent. The expected field is a parent class name to call ClassName::Dump.
 
#define OCCT_DUMP_FIELD_VALUES_STRING(theOStream, theName, theCount, ...)
 Append real values into output values in an order: ["value_1", "value_2", ...] It computes Dump of the parent. The expected field is a parent class name to call ClassName::Dump.
 
#define OCCT_DUMP_BASE_CLASS(theOStream, theDepth, theField)
 Append into output value: "Name": { field dumped values } It computes Dump of the parent. The expected field is a parent class name to call ClassName::Dump. Use this macro for parent of the current class. The macros is recursive. Recursive is stopped when the depth value becomes equal to zero. Depth = -1 is the default value, dump here is unlimited.
 
#define OCCT_DUMP_VECTOR_CLASS(theOStream, theName, theCount, ...)
 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. 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.
 
#define OCCT_INIT_VECTOR_CLASS(theOStream, theName, theStreamPos, theCount, ...)
 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. 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.
 

Enumerations

enum  Standard_JsonKey {
  Standard_JsonKey_None , Standard_JsonKey_OpenChild , Standard_JsonKey_CloseChild , Standard_JsonKey_OpenContainer ,
  Standard_JsonKey_CloseContainer , Standard_JsonKey_Quote , Standard_JsonKey_SeparatorKeyToValue , Standard_JsonKey_SeparatorValueToValue
}
 Kind of key in Json string. More...
 

Detailed Description

The file contains interface to prepare dump output for OCCT objects. Format of the dump is JSON.

To prepare this output, implement method DumpJson in the object and use macro functions from this file. Macros have one parameter for both, key and the value. It is a field of the current class. Macro has internal analyzer that uses the variable name to generate key. If the parameter has prefix symbols "&", "*" and "my", it is cut.

  • OCCT_DUMP_FIELD_VALUE_NUMERICAL. Use it for fields of numerical C++ types, like int, float, double. It creates a pair "key", "value",
  • OCCT_DUMP_FIELD_VALUE_NUMERICAL_INC. Use it for fields of numerical C++ types, like int, float, double. It creates a pair "key_inc", "value",
  • OCCT_DUMP_FIELD_VALUE_STRING. Use it for char* type. It creates a pair "key", "value",
  • OCCT_DUMP_FIELD_VALUE_POINTER. Use it for pointer fields. It creates a pair "key", "value", where the value is the pointer address,
  • OCCT_DUMP_FIELD_VALUES_DUMPED. Use it for fields that has own Dump implementation. It expects the pointer to the class instance. It creates "key": { result of dump of the field }
  • OCCT_DUMP_FIELD_VALUES_DUMPED_INC. Use it for fields that has own Dump implementation. It expects the pointer to the class instance. It creates "key_inc": { result of dump of the field }
  • OCCT_DUMP_STREAM_VALUE_DUMPED. Use it for Standard_SStream. It creates "key": { text of stream }
  • OCCT_DUMP_FIELD_VALUES_NUMERICAL. Use it for unlimited list of fields of C++ double type. It creates massive of values [value_1, value_2, ...]
  • OCCT_DUMP_FIELD_VALUES_STRING. Use it for unlimited list of fields of TCollection_AsciiString types. It creates massive of values ["value_1", "value_2", ...]
  • OCCT_DUMP_BASE_CLASS. Use if Dump implementation of the class is virtual, to perform ClassName::Dump() of the parent class, expected parameter is the parent class name. It creates "key": { result of dump of the field }
  • OCCT_DUMP_VECTOR_CLASS. Use it as a single row in some object dump to have one row in output. It's possible to use it without necessity of OCCT_DUMP_CLASS_BEGIN call. It creates massive of values [value_1, value_2, ...]

The Dump result prepared by these macros is an output stream, it is not arranged with spaces and line feed. To have output in a more readable way, use ConvertToAlignedString method for obtained stream.

Macro Definition Documentation

◆ OCCT_CLASS_NAME

#define OCCT_CLASS_NAME ( theClass)
Value:
#theClass

Converts the class type into a string value.

◆ OCCT_DUMP_BASE_CLASS

#define OCCT_DUMP_BASE_CLASS ( theOStream,
theDepth,
theField )
Value:
{ \
if (theDepth != 0) \
{ \
Standard_Dump::AddValuesSeparator (theOStream); \
theField::DumpJson (theOStream, theDepth - 1); \
} \
}

Append into output value: "Name": { field dumped values } It computes Dump of the parent. The expected field is a parent class name to call ClassName::Dump. Use this macro for parent of the current class. The macros is recursive. Recursive is stopped when the depth value becomes equal to zero. Depth = -1 is the default value, dump here is unlimited.

◆ OCCT_DUMP_CLASS_BEGIN

#define OCCT_DUMP_CLASS_BEGIN ( theOStream,
theField )
Value:
{ \
const char* className = OCCT_CLASS_NAME(theField); \
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, className) \
}
#define OCCT_CLASS_NAME(theClass)
Converts the class type into a string value.
Definition Standard_Dump.hxx:55

Creates an instance of Sentry to cover the current Dump implementation with keys of start and end. This row should be inserted before other macros. The end key will be added by the sentry remove, (exit of the method).

◆ OCCT_DUMP_FIELD_VALUE_GUID

#define OCCT_DUMP_FIELD_VALUE_GUID ( theOStream,
theField )
Value:
{ \
Standard_Dump::AddValuesSeparator (theOStream); \
theField.ToCString (aStr); \
theOStream << "\"" << aName << "\": \"" << aStr << "\""; \
}
#define Standard_GUID_SIZE_ALLOC
Definition Standard_GUID.hxx:30
static TCollection_AsciiString DumpFieldToName(const TCollection_AsciiString &theField)
Convert field name into dump text value, removes "&" and "my" prefixes An example,...
Class defines a variable-length sequence of 8-bit characters. Despite class name (kept for historical...
Definition TCollection_AsciiString.hxx:46

◆ OCCT_DUMP_FIELD_VALUE_NUMERICAL

#define OCCT_DUMP_FIELD_VALUE_NUMERICAL ( theOStream,
theField )
Value:
{ \
Standard_Dump::AddValuesSeparator (theOStream); \
theOStream << "\"" << aName << "\": " << theField; \
}

Append into output value: "Name": Field.

Append into output value: "Name": Field Inc name value added to the key to provide unique keys.

◆ OCCT_DUMP_FIELD_VALUE_NUMERICAL_INC

#define OCCT_DUMP_FIELD_VALUE_NUMERICAL_INC ( theOStream,
theField,
theIncName )
Value:
{ \
TCollection_AsciiString aName = Standard_Dump::DumpFieldToName (#theField) + theIncName; \
Standard_Dump::AddValuesSeparator (theOStream); \
theOStream << "\"" << aName << "\": " << theField; \
}

◆ OCCT_DUMP_FIELD_VALUE_POINTER

#define OCCT_DUMP_FIELD_VALUE_POINTER ( theOStream,
theField )
Value:
{ \
Standard_Dump::AddValuesSeparator (theOStream); \
theOStream << "\"" << aName << "\": \"" << Standard_Dump::GetPointerInfo (theField) << "\""; \
}
static TCollection_AsciiString GetPointerInfo(const Handle< Standard_Transient > &thePointer, const bool isShortInfo=true)
Convert handle pointer to address of the pointer. If the handle is NULL, the result is an empty strin...

Append into output value: "Name": "address of the pointer".

◆ OCCT_DUMP_FIELD_VALUE_STRING

#define OCCT_DUMP_FIELD_VALUE_STRING ( theOStream,
theField )
Value:
{ \
Standard_Dump::AddValuesSeparator (theOStream); \
theOStream << "\"" << aName << "\": \"" << theField << "\""; \
}

Append into output value: "Name": "Field".

◆ OCCT_DUMP_FIELD_VALUES_DUMPED

#define OCCT_DUMP_FIELD_VALUES_DUMPED ( theOStream,
theDepth,
theField )
Value:
{ \
if (theDepth != 0 && (void*)(theField) != NULL) \
{ \
Standard_SStream aFieldStream; \
(theField)->DumpJson (aFieldStream, theDepth - 1); \
Standard_Dump::DumpKeyToClass (theOStream, aName, Standard_Dump::Text (aFieldStream)); \
} \
}
std::stringstream Standard_SStream
Defines Standard_SStream as typedef to C++ string stream.
Definition Standard_SStream.hxx:21
static TCollection_AsciiString Text(const Standard_SStream &theStream)
Converts stream value to string value. The result is original stream value.

Append into output value: "Name": { field dumped values } It computes Dump of the fields. The expected field is a pointer. Use this macro for fields of the dumped class which has own Dump implementation. The macros is recursive. Recursion is stopped when the depth value becomes equal to zero. Depth = -1 is the default value, dump here is unlimited.

◆ OCCT_DUMP_FIELD_VALUES_DUMPED_INC

#define OCCT_DUMP_FIELD_VALUES_DUMPED_INC ( theOStream,
theDepth,
theField,
theIncName )
Value:
{ \
if (theDepth != 0 && (void*)(theField) != NULL) \
{ \
Standard_SStream aFieldStream; \
(theField)->DumpJson (aFieldStream, theDepth - 1); \
TCollection_AsciiString aName = Standard_Dump::DumpFieldToName (#theField) + theIncName; \
Standard_Dump::DumpKeyToClass (theOStream, aName, Standard_Dump::Text (aFieldStream)); \
} \
}

Append into output value: "Name": { field dumped values } It computes Dump of the fields. The expected field is a pointer. Use this macro for fields of the dumped class which has own Dump implementation. The macros is recursive. Recursion is stopped when the depth value becomes equal to zero. Depth = -1 is the default value, dump here is unlimited. Inc name value added to the key to provide unique keys.

◆ OCCT_DUMP_FIELD_VALUES_NUMERICAL

#define OCCT_DUMP_FIELD_VALUES_NUMERICAL ( theOStream,
theName,
theCount,
... )
Value:
{ \
Standard_Dump::AddValuesSeparator (theOStream); \
theOStream << "\"" << theName << "\": ["; \
Standard_Dump::DumpRealValues (theOStream, theCount, __VA_ARGS__);\
theOStream << "]"; \
}

Append real values into output values in an order: [value_1, value_2, ...] It computes Dump of the parent. The expected field is a parent class name to call ClassName::Dump.

◆ OCCT_DUMP_FIELD_VALUES_STRING

#define OCCT_DUMP_FIELD_VALUES_STRING ( theOStream,
theName,
theCount,
... )
Value:
{ \
Standard_Dump::AddValuesSeparator (theOStream); \
theOStream << "\"" << theName << "\": ["; \
Standard_Dump::DumpCharacterValues (theOStream, theCount, __VA_ARGS__);\
theOStream << "]"; \
}

Append real values into output values in an order: ["value_1", "value_2", ...] It computes Dump of the parent. The expected field is a parent class name to call ClassName::Dump.

◆ OCCT_DUMP_STREAM_VALUE_DUMPED

#define OCCT_DUMP_STREAM_VALUE_DUMPED ( theOStream,
theField )
Value:
{ \
Standard_Dump::DumpKeyToClass (theOStream, aName, Standard_Dump::Text (theField)); \
}

Append into output value: "Name": { stream text } It computes Dump of the fields. The expected field is a pointer. Use this macro for Standard_SStream field.

◆ OCCT_DUMP_TRANSIENT_CLASS_BEGIN

#define OCCT_DUMP_TRANSIENT_CLASS_BEGIN ( theOStream)
Value:
{ \
const char* className = get_type_name(); \
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, className) \
}

Creates an instance of Sentry to cover the current Dump implementation with keys of start and end. This row should be inserted before other macros. The end key will be added by the sentry remove, (exit of the method).

◆ OCCT_DUMP_VECTOR_CLASS

#define OCCT_DUMP_VECTOR_CLASS ( theOStream,
theName,
theCount,
... )
Value:
{ \
Standard_Dump::AddValuesSeparator (theOStream); \
theOStream << "\"" << theName << "\": ["; \
Standard_Dump::DumpRealValues (theOStream, theCount, __VA_ARGS__);\
theOStream << "]"; \
}

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. 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.

◆ OCCT_INIT_FIELD_VALUE_INTEGER

#define OCCT_INIT_FIELD_VALUE_INTEGER ( theOStream,
theStreamPos,
theField )
Value:
{ \
Standard_Integer aStreamPos = theStreamPos; \
if (!Standard_Dump::ProcessFieldName (theOStream, #theField, aStreamPos)) \
return Standard_False; \
if (!Standard_Dump::InitValue (theOStream, aStreamPos, aValueText) || !aValueText.IsIntegerValue()) \
return Standard_False; \
theField = aValueText.IntegerValue(); \
theStreamPos = aStreamPos; \
}
#define Standard_False
Definition Standard_TypeDef.hxx:56
int Standard_Integer
Definition Standard_TypeDef.hxx:61
static Standard_Boolean InitValue(const TCollection_AsciiString &theStreamStr, Standard_Integer &theStreamPos, TCollection_AsciiString &theValue)
Returns real value.
static Standard_Boolean ProcessFieldName(const TCollection_AsciiString &theStreamStr, const TCollection_AsciiString &theName, Standard_Integer &theStreamPos)
Check whether the field name is equal to the name in the stream at position.
Standard_Integer IntegerValue() const
Converts a AsciiString containing a numeric expression to an Integer. Example: "215" returns 215.
Standard_Boolean IsIntegerValue() const
Returns True if the AsciiString contains an integer value. Note: an integer value is considered to be...

◆ OCCT_INIT_FIELD_VALUE_REAL

#define OCCT_INIT_FIELD_VALUE_REAL ( theOStream,
theStreamPos,
theField )
Value:
{ \
Standard_Integer aStreamPos = theStreamPos; \
if (!Standard_Dump::ProcessFieldName (theOStream, #theField, aStreamPos)) \
return Standard_False; \
if (!Standard_Dump::InitValue (theOStream, aStreamPos, aValueText) || !aValueText.IsRealValue()) \
return Standard_False; \
theField = aValueText.RealValue(); \
theStreamPos = aStreamPos; \
}
Standard_Boolean IsRealValue(Standard_Boolean theToCheckFull=Standard_False) const
Returns True if the AsciiString starts with some characters that can be interpreted as integer or rea...
Standard_Real RealValue() const
Converts an AsciiString containing a numeric expression. to a Real. Example: ex: "215" returns 215....

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. 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.

◆ OCCT_INIT_FIELD_VALUES_DUMPED

#define OCCT_INIT_FIELD_VALUES_DUMPED ( theSStream,
theStreamPos,
theField )
Value:
{ \
if ((theField) == NULL || !(theField)->InitFromJson (theSStream, theStreamPos)) \
return Standard_False; \
}

Append into output value: "Name": { field dumped values } It computes Dump of the fields. The expected field is a pointer. Use this macro for fields of the dumped class which has own Dump implementation. The macros is recursive. Recursion is stopped when the depth value becomes equal to zero. Depth = -1 is the default value, dump here is unlimited.

◆ OCCT_INIT_VECTOR_CLASS

#define OCCT_INIT_VECTOR_CLASS ( theOStream,
theName,
theStreamPos,
theCount,
... )
Value:
{ \
Standard_Integer aStreamPos = theStreamPos; \
if (!Standard_Dump::ProcessStreamName (theOStream, theName, aStreamPos)) \
return Standard_False; \
if (!Standard_Dump::InitRealValues (theOStream, aStreamPos, theCount, __VA_ARGS__)) \
return Standard_False; \
theStreamPos = aStreamPos; \
}
static Standard_Boolean ProcessStreamName(const TCollection_AsciiString &theStreamStr, const TCollection_AsciiString &theName, Standard_Integer &theStreamPos)
Check whether the parameter name is equal to the name in the stream at position.
static Standard_Boolean InitRealValues(const TCollection_AsciiString &theStreamStr, Standard_Integer &theStreamPos, int theCount,...)
Unite values in one value using template: value_1, value_2, ..., value_n.

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. 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.

Enumeration Type Documentation

◆ Standard_JsonKey

Kind of key in Json string.

Enumerator
Standard_JsonKey_None 

no key

Standard_JsonKey_OpenChild 

"{"

Standard_JsonKey_CloseChild 

"}"

Standard_JsonKey_OpenContainer 

"["

Standard_JsonKey_CloseContainer 

"]"

Standard_JsonKey_Quote 

"\""

Standard_JsonKey_SeparatorKeyToValue 

": "

Standard_JsonKey_SeparatorValueToValue 

", "