User guide

65
To provide an error message the getLocalAttrNames() function can add the errorMessage name to the list of
attribute names it modifies, and the getLocalAttr() function can return a value for the errorMessage attribute,
wrapped in a StringAttribute as mentioned above.
TIP: The text of an error message can be copied to the clipboard through the context menu of the
“errorMessage” attribute in an Attributes tab.
The following code snippet shows examples of how error information can be returned from the
getLocalAttrNames() and getLocalAttr() functions. In this example, both functions check the value of a boolean
instance variable named _errorOccurred, which states whether or not an error occurred. The description of the error
is stored in an instance variable named _errorMessage of type std::string.
void CubeRootContext::getLocalAttrNames(
std::vector<std::string>* names) const
{
names->clear();
names->push_back("type");
names->push_back("xform");
if (_errorOccurred && !_errorMessage.empty())
{
names.push_back("errorMessage")
}
}
FnKat::Attribute CubeRootContext::getLocalAttr(
const std::string& name) const
{
if (name == "type")
{
return FnKat::StringAttribute(
!_errorOccurred ? "group" : "error");
}
8 SCENE GRAPH GENERATOR PLUG-INS | SGG PLUG-IN API CLASSES