utils/print-introspected-doxygen.cc
changeset 4580 8092e3e83487
parent 4513 544c9d637ff1
child 4641 7b5db4e35985
     1.1 --- a/utils/print-introspected-doxygen.cc	Mon Jun 08 14:14:04 2009 +0200
     1.2 +++ b/utils/print-introspected-doxygen.cc	Wed Jun 24 09:45:31 2009 +0200
     1.3 @@ -83,6 +83,7 @@
     1.4    void DoGather (TypeId tid);
     1.5    void RecordOutput (TypeId tid);
     1.6    bool HasAlreadyBeenProcessed (TypeId tid) const;
     1.7 +  void find_and_replace (std::string &source, const std::string find, std::string replace );
     1.8    std::vector<std::pair<TypeId,std::string> > m_output;
     1.9    std::vector<std::string> m_currentPath;
    1.10    std::vector<TypeId> m_alreadyProcessed;
    1.11 @@ -174,62 +175,88 @@
    1.12        Ptr<const AttributeChecker> checker = tid.GetAttributeChecker (i);
    1.13        const PointerChecker *ptrChecker = dynamic_cast<const PointerChecker *> (PeekPointer (checker));
    1.14        if (ptrChecker != 0)
    1.15 -	{
    1.16 -	  TypeId pointee = ptrChecker->GetPointeeTypeId ();
    1.17 -	  m_currentPath.push_back (tid.GetAttributeName (i));
    1.18 -	  m_alreadyProcessed.push_back (tid);
    1.19 -	  DoGather (pointee);
    1.20 -	  m_alreadyProcessed.pop_back ();
    1.21 -	  m_currentPath.pop_back ();
    1.22 -	  continue;
    1.23 -	}
    1.24 +        {
    1.25 +          TypeId pointee = ptrChecker->GetPointeeTypeId ();
    1.26 +          m_currentPath.push_back (tid.GetAttributeName (i));
    1.27 +          m_alreadyProcessed.push_back (tid);
    1.28 +          DoGather (pointee);
    1.29 +          m_alreadyProcessed.pop_back ();
    1.30 +          m_currentPath.pop_back ();
    1.31 +          continue;
    1.32 +        }
    1.33        // attempt to cast to an object vector.
    1.34        const ObjectVectorChecker *vectorChecker = dynamic_cast<const ObjectVectorChecker *> (PeekPointer (checker));
    1.35        if (vectorChecker != 0)
    1.36 -	{
    1.37 -	  TypeId item = vectorChecker->GetItemTypeId ();
    1.38 -	  m_currentPath.push_back (tid.GetAttributeName (i) + "/[i]");
    1.39 -	  m_alreadyProcessed.push_back (tid);
    1.40 -	  DoGather (item);
    1.41 -	  m_alreadyProcessed.pop_back ();
    1.42 -	  m_currentPath.pop_back ();
    1.43 -	  continue;
    1.44 -	}
    1.45 +        {
    1.46 +          TypeId item = vectorChecker->GetItemTypeId ();
    1.47 +          m_currentPath.push_back (tid.GetAttributeName (i) + "/[i]");
    1.48 +          m_alreadyProcessed.push_back (tid);
    1.49 +          DoGather (item);
    1.50 +          m_alreadyProcessed.pop_back ();
    1.51 +          m_currentPath.pop_back ();
    1.52 +          continue;
    1.53 +        }
    1.54      }
    1.55    for (uint32_t j = 0; j < TypeId::GetRegisteredN (); j++)
    1.56      {
    1.57        TypeId child = TypeId::GetRegistered (j);
    1.58        if (child.IsChildOf (tid))
    1.59 -	{
    1.60 -	  m_currentPath.push_back ("$%" + child.GetName ());
    1.61 -	  m_alreadyProcessed.push_back (tid);
    1.62 -	  DoGather (child);
    1.63 -	  m_alreadyProcessed.pop_back ();
    1.64 -	  m_currentPath.pop_back ();
    1.65 -	}
    1.66 +        {
    1.67 +          //please take a look at the following note for an explanation 
    1.68 +          std::string childName = "$%" + child.GetName ();
    1.69 +          find_and_replace(childName,"::","::%");
    1.70 +          m_currentPath.push_back (childName);
    1.71 +          m_alreadyProcessed.push_back (tid);
    1.72 +          DoGather (child);
    1.73 +          m_alreadyProcessed.pop_back ();
    1.74 +          m_currentPath.pop_back ();
    1.75 +        }
    1.76      }
    1.77    for (uint32_t k = 0; k < m_aggregates.size (); ++k)
    1.78      {
    1.79        std::pair<TypeId,TypeId> tmp = m_aggregates[k];
    1.80        if (tmp.first == tid || tmp.second == tid)
    1.81 -	{
    1.82 -	  TypeId other;
    1.83 -	  if (tmp.first == tid)
    1.84 -	    {
    1.85 -	      other = tmp.second;
    1.86 -	    }
    1.87 -	  if (tmp.second == tid)
    1.88 -	    {
    1.89 -	      other = tmp.first;
    1.90 -	    }
    1.91 -	  // Note: we insert a % in the path below to ensure that doxygen does not
    1.92 -	  // attempt to resolve the typeid names included in the string.
    1.93 -	  m_currentPath.push_back ("$%" + other.GetName ());
    1.94 -	  m_alreadyProcessed.push_back (tid);
    1.95 -	  DoGather (other);
    1.96 -	  m_alreadyProcessed.pop_back ();
    1.97 -	  m_currentPath.pop_back ();	  
    1.98 -	}
    1.99 +        {
   1.100 +          TypeId other;
   1.101 +          if (tmp.first == tid)
   1.102 +            {
   1.103 +              other = tmp.second;
   1.104 +            }
   1.105 +          if (tmp.second == tid)
   1.106 +            {
   1.107 +              other = tmp.first;
   1.108 +            }
   1.109 +          /**
   1.110 +           * Note: we insert a % in the path below to ensure that doxygen does not
   1.111 +           * attempt to resolve the typeid names included in the string.
   1.112 +           * if the name contains ::, using the % sign will remove that sign
   1.113 +           * resulting for instance in $ns3MobilityModel instead of $ns3::MobilityModel
   1.114 +           * hence the output must be in the form $%ns3::%MobilityModel in order to
   1.115 +           * show correctly $ns3::MobilityModel
   1.116 +           * We add at the beginning of the name $% and we replace all the :: in the
   1.117 +           * string by ::%.
   1.118 +           */  
   1.119 +          std::string name = "$%" + other.GetName ();
   1.120 +          //finding and replacing :: by ::%
   1.121 +          find_and_replace(name,"::","::%");
   1.122 +          m_currentPath.push_back (name);
   1.123 +          m_alreadyProcessed.push_back (tid);
   1.124 +          DoGather (other);
   1.125 +          m_alreadyProcessed.pop_back ();
   1.126 +          m_currentPath.pop_back ();	  
   1.127 +        }
   1.128 +    }
   1.129 +}
   1.130 +
   1.131 +void 
   1.132 +StaticInformation::find_and_replace( std::string &source, const std::string find, std::string replace )
   1.133 +{
   1.134 +  size_t j; 
   1.135 +  j = source.find (find);
   1.136 +  while (j != std::string::npos ) 
   1.137 +    {
   1.138 +      source.replace (j, find.length (),replace);
   1.139 +      j = source.find (find,j+1);
   1.140      }
   1.141  }
   1.142