classlist.cpp 5.88 KB
Newer Older
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1 2
/******************************************************************************
 *
3
 * 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
4
 *
Dimitri van Heesch's avatar
Dimitri van Heesch committed
5
 * Copyright (C) 1997-2013 by Dimitri van Heesch.
Dimitri van Heesch's avatar
Dimitri van Heesch committed
6 7 8 9 10 11 12
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation under the terms of the GNU General Public License is hereby 
 * granted. No representations are made about the suitability of this software 
 * for any purpose. It is provided "as is" without express or implied warranty.
 * See the GNU General Public License for more details.
 *
Dimitri van Heesch's avatar
Dimitri van Heesch committed
13 14
 * Documents produced by Doxygen are derivative works derived from the
 * input used in their production; they are not affected by this license.
Dimitri van Heesch's avatar
Dimitri van Heesch committed
15 16 17 18
 *
 */

#include "classlist.h"
Dimitri van Heesch's avatar
Dimitri van Heesch committed
19
#include "config.h"
20
#include "util.h"
21 22
#include "outputlist.h"
#include "language.h"
23
#include "doxygen.h"
24
#include "vhdldocgen.h"
Dimitri van Heesch's avatar
Dimitri van Heesch committed
25 26
#include "defargs.h"
#include "arguments.h"
Dimitri van Heesch's avatar
Dimitri van Heesch committed
27 28 29 30 31 32 33 34 35

ClassList::ClassList() : QList<ClassDef>()
{
}

ClassList::~ClassList()
{
}

36
static int compItems(void *item1,void *item2)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
37 38 39
{
  ClassDef *c1=(ClassDef *)item1;
  ClassDef *c2=(ClassDef *)item2;
40
  static bool b = Config_getBool("SORT_BY_SCOPE_NAME");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
41
  //printf("compItems: %d %s<->%s\n",b,c1->name().data(),c2->name().data());
42
  if (b) 
43
  { 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
44
     return qstricmp(c1->name(),
45
                    c2->name());
46 47 48
  }
  else
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
49
     return qstricmp(c1->className(),
50
                    c2->className());
51 52 53
  }
}

54
int ClassList::compareItems(QCollection::Item item1, QCollection::Item item2)
55 56
{
  return compItems(item1,item2);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
57 58
}

59
int ClassSDict::compareItems(QCollection::Item item1, QCollection::Item item2)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
60
{
61
  return compItems(item1,item2);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
62 63 64 65 66 67
}

ClassListIterator::ClassListIterator(const ClassList &cllist) :
  QListIterator<ClassDef>(cllist)
{
}
68

69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
bool ClassSDict::declVisible(const ClassDef::CompoundType *filter) const
{
  static bool hideUndocClasses = Config_getBool("HIDE_UNDOC_CLASSES");
  static bool extractLocalClasses = Config_getBool("EXTRACT_LOCAL_CLASSES");
  if (count()>0)
  {
    ClassSDict::Iterator sdi(*this);
    ClassDef *cd=0;
    for (sdi.toFirst();(cd=sdi.current());++sdi)
    {
      if (cd->name().find('@')==-1 && 
          (filter==0 || *filter==cd->compoundType())
         )
      {
        bool isLink = cd->isLinkable();
        if (isLink || 
             (!hideUndocClasses && 
              (!cd->isLocal() || extractLocalClasses)
             )
           )
        {
          return TRUE;
        }
      }
    }
  }
  return FALSE;
}

98 99
void ClassSDict::writeDeclaration(OutputList &ol,const ClassDef::CompoundType *filter,
                                  const char *header,bool localNames)
