groupdef.cpp 46.1 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-2014 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 <ctype.h>
19
#include <qregexp.h>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
20 21 22 23 24 25 26 27
#include "groupdef.h"
#include "classdef.h"
#include "filedef.h"
#include "classlist.h"
#include "outputlist.h"
#include "namespacedef.h"
#include "language.h"
#include "util.h"
Dimitri van Heesch's avatar
Dimitri van Heesch committed
28 29
#include "memberlist.h"
#include "message.h"
30 31
#include "membergroup.h"
#include "doxygen.h"
32 33
#include "pagedef.h"
#include "docparser.h"
Dimitri van Heesch's avatar
Dimitri van Heesch committed
34
#include "searchindex.h"
35
#include "dot.h"
36
#include "vhdldocgen.h"
37
#include "layout.h"
38 39
#include "arguments.h"
#include "entry.h"
40 41 42
#include "membername.h"
#include "dirdef.h"
#include "config.h"
43 44

//---------------------------------------------------------------------------
Dimitri van Heesch's avatar
Dimitri van Heesch committed
45

46
GroupDef::GroupDef(const char *df,int dl,const char *na,const char *t,
47
                   const char *refFileName) : Definition(df,dl,1,na)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
48 49
{
  fileList = new FileList;
50
  classSDict = new ClassSDict(17);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
51
  groupList = new GroupList;
52 53 54
  namespaceSDict = new NamespaceSDict(17);
  pageDict = new PageSDict(17);
  exampleDict = new PageSDict(17);
55
  dirList = new DirList;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
56
  allMemberNameInfoSDict = new MemberNameInfoSDict(17);
57
  allMemberNameInfoSDict->setAutoDelete(TRUE);
58 59 60 61 62 63 64 65
  if (refFileName)
  {
    fileName=stripExtension(refFileName);
  }
  else
  {
    fileName = (QCString)"group_"+na;
  }
66
  setGroupTitle( t );
67 68
  memberGroupSDict = new MemberGroupSDict;
  memberGroupSDict->setAutoDelete(TRUE);
69

70
  allMemberList = new MemberList(MemberListType_allMembersList);
71

72
  visited = 0;
73
  groupScope = 0;
74
  m_subGrouping=Config_getBool("SUBGROUPING");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
75 76 77 78 79
}

GroupDef::~GroupDef()
{
  delete fileList;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
80
  delete classSDict;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
81
  delete groupList;
82
  delete namespaceSDict;
83 84
  delete pageDict;
  delete exampleDict;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
85
  delete allMemberList;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
86
  delete allMemberNameInfoSDict;
87
  delete memberGroupSDict;
88
  delete dirList;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
89 90
}

91 92
void GroupDef::setGroupTitle( const char *t )
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
93
  if ( t && qstrlen(t) )
94 95 96 97 98 99 100 101 102 103 104 105 106
  {
    title = t;
    titleSet = TRUE;
  }
  else
  {
    title = name();
    title.at(0)=toupper(title.at(0));
    titleSet = FALSE;
  }
}


107 108
void GroupDef::distributeMemberGroupDocumentation()
{
109
  MemberGroupSDict::Iterator mgli(*memberGroupSDict);
110 111 112 113 114 115 116
  MemberGroup *mg;
  for (;(mg=mgli.current());++mgli)
  {
    mg->distributeMemberGroupDocumentation();
  }
}

117 118
void GroupDef::findSectionsInDocumentation()
{
119
  docFindSections(documentation(),this,0,docFile());
120 121 122 123 124 125
  MemberGroupSDict::Iterator mgli(*memberGroupSDict);
  MemberGroup *mg;
  for (;(mg=mgli.current());++mgli)
  {
    mg->findSectionsInDocumentation();
  }
126 127 128 129 130

  QListIterator<MemberList> mli(m_memberLists);
  MemberList *ml;
  for (mli.toFirst();(ml=mli.current());++mli)
  {
131
    if (ml->listType()&MemberListType_declarationLists)
132 133 134 135
    {
      ml->findSectionsInDocumentation();
    }
  }
136 137
}

Dimitri van Heesch's avatar
Dimitri van Heesch committed
138 139
void GroupDef::addFile(const FileDef *def)
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
140
  static bool sortBriefDocs = Config_getBool("SORT_BRIEF_DOCS");
141
  if (def->isHidden()) return;
142
  updateLanguage(def);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
143
  if (sortBriefDocs)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
144 145 146
    fileList->inSort(def);
  else
    fileList->append(def);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
147 148
}

149
bool GroupDef::addClass(const ClassDef *cd)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
150
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
151
  static bool sortBriefDocs = Config_getBool("SORT_BRIEF_DOCS");
152
  if (cd->isHidden()) return FALSE;
153
  updateLanguage(cd);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
154
  if (classSDict->find(cd->qualifiedName())==0)
155
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
156 157
    QCString qn = cd->qualifiedName();
    //printf("--- addClass %s sort=%d\n",qn.data(),sortBriefDocs);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
158
    if (sortBriefDocs)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
159
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
160
      classSDict->inSort(cd->qualifiedName(),cd);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
161
    }
162
    else
Dimitri van Heesch's avatar
Dimitri van Heesch committed
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
    {
      int i=qn.findRev("::");
      if (i==-1) i=qn.find('.');
      bool found=FALSE;
      //printf("i=%d\n",i);
      if (i!=-1)
      {
        // add nested classes (e.g. A::B, A::C) after their parent (A) in 
        // order of insertion
        QCString scope = qn.left(i);
        int j=classSDict->findAt(scope);
        if (j!=-1)
        {
          while (j<(int)classSDict->count() && 
              classSDict->at(j)->qualifiedName().left(i)==scope)
          {
            //printf("skipping over %s\n",classSDict->at(j)->qualifiedName().data());
            j++;
          }
          //printf("Found scope at index %d\n",j);
          classSDict->insertAt(j,cd->qualifiedName(),cd);
          found=TRUE;
        }
      }
      if (!found) // no insertion point found -> just append
      {
        classSDict->append(cd->qualifiedName(),cd);
      }
    }
192 193 194
    return TRUE;
  }
  return FALSE;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
195 196
}

197
bool GroupDef::addNamespace(const NamespaceDef *def)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
198
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
199
  static bool sortBriefDocs = Config_getBool("SORT_BRIEF_DOCS");
200
  if (def->isHidden()) return FALSE;
201
  updateLanguage(def);
202 203
  if (namespaceSDict->find(def->name())==0)
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
204
    if (sortBriefDocs)
205 206 207 208 209 210
      namespaceSDict->inSort(def->name(),def);  
    else
      namespaceSDict->append(def->name(),def);
    return TRUE;
  }
  return FALSE;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
211 212
}

213 214
void GroupDef::addDir(const DirDef *def)
{
215
  if (def->isHidden()) return;
216 217 218 219 220 221
  if (Config_getBool("SORT_BRIEF_DOCS"))
    dirList->inSort(def);  
  else
    dirList->append(def);
}

222
void GroupDef::addPage(PageDef *def)
223
{
224
  if (def->isHidden()) return;
225
  //printf("Making page %s part of a group\n",def->name.data());
226
  pageDict->append(def->name(),def);
227
  def->makePartOfGroup(this);
228 229
}

230
void GroupDef::addExample(const PageDef *def)
231
{
232
  if (def->isHidden()) return;
233
  exampleDict->append(def->name(),def);
234 235
}

236

