Debian Codegraph @

plugins/aiksaurus/aiksaurusgtk3/AiksaurusGTK_strlist.h

raw
1 /*
2 * AiksaurusGTK - A GTK interface to the AikSaurus library
3 * Copyright (C) 2001 by Jared Davis
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (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., 59 Temple Place - Suite 330, Boston, MA
18 * 02111-1307, USA.
19 */
20
21 #ifndef INCLUDED_JARED_GPL_AIKSAURUSGTK_STRLIST_H
22 #define INCLUDED_JARED_GPL_AIKSAURUSGTK_STRLIST_H
23
24 #include <glib.h>
25
26 //
27 // AiksaurusGTK_strlist class
28 // --------------------------
29 // This is a wrapper for the GList class which provides string copying
30 // features so that you can add strings and store them directly in the list
31 // with a minimum of fuss.
32 //
33 // In other words, when you push_back() or push_front() strings to this list,
34 // a copy of the string will be put in the list. This makes it much easier
35 // to reuse pointers and so forth, and you don't have to remember to delete
36 // the strings you've added because the destructor does it for you.
37 //
38
39 class AiksaurusGTK_strlist
40 {
41 private:
42
43 // d_list_ptr: pointer to the actual list itself.
44 GList* d_front_ptr;
45 GList* d_back_ptr;
46
47 // d_size: stores number of elements in list.
48 int d_size;
49
50 GList* find_first(const char* str);
51
52 // do not allow copying.
53 AiksaurusGTK_strlist(const AiksaurusGTK_strlist& rhs);
54 const AiksaurusGTK_strlist& operator=(const AiksaurusGTK_strlist& rhs);
55
56 GList* create_node(const char* str) const;
57 void free_data(GList* node) const;
58
59 void remove_node(GList* node);
60
61 public:
62
63 AiksaurusGTK_strlist();
64 ~AiksaurusGTK_strlist();
65
66
67
68 // size: returns number of elements in list.
69 unsigned int size() const;
70
71 // getList: returns ptr to actual glist.
72 const GList* list() const;
73
74 // look_back: returns pointer to last element in list
75 // or NULL if list is empty.
76 const char* look_back() const;
77
78 // look_front: returns pointer to first element in list
79 // or NULL if list is empty.
80 const char* look_front() const;
81
82
83
84 // clear: destroy all data in glist.
85 void clear();
86
87 // push_back: adds str to end of list.
88 void push_back(const char* str);
89
90 // pop_back: removes last element of list, or does
91 // nothing if list is empty.
92 void pop_back();
93
94 // push_front: adds str to front of list.
95 void push_front(const char* str);
96
97 // pop_front: removes first element from list, or does
98 // nothing if list is empty.
99 void pop_front();
100
101
102
103 // remove_first: removes first instance of str in list if found.
104 void remove_first(const char* str);
105
106 #ifndef NDEBUG
107 // debug: prints debug information.
108 void debug();
109 #endif
110 };
111
112 #endif // INCLUDED_JARED_GPL_AIKSAURUSGTK_STRLIST_H