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

Macros

#define vtkMRMLReadXMLBeginMacro(atts)
 
#define vtkMRMLReadXMLBooleanMacro(xmlAttributeName, propertyName)
 Macro for reading bool node property from XML. More...
 
#define vtkMRMLReadXMLEndMacro()   }};
 This macro must be placed after the last value reading macro. More...
 
#define vtkMRMLReadXMLEnumMacro(xmlAttributeName, propertyName)
 
#define vtkMRMLReadXMLFloatMacro(xmlAttributeName, propertyName)
 Macro for reading floating-point (float or double) node property from XML. More...
 
#define vtkMRMLReadXMLIntMacro(xmlAttributeName, propertyName)
 Macro for reading int node property from XML. More...
 
#define vtkMRMLReadXMLStdFloatVectorMacro(xmlAttributeName, propertyName, vectorType)
 Macro for reading an iterable container (float or double) node property from XML. More...
 
#define vtkMRMLReadXMLStdIntVectorMacro(xmlAttributeName, propertyName, vectorType)
 Macro for reading an iterable container (int) node property from XML. More...
 
#define vtkMRMLReadXMLStdStringMacro(xmlAttributeName, propertyName)
 
#define vtkMRMLReadXMLStdStringVectorMacro(xmlAttributeName, propertyName, vectorType)
 Macro for reading an iterable container (of std::string) node property from XML. More...
 
#define vtkMRMLReadXMLStringMacro(xmlAttributeName, propertyName)
 
#define vtkMRMLReadXMLVectorMacro(xmlAttributeName, propertyName, vectorType, vectorSize)
 Macro for reading floating-point (float or double) vector node property from XML. More...
 

Detailed Description

They are To be used in ReadXMLAttributes(const char** atts) method. Arguments of value writing macros:

Macro Definition Documentation

◆ vtkMRMLReadXMLBeginMacro

