# HG changeset patch # User fmoatamr # Date 1245829531 -7200 # Node ID 8092e3e83487fe2615d465e7a379883e0d6d3275 # Parent c8668105054121d1836927786cb82515ce852107 Bug 456: doxygen introspection for trace source config paths is wrong diff -r c86681050541 -r 8092e3e83487 utils/print-introspected-doxygen.cc --- a/utils/print-introspected-doxygen.cc Tue Jun 23 22:42:09 2009 -0700 +++ b/utils/print-introspected-doxygen.cc Wed Jun 24 09:45:31 2009 +0200 @@ -83,6 +83,7 @@ void DoGather (TypeId tid); void RecordOutput (TypeId tid); bool HasAlreadyBeenProcessed (TypeId tid) const; + void find_and_replace (std::string &source, const std::string find, std::string replace ); std::vector > m_output; std::vector m_currentPath; std::vector m_alreadyProcessed; @@ -174,62 +175,88 @@ Ptr checker = tid.GetAttributeChecker (i); const PointerChecker *ptrChecker = dynamic_cast (PeekPointer (checker)); if (ptrChecker != 0) - { - TypeId pointee = ptrChecker->GetPointeeTypeId (); - m_currentPath.push_back (tid.GetAttributeName (i)); - m_alreadyProcessed.push_back (tid); - DoGather (pointee); - m_alreadyProcessed.pop_back (); - m_currentPath.pop_back (); - continue; - } + { + TypeId pointee = ptrChecker->GetPointeeTypeId (); + m_currentPath.push_back (tid.GetAttributeName (i)); + m_alreadyProcessed.push_back (tid); + DoGather (pointee); + m_alreadyProcessed.pop_back (); + m_currentPath.pop_back (); + continue; + } // attempt to cast to an object vector. const ObjectVectorChecker *vectorChecker = dynamic_cast (PeekPointer (checker)); if (vectorChecker != 0) - { - TypeId item = vectorChecker->GetItemTypeId (); - m_currentPath.push_back (tid.GetAttributeName (i) + "/[i]"); - m_alreadyProcessed.push_back (tid); - DoGather (item); - m_alreadyProcessed.pop_back (); - m_currentPath.pop_back (); - continue; - } + { + TypeId item = vectorChecker->GetItemTypeId (); + m_currentPath.push_back (tid.GetAttributeName (i) + "/[i]"); + m_alreadyProcessed.push_back (tid); + DoGather (item); + m_alreadyProcessed.pop_back (); + m_currentPath.pop_back (); + continue; + } } for (uint32_t j = 0; j < TypeId::GetRegisteredN (); j++) { TypeId child = TypeId::GetRegistered (j); if (child.IsChildOf (tid)) - { - m_currentPath.push_back ("$%" + child.GetName ()); - m_alreadyProcessed.push_back (tid); - DoGather (child); - m_alreadyProcessed.pop_back (); - m_currentPath.pop_back (); - } + { + //please take a look at the following note for an explanation + std::string childName = "$%" + child.GetName (); + find_and_replace(childName,"::","::%"); + m_currentPath.push_back (childName); + m_alreadyProcessed.push_back (tid); + DoGather (child); + m_alreadyProcessed.pop_back (); + m_currentPath.pop_back (); + } } for (uint32_t k = 0; k < m_aggregates.size (); ++k) { std::pair tmp = m_aggregates[k]; if (tmp.first == tid || tmp.second == tid) - { - TypeId other; - if (tmp.first == tid) - { - other = tmp.second; - } - if (tmp.second == tid) - { - other = tmp.first; - } - // Note: we insert a % in the path below to ensure that doxygen does not - // attempt to resolve the typeid names included in the string. - m_currentPath.push_back ("$%" + other.GetName ()); - m_alreadyProcessed.push_back (tid); - DoGather (other); - m_alreadyProcessed.pop_back (); - m_currentPath.pop_back (); - } + { + TypeId other; + if (tmp.first == tid) + { + other = tmp.second; + } + if (tmp.second == tid) + { + other = tmp.first; + } + /** + * Note: we insert a % in the path below to ensure that doxygen does not + * attempt to resolve the typeid names included in the string. + * if the name contains ::, using the % sign will remove that sign + * resulting for instance in $ns3MobilityModel instead of $ns3::MobilityModel + * hence the output must be in the form $%ns3::%MobilityModel in order to + * show correctly $ns3::MobilityModel + * We add at the beginning of the name $% and we replace all the :: in the + * string by ::%. + */ + std::string name = "$%" + other.GetName (); + //finding and replacing :: by ::% + find_and_replace(name,"::","::%"); + m_currentPath.push_back (name); + m_alreadyProcessed.push_back (tid); + DoGather (other); + m_alreadyProcessed.pop_back (); + m_currentPath.pop_back (); + } + } +} + +void +StaticInformation::find_and_replace( std::string &source, const std::string find, std::string replace ) +{ + size_t j; + j = source.find (find); + while (j != std::string::npos ) + { + source.replace (j, find.length (),replace); + j = source.find (find,j+1); } }