Qucs-core  0.0.19
strlist.h
Go to the documentation of this file.
00001 /*
00002  * strlist.h - string list class definitions
00003  *
00004  * Copyright (C) 2003, 2005, 2006 Stefan Jahn <stefan@lkcc.org>
00005  *
00006  * This is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2, or (at your option)
00009  * any later version.
00010  *
00011  * This software is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this package; see the file COPYING.  If not, write to
00018  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020  *
00021  * $Id$
00022  *
00023  */
00024 
00025 #ifndef __STRLIST_H__
00026 #define __STRLIST_H__
00027 
00028 namespace qucs {
00029 
00030 /* String list entry. */
00031 struct strlist_t {
00032   char * str;
00033   struct strlist_t * next;
00034 };
00035 
00036 /* String list class. */
00037 class strlist
00038 {
00039   friend class strlistiterator;
00040 
00041  public:
00042   strlist ();
00043   strlist (const strlist &);
00044   ~strlist ();
00045   void add (const char * const);
00046   void add (const strlist * const);
00047   void append (const char * const);
00048   void append (const strlist * const);
00049   int length (void) const;
00050   int contains (const char * const) const;
00051   char * get (int) const;
00052   char * first (void) const;
00053   char * last (void) const;
00054   int index (char *);
00055   static strlist * join (strlist *, strlist *);
00056   void del (strlist *);
00057   char * toString (const char * concat = " ");
00058 
00059  private:
00060   struct strlist_t * root;
00061   char * txt;
00062 };
00063 
00064 /* String list iterator. */
00065 class strlistiterator
00066 {
00067  public:
00068   strlistiterator ();
00069   strlistiterator (strlist &);
00070   strlistiterator (strlist *);
00071   ~strlistiterator ();
00072 
00073   int count (void);
00074   char * toFirst (void);
00075   char * toLast (void);
00076   char * operator++ (void);
00077   char * operator * (void) { return current (); }
00078   char * current (void);
00079   char * first (void);
00080   char * last (void);
00081 
00082  private:
00083   strlist * _strlist;
00084   struct strlist_t * _first;
00085   struct strlist_t * _last;
00086   struct strlist_t * _current;
00087 };
00088 
00089 } // namespace qucs
00090 
00091 #endif /* __STRLIST_H__ */