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
,
95 static inline MalaString
96 mala_stringlist_string (MalaStringList self
);
98 static inline MalaStringList
99 mala_stringlist_next (MalaStringList self
);
102 mala_stringlist_fwd (MalaStringList_ref self
);
105 mala_stringlist_rev (MalaStringList_ref self
);
108 mala_stringlist_remove (MalaStringList self
);
111 mala_stringlist_insert_tail (MalaStringList self
, MalaStringList node
);
114 mala_stringlist_insert_head (MalaStringList self
, MalaStringList node
);
116 #define mala_stringlist_insert_before mala_stringlist_insert_tail
117 #define mala_stringlist_insert_after mala_stringlist_insert_head
121 mala_stringlist_insert_after_stringlist (MalaStringList self
, MalaStringList src
)
123 llist_insert_list_after (&src
->node
, &self
->node
);
126 static inline MalaString
127 mala_stringlist_string (MalaStringList self
)
132 static inline MalaStringList
133 mala_stringlist_head_get (MalaStringList self
)
135 return LLIST_TO_STRUCTP(llist_get_next (&self
->node
), mala_stringlist
, node
);
138 static inline MalaString
139 mala_stringlist_string_from_llist (const_LList self
)
141 return LLIST_TO_STRUCTP(self
, mala_stringlist
, node
)->string
;
144 static inline const char *
145 mala_stringlist_cstr_from_llist (const_LList self
)
147 return mala_string_cstr (mala_stringlist_string_from_llist (self
));
151 mala_stringlist_fwd (MalaStringList_ref self
)
153 *self
= LLIST_TO_STRUCTP (llist_get_next (&(*self
)->node
), mala_stringlist
, node
);
157 mala_stringlist_rev (MalaStringList_ref self
)
159 *self
= LLIST_TO_STRUCTP (llist_get_prev (&(*self
)->node
), mala_stringlist
, node
);
163 mala_stringlist_remove (MalaStringList self
)
165 llist_unlink (&self
->node
);
168 static inline MalaStringList
169 mala_stringlist_next (MalaStringList self
)
171 return LLIST_TO_STRUCTP (llist_get_next(&self
->node
), mala_stringlist
, node
);
175 mala_stringlist_insert_tail (MalaStringList self
, MalaStringList node
)
177 llist_insert_tail (&self
->node
, &node
->node
);
181 mala_stringlist_insert_head (MalaStringList self
, MalaStringList node
)
183 llist_insert_head (&self
->node
, &node
->node
);
186 static inline MalaStringList
187 mala_stringlist_tail_get (MalaStringList self
)
189 return LLIST_TO_STRUCTP(llist_get_tail (&self
->node
), mala_stringlist
, node
);
193 mala_stringlist_is_end (MalaStringList self
, MalaStringList other
)
195 return self
== other
;
198 #endif /* MALA_STRINGLIST_H */
203 // c-file-style: "gnu"
205 // arch-tag: 44b2b6d9-80b8-43fa-938a-a492bd52cea2