Dimitri van Heesch's avatar
Dimitri van Heesch committed
237 238
void GroupDef::addMembersToMemberGroup()
{
239 240 241 242
  QListIterator<MemberList> mli(m_memberLists);
  MemberList *ml;
  for (mli.toFirst();(ml=mli.current());++mli)
  {
243
    if (ml->listType()&MemberListType_declarationLists)
244 245 246 247
    {
      ::addMembersToMemberGroup(ml,&memberGroupSDict,this);
    }
  }
248 249

  //printf("GroupDef::addMembersToMemberGroup() memberGroupList=%d\n",memberGroupList->count());
250
  MemberGroupSDict::Iterator mgli(*memberGroupSDict);
251 252 253 254 255
  MemberGroup *mg;
  for (;(mg=mgli.current());++mgli)
  {
    mg->setInGroup(TRUE);
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
256 257 258
}


259
bool GroupDef::insertMember(MemberDef *md,bool docOnly)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
260
{
261
  if (md->isHidden()) return FALSE;
262
  updateLanguage(md);
263
  //printf("GroupDef(%s)::insertMember(%s)\n", title.data(), md->name().data());
264
  MemberNameInfo *mni=0;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
265
  if ((mni=(*allMemberNameInfoSDict)[md->name()]))
266 267 268 269
  { // member with this name already found
    MemberNameInfoIterator srcMnii(*mni); 
    MemberInfo *srcMi;
    for ( ; (srcMi=srcMnii.current()) ; ++srcMnii )
Dimitri van Heesch's avatar
Dimitri van Heesch committed
270
    {
271
      MemberDef *srcMd = srcMi->memberDef;
272
      if (srcMd==md) return FALSE; // already added before!
273 274 275 276

      bool sameScope = srcMd->getOuterScope()==md->getOuterScope() || // same class or namespace
          // both inside a file => definition and declaration do not have to be in the same file
           (srcMd->getOuterScope()->definitionType()==Definition::TypeFile &&
277
               md->getOuterScope()->definitionType()==Definition::TypeFile); 
278

279 280 281 282
      ArgumentList *srcMdAl  = srcMd->argumentList();
      ArgumentList *mdAl     = md->argumentList();
      ArgumentList *tSrcMdAl = srcMd->templateArguments();
      ArgumentList *tMdAl    = md->templateArguments();
283
      
284
      if (srcMd->isFunction() && md->isFunction() && // both are a function
285 286
          ((tSrcMdAl==0 && tMdAl==0) || 
           (tSrcMdAl!=0 && tMdAl!=0 && tSrcMdAl->count()==tMdAl->count())
287
          ) &&       // same number of template arguments
288 289
          matchArguments2(srcMd->getOuterScope(),srcMd->getFileDef(),srcMdAl,
                          md->getOuterScope(),md->getFileDef(),mdAl,
290
                          TRUE
291 292
                         ) && // matching parameters
          sameScope // both are found in the same scope
293
         )
294
      {
295 296 297 298
        if (srcMd->getGroupAlias()==0) 
        {
          md->setGroupAlias(srcMd); 
        }
299
        else if (md!=srcMd->getGroupAlias())
300 301 302 303
        {
          md->setGroupAlias(srcMd->getGroupAlias()); 
        }
        return FALSE; // member is the same as one that is already added
304
      }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
305
    }
306
    mni->append(new MemberInfo(md,md->protection(),md->virtualness(),FALSE));
307 308 309 310
  }
  else
  {
    mni = new MemberNameInfo(md->name());
311
    mni->append(new MemberInfo(md,md->protection(),md->virtualness(),FALSE));
Dimitri van Heesch's avatar
Dimitri van Heesch committed
312
    allMemberNameInfoSDict->append(mni->memberName(),mni);
313
  }
314
  //printf("Added member!\n");
315 316 317
  allMemberList->append(md); 
  switch(md->memberType())
  {
318
    case MemberType_Variable:     
319 320
      if (!docOnly)
      {
321
        addMemberToList(MemberListType_decVarMembers,md);
322
      }
323
      addMemberToList(MemberListType_docVarMembers,md);
324
      break;
325
    case MemberType_Function: 
326 327
      if (!docOnly)
      {
328
        addMemberToList(MemberListType_decFuncMembers,md);
329
      }
330
      addMemberToList(MemberListType_docFuncMembers,md);
331
      break;
332
    case MemberType_Typedef:      
333 334
      if (!docOnly)
      {
335
        addMemberToList(MemberListType_decTypedefMembers,md);
336
      }
337
      addMemberToList(MemberListType_docTypedefMembers,md);
338
      break;
339
    case MemberType_Enumeration:  
340 341
      if (!docOnly)
      {
342
        addMemberToList(MemberListType_decEnumMembers,md);
343
      }
344
      addMemberToList(MemberListType_docEnumMembers,md);
345
      break;
346
    case MemberType_EnumValue:    
Dimitri van Heesch's avatar
Dimitri van Heesch committed
347 348
      if (!docOnly)
      {
349
        addMemberToList(MemberListType_decEnumValMembers,md);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
350
      }
351
      addMemberToList(MemberListType_docEnumValMembers,md);
352
      break;
353
    case MemberType_Define:       
354 355
      if (!docOnly)
      {
356
        addMemberToList(MemberListType_decDefineMembers,md);
357
      }
358
      addMemberToList(MemberListType_docDefineMembers,md);
359
      break;
360
    case MemberType_Signal:       
361 362
      if (!docOnly)
      {
363
        addMemberToList(MemberListType_decSignalMembers,md);
364
      }
365
      addMemberToList(MemberListType_docSignalMembers,md);
366
      break;
367
    case MemberType_Slot:       
368 369 370 371
      if (md->protection()==Public)
      {
        if (!docOnly)
        {
372
          addMemberToList(MemberListType_decPubSlotMembers,md);
373
        }
374
        addMemberToList(MemberListType_docPubSlotMembers,md);
375 376 377 378 379
      }
      else if (md->protection()==Protected)
      {
        if (!docOnly)
        {
380
          addMemberToList(MemberListType_decProSlotMembers,md);
381
        }
382
        addMemberToList(MemberListType_docProSlotMembers,md);
383 384 385 386 387
      }
      else
      {
        if (!docOnly)
        {
388
          addMemberToList(MemberListType_decPriSlotMembers,md);
389
        }
390
        addMemberToList(MemberListType_docPriSlotMembers,md);
391 392
      }
      break;
393
    case MemberType_Event:       
394 395
      if (!docOnly)
      {
396
        addMemberToList(MemberListType_decEventMembers,md);
397
      }
398
      addMemberToList(MemberListType_docEventMembers,md);
399
      break;
400
    case MemberType_Property:       
401 402
      if (!docOnly)
      {
403
        addMemberToList(MemberListType_decPropMembers,md);
404
      }
405
      addMemberToList(MemberListType_docPropMembers,md);
406
      break;
407
    case MemberType_Friend:       
408 409
      if (!docOnly)
      {
410
        addMemberToList(MemberListType_decFriendMembers,md);
411
      }
412
      addMemberToList(MemberListType_docFriendMembers,md);
413 414
      break;
    default:
415
      err("GroupDef::insertMembers(): "
416 417
           "member `%s' (typeid=%d) with scope `%s' inserted in group scope `%s'!\n",
           md->name().data(),md->memberType(),
418 419
           md->getClassDef() ? md->getClassDef()->name().data() : "",
           name().data());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
420
  }
421
  return TRUE;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
422 423
}

424 425 426
void GroupDef::removeMember(MemberDef *md)
{
  // fprintf(stderr, "GroupDef(%s)::removeMember( %s )\n", title.data(), md->name().data());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
427
  MemberNameInfo *mni = allMemberNameInfoSDict->find(md->name());
428 429 430 431 432 433 434 435 436 437 438 439 440 441
  if (mni)
  {
    MemberNameInfoIterator mnii(*mni);
    while( mnii.current() )
    {
      if( mnii.current()->memberDef == md )
      {
	mni->remove(mnii.current());
        break;
      }
      ++mnii;
    }
    if( mni->isEmpty() )
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
442
      allMemberNameInfoSDict->remove(md->name());
443 444
    }

445
    removeMemberFromList(MemberListType_allMembersList,md);
446 447
    switch(md->memberType())
    {
448 449 450
      case MemberType_Variable:
	removeMemberFromList(MemberListType_decVarMembers,md);
        removeMemberFromList(MemberListType_docVarMembers,md);
451
        break;
452 453 454
      case MemberType_Function: 
        removeMemberFromList(MemberListType_decFuncMembers,md);
        removeMemberFromList(MemberListType_docFuncMembers,md);
455
        break;
456 457 458
      case MemberType_Typedef:      
        removeMemberFromList(MemberListType_decTypedefMembers,md);
        removeMemberFromList(MemberListType_docTypedefMembers,md);
459
        break;
460 461 462
      case MemberType_Enumeration:  
        removeMemberFromList(MemberListType_decEnumMembers,md);
        removeMemberFromList(MemberListType_docEnumMembers,md);
463
        break;
464 465 466
      case MemberType_EnumValue:    
        removeMemberFromList(MemberListType_decEnumValMembers,md);
        removeMemberFromList(MemberListType_docEnumValMembers,md);
467
        break;
468 469 470
      case MemberType_Define:       
        removeMemberFromList(MemberListType_decDefineMembers,md);
        removeMemberFromList(MemberListType_docDefineMembers,md);
471
        break;
472 473 474
      case MemberType_Signal:       
        removeMemberFromList(MemberListType_decSignalMembers,md);
        removeMemberFromList(MemberListType_docSignalMembers,md);
475
        break;
476
      case MemberType_Slot:       
477 478
        if (md->protection()==Public)
        {
479 480
          removeMemberFromList(MemberListType_decPubSlotMembers,md);
          removeMemberFromList(MemberListType_docPubSlotMembers,md);
481 482 483
        }
        else if (md->protection()==Protected)
        {
484 485
          removeMemberFromList(MemberListType_decProSlotMembers,md);
          removeMemberFromList(MemberListType_docProSlotMembers,md);
486 487 488
        }
        else
        {
489 490
          removeMemberFromList(MemberListType_decPriSlotMembers,md);
          removeMemberFromList(MemberListType_docPriSlotMembers,md);
491 492
        }
        break;
493 494 495
      case MemberType_Event:       
        removeMemberFromList(MemberListType_decEventMembers,md);
        removeMemberFromList(MemberListType_docEventMembers,md);
496
        break;
497 498 499
      case MemberType_Property:       
        removeMemberFromList(MemberListType_decPropMembers,md);
        removeMemberFromList(MemberListType_docPropMembers,md);
500
        break;
501 502 503
      case MemberType_Friend:       
        removeMemberFromList(MemberListType_decFriendMembers,md);
        removeMemberFromList(MemberListType_docFriendMembers,md);
504
        break;
505 506 507 508 509 510 511 512
      default:
        err("GroupDef::removeMember(): unexpected member remove in file!\n");
    }
  }
}

