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);
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 */
#define str
Definition astring.c:76
char * incite_cost
Definition comments.c:75
static gint cmp_func(gconstpointer a_p, gconstpointer b_p)
Definition repodlgs.c:368
size_t size
Definition specvec.h:72
void strvec_destroy(struct strvec *psv)
void strvec_sort(struct strvec *psv, int(*sort_func)(const char *const *, const char *const *))
void strvec_to_str(const struct strvec *psv, char separator, char *buf, size_t buf_len)
bool strvec_set(struct strvec *psv, size_t svindex, const char *string)
bool strvec_index_valid(const struct strvec *psv, size_t svindex)
const char *const * strvec_data(const struct strvec *psv)
void strvec_store(struct strvec *psv, const char *const *vec, size_t size)
void strvec_append(struct strvec *psv, const char *string)
void strvec_from_str(struct strvec *psv, char separator, const char *str)
void strvec_reserve(struct strvec *psv, size_t reserve)
const char * strvec_to_or_list(const struct strvec *psv, struct astring *astr)
const char * strvec_get(const struct strvec *psv, size_t svindex)
void strvec_prepend(struct strvec *psv, const char *string)
void strvec_copy(struct strvec *dest, const struct strvec *src)
struct strvec * strvec_new(void)
void strvec_clear(struct strvec *psv)
size_t strvec_size(const struct strvec *psv)
const char * strvec_to_and_list(const struct strvec *psv, struct astring *astr)
void strvec_remove_duplicate(struct strvec *psv, int(*cmp_func)(const char *, const char *))
bool are_strvecs_equal(const struct strvec *stv1, const struct strvec *stv2)
bool strvec_remove(struct strvec *psv, size_t svindex)
void strvec_remove_empty(struct strvec *psv)
void strvec_insert(struct strvec *psv, size_t svindex, const char *string)
char ** vec