Freeciv-3.3
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)
32void strvec_store(struct strvec *psv, const char *const *vec, size_t size)
33 fc__attribute((nonnull (1, 2)));
34void strvec_from_str(struct strvec *psv, char separator, const char *str)
36void strvec_clear(struct strvec *psv)
38void strvec_remove_empty(struct strvec *psv)
41 int (*cmp_func) (const char *, const char *))
43void strvec_copy(struct strvec *dest, const struct strvec *src)
44 fc__attribute((nonnull (1, 2)));
45void strvec_sort(struct strvec *psv, int (*sort_func) (const char *const *,
46 const char *const *))
48
49void strvec_prepend(struct strvec *psv, const char *string)
51void strvec_append(struct strvec *psv, const char *string)
53void strvec_insert(struct strvec *psv, size_t svindex, const char *string)
55bool strvec_set(struct strvec *psv, size_t svindex, const char *string);
56bool strvec_remove(struct strvec *psv, size_t svindex);
57
58size_t strvec_size(const struct strvec *psv)
60bool are_strvecs_equal(const struct strvec *stv1,
61 const struct strvec *stv2)
62 fc__attribute((nonnull (1, 2)));
63const char *const *strvec_data(const struct strvec *psv)
65bool strvec_index_valid(const struct strvec *psv, size_t svindex)
67const char *strvec_get(const struct strvec *psv, size_t svindex)
69void strvec_to_str(const struct strvec *psv, char separator,
70 char *buf, size_t buf_len);
71const char *strvec_to_or_list(const struct strvec *psv,
72 struct astring *astr)
74const char *strvec_to_and_list(const struct strvec *psv,
75 struct astring *astr)
77
78/* Iteration macro. */
79#define strvec_iterate(psv, str) \
80{ \
81 size_t _id; \
82 const char *str; \
83 for (_id = 0; _id < strvec_size((psv)); _id++) { \
84 str = strvec_get((psv), _id);
85
86#define strvec_iterate_end \
87 } \
88}
89
90#ifdef __cplusplus
91}
92#endif /* __cplusplus */
93
94#endif /* FC__STRING_VECTOR_H */
#define str
Definition astring.c:76
char * incite_cost
Definition comments.c:76
static gint cmp_func(gconstpointer a_p, gconstpointer b_p)
Definition repodlgs.c:368
size_t size
Definition specvec.h:72
bool strvec_index_valid(const struct strvec *psv, size_t svindex) fc__attribute((nonnull(1)))
void strvec_destroy(struct strvec *psv)
void strvec_to_str(const struct strvec *psv, char separator, char *buf, size_t buf_len)
const char * strvec_to_and_list(const struct strvec *psv, struct astring *astr) fc__attribute((nonnull(1)))
size_t strvec_size(const struct strvec *psv) fc__attribute((nonnull(1)))
void strvec_append(struct strvec *psv, const char *string) fc__attribute((nonnull(1)))
bool are_strvecs_equal(const struct strvec *stv1, const struct strvec *stv2) fc__attribute((nonnull(1
const char * strvec_get(const struct strvec *psv, size_t svindex) fc__attribute((nonnull(1)))
bool strvec_set(struct strvec *psv, size_t svindex, const char *string)
const char * strvec_to_or_list(const struct strvec *psv, struct astring *astr) fc__attribute((nonnull(1)))
void strvec_reserve(struct strvec *psv, size_t reserve) fc__attribute((nonnull(1)))
void strvec_prepend(struct strvec *psv, const char *string) fc__attribute((nonnull(1)))
void strvec_remove_empty(struct strvec *psv) fc__attribute((nonnull(1)))
void strvec_insert(struct strvec *psv, size_t svindex, const char *string) fc__attribute((nonnull(1)))
void strvec_clear(struct strvec *psv) fc__attribute((nonnull(1)))
void void strvec_from_str(struct strvec *psv, char separator, const char *str) fc__attribute((nonnull(1)))
struct strvec * strvec_new(void)
void strvec_store(struct strvec *psv, const char *const *vec, size_t size) fc__attribute((nonnull(1
void strvec_copy(struct strvec *dest, const struct strvec *src) fc__attribute((nonnull(1
void void strvec_sort(struct strvec *psv, int(*sort_func)(const char *const *, const char *const *)) fc__attribute((nonnull(1)))
bool strvec_remove(struct strvec *psv, size_t svindex)
bool const char *const * strvec_data(const struct strvec *psv) fc__attribute((nonnull(1)))
void strvec_remove_duplicate(struct strvec *psv, int(*cmp_func)(const char *, const char *)) fc__attribute((nonnull(1)))
char ** vec
#define fc__attribute(x)
Definition support.h:99