bool GroupDef::containsGroup(const GroupDef *def)
{
513
    return this==def || groupList->find(def) >= 0;
514 515
}

Dimitri van Heesch's avatar
Dimitri van Heesch committed
516 517
void GroupDef::addGroup(const GroupDef *def)
{
518
  //printf("adding group `%s' to group `%s'\n",def->name().data(),name().data());
519 520 521 522
  //if (Config_getBool("SORT_MEMBER_DOCS"))
  //  groupList->inSort(def);
  //else
  groupList->append(def);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
523
}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
524

525 526
bool GroupDef::isASubGroup() const
{
527
  GroupList *groups = partOfGroups();
528
  return groups!=0 && groups->count()!=0;
529 530
}

Dimitri van Heesch's avatar
Dimitri van Heesch committed
531 532
int GroupDef::countMembers() const
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
533
  return fileList->count()+
Dimitri van Heesch's avatar
Dimitri van Heesch committed
534
         classSDict->count()+
535
         namespaceSDict->count()+
Dimitri van Heesch's avatar
Dimitri van Heesch committed
536
         groupList->count()+
537 538 539
         allMemberList->count()+
         pageDict->count()+
         exampleDict->count();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
540 541
}

542
/*! Compute the HTML anchor names for all members in the group */ 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
543 544
void GroupDef::computeAnchors()
{
545
  //printf("GroupDef::computeAnchors()\n");
546
  setAnchors(allMemberList);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
547 548
}

549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691
void GroupDef::writeTagFile(FTextStream &tagFile)
{
  tagFile << "  <compound kind=\"group\">" << endl;
  tagFile << "    <name>" << convertToXML(name()) << "</name>" << endl;
  tagFile << "    <title>" << convertToXML(title) << "</title>" << endl;
  tagFile << "    <filename>" << convertToXML(getOutputFileBase()) << Doxygen::htmlFileExtension << "</filename>" << endl;
  QListIterator<LayoutDocEntry> eli(
      LayoutDocManager::instance().docEntries(LayoutDocManager::Group));
  LayoutDocEntry *lde;
  for (eli.toFirst();(lde=eli.current());++eli)
  {
    switch (lde->kind())
    {
      case LayoutDocEntry::GroupClasses:
        {
          if (classSDict)
          {
            SDict<ClassDef>::Iterator ci(*classSDict);
            ClassDef *cd;
            for (ci.toFirst();(cd=ci.current());++ci)
            {
              if (cd->isLinkableInProject())
              {
                tagFile << "    <class kind=\"" << cd->compoundTypeString()
                        << "\">" << convertToXML(cd->name()) << "</class>" << endl;
              }
            }
          }
        }
        break;
      case LayoutDocEntry::GroupNamespaces:
        {
          if (namespaceSDict)
          {
            SDict<NamespaceDef>::Iterator ni(*namespaceSDict);
            NamespaceDef *nd;
            for (ni.toFirst();(nd=ni.current());++ni)
            {
              if (nd->isLinkableInProject())
              {
                tagFile << "    <namespace>" << convertToXML(nd->name())
                        << "</namespace>" << endl;
              }
            }
          }
        }
        break;
      case LayoutDocEntry::GroupFiles:
        {
          if (fileList)
          {
            QListIterator<FileDef> it(*fileList);
            FileDef *fd;
            for (;(fd=it.current());++it)
            {
              if (fd->isLinkableInProject())
              {
                tagFile << "    <file>" << convertToXML(fd->name()) << "</file>" << endl;
              }
            }
          }
        }
        break;
      case LayoutDocEntry::GroupPageDocs:
        {
          if (pageDict)
          {
            PageSDict::Iterator pdi(*pageDict);
            PageDef *pd=0;
            for (pdi.toFirst();(pd=pdi.current());++pdi)
            {
              QCString pageName = pd->getOutputFileBase();
              if (pd->isLinkableInProject())
              {
                tagFile << "    <page>" << convertToXML(pageName) << "</page>" << endl;
              }
            }
          }
        }
        break;
      case LayoutDocEntry::GroupDirs:
        {
          if (dirList)
          {
            QListIterator<DirDef> it(*dirList);
            DirDef *dd;
            for (;(dd=it.current());++it)
            {
              if (dd->isLinkableInProject())
              {
                tagFile << "    <dir>" << convertToXML(dd->displayName()) << "</dir>" << endl;
              }
            }
          }
        }
        break;
      case LayoutDocEntry::GroupNestedGroups:
        {
          if (groupList)
          {
            QListIterator<GroupDef> it(*groupList);
            GroupDef *gd;
            for (;(gd=it.current());++it)
            {
              if (gd->isVisible())
              {
                tagFile << "    <subgroup>" << convertToXML(gd->name()) << "</subgroup>" << endl;
              }
            }
          }
        }
        break;
      case LayoutDocEntry::MemberDecl:
        {
          LayoutDocEntryMemberDecl *lmd = (LayoutDocEntryMemberDecl*)lde;
          MemberList * ml = getMemberList(lmd->type);
          if (ml)
          {
            ml->writeTagFile(tagFile);
          }
        }
        break;
      case LayoutDocEntry::MemberGroups:
        {
          if (memberGroupSDict)
          {
            MemberGroupSDict::Iterator mgli(*memberGroupSDict);
            MemberGroup *mg;
            for (;(mg=mgli.current());++mgli)
            {
              mg->writeTagFile(tagFile);
            }
          }
        }
        break;
      default:
        break;
    }
  }
  writeDocAnchorsToTagFile(tagFile);
  tagFile << "  </compound>" << endl;
}

