Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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$
22  *
23  */
24 
25 #ifndef __STRLIST_H__
26 #define __STRLIST_H__
27 
28 namespace qucs {
29 
30 /* String list entry. */
31 struct strlist_t {
32  char * str;
33  struct strlist_t * next;
34 };
35 
36 /* String list class. */
37 class strlist
38 {
39  friend class strlistiterator;
40 
41  public:
42  strlist ();
43  strlist (const strlist &);
44  ~strlist ();
45  void add (char *);
46  void add (strlist *);
47  void append (char *);
48  void append (strlist *);
49  int length (void);
50  int contains (char *);
51  char * get (int);
52  char * first (void);
53  char * last (void);
54  int index (char *);
55  static strlist * join (strlist *, strlist *);
56  void del (strlist *);
57  char * toString (const char * concat = " ");
58 
59  private:
60  struct strlist_t * root;
61  char * txt;
62 };
63 
64 /* String list iterator. */
65 class strlistiterator
66 {
67  public:
68  strlistiterator ();
69  strlistiterator (strlist &);
70  strlistiterator (strlist *);
72 
73  int count (void);
74  char * toFirst (void);
75  char * toLast (void);
76  char * operator++ (void);
77  char * operator * (void) { return current (); }
78  char * current (void);
79  char * first (void);
80  char * last (void);
81 
82  private:
83  strlist * _strlist;
84  struct strlist_t * _first;
85  struct strlist_t * _last;
86  struct strlist_t * _current;
87 };
88 
89 } // namespace qucs
90 
91 #endif /* __STRLIST_H__ */
void add(char *)
Definition: strlist.cpp:65
char * last(void)
Definition: strlist.cpp:137
char * current(void)
Definition: strlist.cpp:241
void append(char *)
Definition: strlist.cpp:84
int contains(char *)
Definition: strlist.cpp:107
struct strlist_t * _last
Definition: parse_citi.y:86
friend class strlistiterator
Definition: parse_citi.y:40
static strlist * join(strlist *, strlist *)
Definition: strlist.cpp:168
struct strlist_t * _first
Definition: parse_citi.y:85
struct strlist_t * _current
Definition: parse_citi.y:87
char * operator*(void)
Definition: parse_citi.y:78
char * toFirst(void)
Definition: strlist.cpp:222
char * toLast(void)
Definition: strlist.cpp:228
void del(strlist *)
Definition: strlist.cpp:152
int length(void)
Definition: strlist.cpp:100
char * txt
Definition: parse_citi.y:62
char * last(void)
Definition: strlist.cpp:251
struct strlist_t * next
Definition: parse_citi.y:34
char * toString(const char *concat=" ")
Definition: strlist.cpp:177
List int
Definition: parse_citi.y:183
int index(char *)
Definition: strlist.cpp:118
char * operator++(void)
Definition: strlist.cpp:235
char * first(void)
Definition: strlist.cpp:246
struct strlist_t * root
Definition: parse_citi.y:61
char * first(void)
Definition: strlist.cpp:145