Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
valuelist.h
Go to the documentation of this file.
1 /*
2  * valuelist.h - value list template class definitions
3  *
4  * Copyright (C) 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 __VALUELIST_H__
26 #define __VALUELIST_H__
27 
28 namespace qucs {
29 
30 template <class type_t> class valentry;
31 template <class type_t> class valuelist;
32 template <class type_t> class valuelistiterator;
33 
34 /* Value list entry. */
35 template <class type_t>
36 class valentry
37 {
38  friend class valuelistiterator<type_t>;
39  friend class valuelist<type_t>;
40 
41  public:
42  ~valentry () { free (key); delete value; }
43  char * key;
44  type_t * value;
47 };
48 
49 /* The value list class. */
50 template <class type_t>
51 class valuelist
52 {
53  friend class valuelistiterator<type_t>;
54 
55  public:
56  valuelist ();
57  ~valuelist ();
58  valuelist (const valuelist &);
59  void add (const char *, type_t *);
60  void append (char *, type_t *);
61  void append (valuelist *);
62  void del (char *);
63  int length (void);
64  int contains (char *);
65  type_t * get (const char *);
66  void clear (void);
67 
68  private:
69  int size;
72 };
73 
74 /* Value list iterator. */
75 template <class type_t>
77 {
78  public:
81 
82  int count (void);
83  char * toFirst (void);
84  char * toLast (void);
85  char * operator++ (void);
86  char * operator-- (void);
87  char * operator * (void) { return current (); }
88  char * current (void);
89  char * currentKey (void);
90  type_t * currentVal (void);
91  char * first (void);
92  char * last (void);
93 
94  private:
99 };
100 
101 } // namespace qucs
102 
103 #include "valuelist.cpp"
104 
105 #endif /* __VALUELIST_H__ */
int contains(char *)
Definition: valuelist.cpp:143
char * key
Definition: valuelist.h:43
valentry< type_t > * _first
Definition: valuelist.h:96
type_t * currentVal(void)
Definition: valuelist.cpp:221
valentry * next
Definition: valuelist.h:45
char * operator*(void)
Definition: valuelist.h:87
valuelistiterator(valuelist< type_t > &)
Definition: valuelist.cpp:162
valentry< type_t > * last
Definition: valuelist.h:71
valentry< type_t > * root
Definition: valuelist.h:70
valentry * prev
Definition: valuelist.h:46
valentry< type_t > * _current
Definition: valuelist.h:98
void add(const char *, type_t *)
Definition: valuelist.cpp:73
void append(char *, type_t *)
Definition: valuelist.cpp:87
free($1)
char * operator--(void)
Definition: valuelist.cpp:202
void clear(void)
Definition: valuelist.cpp:60
char * operator++(void)
Definition: valuelist.cpp:195
valuelist< type_t > * _valuelist
Definition: valuelist.h:95
char * currentKey(void)
Definition: valuelist.cpp:215
valentry< type_t > * _last
Definition: valuelist.h:97
int length(void)
Definition: valuelist.cpp:115
void del(char *)
Definition: valuelist.cpp:121
type_t * value
Definition: valuelist.h:44