692
void GroupDef::writeDetailedDescription(OutputList &ol,const QCString &title)
693
{
694
  if ((!briefDescription().isEmpty() && Config_getBool("REPEAT_BRIEF")) 
695
      || !documentation().isEmpty() || !inbodyDocumentation().isEmpty()
696
     )
697
  {
698
    if (pageDict->count()!=countMembers()) // not only pages -> classical layout
699 700
    {
      ol.pushGeneratorState();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
701 702 703 704 705
        ol.disable(OutputGenerator::Html);
        ol.writeRuler();
      ol.popGeneratorState();
      ol.pushGeneratorState();
        ol.disableAllBut(OutputGenerator::Html);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
706
        ol.writeAnchor(0,"details");
707 708
      ol.popGeneratorState();
      ol.startGroupHeader();
709
      ol.parseText(title);
710
      ol.endGroupHeader();
711
    }
712

713 714 715
    // repeat brief description
    if (!briefDescription().isEmpty() && Config_getBool("REPEAT_BRIEF"))
    {
716
      ol.generateDoc(briefFile(),briefLine(),this,0,briefDescription(),FALSE,FALSE);
717 718 719 720 721 722 723 724
    }
    // write separator between brief and details
    if (!briefDescription().isEmpty() && Config_getBool("REPEAT_BRIEF") &&
        !documentation().isEmpty())
    {
      ol.pushGeneratorState();
      ol.disable(OutputGenerator::Man);
      ol.disable(OutputGenerator::RTF);
725
      // ol.newParagraph(); // FIXME:PARA
726 727
      ol.enableAll();
      ol.disableAllBut(OutputGenerator::Man);
728
      ol.enable(OutputGenerator::Latex);
729 730
      ol.writeString("\n\n");
      ol.popGeneratorState();
731 732
    }

733
    // write detailed documentation
734 735
    if (!documentation().isEmpty())
    {
736
      ol.generateDoc(docFile(),docLine(),this,0,documentation()+"\n",TRUE,FALSE);
737
    }
738 739 740 741

    // write inbody documentation
    if (!inbodyDocumentation().isEmpty())
    {
742
      ol.generateDoc(inbodyFile(),inbodyLine(),this,0,inbodyDocumentation()+"\n",TRUE,FALSE);
743
    }
744 745 746
  }
}

747
void GroupDef::writeBriefDescription(OutputList &ol)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
748
{
749
  if (!briefDescription().isEmpty() && Config_getBool("BRIEF_MEMBER_DESC"))
Dimitri van Heesch's avatar
Dimitri van Heesch committed
750
  {
751 752 753
    DocRoot *rootNode = validatingParseDoc(briefFile(),briefLine(),this,0,
                                briefDescription(),TRUE,FALSE,0,TRUE,FALSE);
    if (rootNode && !rootNode->isEmpty())
754
    {
755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772
      ol.startParagraph();
      ol.writeDoc(rootNode,this,0);
      ol.pushGeneratorState();
      ol.disable(OutputGenerator::RTF);
      ol.writeString(" \n");
      ol.enable(OutputGenerator::RTF);

      if (Config_getBool("REPEAT_BRIEF") ||
          !documentation().isEmpty()
         )
      {
        ol.disableAllBut(OutputGenerator::Html);
        ol.startTextLink(0,"details");
        ol.parseText(theTranslator->trMore());
        ol.endTextLink();
      }
      ol.popGeneratorState();
      ol.endParagraph();
773
    }
774
    delete rootNode;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
775
  }
776
}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
777

778 779 780
void GroupDef::writeGroupGraph(OutputList &ol)
{
  if (Config_getBool("HAVE_DOT") /*&& Config_getBool("GROUP_GRAPHS")*/ )
781 782 783 784 785 786 787
  {
    DotGroupCollaboration graph(this);
    if (!graph.isTrivial())
    {
      msg("Generating dependency graph for group %s\n",qualifiedName().data());
      ol.pushGeneratorState();
      ol.disable(OutputGenerator::Man);
788
      //ol.startParagraph();
789 790 791
      ol.startGroupCollaboration();
      ol.parseText(theTranslator->trCollaborationDiagram(title));
      ol.endGroupCollaboration(graph);
792
      //ol.endParagraph();
793 794 795
      ol.popGeneratorState();
    }
  }
796
}
797

798 799
void GroupDef::writeFiles(OutputList &ol,const QCString &title)
{
800
  // write list of files
Dimitri van Heesch's avatar
Dimitri van Heesch committed
801 802
  if (fileList->count()>0)
  {
803
    ol.startMemberHeader("files");
804
    ol.parseText(title);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
805
    ol.endMemberHeader();
806
    ol.startMemberList();
807 808 809
    QListIterator<FileDef> it(*fileList);
    FileDef *fd;
    for (;(fd=it.current());++it)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
810
    {
811
      ol.startMemberDeclaration();
812
      ol.startMemberItem(fd->getOutputFileBase(),0);
813
      ol.docify(theTranslator->trFile(FALSE,TRUE)+" ");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
814 815
      ol.insertMemberAlign();
      ol.writeObjectLink(fd->getReference(),fd->getOutputFileBase(),0,fd->name());
816
      ol.endMemberItem();
817
      if (!fd->briefDescription().isEmpty() && Config_getBool("BRIEF_MEMBER_DESC"))
Dimitri van Heesch's avatar
Dimitri van Heesch committed
818
      {
819
        ol.startMemberDescription(fd->getOutputFileBase());
820
        ol.generateDoc(briefFile(),briefLine(),fd,0,fd->briefDescription(),FALSE,FALSE,0,TRUE,FALSE);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
821 822
        ol.endMemberDescription();
      }
823
      ol.endMemberDeclaration(0,0);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
824
    }
825
    ol.endMemberList();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
826
  }
827
}
828

829 830
void GroupDef::writeNamespaces(OutputList &ol,const QCString &title)
{
831
  // write list of namespaces
832 833
  namespaceSDict->writeDeclaration(ol,title);
}
834