#define vtkMRMLReadXMLBeginMacro (   atts)
Value:
{ \
const char* xmlReadAttName; \
const char* xmlReadAttValue; \
const char** xmlReadAtts = atts; \
while (*xmlReadAtts != NULL) \
{ \
xmlReadAttName = *(xmlReadAtts++); \
xmlReadAttValue = *(xmlReadAtts++); \
if (xmlReadAttValue == NULL) \
{ \
break; \
}

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

Parameters
attsis the C array of of attribute name/value pointer pairs

Definition at line 146 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLReadXMLBooleanMacro

#define vtkMRMLReadXMLBooleanMacro (   xmlAttributeName,
  propertyName 
)
Value:
if (!strcmp(xmlReadAttName, #xmlAttributeName)) \
{ \
this->Set##propertyName(strcmp(xmlReadAttValue,"true") ? false : true); \
}

Macro for reading bool node property from XML.

Definition at line 165 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLReadXMLEndMacro

#define vtkMRMLReadXMLEndMacro ( )    }};

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

Definition at line 161 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLReadXMLEnumMacro

#define vtkMRMLReadXMLEnumMacro (   xmlAttributeName,
  propertyName 
)
Value:
if (!strcmp(xmlReadAttName, #xmlAttributeName)) \
{ \
int propertyValue = this->Get##propertyName##FromString(xmlReadAttValue); \
if (propertyValue >= 0) \
{ \
this->Set##propertyName(propertyValue); \
} \
else \
{ \
vtkErrorMacro("Failed to read #xmlAttributeName attribute value from string '" << xmlReadAttValue << "'"); \
} \
}

Macro for reading enum node property from XML. Requires Get(propertyName)FromString method to convert from string to numeric value. XML decoding is not needed as attribute values are already decoded by the XML parser.

Definition at line 190 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLReadXMLFloatMacro

#define vtkMRMLReadXMLFloatMacro (   xmlAttributeName,
  propertyName 
)
Value:
if (!strcmp(xmlReadAttName, #xmlAttributeName)) \
{ \
vtkVariant variantValue(xmlReadAttValue); \
bool valid = false; \
double scalarValue = variantValue.ToDouble(&valid); \
if (valid) \
{ \
this->Set##propertyName(scalarValue); \
} \
else \
{ \
vtkErrorMacro("Failed to read #xmlAttributeName attribute value from string '" << xmlReadAttValue << "': float expected"); \
} \
}

Macro for reading floating-point (float or double) node property from XML.

Definition at line 222 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLReadXMLIntMacro

#define vtkMRMLReadXMLIntMacro (   xmlAttributeName,
  propertyName 
)
Value:
if (!strcmp(xmlReadAttName, #xmlAttributeName)) \
{ \
vtkVariant variantValue(xmlReadAttValue); \
bool valid = false; \
int intValue = variantValue.ToInt(&valid); \
if (valid) \
{ \
this->Set##propertyName(intValue); \
} \
else \
{ \
vtkErrorMacro("Failed to read #xmlAttributeName attribute value from string '" << xmlReadAttValue << "': integer expected"); \
} \
}

Macro for reading int node property from XML.

Definition at line 205 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLReadXMLStdFloatVectorMacro

#define vtkMRMLReadXMLStdFloatVectorMacro (   xmlAttributeName,
  propertyName,
  vectorType 
)
Value:
if (!strcmp(xmlReadAttName, #xmlAttributeName)) \
{ \
vectorType vector; \
std::string valueString(xmlReadAttValue); \
size_t separatorPosition = valueString.find(" "); \
while(separatorPosition != std::string::npos) \
{ \
std::string attributeValue = valueString.substr(0, separatorPosition); \
vtkVariant variantValue(attributeValue); \
bool valid = false; \
vectorType::value_type scalarValue = variantValue.ToDouble(&valid); \
if (valid) \
{ \
vector.insert(vector.end(), scalarValue); \
} \
valueString = valueString.substr(separatorPosition+1); \
separatorPosition = valueString.find(" "); \
} \
this->Set##propertyName(vector); \
}

Macro for reading an iterable container (float or double) node property from XML.

Definition at line 255 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLReadXMLStdIntVectorMacro

#define vtkMRMLReadXMLStdIntVectorMacro (   xmlAttributeName,
  propertyName,
  vectorType 
)
Value:
if (!strcmp(xmlReadAttName, #xmlAttributeName)) \
{ \
vectorType vector; \
std::string valueString(xmlReadAttValue); \
size_t separatorPosition = valueString.find(" "); \
while(separatorPosition != std::string::npos) \
{ \
std::string attributeValue = valueString.substr(0, separatorPosition); \
vtkVariant variantValue(attributeValue); \
bool valid = false; \
vectorType::value_type scalarValue = variantValue.ToInt(&valid); \
if (valid) \
{ \
vector.insert(vector.end(), scalarValue); \
} \
valueString = valueString.substr(separatorPosition+1); \
separatorPosition = valueString.find(" "); \
} \
this->Set##propertyName(vector); \
}

Macro for reading an iterable container (int) node property from XML.

Definition at line 278 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLReadXMLStdStringMacro

#define vtkMRMLReadXMLStdStringMacro (   xmlAttributeName,
  propertyName 
)
Value:
if (!strcmp(xmlReadAttName, #xmlAttributeName)) \
{ \
this->Set##propertyName(xmlReadAttValue); \
}

Macro for reading std::string node property from XML. XML decoding is not needed as attribute values are already decoded by the XML parser.

Definition at line 181 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLReadXMLStdStringVectorMacro

#define vtkMRMLReadXMLStdStringVectorMacro (   xmlAttributeName,
  propertyName,
  vectorType 
)
Value:
if (!strcmp(xmlReadAttName, #xmlAttributeName)) \
{ \
vectorType<std::string> vector; \
std::string valueString(xmlReadAttValue); \
size_t separatorPosition = valueString.find(";"); \
while(separatorPosition != std::string::npos) \
{ \
std::string attributeValue = valueString.substr(0,separatorPosition); \
vtksys::SystemTools::ReplaceString(attributeValue, "%3B", ";"); \
vtksys::SystemTools::ReplaceString(attributeValue, "%25", "%"); \
vector.insert(vector.end(), attributeValue); \
valueString = valueString.substr(separatorPosition+1); \
separatorPosition = valueString.find(";"); \
} \
if (!valueString.empty()) \
{ \
vector.push_back(valueString); \
} \
this->Set##propertyName(vector); \
}

Macro for reading an iterable container (of std::string) node property from XML.

Definition at line 301 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLReadXMLStringMacro

#define vtkMRMLReadXMLStringMacro (   xmlAttributeName,
  propertyName 
)
Value:
if (!strcmp(xmlReadAttName, #xmlAttributeName)) \
{ \
this->Set##propertyName(xmlReadAttValue); \
}

Macro for reading char* node property from XML. XML decoding is not needed as attribute values are already decoded by the XML parser.

Definition at line 173 of file vtkMRMLNodePropertyMacros.h.

◆ vtkMRMLReadXMLVectorMacro

#define vtkMRMLReadXMLVectorMacro (   xmlAttributeName,
  propertyName,
  vectorType,
  vectorSize 
)
Value:
if (!strcmp(xmlReadAttName, #xmlAttributeName)) \
{ \
vectorType vectorValue[vectorSize] = {0}; \
std::stringstream ss; \
ss << xmlReadAttValue; \
for (int i=0; i<vectorSize; i++) \
{ \
vectorType val; \
ss >> val; \
vectorValue[i] = val; \
} \
this->Set##propertyName(vectorValue); \
}

Macro for reading floating-point (float or double) vector node property from XML.

Definition at line 239 of file vtkMRMLNodePropertyMacros.h.