CCCC - C and C++ Code Counter  9999-git
CCCC Development version (post-3.1.4)
cccc_rec.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 /*
20  * cccc_rec.cc
21  */
22 
23 #include "cccc_itm.h"
24 #include "cccc_rec.h"
25 #include "cccc_db.h"
26 
30 
31 void CCCC_Record::merge_flags(string& new_flags)
32 {
33  const char *new_flag_array=new_flags.c_str();
34  const char *flag_array=flags.c_str();
35  unsigned int len=strlen(flag_array);
36  if(strlen(new_flag_array)==len)
37  {
38  char buf[100];
39  unsigned int i;
40  for(i=0; i<len;i++)
41  {
42  if(flag_array[i]=='?')
43  {
44  buf[i]=new_flag_array[i];
45  }
46  else
47  {
48  buf[i]=flag_array[i];
49  }
50  }
51  buf[len]='\0';
52  flags=buf;
53  }
54  else
55  {
56  // if the parent record has just been created it may have
57  // an empty flags member, so we use Resolve_Fields to copy
58  // the flags from the first extent
59  Resolve_Fields(flags,new_flags);
60  }
61 }
62 
64 {
65  CCCC_Extent *new_extent=new CCCC_Extent;
66  new_extent->GetFromItem(is);
67  CCCC_Extent *inserted_extent=extent_table.find_or_insert(new_extent);
68  if(new_extent != inserted_extent)
69  {
70  delete new_extent;
71  }
72 }
73 
74 
75 string CCCC_Record::name(int /* level */) const { return ""; }
76 string CCCC_Record::key() const { return name(nlRANK); }
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
virtual string name(int level) const
Definition: cccc_rec.cc:75
virtual string key() const
Definition: cccc_rec.cc:76
static CCCC_Project * get_active_project()
Definition: cccc_rec.cc:28
CCCC_Project * prj
Definition: ccccmain.cc:49
int GetFromItem(CCCC_Item &item)
Definition: cccc_ext.cc:84
T * find_or_insert(T *new_item_ptr)
Definition: cccc_tbl.cc:78
Extent_Table extent_table
Definition: cccc_rec.h:45
static void set_active_project(CCCC_Project *prj)
Definition: cccc_rec.cc:29
virtual void merge_flags(string &new_flags)
Definition: cccc_rec.cc:31
void Resolve_Fields(string &field1, string &field2)
Definition: cccc_db.cc:105
static CCCC_Project * active_project
Definition: cccc_rec.h:42
string flags
Definition: cccc_rec.h:46
virtual void add_extent(CCCC_Item &)
Definition: cccc_rec.cc:63