835 836
void GroupDef::writeNestedGroups(OutputList &ol,const QCString &title)
{
837
  // write list of groups
Dimitri van Heesch's avatar
Dimitri van Heesch committed
838
  int count=0;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
839
  if (groupList->count()>0)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
840
  {
841 842 843
    QListIterator<GroupDef> it(*groupList);
    GroupDef *gd;
    for (;(gd=it.current());++it)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
844 845 846 847 848
    {
      if (gd->isVisible()) count++;
    }
  }
  if (count>0)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
849
  {
850
    ol.startMemberHeader("groups");
851
    ol.parseText(title);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
852 853
    ol.endMemberHeader();
    ol.startMemberList();
854 855 856 857
    if (Config_getBool("SORT_GROUP_NAMES"))
    {
      groupList->sort();
    }
858 859 860
    QListIterator<GroupDef> it(*groupList);
    GroupDef *gd;
    for (;(gd=it.current());++it)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
861
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
862
      if (gd->isVisible())
Dimitri van Heesch's avatar
Dimitri van Heesch committed
863
      {
864
        ol.startMemberDeclaration();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
865 866 867 868 869 870 871 872 873
        ol.startMemberItem(gd->getOutputFileBase(),0);
        //ol.docify(theTranslator->trGroup(FALSE,TRUE));
        //ol.docify(" ");
        ol.insertMemberAlign();
        ol.writeObjectLink(gd->getReference(),gd->getOutputFileBase(),0,gd->groupTitle());
        ol.endMemberItem();
        if (!gd->briefDescription().isEmpty() && Config_getBool("BRIEF_MEMBER_DESC"))
        {
          ol.startMemberDescription(gd->getOutputFileBase());
874
          ol.generateDoc(briefFile(),briefLine(),gd,0,gd->briefDescription(),FALSE,FALSE,0,TRUE,FALSE);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
875 876
          ol.endMemberDescription();
        }
877
        ol.endMemberDeclaration(0,0);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
878 879 880 881
      }
    }
    ol.endMemberList();
  }
882
}
883

884 885
void GroupDef::writeDirs(OutputList &ol,const QCString &title)
{
886 887 888
  // write list of directories
  if (dirList->count()>0)
  {
889
    ol.startMemberHeader("dirs");
890
    ol.parseText(title);
891 892
    ol.endMemberHeader();
    ol.startMemberList();
893 894 895
    QListIterator<DirDef> it(*dirList);
    DirDef *dd;
    for (;(dd=it.current());++it)
896
    {
897
      ol.startMemberDeclaration();
898
      ol.startMemberItem(dd->getOutputFileBase(),0);
899 900 901 902 903 904
      ol.parseText(theTranslator->trDir(FALSE,TRUE));
      ol.insertMemberAlign();
      ol.writeObjectLink(dd->getReference(),dd->getOutputFileBase(),0,dd->shortName());
      ol.endMemberItem();
      if (!dd->briefDescription().isEmpty() && Config_getBool("BRIEF_MEMBER_DESC"))
      {
905
        ol.startMemberDescription(dd->getOutputFileBase());
906
        ol.generateDoc(briefFile(),briefLine(),dd,0,dd->briefDescription(),FALSE,FALSE,0,TRUE,FALSE);
907 908
        ol.endMemberDescription();
      }
909
      ol.endMemberDeclaration(0,0);
910 911 912 913
    }

    ol.endMemberList();
  }
914
}
915

916 917 918 919 920
void GroupDef::writeClasses(OutputList &ol,const QCString &title)
{
  // write list of classes
  classSDict->writeDeclaration(ol,0,title,FALSE);
}
921

Dimitri van Heesch's avatar
Dimitri van Heesch committed
922 923 924 925 926
void GroupDef::writeInlineClasses(OutputList &ol)
{
  classSDict->writeDocumentation(ol);
}

927 928
void GroupDef::writePageDocumentation(OutputList &ol)
{
929
  PageDef *pd=0;
930
  PageSDict::Iterator pdi(*pageDict);
931
  for (pdi.toFirst();(pd=pdi.current());++pdi)
932
  {
933
    if (!pd->isReference())
934
    {
935
      SectionInfo *si=0;
936
      if (!pd->title().isEmpty() && !pd->name().isEmpty() &&
937
          (si=Doxygen::sectionDict->find(pd->name()))!=0)
938
      {
939
        ol.startSection(si->label,si->title,SectionInfo::Subsection);
940
        ol.docify(si->title);
941
        ol.endSection(si->label,SectionInfo::Subsection);
942 943
      }
      ol.startTextBlock();
944
      ol.generateDoc(pd->docFile(),pd->docLine(),pd,0,pd->documentation()+pd->inbodyDocumentation(),TRUE,FALSE,0,TRUE,FALSE);
945
      ol.endTextBlock();
946 947
    }
  }
948
}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
949

950 951 952 953
void GroupDef::writeMemberGroups(OutputList &ol)
{
  /* write user defined member groups */
  if (memberGroupSDict)
954
  {
955
    memberGroupSDict->sort();
956 957 958 959 960 961 962
    /* write user defined member groups */
    MemberGroupSDict::Iterator mgli(*memberGroupSDict);
    MemberGroup *mg;
    for (;(mg=mgli.current());++mgli)
    {
      mg->writeDeclarations(ol,0,0,0,this);
    }
963
  }
964
}
965

966 967 968 969 970 971 972 973 974
void GroupDef::startMemberDeclarations(OutputList &ol)
{
  ol.startMemberSections();
}

void GroupDef::endMemberDeclarations(OutputList &ol)
{
  ol.endMemberSections();
}
975

976 977
void GroupDef::startMemberDocumentation(OutputList &ol)
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
978
  //printf("** GroupDef::startMemberDocumentation()\n");
979 980
  if (Config_getBool("SEPARATE_MEMBER_PAGES"))
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
981
    ol.pushGeneratorState();
982 983
    ol.disable(OutputGenerator::Html);
    Doxygen::suppressDocWarnings = TRUE;
984 985 986
  }
}

987
void GroupDef::endMemberDocumentation(OutputList &ol)
988
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
989
  //printf("** GroupDef::endMemberDocumentation()\n");
990 991
  if (Config_getBool("SEPARATE_MEMBER_PAGES"))
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
992
    ol.popGeneratorState();
993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008
    Doxygen::suppressDocWarnings = FALSE;
  }
}

void GroupDef::writeAuthorSection(OutputList &ol)
{
  // write Author section (Man only)
  ol.pushGeneratorState();
  ol.disableAllBut(OutputGenerator::Man);
  ol.startGroupHeader();
  ol.parseText(theTranslator->trAuthor(TRUE,TRUE));
  ol.endGroupHeader();
  ol.parseText(theTranslator->trGeneratedAutomatically(Config_getString("PROJECT_NAME")));
  ol.popGeneratorState();
}

1009 1010 1011 1012 1013 1014 1015 1016
void GroupDef::writeSummaryLinks(OutputList &ol)
{
  ol.pushGeneratorState();
  ol.disableAllBut(OutputGenerator::Html);
  QListIterator<LayoutDocEntry> eli(
      LayoutDocManager::instance().docEntries(LayoutDocManager::Group));
  LayoutDocEntry *lde;
  bool first=TRUE;
1017
  SrcLangExt lang = getLanguage();
1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032
  for (eli.toFirst();(lde=eli.current());++eli)
  {
    if ((lde->kind()==LayoutDocEntry::GroupClasses && classSDict->declVisible()) || 
        (lde->kind()==LayoutDocEntry::GroupNamespaces && namespaceSDict->declVisible()) ||
        (lde->kind()==LayoutDocEntry::GroupFiles && fileList->count()>0) ||
        (lde->kind()==LayoutDocEntry::GroupNestedGroups && groupList->count()>0) ||
        (lde->kind()==LayoutDocEntry::GroupDirs && dirList->count()>0)
       )
    {
      LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde;
      QCString label = lde->kind()==LayoutDocEntry::GroupClasses      ? "nested-classes" : 
                       lde->kind()==LayoutDocEntry::GroupNamespaces   ? "namespaces"     :
                       lde->kind()==LayoutDocEntry::GroupFiles        ? "files"          :
                       lde->kind()==LayoutDocEntry::GroupNestedGroups ? "groups"         :
                       "dirs";
1033
      ol.writeSummaryLink(0,label,ls->title(lang),first);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1034
      first=FALSE;
1035 1036 1037 1038 1039 1040 1041
    }
    else if (lde->kind()==LayoutDocEntry::MemberDecl)
    {
      LayoutDocEntryMemberDecl *lmd = (LayoutDocEntryMemberDecl*)lde;
      MemberList * ml = getMemberList(lmd->type);
      if (ml && ml->declVisible())
      {
1042
        ol.writeSummaryLink(0,MemberList::listTypeAsString(ml->listType()),lmd->title(lang),first);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1043
        first=FALSE;
1044 1045 1046 1047 1048 1049 1050 1051 1052 1053
      }
    }
  }
  if (!first)
  {
    ol.writeString("  </div>\n");
  }
  ol.popGeneratorState();
}

