• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

AiksaurusGTK_strlist.h

Go to the documentation of this file.
00001 /*
00002  * AiksaurusGTK - A GTK interface to the AikSaurus library
00003  * Copyright (C) 2001 by Jared Davis
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00018  * 02111-1307, USA.
00019  */
00020 
00021 #ifndef INCLUDED_JARED_GPL_AIKSAURUSGTK_STRLIST_H
00022 #define INCLUDED_JARED_GPL_AIKSAURUSGTK_STRLIST_H
00023 
00024 #include <glib.h>
00025 
00026 //
00027 // AiksaurusGTK_strlist class
00028 // --------------------------
00029 //   This is a wrapper for the GList class which provides string copying
00030 //   features so that you can add strings and store them directly in the list
00031 //   with a minimum of fuss.
00032 //
00033 //   In other words, when you push_back() or push_front() strings to this list,
00034 //   a copy of the string will be put in the list.  This makes it much easier
00035 //   to reuse pointers and so forth, and you don't have to remember to delete
00036 //   the strings you've added because the destructor does it for you.
00037 //
00038 
00039 class AiksaurusGTK_strlist
00040 {
00041     private:
00042 
00043         // d_list_ptr: pointer to the actual list itself.
00044         GList* d_front_ptr;
00045         GList* d_back_ptr;
00046 
00047         // d_size: stores number of elements in list.
00048         int d_size;
00049 
00050         GList* find_first(const char* str);
00051 
00052         // do not allow copying.
00053         AiksaurusGTK_strlist(const AiksaurusGTK_strlist& rhs);
00054         const AiksaurusGTK_strlist& operator=(const AiksaurusGTK_strlist& rhs);
00055 
00056         GList* create_node(const char* str) const;
00057         void free_data(GList* node) const;
00058 
00059         void remove_node(GList* node);
00060 
00061     public:
00062 
00063         AiksaurusGTK_strlist();
00064         ~AiksaurusGTK_strlist();
00065 
00066 
00067 
00068         // size: returns number of elements in list.
00069         unsigned int size() const;
00070 
00071         // getList: returns ptr to actual glist.
00072         const GList* list() const;
00073 
00074         // look_back: returns pointer to last element in list
00075         // or NULL if list is empty.
00076         const char* look_back() const;
00077 
00078         // look_front: returns pointer to first element in list
00079         // or NULL if list is empty.
00080         const char* look_front() const;
00081 
00082 
00083 
00084         // clear: destroy all data in glist.
00085         void clear();
00086 
00087         // push_back: adds str to end of list.
00088         void push_back(const char* str);
00089 
00090         // pop_back: removes last element of list, or does
00091         // nothing if list is empty.
00092         void pop_back();
00093 
00094         // push_front: adds str to front of list.
00095         void push_front(const char* str);
00096 
00097         // pop_front: removes first element from list, or does
00098         // nothing if list is empty.
00099         void pop_front();
00100 
00101 
00102 
00103         // remove_first: removes first instance of str in list if found.
00104         void remove_first(const char* str);
00105 
00106         #ifndef NDEBUG
00107         // debug: prints debug information.
00108         void debug();
00109         #endif
00110 };
00111 
00112 #endif // INCLUDED_JARED_GPL_AIKSAURUSGTK_STRLIST_H

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1