2
CCCC - C and C++ Code Counter
3
Copyright (C) 1994-2005 Tim Littlefair (tim_littlefair@hotmail.com)
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.
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.
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
20
#ifndef _CCCC_TBL_BODY
21
#define _CCCC_TBL_BODY
27
#define LINE_BUFFER_SIZE 1000
30
template <class T> CCCC_Table<T>::CCCC_Table()
36
template <class T> CCCC_Table<T>::~CCCC_Table()
38
// the container should manage the destruction of its own
39
// nodes correctly, we just need to get rid of the
40
// objects to which we hold pointers.
41
// NB Although CCCC_Table holds pointers, it owns the
42
// objects they point to and is responsible for their disposal.
43
T* itemptr=first_item();
52
int CCCC_Table<T>::get_count(const char* count_tag)
55
T* itemptr=first_item();
58
retval+=itemptr->get_count(count_tag);
66
T* CCCC_Table<T>::find(string name)
69
typename map_t::iterator value_iterator=map_t::find(name);
70
if(value_iterator!=map_t::end())
72
retval=(*value_iterator).second;
78
T* CCCC_Table<T>::find_or_insert(T* new_item_ptr)
80
string new_key=new_item_ptr->key();
81
T *retval=find(new_key);
84
typename map_t::value_type new_pair(new_key,new_item_ptr);
85
map_t::insert(new_pair);
93
bool CCCC_Table<T>::remove(T* old_item_ptr)
96
typename map_t::iterator value_iterator=map_t::find(old_item_ptr->key());
97
if(value_iterator!=map_t::end())
99
erase(value_iterator);
105
template <class T> void CCCC_Table<T>::sort()
113
template <class T> void CCCC_Table<T>::reset_iterator()
115
iter_=map_t::begin();
118
template <class T> T* CCCC_Table<T>::first_item()
124
template <class T> T* CCCC_Table<T>::next_item()
127
if(iter_!=map_t::end())
129
retval=(*iter_).second;
135
template <class T> int CCCC_Table<T>::records()
137
return map_t::size();
140
#endif // _CCCC_TBL_BODY