1054 1055
void GroupDef::writeDocumentation(OutputList &ol)
{
1056
  //static bool generateTreeView = Config_getBool("GENERATE_TREEVIEW");
1057
  ol.pushGeneratorState();
1058
  startFile(ol,getOutputFileBase(),name(),title,HLI_None);
1059 1060 1061 1062 1063 1064

  ol.startHeaderSection();
  writeSummaryLinks(ol);
  ol.startTitleHead(getOutputFileBase());
  ol.pushGeneratorState();
  ol.disable(OutputGenerator::Man);
1065
  ol.parseText(title);
1066
  ol.popGeneratorState();
1067
  addGroupListToTitle(ol,this);
1068 1069
  ol.pushGeneratorState();
  ol.disable(OutputGenerator::Man);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1070
  ol.endTitleHead(getOutputFileBase(),title);
1071 1072 1073 1074 1075 1076
  ol.popGeneratorState();
  ol.pushGeneratorState();
  ol.disableAllBut(OutputGenerator::Man);
  ol.endTitleHead(getOutputFileBase(),name());
  ol.parseText(title);
  ol.popGeneratorState();
1077
  ol.endHeaderSection();
1078
  ol.startContents();
1079

1080
  if (Doxygen::searchIndex)
1081
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1082
    Doxygen::searchIndex->setCurrentDoc(this,anchor(),FALSE);
1083
    static QRegExp we("[a-zA-Z_][-a-zA-Z_0-9]*");
1084 1085 1086 1087 1088 1089 1090
    int i=0,p=0,l=0;
    while ((i=we.match(title,p,&l))!=-1) // foreach word in the title
    {
      Doxygen::searchIndex->addWord(title.mid(i,l),TRUE);
      p=i+l;
    }
  }
1091

1092
  Doxygen::indexList->addIndexItem(this,0,0,title);
1093 1094 1095

  //---------------------------------------- start flexible part -------------------------------

1096
  SrcLangExt lang=getLanguage();
1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112
  QListIterator<LayoutDocEntry> eli(
      LayoutDocManager::instance().docEntries(LayoutDocManager::Group));
  LayoutDocEntry *lde;
  for (eli.toFirst();(lde=eli.current());++eli)
  {
    switch (lde->kind())
    {
      case LayoutDocEntry::BriefDesc: 
        writeBriefDescription(ol);
        break; 
      case LayoutDocEntry::MemberDeclStart: 
        startMemberDeclarations(ol);
        break; 
      case LayoutDocEntry::GroupClasses: 
        {
          LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde;
1113
          writeClasses(ol,ls->title(lang));
1114 1115
        }
        break; 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1116 1117 1118 1119 1120
      case LayoutDocEntry::GroupInlineClasses: 
        {
          writeInlineClasses(ol);
        }
        break;
1121 1122 1123
      case LayoutDocEntry::GroupNamespaces: 
        {
          LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde;
1124
          writeNamespaces(ol,ls->title(lang));
1125 1126 1127 1128 1129 1130 1131 1132
        }
        break; 
      case LayoutDocEntry::MemberGroups: 
        writeMemberGroups(ol);
        break; 
      case LayoutDocEntry::MemberDecl: 
        {
          LayoutDocEntryMemberDecl *lmd = (LayoutDocEntryMemberDecl*)lde;
1133
          writeMemberDeclarations(ol,lmd->type,lmd->title(lang));
1134 1135 1136 1137 1138 1139 1140 1141
        }
        break; 
      case LayoutDocEntry::MemberDeclEnd: 
        endMemberDeclarations(ol);
        break;
      case LayoutDocEntry::DetailedDesc: 
        {
          LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde;
1142
          writeDetailedDescription(ol,ls->title(lang));
1143 1144 1145 1146 1147 1148 1149 1150
        }
        break;
      case LayoutDocEntry::MemberDefStart: 
        startMemberDocumentation(ol);
        break; 
      case LayoutDocEntry::MemberDef: 
        {
          LayoutDocEntryMemberDef *lmd = (LayoutDocEntryMemberDef*)lde;
1151
          writeMemberDocumentation(ol,lmd->type,lmd->title(lang));
1152 1153 1154 1155 1156 1157 1158 1159
        }
        break;
      case LayoutDocEntry::MemberDefEnd: 
        endMemberDocumentation(ol);
        break;
      case LayoutDocEntry::GroupNestedGroups: 
        {
          LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde;
1160
          writeNestedGroups(ol,ls->title(lang));
1161 1162 1163 1164 1165 1166 1167 1168
        }
        break;
      case LayoutDocEntry::GroupPageDocs: 
        writePageDocumentation(ol);
        break;
      case LayoutDocEntry::GroupDirs: 
        {
          LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde;
1169
          writeDirs(ol,ls->title(lang));
1170 1171 1172 1173 1174
        }
        break;
      case LayoutDocEntry::GroupFiles: 
        {
          LayoutDocEntrySection *ls = (LayoutDocEntrySection*)lde;
1175
          writeFiles(ol,ls->title(lang));
1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189
        }
        break;
      case LayoutDocEntry::GroupGraph: 
        writeGroupGraph(ol);
        break;
      case LayoutDocEntry::AuthorSection: 
        writeAuthorSection(ol);
        break;
      case LayoutDocEntry::ClassIncludes:
      case LayoutDocEntry::ClassInheritanceGraph:
      case LayoutDocEntry::ClassNestedClasses:
      case LayoutDocEntry::ClassCollaborationGraph:
      case LayoutDocEntry::ClassAllMembersLink:
      case LayoutDocEntry::ClassUsedFiles:
1190
      case LayoutDocEntry::ClassInlineClasses:
1191
      case LayoutDocEntry::NamespaceNestedNamespaces:
1192
      case LayoutDocEntry::NamespaceNestedConstantGroups:
1193
      case LayoutDocEntry::NamespaceClasses:
1194
      case LayoutDocEntry::NamespaceInlineClasses:
1195 1196
      case LayoutDocEntry::FileClasses:
      case LayoutDocEntry::FileNamespaces:
1197
      case LayoutDocEntry::FileConstantGroups:
1198 1199 1200 1201
      case LayoutDocEntry::FileIncludes:
      case LayoutDocEntry::FileIncludeGraph:
      case LayoutDocEntry::FileIncludedByGraph: 
      case LayoutDocEntry::FileSourceLink:
1202
      case LayoutDocEntry::FileInlineClasses:
1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214
      case LayoutDocEntry::DirSubDirs:
      case LayoutDocEntry::DirFiles:
      case LayoutDocEntry::DirGraph:
        err("Internal inconsistency: member %d should not be part of "
            "LayoutDocManager::Group entry list\n",lde->kind());
        break;
    }
  }

  //---------------------------------------- end flexible part -------------------------------

  endFile(ol); 
