CCCC - C and C++ Code Counter  9999-git
CCCC Development version (post-3.1.4)
cccc_xml.cc
Go to the documentation of this file.
1 /*
2  CCCC - C and C++ Code Counter
3  Copyright (C) 1994-2005 Tim Littlefair (tim_littlefair@hotmail.com)
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 // cccc_xml.cc
20 
21 // this file defines XML output facilities for the CCCC project
22 
23 #include "cccc.h"
24 #include "cccc_itm.h"
25 #include "cccc_xml.h"
26 
27 // I would love to use the C++ standard preprocessor
28 // directive #if here, but I have had reports before now
29 // of people who are using compilers which only support
30 // #ifdef.
31 #ifdef CCCC_CONF_W32VC
32 #include <direct.h>
33 #else
34 #ifdef CCCC_CONF_W32BC
35 #include <direct.h>
36 #else
37 #include <unistd.h>
38 #endif
39 #endif
40 
41 #include <string.h>
42 #include <time.h>
43 #include <sys/stat.h>
44 #include "cccc_utl.h"
45 
46 
47 // class static data members
51 
52 static const string XML_PREAMBLE = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
53 static const string XML_COMMENT_BEGIN = "<!--";
54 static const string XML_COMMENT_END = "-->";
55 static const string XML_TAG_OPEN_BEGIN = "<";
56 static const string XML_TAG_OPEN_END = ">";
57 static const string XML_TAG_CLOSE_BEGIN = "</";
58 static const string XML_TAG_CLOSE_END = ">";
59 static const string XML_TAG_INLINE_BEGIN = "<";
60 static const string XML_TAG_INLINE_END = "/>";
61 static const string XML_SPACE = " ";
62 static const string XML_NEWLINE = "\n";
63 static const string XML_DQUOTE = "\"";
64 static const string XML_EQUALS = "=";
65 
66 static const string PROJECT_NODE_NAME = "CCCC_Project";
67 static const string TIMESTAMP_NODE_NAME = "timestamp";
68 static const string SUMMARY_NODE_NAME = "project_summary";
69 static const string MODSUM_NODE_NAME = "module_summary";
70 static const string MODDET_NODE_NAME = "module_detail";
71 static const string PROCSUM_NODE_NAME = "procedural_summary";
72 static const string PROCDET_NODE_NAME = "procedural_detail";
73 static const string STRUCTSUM_NODE_NAME = "structural_summary";
74 static const string STRUCTDET_NODE_NAME = "structural_detail";
75 static const string OODESIGN_NODE_NAME = "oo_design";
76 static const string OTHER_NODE_NAME = "other_extents";
77 static const string REJECTED_NODE_NAME = "rejected_extent";
78 static const string NAME_NODE_NAME = "name";
79 static const string MODULE_NODE_NAME = "module";
80 static const string MEMBER_NODE_NAME = "member_function";
81 static const string EXTENT_NODE_NAME = "extent";
82 static const string SUPPLIERS_NODE_NAME = "suppliers";
83 static const string SUPMOD_NODE_NAME = "supplier_module";
84 static const string CLIENTS_NODE_NAME = "clients";
85 static const string CLIMOD_NODE_NAME = "client_module";
86 static const string DESC_NODE_NAME = "description";
87 static const string SRCREF_NODE_NAME = "source_reference";
88 
89 static const string NOM_NODE_NAME = "number_of_modules";
90 static const string LOC_NODE_NAME = "lines_of_code";
91 static const string LOCPERMOD_NODE_NAME = "lines_of_code_per_module";
92 static const string LOCPERCOM_NODE_NAME = "lines_of_code_per_line_of_comment";
93 static const string LOCPERMEM_NODE_NAME = "lines_of_code_per_member_function";
94 static const string MVG_NODE_NAME = "McCabes_cyclomatic_complexity";
95 static const string MVGPERMOD_NODE_NAME = "McCabes_cyclomatic_complexity_per_module";
96 static const string MVGPERCOM_NODE_NAME = "McCabes_cyclomatic_complexity_per_line_of_comment";
97 static const string MVGPERMEM_NODE_NAME = "McCabes_cyclomatic_complexity_per_member_function";
98 static const string COM_NODE_NAME = "lines_of_comment";
99 static const string COMPERMOD_NODE_NAME = "lines_of_comment_per_module";
100 static const string COMPERMEM_NODE_NAME = "lines_of_comment_per_member_function";
101 static const string WMC1_NODE_NAME = "weighted_methods_per_class_unity";
102 static const string WMCV_NODE_NAME = "weighted_methods_per_class_visibility";
103 static const string DIT_NODE_NAME = "depth_of_inheritance_tree";
104 static const string NOC_NODE_NAME = "number_of_children";
105 static const string CBO_NODE_NAME = "coupling_between_objects";
106 static const string IF4_NODE_NAME = "IF4";
107 static const string IF4PERMOD_NODE_NAME = "IF4_per_module";
108 static const string IF4PERMEM_NODE_NAME = "IF4_per_member_function";
109 static const string IF4VIS_NODE_NAME = "IF4_visible";
110 static const string IF4VISPERMOD_NODE_NAME = "IF4_visible_per_module";
111 static const string IF4VISPERMEM_NODE_NAME = "IF4_visible_per_member_function";
112 static const string IF4CON_NODE_NAME = "IF4_concrete";
113 static const string IF4CONPERMOD_NODE_NAME = "IF4_concrete";
114 static const string IF4CONPERMEM_NODE_NAME = "IF4_concrete_per_member_function";
115 static const string FO_NODE_NAME = "fan_out";
116 static const string FOV_NODE_NAME = "fan_out_visible";
117 static const string FOC_NODE_NAME = "fan_out_concrete";
118 static const string FI_NODE_NAME = "fan_in";
119 static const string FIV_NODE_NAME = "fan_in_visible";
120 static const string FIC_NODE_NAME = "fan_in_concrete";
121 static const string REJ_LOC_NODE_NAME = "rejected_lines_of_code";
122 
123 static const string VALUE_ATTR = "value";
124 static const string LEVEL_ATTR = "level";
125 static const string FILE_ATTR = "file";
126 static const string LINE_ATTR = "line";
127 static const string VISIBLE_ATTR = "visible";
128 static const string CONCRETE_ATTR = "concrete";
129 
130 static const string LEVEL_NORMAL = "0";
131 static const string LEVEL_MEDIUM = "1";
132 static const string LEVEL_HIGH = "2";
133 static const string BOOL_FALSE = "false";
134 static const string BOOL_TRUE = "true";
135 
136 static string ltrim(string value)
137 {
138  const int MAX_LENGTH = 1000;
139  int i = 0;
140  while(i<value.size() && value[i]==' ')
141  {
142  ++i;
143  }
144  return value.substr(i,MAX_LENGTH);
145 }
146 
148  int report_mask,
149  const string& file,
150  const string& dir)
151 {
152  prjptr=prj;
153  outdir=dir;
154 
155  CCCC_Xml_Stream main_xml_stream(file.c_str(),"Report on software metrics");
156 
157  // For testing purposes, we want to be able to disable the inclusion
158  // of the current time in the report. This enables us to store a
159  // reference version of the report in RCS and expect the program
160  // to generate an identical one at regression testing time.
161  if(report_mask & rtSHOW_GEN_TIME)
162  {
163  main_xml_stream.Timestamp();
164  }
165 
166  if(report_mask & rtSUMMARY)
167  {
168  main_xml_stream.Project_Summary();
169  }
170 
171  if(report_mask & rtPROC1)
172  {
173  main_xml_stream.Procedural_Summary();
174  }
175 
176  if(report_mask & rtPROC2)
177  {
178  main_xml_stream.Procedural_Detail();
179  }
180 
181  if(report_mask & rtOODESIGN)
182  {
183  main_xml_stream.OO_Design();
184  }
185 
186  if(report_mask & rtSTRUCT1)
187  {
188  main_xml_stream.Structural_Summary();
189  }
190 
191  if(report_mask & rtSTRUCT2)
192  {
193  main_xml_stream.Structural_Detail();
194  }
195 
196  if(report_mask & rtSEPARATE_MODULES)
197  {
198  main_xml_stream.Separate_Modules();
199  }
200 
201  if(report_mask & rtOTHER)
202  {
203  main_xml_stream.Other_Extents();
204  }
205 }
206 
207 CCCC_Xml_Stream::CCCC_Xml_Stream(const string& fname, const string& info)
208 {
209  // cerr << "Attempting to open file in directory " << outdir.c_str() << endl;
210  fstr.open(fname.c_str());
211  if(fstr.good() != TRUE)
212  {
213  cerr << "failed to open " << fname.c_str()
214  << " for output in directory " << outdir.c_str() << endl;
215  exit(1);
216  }
217 
218  fstr << XML_PREAMBLE << endl
219  << XML_COMMENT_BEGIN << info << XML_COMMENT_END << endl
221 }
222 
224 {
226  fstr.close();
227 }
228 
230 {
231  time_t generationTime=time(NULL);
233  << ctime(&generationTime)
235  << endl;
236 }
237 
239  // calculate the counts on which all displayed data will be based
240  int nom=prjptr->get_count("NOM"); // number of modules
241  int loc=prjptr->get_count("LOC"); // lines of code
242  int mvg=prjptr->get_count("MVG"); // McCabes cyclomatic complexity
243  int com=prjptr->get_count("COM"); // lines of comment
244  int if4=prjptr->get_count("IF4"); // intermodule complexity (all couplings)
245  int if4v=prjptr->get_count("IF4v"); // intermodule complexity (visible only)
246  int if4c=prjptr->get_count("IF4c"); // intermodule complexity (concrete only)
247  int rej=prjptr->rejected_extent_table.get_count("LOC");
248 
250 
252  Put_Metric_Node(LOC_NODE_NAME,loc,"LOCp");
253  Put_Metric_Node(LOCPERMOD_NODE_NAME,loc,nom,"LOCper");
254  Put_Metric_Node(MVG_NODE_NAME,mvg,"MVGp");
255  Put_Metric_Node(MVGPERMOD_NODE_NAME,mvg,nom,"MVGper");
256  Put_Metric_Node(COM_NODE_NAME,com,"COM");
257  Put_Metric_Node(COMPERMOD_NODE_NAME,com,nom,"COMper");
258  Put_Metric_Node(LOCPERCOM_NODE_NAME,loc,com,"L_C");
259  Put_Metric_Node(MVGPERCOM_NODE_NAME,mvg,com,"M_C");
261  Put_Metric_Node(IF4PERMOD_NODE_NAME,if4,nom,"8.3");
263  Put_Metric_Node(IF4VISPERMOD_NODE_NAME,if4v,nom,"8.3");
265  Put_Metric_Node(IF4CONPERMOD_NODE_NAME,if4c,nom,"8.3");
268 }
269 
271 {
273 
275  int i=0;
276  while(mod_ptr!=NULL)
277  {
278  i++;
279  if( mod_ptr->is_trivial() == FALSE)
280  {
282  Put_Label_Node(NAME_NODE_NAME,mod_ptr->name(nlSIMPLE).c_str(),0,"","");
283 
284  CCCC_Metric wmc1(mod_ptr->get_count("WMC1"),"WMC1");
285  CCCC_Metric wmcv(mod_ptr->get_count("WMCv"),"WMCv");
286  CCCC_Metric dit(mod_ptr->get_count("DIT"),"DIT");
287  CCCC_Metric noc(mod_ptr->get_count("NOC"),"NOC");
288  CCCC_Metric cbo(mod_ptr->get_count("CBO"),"CBO");
289 
295 
297 
298  }
299  mod_ptr=prjptr->module_table.next_item();
300  }
302 }
303 
305 {
306 
308 
310  int i=0;
311  while(mod_ptr!=NULL)
312  {
313  i++;
314  if( mod_ptr->is_trivial() == FALSE)
315  {
317  Put_Label_Node(NAME_NODE_NAME,mod_ptr->name(nlSIMPLE).c_str(),0,"","");
318 
319  int loc=mod_ptr->get_count("LOC");
320  int mvg=mod_ptr->get_count("MVG");
321  int com=mod_ptr->get_count("COM");
322  CCCC_Metric mloc(loc,"LOCm");
323  CCCC_Metric mmvg(mvg,"MVGm");
324  CCCC_Metric ml_c(loc,com,"L_C");
325  CCCC_Metric mm_c(mvg,com,"M_C");
326 
333  }
334  mod_ptr=prjptr->module_table.next_item();
335  }
336 
338 }
339 
341 {
343 
344  CCCC_Module* module_ptr=prjptr->module_table.first_item();
345  while(module_ptr!=NULL)
346  {
347  if(module_ptr->is_trivial()==FALSE)
348  {
350  Put_Label_Node(NAME_NODE_NAME,module_ptr->name(nlSIMPLE).c_str(),0,"","");
351 
352  int fov=module_ptr->get_count("FOv");
353  int foc=module_ptr->get_count("FOc");
354  int fo=module_ptr->get_count("FO");
355 
356  int fiv=module_ptr->get_count("FIv");
357  int fic=module_ptr->get_count("FIc");
358  int fi=module_ptr->get_count("FI");
359 
360  int if4v=module_ptr->get_count("IF4v");
361  int if4c=module_ptr->get_count("IF4c");
362  int if4=module_ptr->get_count("IF4");
363 
364  // the last two arguments here turn on links to enable jumping between
365  // the summary and detail cells for the same module
375 
377  }
378  module_ptr=prjptr->module_table.next_item();
379  }
381 }
382 
384  CCCC_Module *mod, CCCC_Project *prj, int mask, UserelNameLevel nl)
385 {
386 
387 #if 0
388  std::cerr << "Relationships for " << mod->name(nlMODULE_NAME)
389  << " (" << mod << ")" << std::endl;
390 #endif
391 
392 
393  CCCC_Module::relationship_map_t::iterator iter;
394  CCCC_Module::relationship_map_t *relationship_map=NULL;
395 
396  string nodeTag;
397 
398  if(mask==rmeCLIENT)
399  {
400  nodeTag = CLIMOD_NODE_NAME;
401  relationship_map=&(mod->client_map);
402 
403  }
404  else if(mask==rmeSUPPLIER)
405  {
406  nodeTag = SUPMOD_NODE_NAME;
407  relationship_map=&(mod->supplier_map);
408  }
409 
410  if(relationship_map==NULL)
411  {
412  cerr << "unexpected relationship mask " << mask << endl;
413  }
414  else
415  {
416  fstr << XML_TAG_OPEN_BEGIN << nodeTag << XML_TAG_OPEN_END << endl;
417  for(
418  iter=relationship_map->begin();
419  iter!=relationship_map->end();
420  iter++
421  )
422  {
423  CCCC_UseRelationship *ur_ptr=(*iter).second;
424  Put_Label_Node(NAME_NODE_NAME, ur_ptr->name(nl).c_str(),0,"","");
425 
426  AugmentedBool vis=ur_ptr->is_visible();
427  AugmentedBool con=ur_ptr->is_concrete();
428 
429  string visvalue = BOOL_FALSE;
430  string convalue = BOOL_FALSE;
431  if(vis!=abFALSE)
432  {
433  visvalue = BOOL_TRUE;
434  }
435  if(con!=abFALSE)
436  {
437  convalue = BOOL_TRUE;
438  }
439  Put_Label_Node(VISIBLE_ATTR,visvalue,0,"","");
440  Put_Label_Node(CONCRETE_ATTR,convalue,0,"","");
441 
442  Put_Extent_List(*ur_ptr,true);
443  }
444  fstr << XML_TAG_CLOSE_BEGIN << nodeTag << XML_TAG_CLOSE_END << endl;
445  }
446 }
447 
449 {
451  CCCC_Module* module_ptr=prjptr->module_table.first_item();
452  while(module_ptr!=NULL)
453  {
454  if(module_ptr->is_trivial()==FALSE)
455  {
456  Structural_Detail(module_ptr);
457  }
458  module_ptr=prjptr->module_table.next_item();
459  }
461 }
462 
464 
466 
468  while(mod_ptr!=NULL)
469  {
470  if(
471  (mod_ptr->name(nlMODULE_TYPE)!="builtin") &&
472  (mod_ptr->name(nlMODULE_TYPE)!="enum") &&
473  (mod_ptr->name(nlMODULE_TYPE)!="union")
474  )
475  {
477  Put_Label_Node(NAME_NODE_NAME,mod_ptr->name(nlSIMPLE).c_str(),50,
478  "procdet","procsum",mod_ptr);
479  Procedural_Detail(mod_ptr);
481  }
482  mod_ptr=prjptr->module_table.next_item();
483  }
485 }
486 
488 {
490 
492  while(extent_ptr!=NULL)
493  {
495  Put_Label_Node(NAME_NODE_NAME,extent_ptr->name(nlDESCRIPTION).c_str());
496  Put_Extent_Node(*extent_ptr,0);
497  Put_Metric_Node(LOC_NODE_NAME,extent_ptr->get_count("LOC"),"");
498  Put_Metric_Node(COM_NODE_NAME,extent_ptr->get_count("COM"),"");
499  Put_Metric_Node(MVG_NODE_NAME,extent_ptr->get_count("MVG"),"");
500  extent_ptr=prjptr->rejected_extent_table.next_item();
502  }
503 
505 }
506 
507 void CCCC_Xml_Stream::Put_Label_Node(string nodeTag, string label, int width,
508  string ref_name, string ref_href,
509  CCCC_Record *rec_ptr)
510 {
511  if(label.size()>0)
512  {
513  fstr << XML_TAG_OPEN_BEGIN << nodeTag << XML_TAG_OPEN_END;
514  *this << label;
515  fstr << XML_TAG_CLOSE_BEGIN << nodeTag << XML_TAG_CLOSE_END
516  << endl;
517  }
518  else
519  {
520  // Do nothing
521  }
522 
523  if(rec_ptr != 0)
524  {
525  Put_Extent_List(*rec_ptr,true);
526  }
527 }
528 
529 
531  int count, string tag)
532 {
533  CCCC_Metric m(count, tag.c_str());
534  Put_Metric_Node(nodeTag,m);
535 }
536 
538  int num, int denom, string tag)
539 {
540  CCCC_Metric m(num,denom, tag.c_str());
541  Put_Metric_Node(nodeTag,m);
542 }
543 
544 void CCCC_Xml_Stream::Put_Metric_Node(string nodeTag,const CCCC_Metric& metric)
545 {
546  fstr << XML_TAG_INLINE_BEGIN << nodeTag << XML_SPACE
548  *this << metric;
549  fstr << XML_DQUOTE << XML_SPACE
551 
552  switch(metric.emphasis_level())
553  {
554  case elMEDIUM:
555  fstr << LEVEL_MEDIUM;
556  break;
557  case elHIGH:
558  fstr << LEVEL_HIGH;
559  break;
560  default:
561  fstr << LEVEL_NORMAL;
562  break;
563  }
564  fstr << XML_DQUOTE << XML_SPACE << XML_TAG_INLINE_END << endl;
565 }
566 
568 {
569  string filename=extent.name(nlFILENAME);
570  int linenumber=atoi(extent.name(nlLINENUMBER).c_str());
573  *this << filename;
574  fstr << XML_DQUOTE << XML_SPACE
576  *this << linenumber;
577  fstr << XML_DQUOTE << XML_SPACE << XML_TAG_INLINE_END << endl;
578 }
579 
580 void CCCC_Xml_Stream::Put_Extent_Node(const CCCC_Extent& extent, int width, bool withDescription)
581 {
582  if(withDescription)
583  {
585  << extent.name(nlDESCRIPTION)
587  << endl;
588  }
589  Put_Extent_URL(extent);
590 }
591 
592 void CCCC_Xml_Stream::Put_Extent_List(CCCC_Record& record, bool withDescription)
593 {
594  CCCC_Extent *ext_ptr=record.extent_table.first_item();
595  while(ext_ptr!=NULL)
596  {
598  << endl;
599  if(withDescription)
600  {
602  << ext_ptr->name(nlDESCRIPTION)
604  << endl;
605  }
606  Put_Extent_URL(*ext_ptr);
608  << endl;
609  ext_ptr=record.extent_table.next_item();
610  }
611 }
612 
613 // the next two methods define the two basic output operations through which
614 // all of the higher level output operations are composed
615 CCCC_Xml_Stream& operator <<(CCCC_Xml_Stream& os, const string& stg)
616 {
617  // initialise a character pointer to the start of the string's buffer
618  const char *cptr=stg.c_str();
619  while(*cptr!='\000') {
620  char c=*cptr;
621 
622  // the purpose of this is to filter out the characters which
623  // must be escaped in HTML
624  switch(c) {
625  case '>': os.fstr << "&gt;" ; break;
626  case '<': os.fstr << "&lt;" ; break;
627  case '&': os.fstr << "&amp;"; break;
628  default : os.fstr << c;
629  }
630  cptr++;
631  }
632  return os;
633 }
634 
636 {
637  // by writing to the underlying ostream object, we avoid the escape
638  // functionality
639  os.fstr << ltrim(mtc.value_string()) ;
640  return os;
641 }
642 
644 {
645  // this function generates a separate HTML report for each non-trivial
646  // module in the database
647 
649  while(mod_ptr!=NULL)
650  {
651  int trivial_module=mod_ptr->is_trivial();
652  if(trivial_module==FALSE)
653  {
654  string info="Detailed report on module " + mod_ptr->key();
655  string filename=outdir;
656  filename+="/";
657  filename+=mod_ptr->key()+".xml";
658  CCCC_Xml_Stream module_xml_str(filename,info.c_str());
659 
660  module_xml_str.Module_Summary(mod_ptr);
661 
662  module_xml_str.fstr
664  << endl;
665  module_xml_str.Module_Detail(mod_ptr);
666  module_xml_str.fstr
668  << endl;
669 
670  module_xml_str.fstr
672  << endl;
673  module_xml_str.Procedural_Detail(mod_ptr);
674  module_xml_str.fstr
676  << endl;
677 
678  module_xml_str.fstr
680  << endl;
681  module_xml_str.Structural_Detail(mod_ptr);
682  module_xml_str.fstr
684  << endl;
685 
686  }
687  else
688  {
689 #if 0
690  cerr << mod_ptr->module_type << " " << mod_ptr->key()
691  << " is trivial" << endl;
692 #endif
693  }
694  mod_ptr=prjptr->module_table.next_item();
695  }
696 }
697 
699 {
700  // this function generates the contents of the table of definition
701  // and declaration extents for a single module
702 
703  // the output needs to be enveloped in a pair of <TABLE></TABLE> tags
704  // these have not been put within the function because it is designed
705  // to be used in two contexts:
706  // 1. within the Separate_Modules function, wrapped directly in the table
707  // tags
708  // 2. within the Module_Detail function, where the table tags are
709  // around the output of many calls to this function (not yet implemented)
710 
711  CCCC_Record::Extent_Table::iterator eIter = module_ptr->extent_table.begin();
712  while(eIter!=module_ptr->extent_table.end())
713  {
714  CCCC_Extent *ext_ptr=(*eIter).second;
715  Put_Extent_Node(*ext_ptr,0,true);
716  int loc=ext_ptr->get_count("LOC");
717  int mvg=ext_ptr->get_count("MVG");
718  int com=ext_ptr->get_count("COM");
719  CCCC_Metric mloc(loc,"LOCf");
720  CCCC_Metric mmvg(mvg,"MVGf");
721  CCCC_Metric ml_c(loc,com,"L_C");
722  CCCC_Metric mm_c(mvg,com,"M_C");
723 
729 
730  eIter++;
731  }
732 }
733 
735 {
736  // this function generates the contents of the procedural detail table
737  // relating to a single module
738 
739  // the output needs to be enveloped in a pair of <TABLE></TABLE> tags
740  // these have not been put within the function because it is designed
741  // to be used in two contexts:
742  // 1. within the Separate_Modules function, wrapped directly in the table
743  // tags
744  // 2. within the Procedural_Detail function, where the table tags are
745  // around the output of many calls to this function
746 
747  CCCC_Module::member_map_t::iterator iter = module_ptr->member_map.begin();
748 
749  while(iter!=module_ptr->member_map.end())
750  {
752 
753  CCCC_Member *mem_ptr=(*iter).second;
754  Put_Label_Node(NAME_NODE_NAME,mem_ptr->name(nlLOCAL).c_str(),0,"","",mem_ptr);
755  int loc=mem_ptr->get_count("LOC");
756  int mvg=mem_ptr->get_count("MVG");
757  int com=mem_ptr->get_count("COM");
758  CCCC_Metric mloc(loc,"LOCf");
759  CCCC_Metric mmvg(mvg,"MVGf");
760  CCCC_Metric ml_c(loc,com,"L_C");
761  CCCC_Metric mm_c(mvg,com,"M_C");
762 
768 
769  iter++;
770 
772  }
773 }
774 
776 {
778  Put_Label_Node(NAME_NODE_NAME,module_ptr->name(nlSIMPLE).c_str(), 0, "","");
782 }
783 
785 {
786  // calculate the counts on which all displayed data will be based
787  // int nof=module_ptr->member_table.records(); // Number of functions
788  int nof=0;
789  int loc=module_ptr->get_count("LOC"); // lines of code
790  int mvg=module_ptr->get_count("MVG"); // McCabes cyclomatic complexity
791  int com=module_ptr->get_count("COM"); // lines of comment
792 
793  // the variants of IF4 measure information flow and couplings
794  int if4=module_ptr->get_count("IF4"); // (all couplings)
795  int if4v=module_ptr->get_count("IF4v"); // (visible only)
796  int if4c=module_ptr->get_count("IF4c"); // (concrete only)
797 
798  int wmc1=module_ptr->get_count("WMC1"); // Weighted methods/class (unity)
799  int wmcv=module_ptr->get_count("WMCv"); // Weighted methods/class (visible)
800  int dit=module_ptr->get_count("DIT"); // depth of inheritance tree
801  int noc=module_ptr->get_count("NOC"); // number of children
802  int cbo=module_ptr->get_count("CBO"); // coupling between objects
803 
805 
806  Put_Metric_Node(LOC_NODE_NAME,loc,"LOCm");
807  Put_Metric_Node(LOCPERMEM_NODE_NAME,loc,nof,"LOCg");
808  Put_Metric_Node(MVG_NODE_NAME,mvg,"MVGm");
809  Put_Metric_Node(MVGPERMEM_NODE_NAME,mvg,nof,"MVGf");
810  Put_Metric_Node(LOC_NODE_NAME,com,"COMm");
811  Put_Metric_Node(LOCPERMEM_NODE_NAME,com,nof,"8.3");
812  Put_Metric_Node(LOCPERCOM_NODE_NAME,loc,com,"L_C");
813  Put_Metric_Node(MVGPERCOM_NODE_NAME,mvg,com,"M_C");
819  Put_Metric_Node(IF4_NODE_NAME,if4,1,"IF4");
820  Put_Metric_Node(IF4PERMEM_NODE_NAME,if4,nof,"8.3");
821  Put_Metric_Node(IF4VIS_NODE_NAME,if4v,1,"IF4v");
822  Put_Metric_Node(IF4VISPERMEM_NODE_NAME,if4v,nof,"8.3");
823  Put_Metric_Node(IF4CON_NODE_NAME,if4c,1,"IF4c");
824  Put_Metric_Node(IF4CONPERMEM_NODE_NAME,if4c,nof,"8.3");
825 
827 }
828 
829 
830 
832 {
833 }
834 
835 #if 0
836 static string pad_string(int target_width, string the_string, string padding)
837 {
838  int spaces_required=target_width-the_string.size();
839  string pad_string;
840  while(spaces_required>0)
841  {
842  pad_string+=padding;
843  spaces_required--;
844  }
845  return pad_string+the_string;
846 }
847 #endif
848 
849 
850 
851 #ifdef UNIT_TEST
852 int main()
853 {
854  CCCC_Project *prj_ptr=test_project_ptr();
855  CCCC_Xml_Stream os(*prj_ptr,"cccc.htm",".");
856  return 0;
857 }
858 #endif
859 
860 
static const string MODDET_NODE_NAME
Definition: cccc_xml.cc:70
static const string VISIBLE_ATTR
Definition: cccc_xml.cc:127
CCCC_Table< CCCC_Module > module_table
Definition: cccc_prj.h:54
static const string WMC1_NODE_NAME
Definition: cccc_xml.cc:101
static const string LEVEL_NORMAL
Definition: cccc_xml.cc:130
void Put_Extent_URL(const CCCC_Extent &extent)
Definition: cccc_xml.cc:567
static const string SUPPLIERS_NODE_NAME
Definition: cccc_xml.cc:82
static const string CLIENTS_NODE_NAME
Definition: cccc_xml.cc:84
int get_count(const char *count_tag)
Definition: cccc_mem.cc:35
void Put_Structural_Details_Node(CCCC_Module *mod, CCCC_Project *prj, int mask, UserelNameLevel nl)
Definition: cccc_xml.cc:383
static const string EXTENT_NODE_NAME
Definition: cccc_xml.cc:81
virtual string key() const
Definition: cccc_rec.cc:76
static const string SUMMARY_NODE_NAME
Definition: cccc_xml.cc:68
static const string LOCPERCOM_NODE_NAME
Definition: cccc_xml.cc:92
relationship_map_t client_map
Definition: cccc_mod.h:54
static const string SUPMOD_NODE_NAME
Definition: cccc_xml.cc:83
int is_trivial()
Definition: cccc_mod.cc:181
static const string BOOL_FALSE
Definition: cccc_xml.cc:133
static const string XML_TAG_OPEN_END
Definition: cccc_xml.cc:56
static const string OODESIGN_NODE_NAME
Definition: cccc_xml.cc:75
static const string REJECTED_NODE_NAME
Definition: cccc_xml.cc:77
static string ltrim(string value)
Definition: cccc_xml.cc:136
static const string BOOL_TRUE
Definition: cccc_xml.cc:134
void Module_Summary(CCCC_Module *module_ptr)
Definition: cccc_xml.cc:784
void Procedural_Detail()
Definition: cccc_xml.cc:463
static const string IF4VISPERMOD_NODE_NAME
Definition: cccc_xml.cc:110
static const string XML_TAG_CLOSE_BEGIN
Definition: cccc_xml.cc:57
static const string COMPERMEM_NODE_NAME
Definition: cccc_xml.cc:100
CCCC_Table< CCCC_Extent > rejected_extent_table
Definition: cccc_prj.h:57
EmphasisLevel emphasis_level() const
Definition: cccc_met.cc:85
static const string STRUCTDET_NODE_NAME
Definition: cccc_xml.cc:74
static string libdir
Definition: cccc_xml.h:48
static const string WMCV_NODE_NAME
Definition: cccc_xml.cc:102
static string outdir
Definition: cccc_xml.h:49
static const string LEVEL_MEDIUM
Definition: cccc_xml.cc:131
static const string LOCPERMEM_NODE_NAME
Definition: cccc_xml.cc:93
void Timestamp()
Definition: cccc_xml.cc:229
static const string TIMESTAMP_NODE_NAME
Definition: cccc_xml.cc:67
static const string MVGPERMEM_NODE_NAME
Definition: cccc_xml.cc:97
static const string XML_COMMENT_END
Definition: cccc_xml.cc:54
CCCC_Project * prj
Definition: ccccmain.cc:49
static const string XML_TAG_OPEN_BEGIN
Definition: cccc_xml.cc:55
static const string CBO_NODE_NAME
Definition: cccc_xml.cc:105
UserelNameLevel
Definition: cccc_use.h:32
static const string LINE_ATTR
Definition: cccc_xml.cc:126
static const string NOC_NODE_NAME
Definition: cccc_xml.cc:104
string value_string() const
Definition: cccc_met.cc:116
static const string MEMBER_NODE_NAME
Definition: cccc_xml.cc:80
void Put_Label_Node(string nodeTag, string label, int width=0, string ref_name="", string ref_href="", CCCC_Record *rec_ptr=0)
Definition: cccc_xml.cc:507
static const string FI_NODE_NAME
Definition: cccc_xml.cc:118
virtual int get_count(const char *count_tag)
Definition: cccc_mod.cc:64
static const string IF4CONPERMEM_NODE_NAME
Definition: cccc_xml.cc:114
static const string PROCSUM_NODE_NAME
Definition: cccc_xml.cc:71
void Project_Summary()
Definition: cccc_xml.cc:238
virtual int get_count(const char *count_tag)
Definition: cccc_tbl.cc:52
int get_count(const char *count_tag)
Definition: cccc_ext.cc:147
string name(int index) const
Definition: cccc_use.cc:40
string module_type
Definition: cccc_mod.h:48
static const string PROJECT_NODE_NAME
Definition: cccc_xml.cc:66
T * first_item()
Definition: cccc_tbl.cc:118
static const string COMPERMOD_NODE_NAME
Definition: cccc_xml.cc:99
void Structural_Detail()
Definition: cccc_xml.cc:448
void Other_Extents()
Definition: cccc_xml.cc:487
static const string FO_NODE_NAME
Definition: cccc_xml.cc:115
static const string CONCRETE_ATTR
Definition: cccc_xml.cc:128
CCCC_Xml_Stream(const string &fname, const string &info)
Definition: cccc_xml.cc:207
static const string STRUCTSUM_NODE_NAME
Definition: cccc_xml.cc:73
static const string LOC_NODE_NAME
Definition: cccc_xml.cc:90
static const string MVGPERCOM_NODE_NAME
Definition: cccc_xml.cc:96
static const string XML_DQUOTE
Definition: cccc_xml.cc:63
void OO_Design()
Definition: cccc_xml.cc:270
static const string XML_SPACE
Definition: cccc_xml.cc:61
static const string XML_EQUALS
Definition: cccc_xml.cc:64
T * next_item()
Definition: cccc_tbl.cc:124
Extent_Table extent_table
Definition: cccc_rec.h:45
static const string XML_NEWLINE
Definition: cccc_xml.cc:62
static const string MODULE_NODE_NAME
Definition: cccc_xml.cc:79
CCCC_Xml_Stream & operator<<(CCCC_Xml_Stream &os, const string &stg)
Definition: cccc_xml.cc:615
static const string IF4PERMOD_NODE_NAME
Definition: cccc_xml.cc:107
static const string FIV_NODE_NAME
Definition: cccc_xml.cc:119
AugmentedBool is_concrete() const
Definition: cccc_use.h:51
static void GenerateReports(CCCC_Project *project, int report_mask, const string &outfile, const string &outdir)
Definition: cccc_xml.cc:147
static const string IF4PERMEM_NODE_NAME
Definition: cccc_xml.cc:108
static const string XML_TAG_INLINE_END
Definition: cccc_xml.cc:60
static const string DESC_NODE_NAME
Definition: cccc_xml.cc:86
static const string MVGPERMOD_NODE_NAME
Definition: cccc_xml.cc:95
static const string FILE_ATTR
Definition: cccc_xml.cc:125
static const string NAME_NODE_NAME
Definition: cccc_xml.cc:78
static const string VALUE_ATTR
Definition: cccc_xml.cc:123
static const string NOM_NODE_NAME
Definition: cccc_xml.cc:89
string name(int name_level) const
Definition: cccc_mod.cc:35
static const string DIT_NODE_NAME
Definition: cccc_xml.cc:103
static const string IF4CONPERMOD_NODE_NAME
Definition: cccc_xml.cc:113
static const string FIC_NODE_NAME
Definition: cccc_xml.cc:120
static const string IF4CON_NODE_NAME
Definition: cccc_xml.cc:112
static const string FOC_NODE_NAME
Definition: cccc_xml.cc:117
static const string XML_COMMENT_BEGIN
Definition: cccc_xml.cc:53
string name(int index) const
Definition: cccc_mem.cc:99
relationship_map_t supplier_map
Definition: cccc_mod.h:55
ofstream fstr
Definition: cccc_xml.h:47
AugmentedBool is_visible() const
Definition: cccc_use.h:50
static string pad_string(int target_width, string the_string, string padding)
Definition: cccc_htm.cc:1463
static const string FOV_NODE_NAME
Definition: cccc_xml.cc:116
void Procedural_Summary()
Definition: cccc_xml.cc:304
int get_count(const char *count_tag)
Definition: cccc_prj.cc:308
static const string PROCDET_NODE_NAME
Definition: cccc_xml.cc:72
void Source_Listing()
Definition: cccc_xml.cc:831
int main(int argc, char **argv)
Definition: ccccmain.cc:712
static const string COM_NODE_NAME
Definition: cccc_xml.cc:98
void Structural_Summary()
Definition: cccc_xml.cc:340
static const string IF4VISPERMEM_NODE_NAME
Definition: cccc_xml.cc:111
static const string IF4_NODE_NAME
Definition: cccc_xml.cc:106
static const string XML_PREAMBLE
Definition: cccc_xml.cc:52
member_map_t member_map
Definition: cccc_mod.h:51
static const string MVG_NODE_NAME
Definition: cccc_xml.cc:94
static const string LEVEL_ATTR
Definition: cccc_xml.cc:124
static const string SRCREF_NODE_NAME
Definition: cccc_xml.cc:87
std::map< string, CCCC_UseRelationship * > relationship_map_t
Definition: cccc_mod.h:53
void Put_Extent_Node(const CCCC_Extent &extent, int width=0, bool withDescription=false)
Definition: cccc_xml.cc:580
void Put_Extent_List(CCCC_Record &record, bool withDescription=false)
Definition: cccc_xml.cc:592
void Put_Metric_Node(string nodeTag, const CCCC_Metric &metric)
Definition: cccc_xml.cc:544
static CCCC_Project * prjptr
Definition: cccc_xml.h:50
AugmentedBool
Definition: cccc_utl.h:59
void Separate_Modules()
Definition: cccc_xml.cc:643
static const string LEVEL_HIGH
Definition: cccc_xml.cc:132
static const string LOCPERMOD_NODE_NAME
Definition: cccc_xml.cc:91
void Module_Detail(CCCC_Module *module_ptr)
Definition: cccc_xml.cc:698
static const string XML_TAG_CLOSE_END
Definition: cccc_xml.cc:58
static const string XML_TAG_INLINE_BEGIN
Definition: cccc_xml.cc:59
static const string OTHER_NODE_NAME
Definition: cccc_xml.cc:76
static const string IF4VIS_NODE_NAME
Definition: cccc_xml.cc:109
string name(int index) const
Definition: cccc_ext.cc:107
static const string MODSUM_NODE_NAME
Definition: cccc_xml.cc:69
static const string REJ_LOC_NODE_NAME
Definition: cccc_xml.cc:121
static const string CLIMOD_NODE_NAME
Definition: cccc_xml.cc:85