CCCC - C and C++ Code Counter  9999-git
CCCC Development version (post-3.1.4)
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
CCCC_Member Class Reference

#include <cccc_mem.h>

Inheritance diagram for CCCC_Member:
[legend]
Collaboration diagram for CCCC_Member:
[legend]

Public Member Functions

string name (int index) const
 
 CCCC_Member (CCCC_Item &member_data_line, CCCC_Module *parent_ptr=NULL)
 
int FromFile (ifstream &infile)
 
int ToFile (ofstream &outfile)
 
void generate_report (ostream &)
 
int get_count (const char *count_tag)
 
Visibility get_visibility ()
 
- Public Member Functions inherited from CCCC_Record
virtual ~CCCC_Record ()
 
virtual string key () const
 
AugmentedBool get_flag (PSFlag psf)
 
virtual void add_extent (CCCC_Item &)
 
virtual void sort ()
 

Private Member Functions

 CCCC_Member ()
 

Private Attributes

string member_type
 
string member_name
 
string param_list
 
Visibility visibility
 
CCCC_Moduleparent
 

Friends

class CCCC_Project
 
class CCCC_Module
 

Additional Inherited Members

- Static Public Member Functions inherited from CCCC_Record
static CCCC_Projectget_active_project ()
 
static void set_active_project (CCCC_Project *prj)
 
- Protected Types inherited from CCCC_Record
typedef CCCC_Table< CCCC_ExtentExtent_Table
 
- Protected Member Functions inherited from CCCC_Record
virtual void merge_flags (string &new_flags)
 
- Protected Attributes inherited from CCCC_Record
Extent_Table extent_table
 
string flags
 

Detailed Description

Definition at line 34 of file cccc_mem.h.

Constructor & Destructor Documentation

CCCC_Member::CCCC_Member ( )
private

Definition at line 29 of file cccc_mem.cc.

30  : parent(NULL)
31 {
33 }
CCCC_Module * parent
Definition: cccc_mem.h:40
Visibility visibility
Definition: cccc_mem.h:39
CCCC_Member::CCCC_Member ( CCCC_Item member_data_line,
CCCC_Module parent_ptr = NULL 
)

Member Function Documentation

int CCCC_Member::FromFile ( ifstream &  infile)

Definition at line 148 of file cccc_mem.cc.

