C
Christopher
How would I go about indenenting for each level of recursion, if I am
trying to output the contents of a class which contains its own type?
where AttributeGroupMap is
typdef std::map<std::string, AttributeGroup *> AttributeGroupMap;
const std::string AttributeGroup::ToString() const
{
std::stringstream ss;
ss << m_name << std::endl;
for(AttributeGroupMap::const_iterator it =
m_attributeGroups.begin();
it != m_attributeGroups.end(); ++it)
{
// need everything from here indented for each level of
recursion
ss << (it->second)->ToString() << std::endl;
}
return ss.str();
}
I thought if changing the parameters to something like
const std::string AttributeGroup::ToString(unsigned indent = 0) const
and then
but still don't know how to indent the entire thing.
trying to output the contents of a class which contains its own type?
where AttributeGroupMap is
typdef std::map<std::string, AttributeGroup *> AttributeGroupMap;
const std::string AttributeGroup::ToString() const
{
std::stringstream ss;
ss << m_name << std::endl;
for(AttributeGroupMap::const_iterator it =
m_attributeGroups.begin();
it != m_attributeGroups.end(); ++it)
{
// need everything from here indented for each level of
recursion
ss << (it->second)->ToString() << std::endl;
}
return ss.str();
}
I thought if changing the parameters to something like
const std::string AttributeGroup::ToString(unsigned indent = 0) const
and then
ss said:ToString(indent + 3) << std::endl;
but still don't know how to indent the entire thing.