]> git.sesse.net Git - vlc/blob - modules/codec/cmml/xarray.h
Removes trailing spaces. Removes tabs.
[vlc] / modules / codec / cmml / xarray.h
1 /*************************************************************************
2  * xarray.h: Mutable (dynamically growable) array (header file)
3  *************************************************************************
4  * Copyright (C) 2004 Commonwealth Scientific and Industrial Research
5  *                    Organisation (CSIRO) Australia
6  * Copyright (C) 2004 the VideoLAN team
7  *
8  * $Id$
9  *
10  * Authors: Andre Pang <Andre.Pang@csiro.au>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25  ************************************************************************/
26
27 #ifndef __XARRAY_H__
28 #define __XARRAY_H__
29
30 /* define this to 'static' for static linkage */
31 #define XSTATIC
32
33 #define XARRAY_DEFAULT_SIZE 69
34 #define xarray_malloc malloc
35
36 /* Error codes */
37 enum xarray_errors
38 {
39     XARRAY_SUCCESS, XARRAY_ENULLPOINTER, XARRAY_ENEGATIVEINDEX,
40     XARRAY_EINDEXTOOLARGE, XARRAY_ENOMEM, XARRAY_EEMPTYARRAY,
41     XARRAY_ECOUNTOUTOFBOUNDS
42 };
43
44
45 typedef struct
46 {
47     void **array;
48     int last_valid_element;
49     unsigned int size;
50     unsigned int last_error;
51 }
52 XArray;
53
54 /* Mutable methods */
55 XSTATIC int      xarray_AddObject (XArray *xarray, void *object);
56 XSTATIC int      xarray_InsertObject (XArray *xarray, void *object,
57                                       unsigned int at_index);
58 XSTATIC int      xarray_RemoveLastObject (XArray *xarray);
59 XSTATIC int      xarray_RemoveObject (XArray *xarray, unsigned int at_index);
60 XSTATIC int      xarray_RemoveObjects (XArray *xarray, unsigned int at_index,
61                                        int count);
62 XSTATIC int      xarray_RemoveObjectsAfter (XArray *xarray, unsigned int index);
63 XSTATIC int      xarray_ReplaceObject (XArray *xarray, unsigned int index,
64                                        void *new_object);
65
66 /* Immutable methods */
67 XSTATIC XArray * xarray_New ();
68 XSTATIC int      xarray_ObjectAtIndex (XArray *xarray, unsigned int index,
69                                        void **out_object);
70 XSTATIC int      xarray_Count (XArray *xarray, unsigned int *out_count);
71
72 #endif /* __XARRAY_H__ */
73