1 /***************************************************************************
2  $RCSfile$
3  -------------------
4  cvs         : $Id$
5  begin       : Thu Apr 03 2003
6  copyright   : (C) 2003 by Martin Preuss
7  email       : martin@libchipcard.de
8 
9  ***************************************************************************
10  *                                                                         *
11  *   This library is free software; you can redistribute it and/or         *
12  *   modify it under the terms of the GNU Lesser General Public            *
13  *   License as published by the Free Software Foundation; either          *
14  *   version 2.1 of the License, or (at your option) any later version.    *
15  *                                                                         *
16  *   This library is distributed in the hope that it will be useful,       *
17  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
18  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
19  *   Lesser General Public License for more details.                       *
20  *                                                                         *
21  *   You should have received a copy of the GNU Lesser General Public      *
22  *   License along with this library; if not, write to the Free Software   *
23  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
24  *   MA  02111-1307  USA                                                   *
25  *                                                                         *
26  ***************************************************************************/
27 
28 #ifndef GWENHYWFAR_STRINGLIST2_H
29 #define GWENHYWFAR_STRINGLIST2_H
30 
31 #include <gwenhywfar/gwenhywfarapi.h>
32 #include <gwenhywfar/stringlist.h>
33 #include <gwenhywfar/types.h>
34 #include <gwenhywfar/refptr.h>
35 #include <gwenhywfar/list.h>
36 #include <gwenhywfar/db.h>
37 #include <gwenhywfar/xml.h>
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 typedef struct GWEN_STRINGLIST2 GWEN_STRINGLIST2;
44 typedef GWEN_LIST_ITERATOR GWEN_STRINGLIST2_ITERATOR;
45 
46 
47 typedef enum {
48   GWEN_StringList2_IntertMode_AlwaysAdd=0,
49   GWEN_StringList2_IntertMode_NoDouble,
50   GWEN_StringList2_IntertMode_Reuse
51 } GWEN_STRINGLIST2_INSERTMODE;
52 
53 
54 GWENHYWFAR_API
55 GWEN_STRINGLIST2 *GWEN_StringList2_new(void);
56 GWENHYWFAR_API
57 void GWEN_StringList2_free(GWEN_STRINGLIST2 *sl2);
58 GWENHYWFAR_API
59 GWEN_STRINGLIST2 *GWEN_StringList2_dup(GWEN_STRINGLIST2 *sl2);
60 
61 
62 GWENHYWFAR_API
63 int GWEN_StringList2_toDb(GWEN_STRINGLIST2 *sl2, GWEN_DB_NODE *db, const char *varName);
64 
65 GWENHYWFAR_API
66 GWEN_STRINGLIST2 *GWEN_StringList2_fromDb(GWEN_DB_NODE *db, const char *name, GWEN_STRINGLIST2_INSERTMODE m);
67 
68 
69 GWENHYWFAR_API
70 int GWEN_StringList2_toXml(GWEN_STRINGLIST2 *sl2, GWEN_XMLNODE *node);
71 
72 GWENHYWFAR_API
73 GWEN_STRINGLIST2 *GWEN_StringList2_fromXml(GWEN_XMLNODE *node, GWEN_STRINGLIST2_INSERTMODE m);
74 
75 
76 /**
77  * Normally this group of functions ignores cases when comparing two strings.
78  * You can change this behaviour here.
79  * @param sl2 string list
80  * @param i if 0 then cases are ignored
81  */
82 GWENHYWFAR_API
83 void GWEN_StringList2_SetSenseCase(GWEN_STRINGLIST2 *sl2, int i);
84 
85 /**
86  * Normally this group of functions ignores reference counters on stringlist
87  * entries when removing a string via @ref GWEN_StringList2_RemoveString.
88  * You can change this behaviour here.
89  * @param sl2 string list
90  * @param i if 0 then reference counters are honoured
91  */
92 GWENHYWFAR_API
93 void GWEN_StringList2_SetIgnoreRefCount(GWEN_STRINGLIST2 *sl2, int i);
94 
95 /**
96  * Appends a string.
97  * @return 0 if not appended, !=0 if appended
98  * @param take if true then the StringList takes over ownership of the string
99  * @param checkDouble if true the the string will only be appended if it
100  * does not already exist
101  */
102 GWENHYWFAR_API
103 int GWEN_StringList2_AppendString(GWEN_STRINGLIST2 *sl2,
104                                   const char *s,
105                                   int take,
106                                   GWEN_STRINGLIST2_INSERTMODE m);
107 
108 /**
109  * Inserts a string.
110  * @return 0 if not inserted, !=0 if inserted
111  * @param take if true then the StringList takes over ownership of the string
112  * @param checkDouble if true the the string will only be appended if it
113  * does not already exist
114  */
115 GWENHYWFAR_API
116 int GWEN_StringList2_InsertString(GWEN_STRINGLIST2 *sl2,
117                                   const char *s,
118                                   int take,
119                                   GWEN_STRINGLIST2_INSERTMODE m);
120 
121 /**
122  * Removes a given string from the stringlist.
123  * @return 0 if not found, !=0 if found and removed
124  */
125 GWENHYWFAR_API int GWEN_StringList2_RemoveString(GWEN_STRINGLIST2 *sl2,
126                                                  const char *s);
127 
128 /**
129  * Checks whether the given string already exists within in the
130  * string list.
131  * @return !=0 if found, 0 otherwise
132  */
133 GWENHYWFAR_API int GWEN_StringList2_HasString(const GWEN_STRINGLIST2 *sl2,
134                                               const char *s);
135 
136 
137 GWENHYWFAR_API const char *GWEN_StringList2_GetStringAt(const GWEN_STRINGLIST2 *sl2, int idx);
138 
139 
140 
141 GWENHYWFAR_API
142 GWEN_STRINGLIST2_ITERATOR *GWEN_StringList2_First(const GWEN_STRINGLIST2 *l);
143 
144 
145 GWENHYWFAR_API
146 GWEN_STRINGLIST2_ITERATOR *GWEN_StringList2_Last(const GWEN_STRINGLIST2 *l);
147 
148 
149 GWENHYWFAR_API
150 void GWEN_StringList2Iterator_free(GWEN_STRINGLIST2_ITERATOR *li);
151 
152 
153 GWENHYWFAR_API
154 const char *GWEN_StringList2Iterator_Previous(GWEN_STRINGLIST2_ITERATOR *li);
155 
156 
157 GWENHYWFAR_API
158 const char *GWEN_StringList2Iterator_Next(GWEN_STRINGLIST2_ITERATOR *li);
159 
160 
161 GWENHYWFAR_API
162 const char *GWEN_StringList2Iterator_Data(GWEN_STRINGLIST2_ITERATOR *li);
163 
164 GWENHYWFAR_API
165 unsigned int
166 GWEN_StringList2Iterator_GetLinkCount(const GWEN_STRINGLIST2_ITERATOR *li);
167 
168 
169 GWENHYWFAR_API
170 GWEN_REFPTR *
171 GWEN_StringList2Iterator_DataRefPtr(GWEN_STRINGLIST2_ITERATOR *li);
172 
173 
174 GWENHYWFAR_API void GWEN_StringList2_Dump(const GWEN_STRINGLIST2 *sl2);
175 
176 
177 GWENHYWFAR_API unsigned int GWEN_StringList2_GetCount(const GWEN_STRINGLIST2 *l);
178 
179 
180 
181 #ifdef __cplusplus
182 }
183 #endif
184 
185 
186 #endif
187 
188 
189