100
{
101
  static bool extractPrivate = Config_getBool("EXTRACT_PRIVATE");
102 103
  if (count()>0)
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
104 105
    ClassSDict::Iterator sdi(*this);
    ClassDef *cd=0;
106
    bool found=FALSE;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
107
    for (sdi.toFirst();(cd=sdi.current());++sdi)
108
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
109
      //printf("  ClassSDict::writeDeclaration for %s\n",cd->name().data());
110
      if (cd->name().find('@')==-1 && 
111 112
          !cd->isExtension() && 
          (cd->protection()!=Private || extractPrivate) &&
113 114
          (filter==0 || *filter==cd->compoundType())
         )
115
      {
116
        cd->writeDeclarationLink(ol,found,header,localNames);
117 118 119 120 121 122
      }
    }
    if (found) ol.endMemberList();
  }
}
  
Dimitri van Heesch's avatar
Dimitri van Heesch committed
123
void ClassSDict::writeDocumentation(OutputList &ol,Definition * container)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
124 125 126 127
{
  static bool fortranOpt = Config_getBool("OPTIMIZE_FOR_FORTRAN");

  static bool inlineGroupedClasses = Config_getBool("INLINE_GROUPED_CLASSES");
128 129
  static bool inlineSimpleClasses = Config_getBool("INLINE_SIMPLE_STRUCTS");
  if (!inlineGroupedClasses && !inlineSimpleClasses) return;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
130 131 132

  if (count()>0)
  {
133
    bool found=FALSE;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
134 135 136 137 138

    ClassSDict::Iterator sdi(*this);
    ClassDef *cd=0;
    for (sdi.toFirst();(cd=sdi.current());++sdi)
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
139 140 141
      //printf("%s:writeDocumentation() %p embedded=%d container=%p\n",
      //  cd->name().data(),cd->getOuterScope(),cd->isEmbeddedInOuterScope(),
      //  container);
142

Dimitri van Heesch's avatar
Dimitri van Heesch committed
143 144 145 146 147 148 149 150 151
      if (cd->name().find('@')==-1 && 
          cd->isLinkableInProject() &&
          cd->isEmbeddedInOuterScope() &&
          (container==0 || cd->partOfGroups()==0) // if container==0 -> show as part of the group docs, otherwise only show if not part of a group
          //&&
          //(container==0 || // no container -> used for groups
          // cd->getOuterScope()==container || // correct container -> used for namespaces and classes
          // (container->definitionType()==Definition::TypeFile && cd->getOuterScope()==Doxygen::globalScope && cd->partOfGroups()==0) // non grouped class with file scope -> used for files
          //)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
152 153
         )
      {
154 155 156 157 158 159 160 161 162
        if (!found)
        {
          ol.writeRuler();
          ol.startGroupHeader();
          ol.parseText(fortranOpt?theTranslator->trTypeDocumentation():
              theTranslator->trClassDocumentation());
          ol.endGroupHeader();
          found=TRUE;
        }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
163 164 165 166 167 168
        cd->writeInlineDocumentation(ol);
      }
    }
  }
}

Dimitri van Heesch's avatar
Dimitri van Heesch committed
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
//-------------------------------------------

void GenericsSDict::insert(const QCString &key,ClassDef *cd)
{
  int i=key.find('<');
  if (i==-1) return;
  ArgumentList argList;
  stringToArgumentList(key.mid(i),&argList);
  int c = argList.count();
  if (c==0) return;
  GenericsCollection *collection = m_dict.find(key.left(i));
  if (collection==0) // new name
  {
    collection = new GenericsCollection;
    m_dict.append(key.left(i),collection);
  }
  if (collection->find(c)==0) // should always be 0!
  {
    collection->insert(c,cd);
  }
}

ClassDef *GenericsSDict::find(const QCString &key)
{
  int i=key.find('<');
  if (i==-1)
  {
    GenericsCollection *collection = m_dict.find(key);
    if (collection && collection->count()==1)
    {
      QIntDictIterator<ClassDef> it(*collection);
      return it.current();
    }
  }
  else
  {
    GenericsCollection *collection = m_dict.find(key.left(i));
    if (collection)
    {
      ArgumentList argList;
      stringToArgumentList(key.mid(i),&argList);
      int c = argList.count();
      return collection->find(c);
    }
  }
  return 0;
}