My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
strlist.h
Go to the documentation of this file.
1 /*
2  * strlist.h - string list class definitions
3  *
4  * Copyright (C) 2003, 2005, 2006 Stefan Jahn <stefan@lkcc.org>
5  *
6  * This is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * This software is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this package; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  * $Id: strlist.h 1825 2011-03-11 20:42:14Z ela $
22  *
23  */
24 
25 #ifndef __STRLIST_H__
26 #define __STRLIST_H__
27 
28 /* String list entry. */
29 struct strlist_t {
30  char * str;
31  struct strlist_t * next;
32 };
33 
34 /* String list class. */
35 class strlist
36 {
37  friend class strlistiterator;
38 
39  public:
40  strlist ();
41  strlist (const strlist &);
42  ~strlist ();
43  void add (char *);
44  void add (strlist *);
45  void append (char *);
46  void append (strlist *);
47  int length (void);
48  int contains (char *);
49  char * get (int);
50  char * first (void);
51  char * last (void);
52  int index (char *);
53  static strlist * join (strlist *, strlist *);
54  void del (strlist *);
55  char * toString (const char * concat = " ");
56 
57  private:
58  struct strlist_t * root;
59  char * txt;
60 };
61 
62 /* String list iterator. */
64 {
65  public:
66  strlistiterator ();
70 
71  int count (void);
72  char * toFirst (void);
73  char * toLast (void);
74  char * operator++ (void);
75  char * operator * (void) { return current (); }
76  char * current (void);
77  char * first (void);
78  char * last (void);
79 
80  private:
81  strlist * _strlist;
82  struct strlist_t * _first;
83  struct strlist_t * _last;
84  struct strlist_t * _current;
85 };
86 
87 #endif /* __STRLIST_H__ */