Freeciv-3.2: /fast/freeciv/nightly/S3_2/utility/string_vector.h Source File

Freeciv-3.2

Loading...
Searching...
No Matches
string_vector.h
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13#ifndef FC__STRING_VECTOR_H
14#define FC__STRING_VECTOR_H
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20/* utility */
21#include "support.h" /* bool type. */
22
23struct astring;
24
25struct strvec; /* Opaque. */
26
27struct strvec *strvec_new(void);
28void strvec_destroy(struct strvec *psv);
29
30void strvec_reserve(struct strvec *psv, size_t reserve);
31void strvec_store(struct strvec *psv, const char *const *vec, size_t size);
32void strvec_from_str(struct strvec *psv, char separator, const char *str);
33void strvec_clear(struct strvec *psv);
34void strvec_remove_empty(struct strvec *psv);
35void strvec_remove_duplicate(struct strvec *psv,
36 int (*cmp_func) (const char *, const char *));
37void strvec_copy(struct strvec *dest, const struct strvec *src);
38void strvec_sort(struct strvec *psv, int (*sort_func) (const char *const *,
39 const char *const *));
40
41void strvec_prepend(struct strvec *psv, const char *string);
42void strvec_append(struct strvec *psv, const char *string);
43void strvec_insert(struct strvec *psv, size_t svindex, const char *string);
44bool strvec_set(struct strvec *psv, size_t svindex, const char *string);
45bool strvec_remove(struct strvec *psv, size_t svindex);
46
47size_t strvec_size(const struct strvec *psv);
48bool are_strvecs_equal(const struct strvec *stv1,
49 const struct strvec *stv2);
50const char *const *strvec_data(const struct strvec *psv);
51bool strvec_index_valid(const struct strvec *psv, size_t svindex);
52const char *strvec_get(const struct strvec *psv, size_t svindex);
53void strvec_to_str(const struct strvec *psv, char separator,
54 char *buf, size_t buf_len);
55const char *strvec_to_or_list(const struct strvec *psv,
56 struct astring *astr);
57const char *strvec_to_and_list(const struct strvec *psv,
58 struct astring *astr);
59
60/* Iteration macro. */
61#define strvec_iterate(psv, str) \
62{ \
63 size_t _id; \
64 const char *str; \
65 for (_id = 0; _id < strvec_size((psv)); _id++) { \
66 str = strvec_get((psv), _id);
67
68#define strvec_iterate_end \
69 } \
70}
71
72#ifdef __cplusplus
73}
74#endif /* __cplusplus */
75
76#endif /* FC__STRING_VECTOR_H */
str
#define str
Definition astring.c:76
incite_cost
char * incite_cost
Definition comments.c:74
cmp_func
static gint cmp_func(gconstpointer a_p, gconstpointer b_p)
Definition repodlgs.c:368
size
size_t size
Definition specvec.h:72
strvec_destroy
void strvec_destroy(struct strvec *psv)
Definition string_vector.c:71
strvec_sort
void strvec_sort(struct strvec *psv, int(*sort_func)(const char *const *, const char *const *))
Definition string_vector.c:258
strvec_to_str
void strvec_to_str(const struct strvec *psv, char separator, char *buf, size_t buf_len)
Definition string_vector.c:400
strvec_set
bool strvec_set(struct strvec *psv, size_t svindex, const char *string)
Definition string_vector.c:305
strvec_index_valid
bool strvec_index_valid(const struct strvec *psv, size_t svindex)
Definition string_vector.c:380
strvec_data
const char *const * strvec_data(const struct strvec *psv)
Definition string_vector.c:372
strvec_store
void strvec_store(struct strvec *psv, const char *const *vec, size_t size)
Definition string_vector.c:110
strvec_append
void strvec_append(struct strvec *psv, const char *string)
Definition string_vector.c:278
strvec_from_str
void strvec_from_str(struct strvec *psv, char separator, const char *str)
Definition string_vector.c:136
strvec_reserve
void strvec_reserve(struct strvec *psv, size_t reserve)
Definition string_vector.c:80
strvec_to_or_list
const char * strvec_to_or_list(const struct strvec *psv, struct astring *astr)
Definition string_vector.c:428
strvec_get
const char * strvec_get(const struct strvec *psv, size_t svindex)
Definition string_vector.c:388
strvec_prepend
void strvec_prepend(struct strvec *psv, const char *string)
Definition string_vector.c:268
strvec_copy
void strvec_copy(struct strvec *dest, const struct strvec *src)
Definition string_vector.c:237
strvec_new
struct strvec * strvec_new(void)
Definition string_vector.c:58
strvec_clear
void strvec_clear(struct strvec *psv)
Definition string_vector.c:159
strvec_size
size_t strvec_size(const struct strvec *psv)
Definition string_vector.c:343
strvec_to_and_list
const char * strvec_to_and_list(const struct strvec *psv, struct astring *astr)
Definition string_vector.c:441
strvec_remove_duplicate
void strvec_remove_duplicate(struct strvec *psv, int(*cmp_func)(const char *, const char *))
Definition string_vector.c:179
are_strvecs_equal
bool are_strvecs_equal(const struct strvec *stv1, const struct strvec *stv2)
Definition string_vector.c:351
strvec_remove
bool strvec_remove(struct strvec *psv, size_t svindex)
Definition string_vector.c:319
strvec_remove_empty
void strvec_remove_empty(struct strvec *psv)
Definition string_vector.c:207
strvec_insert
void strvec_insert(struct strvec *psv, size_t svindex, const char *string)
Definition string_vector.c:287
astring
Definition astring.h:36
strvec
Definition string_vector.c:29
strvec::vec
char ** vec
Definition string_vector.c:30
support.h