149 {
150  int retval=RECORD_ERROR;
151  enum MemberFromFileStatuses { MEMBER_RECORD_NO_PARENT_FOUND=3 };
152 
153  CCCC_Item next_line;
154  next_line.FromFile(ifstr);
155  ifstr_line++;
156 
157  string line_keyword_dummy;
158  string parent_name;
159 
160  CCCC_Member *found_mptr=NULL;
161 
162  if(
163  next_line.Extract(line_keyword_dummy) &&
164  next_line.Extract(parent_name) &&
165  next_line.Extract(this->member_name) &&
166  next_line.Extract(this->member_type) &&
167  next_line.Extract(this->param_list)
168  )
169  {
171  if(parent!=NULL)
172  {
173  found_mptr=
175  if(found_mptr==this)
176  {
177  // the newly created instance of the module is the first
178  // and has taken its place in the database, so we protect
179  // it from deletion
180  retval=RECORD_ADDED;
181  }
182  else
183  {
184  retval=RECORD_TRANSCRIBED;
185  }
186 
187  // process extent records
188  while(PeekAtNextLinePrefix(ifstr,MEMEXT_PREFIX))
189  {
190  CCCC_Extent *new_extent=new CCCC_Extent;
191  next_line.FromFile(ifstr);
192  ifstr_line++;
193  string parent_key_dummy, member_name_dummy,
194  member_type_dummy, param_list_dummy;
195 
196  if(
197  next_line.Extract(line_keyword_dummy) &&
198  next_line.Extract(parent_key_dummy) &&
199  next_line.Extract(member_name_dummy) &&
200  next_line.Extract(member_type_dummy) &&
201  next_line.Extract(param_list_dummy) &&
202  new_extent->GetFromItem(next_line)
203  )
204  {
205  // We don't ever expect to find duplicated extent records
206  // but just in case...
207  CCCC_Extent *found_eptr=
208  found_mptr->extent_table.find_or_insert(new_extent);
209  if(found_eptr!=new_extent)
210  {
211  cerr << "Failed to add extent for member "
212  << found_mptr->key() << " at line " << ifstr_line
213  << endl;
214  delete new_extent;
215  }
216  }
217  }
218 
219  }
220  else // parent record not found
221  {
222  retval=MEMBER_RECORD_NO_PARENT_FOUND;
223  }
224  }
225  else // extraction of module intial line failed
226  {
227  // unexpected problem with the input
228  retval=RECORD_ERROR;
229  }
230 
231  // If the import was successful, we will also have imported all dependent
232  // extent records following the main record.
233  // If not, we must skip them.
234  while(PeekAtNextLinePrefix(ifstr,MEMEXT_PREFIX))
235  {
236  CCCC_Item next_line;
237  next_line.FromFile(ifstr);
238  ifstr_line++;
239  cerr << "Ignoring member extent on line " << ifstr_line << endl;
240  }
241 
242  return retval;
243 }
CCCC_Table< CCCC_Module > module_table
Definition: cccc_prj.h:54
string param_list
Definition: cccc_mem.h:38
virtual string key() const
Definition: cccc_rec.cc:76
int ifstr_line
Definition: cccc_db.cc:32
string member_type
Definition: cccc_mem.h:38
CCCC_Module * parent
Definition: cccc_mem.h:40
CCCC_Table< CCCC_Member > member_table
Definition: cccc_prj.h:55
bool Extract(string &s)
Definition: cccc_itm.cc:47
CCCC_Project * current_loading_project
Definition: cccc_db.cc:25
int GetFromItem(CCCC_Item &item)
Definition: cccc_ext.cc:84
string member_name
Definition: cccc_mem.h:38
T * find_or_insert(T *new_item_ptr)
Definition: cccc_tbl.cc:78
bool FromFile(ifstream &ifstr)
Definition: cccc_itm.cc:119
Extent_Table extent_table
Definition: cccc_rec.h:45
bool PeekAtNextLinePrefix(ifstream &ifstr, string pfx)
Definition: cccc_db.cc:51
T * find(string name)
Definition: cccc_tbl.cc:66
static const string MEMEXT_PREFIX
Definition: cccc_mem.h:28

Here is the call graph for this function:

Here is the caller graph for this function:

void CCCC_Member::generate_report ( ostream &  )
int CCCC_Member::get_count ( const char *  count_tag)
virtual

Implements CCCC_Record.

Definition at line 35 of file cccc_mem.cc.

35  {
36  int retval=0;
37  string count_tag_str=count_tag;
38 
39  if(count_tag_str=="WMC1")
40  {
41  retval=1;
42  }
43  else if(count_tag_str=="WMCv")
44  {
45  switch(get_visibility())
46  {
47  case vPUBLIC:
48  case vPROTECTED:
49  retval=1;
50  break;
51  default:
52  NULL;
53  }
54  }
55  else
56  {
57  retval=extent_table.get_count(count_tag);
58  }
59 
60  return retval;
61 }
Visibility get_visibility()
Definition: cccc_mem.cc:245
virtual int get_count(const char *count_tag)
Definition: cccc_tbl.cc:52
Extent_Table extent_table
Definition: cccc_rec.h:45

Here is the call graph for this function:

Here is the caller graph for this function:

Visibility CCCC_Member::get_visibility ( )

Definition at line 245 of file cccc_mem.cc.

246 {
247  return visibility;
248 }
Visibility visibility
Definition: cccc_mem.h:39

Here is the caller graph for this function:

string CCCC_Member::name ( int  index) const
virtual

Reimplemented from CCCC_Record.

Definition at line 99 of file cccc_mem.cc.