1215

1216 1217
  ol.popGeneratorState();

1218
  if (Config_getBool("SEPARATE_MEMBER_PAGES"))
1219
  {
1220 1221
    allMemberList->sort();
    writeMemberPages(ol);
1222
  }
1223

1224 1225 1226 1227 1228 1229 1230
}

void GroupDef::writeMemberPages(OutputList &ol)
{
  ol.pushGeneratorState();
  ol.disableAllBut(OutputGenerator::Html);
  
1231 1232 1233 1234
  QListIterator<MemberList> mli(m_memberLists);
  MemberList *ml;
  for (mli.toFirst();(ml=mli.current());++mli)
  {
1235
    if (ml->listType()&MemberListType_documentationLists)
1236 1237 1238 1239
    {
       ml->writeDocumentationPage(ol,name(),this);
    }
  }
1240

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1241
  ol.popGeneratorState();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1242
}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1243

1244 1245
void GroupDef::writeQuickMemberLinks(OutputList &ol,MemberDef *currentMd) const
{
1246 1247
  static bool createSubDirs=Config_getBool("CREATE_SUBDIRS");

1248 1249 1250 1251 1252 1253 1254
  ol.writeString("      <div class=\"navtab\">\n");
  ol.writeString("        <table>\n");

  MemberListIterator mli(*allMemberList);
  MemberDef *md;
  for (mli.toFirst();(md=mli.current());++mli)
  {
1255
    if (md->getGroupDef()==this && md->isLinkable() && !md->isEnumValue())
1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268
    {
      ol.writeString("          <tr><td class=\"navtab\">");
      if (md->isLinkableInProject())
      {
        if (md==currentMd) // selected item => highlight
        {
          ol.writeString("<a class=\"qindexHL\" ");
        }
        else
        {
          ol.writeString("<a class=\"qindex\" ");
        }
        ol.writeString("href=\"");
1269
        if (createSubDirs) ol.writeString("../../");
1270 1271
        ol.writeString(md->getOutputFileBase()+Doxygen::htmlFileExtension+"#"+md->anchor());
        ol.writeString("\">");
1272
        ol.writeString(convertToHtml(md->localName()));
1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284
        ol.writeString("</a>");
      }
      ol.writeString("</td></tr>\n");
    }
  }

  ol.writeString("        </table>\n");
  ol.writeString("      </div>\n");
}



Dimitri van Heesch's avatar
Dimitri van Heesch committed
1285 1286 1287 1288
//---- helper functions ------------------------------------------------------

void addClassToGroups(Entry *root,ClassDef *cd)
{
1289 1290 1291
  QListIterator<Grouping> gli(*root->groups);
  Grouping *g;
  for (;(g=gli.current());++gli)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1292 1293
  {
    GroupDef *gd=0;
1294
    if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g->groupname)))
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1295
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1296 1297 1298 1299 1300
      if (gd->addClass(cd)) 
      {
        cd->makePartOfGroup(gd);
      }
      //printf("Compound %s: in group %s\n",cd->name().data(),gd->groupTitle());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1301 1302 1303 1304 1305 1306 1307
    }
  }
}

void addNamespaceToGroups(Entry *root,NamespaceDef *nd)
{
  //printf("root->groups->count()=%d\n",root->groups->count());
1308 1309 1310
  QListIterator<Grouping> gli(*root->groups);
  Grouping *g;
  for (;(g=gli.current());++gli)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1311 1312 1313
  {
    GroupDef *gd=0;
    //printf("group `%s'\n",s->data());
1314
    if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g->groupname)))
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1315
    {
1316
      if (gd->addNamespace(nd)) nd->makePartOfGroup(gd);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1317 1318 1319 1320 1321
      //printf("Namespace %s: in group %s\n",nd->name().data(),s->data());
    }
  }
}

1322 1323 1324 1325 1326 1327 1328 1329 1330
void addDirToGroups(Entry *root,DirDef *dd)
{
  //printf("*** root->groups->count()=%d\n",root->groups->count());
  QListIterator<Grouping> gli(*root->groups);
  Grouping *g;
  for (;(g=gli.current());++gli)
  {
    GroupDef *gd=0;
    //printf("group `%s'\n",g->groupname.data());
1331
    if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g->groupname)))
1332 1333 1334 1335 1336 1337 1338 1339
    {
      gd->addDir(dd);
      dd->makePartOfGroup(gd);
      //printf("Dir %s: in group %s\n",dd->name().data(),g->groupname.data());
    }
  }
}

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1340 1341
void addGroupToGroups(Entry *root,GroupDef *subGroup)
{
1342 1343
  //printf("addGroupToGroups for %s groups=%d\n",root->name.data(),
  //    root->groups?root->groups->count():-1);
1344 1345 1346
  QListIterator<Grouping> gli(*root->groups);
  Grouping *g;
  for (;(g=gli.current());++gli)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1347 1348
  {
    GroupDef *gd=0;
1349
    if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g->groupname)) &&
1350
	!gd->containsGroup(subGroup) )
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1351 1352
    {
      gd->addGroup(subGroup);
1353
      subGroup->makePartOfGroup(gd);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1354
    }
1355 1356 1357 1358 1359
    else if (gd==subGroup)
    {
      warn(root->fileName,root->startLine,"Trying to add group %s to itself!",
          gd->name().data());
    }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1360 1361 1362
  }
}

1363
/*! Add a member to the group with the highest priority */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1364 1365
void addMemberToGroups(Entry *root,MemberDef *md)
{
1366 1367 1368 1369
  //printf("addMemberToGroups:  Root %p = %s, md %p=%s groups=%d\n", 
  //    root, root->name.data(), md, md->name().data(), root->groups->count() );
  QListIterator<Grouping> gli(*root->groups);
  Grouping *g;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1370

1371 1372 1373 1374 1375 1376 1377 1378 1379
  // Search entry's group list for group with highest pri.
  Grouping::GroupPri_t pri = Grouping::GROUPING_LOWEST;
  GroupDef *fgd=0;
  for (;(g=gli.current());++gli)
  {
    GroupDef *gd=0;
    if (!g->groupname.isEmpty() &&
        (gd=Doxygen::groupSDict->find(g->groupname)) &&
        g->pri >= pri)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1380
    {
1381
      if (fgd && gd!=fgd && g->pri==pri) 
1382
      {
1383
        warn(root->fileName.data(), root->startLine,
1384
            "Member %s found in multiple %s groups! "
1385 1386 1387 1388
            "The member will be put in group %s, and not in group %s",
            md->name().data(), Grouping::getGroupPriName( pri ),
            gd->name().data(), fgd->name().data()
            );
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1389
      }
1390 1391 1392

      fgd = gd;
      pri = g->pri;
1393
    }
1394 1395
  }
  //printf("fgd=%p\n",fgd);
1396

1397 1398 1399 1400 1401 1402 1403
  // put member into group defined by this entry?
  if (fgd)
  {
    GroupDef *mgd = md->getGroupDef();
    //printf("mgd=%p\n",mgd);
    bool insertit = FALSE;
    if (mgd==0)
1404
    {
1405 1406 1407 1408 1409 1410 1411 1412 1413 1414
      insertit = TRUE;
    }
    else if (mgd!=fgd)
    {
      bool moveit = FALSE;

      // move member from one group to another if 
      // - the new one has a higher priority
      // - the new entry has the same priority, but with docs where the old one had no docs
      if (md->getGroupPri()<pri)
1415
      {
1416
        moveit = TRUE;
1417
      }
1418
      else
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1419
      {
1420
        if (md->getGroupPri()==pri)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1421
        {
1422 1423 1424 1425 1426
          if (!root->doc.isEmpty() && !md->getGroupHasDocs())
          {
            moveit = TRUE;
          }
          else if (!root->doc.isEmpty() && md->getGroupHasDocs())
1427
          {
1428
            warn(md->getGroupFileName(),md->getGroupStartLine(),
1429
                "Member documentation for %s found several times in %s groups!\n"
1430 1431 1432 1433 1434 1435
                "%s:%d: The member will remain in group %s, and won't be put into group %s",
                md->name().data(), Grouping::getGroupPriName( pri ),
                root->fileName.data(), root->startLine,
                mgd->name().data(),
                fgd->name().data()
                );
1436 1437
          }
        }
1438
      }
1439

1440 1441 1442 1443 1444
      if (moveit)
      {
        //printf("removeMember\n");
        mgd->removeMember(md);
        insertit = TRUE;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1445
      }
1446
    }
1447

1448 1449 1450 1451 1452 1453 1454
    if (insertit)
    {
      //printf("insertMember found at %s line %d: %s: related %s\n",
      //    md->getDefFileName().data(),md->getDefLine(),
      //    md->name().data(),root->relates.data());
      bool success = fgd->insertMember(md);
      if (success)
1455
      {
1456 1457 1458 1459 1460
        //printf("insertMember successful\n");
        md->setGroupDef(fgd,pri,root->fileName,root->startLine,
            !root->doc.isEmpty());
        ClassDef *cd = md->getClassDefOfAnonymousType();
        if (cd) 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1461
        {
1462
          cd->setGroupDefForAllMembers(fgd,pri,root->fileName,root->startLine,root->doc.length() != 0);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1463
        }
1464
      }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1465 1466 1467 1468
    }
  }
}

