CCCC - C and C++ Code Counter  9999-git
CCCC Development version (post-3.1.4)
cccc_tbl.h
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_tbl.h
21  *
22  * defines the database used by CCCC to generate a report
23  */
24 #ifndef CCCC_TBL_H
25 #define CCCC_TBL_H
26 
27 #include <iostream>
28 #include <string>
29 
30 #include <map>
31 
32 using std::string;
33 
34 // CCCC_Table started its life as an array of pointers to CCCC_Records.
35 // It will ultimately become identical to a std::map from string to T*.
36 // In the mean time we are supporting a legacy API.
37 template <class T> class CCCC_Table
38 : public std::map<string,T*>
39 {
40  typedef std::map<string,T*> map_t;
41  typename map_t::iterator iter_;
42  bool sorted;
43 
44  public:
45  CCCC_Table();
46  virtual ~CCCC_Table();
47  int records();
48  T* find(string name);
49  T* find_or_insert(T* new_item_ptr);
50  bool remove(T* old_item_ptr);
51  void reset_iterator();
52  T* first_item();
53  T* next_item();
54  virtual int get_count(const char *count_tag);
55  void sort();
56 };
57 
58 #include "cccc_tbl.cc"
59 
60 #endif // CCCC_DB_H
61 
void sort()
Definition: cccc_tbl.cc:105
bool sorted
Definition: cccc_tbl.h:42
CCCC_Table()
Definition: cccc_tbl.cc:30
map_t::iterator iter_
Definition: cccc_tbl.h:41
virtual ~CCCC_Table()
Definition: cccc_tbl.cc:36
void reset_iterator()
Definition: cccc_tbl.cc:113
virtual int get_count(const char *count_tag)
Definition: cccc_tbl.cc:52
T * first_item()
Definition: cccc_tbl.cc:118
T * find_or_insert(T *new_item_ptr)
Definition: cccc_tbl.cc:78
T * next_item()
Definition: cccc_tbl.cc:124
T * find(string name)
Definition: cccc_tbl.cc:66
std::map< string, T * > map_t
Definition: cccc_tbl.h:40
int records()
Definition: cccc_tbl.cc:135