2 stringlist.h - MaLa stringlists
4 Copyright (C) 2004, 2005, Christian Thaeter <chth@gmx.net>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License version 2 as
8 published by the Free Software Foundation.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, contact me.
20 #ifndef MALA_STRINGLIST_H
21 #define MALA_STRINGLIST_H
24 #include "mala_types.h"
30 #define MALA_STATIC_STRINGLIST_INIT(args...) \
31 (const char*[]){args, NULL}
38 struct mala_stringlist_struct
46 mala_stringlist_acogc_mark (void* o
);
49 mala_stringlist_acogc_initize (void * o
);
52 mala_stringlist_acogc_finalize (void * o
);
57 mala_stringlist_new (MalaEngine engine
);
60 mala_stringlist_copy (MalaStringList source
, MalaEngine engine
);
63 mala_stringlist_append_cstrs (MalaStringList self
, int nelem
, char** cstrs
, MalaEngine engine
);
66 mala_stringlist_append_literal_cstrs (MalaStringList self
, int nelem
, char** cstrs
, MalaEngine engine
);
69 mala_stringlist_node_new_literal_cstr (const char * cstr
, MalaEngine engine
);
72 mala_stringlist_node_new_cstr (const char * cstr
, MalaEngine engine
);
75 mala_stringlist_node_new (MalaString str
, MalaEngine engine
);
79 mala_stringlist_insert_after_stringlist (MalaStringList self
, MalaStringList src
);
81 static inline MalaString
82 mala_stringlist_string_from_llist (const_LList self
);
84 static inline const char *
85 mala_stringlist_cstr_from_llist (const_LList self
);
88 mala_stringlist_dump (MalaStringList self
, FILE * f
,
96 nobug_mala_stringlist_dump (const_MalaStringList self
,
102 static inline MalaString
103 mala_stringlist_string (MalaStringList self
);
106 mala_stringlist_string_set (MalaStringList self
, MalaString str
);
108 static inline MalaStringList
109 mala_stringlist_next (MalaStringList self
);
111 static inline MalaStringList
112 mala_stringlist_prev (MalaStringList self
);
115 mala_stringlist_fwd (MalaStringList_ref self
);
118 mala_stringlist_rev (MalaStringList_ref self
);
121 mala_stringlist_advance (MalaStringList self
);
124 mala_stringlist_remove (MalaStringList self
);
127 mala_stringlist_insert_tail (MalaStringList self
, MalaStringList node
);
130 mala_stringlist_insert_head (MalaStringList self
, MalaStringList node
);
132 #define mala_stringlist_insert_before mala_stringlist_insert_tail
133 #define mala_stringlist_insert_after mala_stringlist_insert_head
137 mala_stringlist_insert_after_stringlist (MalaStringList self
, MalaStringList src
)
139 llist_insert_list_after (&src
->node
, &self
->node
);
142 static inline MalaString
143 mala_stringlist_string (MalaStringList self
)
149 mala_stringlist_string_set (MalaStringList self
, MalaString str
)
154 static inline const char*
155 mala_stringlist_cstr (MalaStringList self
)
157 return mala_string_cstr (self
->string
);
160 static inline MalaStringList
161 mala_stringlist_head_get (MalaStringList self
)
163 return LLIST_TO_STRUCTP (llist_get_next (&self
->node
), mala_stringlist
, node
);
166 static inline MalaString
167 mala_stringlist_string_from_llist (const_LList self
)
169 return LLIST_TO_STRUCTP (self
, mala_stringlist
, node
)->string
;
172 static inline const char *
173 mala_stringlist_cstr_from_llist (const_LList self
)
175 return mala_string_cstr (mala_stringlist_string_from_llist (self
));
179 mala_stringlist_fwd (MalaStringList_ref self
)
181 *self
= LLIST_TO_STRUCTP (llist_get_next (&(*self
)->node
), mala_stringlist
, node
);
185 mala_stringlist_rev (MalaStringList_ref self
)
187 *self
= LLIST_TO_STRUCTP (llist_get_prev (&(*self
)->node
), mala_stringlist
, node
);
191 mala_stringlist_advance (MalaStringList self
)
193 llist_advance (&self
->node
);
197 mala_stringlist_remove (MalaStringList self
)
199 llist_unlink (&self
->node
);
202 static inline MalaStringList
203 mala_stringlist_next (MalaStringList self
)
205 return LLIST_TO_STRUCTP (llist_get_next(&self
->node
), mala_stringlist
, node
);
208 static inline MalaStringList
209 mala_stringlist_prev (MalaStringList self
)
211 return LLIST_TO_STRUCTP (llist_get_prev(&self
->node
), mala_stringlist
, node
);
215 mala_stringlist_insert_tail (MalaStringList self
, MalaStringList node
)
217 llist_insert_tail (&self
->node
, &node
->node
);
221 mala_stringlist_insert_head (MalaStringList self
, MalaStringList node
)
223 llist_insert_head (&self
->node
, &node
->node
);
226 static inline MalaStringList
227 mala_stringlist_tail_get (MalaStringList self
)
229 return LLIST_TO_STRUCTP(llist_get_tail (&self
->node
), mala_stringlist
, node
);
233 mala_stringlist_is_end (MalaStringList self
, MalaStringList other
)
235 return self
== other
;
238 #endif /* MALA_STRINGLIST_H */
243 // c-file-style: "gnu"
245 // arch-tag: 44b2b6d9-80b8-43fa-938a-a492bd52cea2