1469

1470
void addExampleToGroups(Entry *root,PageDef *eg)
1471
{
1472 1473 1474
  QListIterator<Grouping> gli(*root->groups);
  Grouping *g;
  for (;(g=gli.current());++gli)
1475 1476
  {
    GroupDef *gd=0;
1477
    if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g->groupname)))
1478 1479
    {
      gd->addExample(eg);
1480
      eg->makePartOfGroup(gd);
1481 1482 1483 1484 1485
      //printf("Example %s: in group %s\n",eg->name().data(),s->data());
    }
  }
}

1486 1487
QCString GroupDef::getOutputFileBase() const 
{ 
1488 1489 1490 1491 1492 1493 1494 1495
  if (isReference())
  {
    return fileName;
  }
  else
  {
    return convertNameToFile(fileName); 
  }
1496
}
1497 1498 1499

void GroupDef::addListReferences()
{
1500
  {
1501 1502
    QList<ListItemInfo> *xrefItems = xrefListItems();
    addRefItem(xrefItems,
1503
             getOutputFileBase(),
1504
             theTranslator->trGroup(TRUE,TRUE),
1505 1506
             getOutputFileBase(),name(),
             0
1507
            );
1508
  }
1509
  MemberGroupSDict::Iterator mgli(*memberGroupSDict);
1510 1511 1512 1513 1514
  MemberGroup *mg;
  for (;(mg=mgli.current());++mgli)
  {
    mg->addListReferences(this);
  }
1515 1516 1517 1518
  QListIterator<MemberList> mli(m_memberLists);
  MemberList *ml;
  for (mli.toFirst();(ml=mli.current());++mli)
  {
1519
    if (ml->listType()&MemberListType_documentationLists)
1520 1521 1522 1523 1524 1525
    {
      ml->addListReferences(this);
    }
  }
}

1526
MemberList *GroupDef::createMemberList(MemberListType lt)
1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544
{
  m_memberLists.setAutoDelete(TRUE);
  QListIterator<MemberList> mli(m_memberLists);
  MemberList *ml;
  for (mli.toFirst();(ml=mli.current());++mli)
  {
    if (ml->listType()==lt)
    {
      return ml;
    }
  }
  // not found, create a new member list
  ml = new MemberList(lt);
  m_memberLists.append(ml);
  ml->setInGroup(TRUE);
  return ml;
}

1545
void GroupDef::addMemberToList(MemberListType lt,MemberDef *md)
1546 1547 1548 1549
{
  static bool sortBriefDocs = Config_getBool("SORT_BRIEF_DOCS");
  static bool sortMemberDocs = Config_getBool("SORT_MEMBER_DOCS");
  MemberList *ml = createMemberList(lt);
1550
  ml->setNeedsSorting(
1551 1552
      ((ml->listType()&MemberListType_declarationLists) && sortBriefDocs) ||
      ((ml->listType()&MemberListType_documentationLists) && sortMemberDocs));
1553
  ml->append(md);
1554 1555
}

1556 1557
void GroupDef::sortMemberLists()
{
1558 1559 1560
  QListIterator<MemberList> mli(m_memberLists);
  MemberList *ml;
  for (;(ml=mli.current());++mli)
1561 1562 1563 1564 1565
  {
    if (ml->needsSorting()) { ml->sort(); ml->setNeedsSorting(FALSE); }
  }
}

1566
MemberList *GroupDef::getMemberList(MemberListType lt) const
1567
{
1568 1569 1570
  QListIterator<MemberList> mli(m_memberLists);
  MemberList *ml;
  for (;(ml=mli.current());++mli)
1571 1572 1573 1574 1575 1576 1577 1578 1579
  {
    if (ml->listType()==lt)
    {
      return ml;
    }
  }
  return 0;
}

1580
void GroupDef::writeMemberDeclarations(OutputList &ol,MemberListType lt,const QCString &title)
1581
{
1582 1583
  static bool optimizeVhdl = Config_getBool("OPTIMIZE_OUTPUT_VHDL");

1584
  MemberList * ml = getMemberList(lt);
1585 1586
  if (optimizeVhdl && ml) 
  {
1587
    VhdlDocGen::writeVhdlDeclarations(ml,ol,this,0,0,0);
1588 1589
    return;
  }
1590
  if (ml) 
1591
  {
1592
    ml->writeDeclarations(ol,0,0,0,this,title,0,definitionType());
1593
  }
1594 1595
}

1596
void GroupDef::writeMemberDocumentation(OutputList &ol,MemberListType lt,const QCString &title)
1597 1598 1599 1600 1601
{
  MemberList * ml = getMemberList(lt);
  if (ml) ml->writeDocumentation(ol,name(),this,title);
}

1602
void GroupDef::removeMemberFromList(MemberListType lt,MemberDef *md)
1603 1604 1605 1606
{
    MemberList *ml = getMemberList(lt);
    if (ml) ml->remove(md); 
}
1607

1608 1609 1610 1611 1612
void GroupDef::sortSubGroups() 
{ 
    groupList->sort(); 
}

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1613 1614 1615 1616 1617 1618 1619 1620 1621 1622
bool GroupDef::isLinkableInProject() const
{
  return !isReference() && isLinkable();
}

bool GroupDef::isLinkable() const
{
  return hasUserDocumentation();
}

1623 1624 1625 1626 1627 1628 1629 1630 1631 1632
// let the "programming language" for a group depend on what is inserted into it.
// First item that has an associated languages determines the language for the whole group.
void GroupDef::updateLanguage(const Definition *d)
{
  if (getLanguage()==SrcLangExt_Unknown && d->getLanguage()!=SrcLangExt_Unknown)
  {
    setLanguage(d->getLanguage());
  }
}

1633 1634 1635 1636 1637 1638
bool GroupDef::hasDetailedDescription() const
{
  static bool repeatBrief = Config_getBool("REPEAT_BRIEF");
  return ((!briefDescription().isEmpty() && repeatBrief) ||
          !documentation().isEmpty());
}
1639