100 {
101  string namestr;
102 
103  switch(name_level)
104  {
105  case nlRANK:
106  case nlSEARCH:
107  // there is no scoping for C-style functions ...
108  if(parent==NULL)
109  {
110  namestr.append("<NULL>::");
111  }
112  else if(
113  (parent->name(nlMODULE_NAME)!="") &&
114  (parent->name(nlMODULE_TYPE)!="file")
115  )
116  {
117  namestr.append(parent->name(nlMODULE_NAME));
118  namestr.append("::");
119  }
120  namestr.append(member_name);
121  namestr.append(param_list);
122  break;
123 
124  case nlMEMBER_NAME:
125  case nlSIMPLE:
126  namestr=member_name;
127  break;
128 
129  case nlMEMBER_TYPE:
130  namestr=member_type;
131  break;
132 
133  case nlMEMBER_PARAMS:
134  namestr=param_list;
135  break;
136  case nlLOCAL:
137  namestr.append(member_name);
138  namestr.append(param_list);
139  break;
140 
141  default:
142  cerr << "unexpected name level" << endl;
143  }
144 
145  return namestr.c_str();
146 }
string param_list
Definition: cccc_mem.h:38
string member_type
Definition: cccc_mem.h:38
CCCC_Module * parent
Definition: cccc_mem.h:40
string member_name
Definition: cccc_mem.h:38
string name(int name_level) const
Definition: cccc_mod.cc:35

Here is the call graph for this function:

Here is the caller graph for this function:

int CCCC_Member::ToFile ( ofstream &  outfile)

Definition at line 64 of file cccc_mem.cc.

65 {
66  int retval=FALSE;
67 
68  CCCC_Item member_line;
69  member_line.Insert(MEMBER_PREFIX);
70  member_line.Insert(parent->key());
71  member_line.Insert(member_name);
72  member_line.Insert(member_type);
73  member_line.Insert(param_list);
74  member_line.ToFile(ofstr);
75 
76  CCCC_Extent *extent_ptr=extent_table.first_item();
77  while(extent_ptr!=NULL)
78  {
79  CCCC_Item extent_line;
80  extent_line.Insert(MEMEXT_PREFIX);
81  extent_line.Insert(parent->key());
82  extent_line.Insert(member_name);
83  extent_line.Insert(member_type);
84  extent_line.Insert(param_list);
85  extent_ptr->AddToItem(extent_line);
86  extent_line.ToFile(ofstr);
87 
88  extent_ptr=extent_table.next_item();
89  }
90 
91  if(ofstr.good())
92  {
93  retval=TRUE;
94  }
95 
96  return retval;
97 }
string param_list
Definition: cccc_mem.h:38
virtual string key() const
Definition: cccc_rec.cc:76
string member_type
Definition: cccc_mem.h:38
CCCC_Module * parent
Definition: cccc_mem.h:40
bool Insert(const string &s)
Definition: cccc_itm.cc:31
T * first_item()
Definition: cccc_tbl.cc:118
static const string MEMBER_PREFIX
Definition: cccc_mem.h:27
string member_name
Definition: cccc_mem.h:38
T * next_item()
Definition: cccc_tbl.cc:124
Extent_Table extent_table
Definition: cccc_rec.h:45
int AddToItem(CCCC_Item &item)
Definition: cccc_ext.cc:64
static const string MEMEXT_PREFIX
Definition: cccc_mem.h:28
bool ToFile(ofstream &ofstr)
Definition: cccc_itm.cc:112

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class CCCC_Module
friend

Definition at line 37 of file cccc_mem.h.

friend class CCCC_Project
friend

Definition at line 36 of file cccc_mem.h.

Member Data Documentation

string CCCC_Member::member_name
private

Definition at line 38 of file cccc_mem.h.

string CCCC_Member::member_type
private

Definition at line 38 of file cccc_mem.h.

string CCCC_Member::param_list
private

Definition at line 38 of file cccc_mem.h.

CCCC_Module* CCCC_Member::parent
private

Definition at line 40 of file cccc_mem.h.

Visibility CCCC_Member::visibility
private

Definition at line 39 of file cccc_mem.h.


The documentation for this class was generated from the following files: