Slicer  4.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Macros
Helper macros for writing MRML node properties to XML attributes.

Macros

#define vtkMRMLWriteXMLBeginMacro(of)
 
#define vtkMRMLWriteXMLBooleanMacro(xmlAttributeName, propertyName)   xmlWriteOutputStream << " " #xmlAttributeName "=\"" << (Get##propertyName() ? "true" : "false") << "\"";
 Macro for writing bool node property to XML. More...
 
#define vtkMRMLWriteXMLEndMacro()   }
 This macro must be placed after the last value writing macro. More...
 
#define vtkMRMLWriteXMLEnumMacro(xmlAttributeName, propertyName)
 
#define vtkMRMLWriteXMLFloatMacro(xmlAttributeName, propertyName)   xmlWriteOutputStream << " " #xmlAttributeName "=\"" << Get##propertyName() << "\"";
 Macro for writing floating-point (double or float) node property to XML. More...
 
#define vtkMRMLWriteXMLIntMacro(xmlAttributeName, propertyName)   xmlWriteOutputStream << " " #xmlAttributeName "=\"" << Get##propertyName() << "\"";
 Macro for writing int node property to XML. More...
 
#define vtkMRMLWriteXMLMatrix4x4Macro(xmlAttributeName, propertyName)
 Macro for writing vtkMatrix4x4 to XML. More...
 
#define vtkMRMLWriteXMLStdFloatVectorMacro(xmlAttributeName, propertyName, vectorType)
 Macro for writing std::vector (float or double) node property to XML. More...
 
#define vtkMRMLWriteXMLStdIntVectorMacro(xmlAttributeName, propertyName, vectorType)
 Macro for writing std::vector (int) node property to XML. More...
 
#define vtkMRMLWriteXMLStdStringMacro(xmlAttributeName, propertyName)   xmlWriteOutputStream << " " #xmlAttributeName "=\"" << vtkMRMLNode::XMLAttributeEncodeString(Get##propertyName().c_str()) << "\""; \
 Macro for writing std::string node property to XML. More...
 
#define vtkMRMLWriteXMLStdStringVectorMacro(xmlAttributeName, propertyName, vectorType)
 Macro for writing std::vector (of std::string) node property to XML. More...
 
#define vtkMRMLWriteXMLStringMacro(xmlAttributeName, propertyName)
 
#define vtkMRMLWriteXMLVectorMacro(xmlAttributeName, propertyName, vectorType, vectorSize)
 Macro for writing vector (of numbers) node property to XML. More...
 

Detailed Description

They are To be used in WriteXML(ostream& of, int nIndent) method. Arguments of value writing macros:

Macro Definition Documentation

◆ vtkMRMLWriteXMLBeginMacro

#define vtkMRMLWriteXMLBeginMacro (   of)
Value:
{ \
ostream& xmlWriteOutputStream = of;

This macro must be placed before the first value writing macro.

Parameters
ofis the output stream where node values will be written to

Definition at line 29 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLWriteXMLBooleanMacro

#define vtkMRMLWriteXMLBooleanMacro (   xmlAttributeName,
  propertyName 
)    xmlWriteOutputStream << " " #xmlAttributeName "=\"" << (Get##propertyName() ? "true" : "false") << "\"";

Macro for writing bool node property to XML.

Definition at line 38 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLWriteXMLEndMacro

#define vtkMRMLWriteXMLEndMacro ( )    }

This macro must be placed after the last value writing macro.

Definition at line 34 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLWriteXMLEnumMacro

#define vtkMRMLWriteXMLEnumMacro (   xmlAttributeName,
  propertyName 
)
Value:
xmlWriteOutputStream << " " #xmlAttributeName "=\""; \
if (Get##propertyName##AsString(Get##propertyName()) != nullptr) \
{ \
xmlWriteOutputStream << vtkMRMLNode::XMLAttributeEncodeString(Get##propertyName##AsString(Get##propertyName())); \
} \
xmlWriteOutputStream << "\"";
std::string XMLAttributeEncodeString(const std::string &inString)
Encode an XML attribute string (replaces special characters by code sequences)

Macro for writing enum node property to XML. Requires Get(propertyName)AsString method to convert from numeric value to code string.

Definition at line 57 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLWriteXMLFloatMacro

#define vtkMRMLWriteXMLFloatMacro (   xmlAttributeName,
  propertyName 
)    xmlWriteOutputStream << " " #xmlAttributeName "=\"" << Get##propertyName() << "\"";

Macro for writing floating-point (double or float) node property to XML.

Definition at line 70 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLWriteXMLIntMacro

#define vtkMRMLWriteXMLIntMacro (   xmlAttributeName,
  propertyName 
)    xmlWriteOutputStream << " " #xmlAttributeName "=\"" << Get##propertyName() << "\"";

Macro for writing int node property to XML.

Definition at line 66 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLWriteXMLMatrix4x4Macro

#define vtkMRMLWriteXMLMatrix4x4Macro (   xmlAttributeName,
  propertyName 
)
Value:
{ \
xmlWriteOutputStream << " " #xmlAttributeName "=\""; \
vtkMatrix4x4* matrix = this->Get##propertyName(); \
for (int row = 0; row < 4; row++) \
{ \
for (int col = 0; col < 4; col++) \
{ \
of << matrix->GetElement(row, col); \
if (!(row == 3 && col == 3)) \
{ \
of << " "; \
} \
} \
if (row != 3) \
{ \
of << " "; \
} \
} \
xmlWriteOutputStream << "\""; \
}

Macro for writing vtkMatrix4x4 to XML.

Definition at line 139 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLWriteXMLStdFloatVectorMacro

#define vtkMRMLWriteXMLStdFloatVectorMacro (   xmlAttributeName,
  propertyName,
  vectorType 
)
Value:
{ \
xmlWriteOutputStream << " " #xmlAttributeName "=\""; \
vectorType vector = Get##propertyName(); \
for (vectorType::iterator it=vector.begin(); it!=vector.end(); it++) \
{ \
xmlWriteOutputStream << *it; \
xmlWriteOutputStream << " "; \
} \
xmlWriteOutputStream << "\""; \
}

Macro for writing std::vector (float or double) node property to XML.

Definition at line 93 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLWriteXMLStdIntVectorMacro

#define vtkMRMLWriteXMLStdIntVectorMacro (   xmlAttributeName,
  propertyName,
  vectorType 
)
Value:
{ \
xmlWriteOutputStream << " " #xmlAttributeName "=\""; \
vectorType vector = Get##propertyName(); \
for (vectorType::iterator it=vector.begin(); it!=vector.end(); it++) \
{ \
xmlWriteOutputStream << *it; \
xmlWriteOutputStream << " "; \
} \
xmlWriteOutputStream << "\""; \
}

Macro for writing std::vector (int) node property to XML.

Definition at line 106 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLWriteXMLStdStringMacro

#define vtkMRMLWriteXMLStdStringMacro (   xmlAttributeName,
  propertyName 
)    xmlWriteOutputStream << " " #xmlAttributeName "=\"" << vtkMRMLNode::XMLAttributeEncodeString(Get##propertyName().c_str()) << "\""; \

Macro for writing std::string node property to XML.

Definition at line 52 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLWriteXMLStdStringVectorMacro

#define vtkMRMLWriteXMLStdStringVectorMacro (   xmlAttributeName,
  propertyName,
  vectorType 
)
Value:
{ \
xmlWriteOutputStream << " " #xmlAttributeName "=\""; \
vectorType<std::string> vector = Get##propertyName(); \
for (vectorType<std::string>::iterator it=vector.begin(); it!=vector.end(); it++) \
{ \
if (it!=vector.begin()) \
{ \
xmlWriteOutputStream << ";"; \
} \
std::string attributeValue = *it; \
vtksys::SystemTools::ReplaceString(attributeValue, "%", "%25"); \
vtksys::SystemTools::ReplaceString(attributeValue, ";", "%3B"); \
xmlWriteOutputStream << vtkMRMLNode::XMLAttributeEncodeString(attributeValue); \
} \
xmlWriteOutputStream << "\""; \
}
std::string XMLAttributeEncodeString(const std::string &inString)
Encode an XML attribute string (replaces special characters by code sequences)

Macro for writing std::vector (of std::string) node property to XML.

Definition at line 119 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLWriteXMLStringMacro

#define vtkMRMLWriteXMLStringMacro (   xmlAttributeName,
  propertyName 
)
Value:
if (Get##propertyName() != nullptr) \
{ \
xmlWriteOutputStream << " " #xmlAttributeName "=\""; \
xmlWriteOutputStream << vtkMRMLNode::XMLAttributeEncodeString(Get##propertyName()); \
xmlWriteOutputStream << "\""; \
}
std::string XMLAttributeEncodeString(const std::string &inString)
Encode an XML attribute string (replaces special characters by code sequences)

Macro for writing char* node property to XML. If pointer is nullptr then the attribute will not be written to XML.

Definition at line 43 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLWriteXMLVectorMacro

#define vtkMRMLWriteXMLVectorMacro (   xmlAttributeName,
  propertyName,
  vectorType,
  vectorSize 
)
Value:
{ \
xmlWriteOutputStream << " " #xmlAttributeName "=\""; \
vectorType* vectorPtr = Get##propertyName(); \
if (vectorPtr != nullptr) \
{ \
for (int i=0; i<vectorSize; i++) \
{ \
if (i > 0) \
{ \
xmlWriteOutputStream << " "; \
} \
xmlWriteOutputStream << vectorPtr[i]; \
} \
} \
xmlWriteOutputStream << "\""; \
}

Macro for writing vector (of numbers) node property to XML.

Definition at line 74 of file vtkMRMLNodePropertyMacros.h.