2
Copyright (C) 2008- The University of Notre Dame
3
This software is distributed under the GNU General Public License.
4
See the file COPYING for details.
10
/** @file text_array.h
11
A two dimensional array of strings.
12
Each cell may contain either a null pointer or a pointer to an ordinary string.
13
A simple external representation is used to load, store, and subset arrays between processes.
16
/** Create a new text array.
17
@param w Width of the array.
18
@param h Height of the array.
19
@return A new text array on success, or null on failure.
21
struct text_array * text_array_create( int w, int h );
23
/** Delete a text array and all of its contents.
24
@param t The text array to deleted.
26
void text_array_delete( struct text_array *t );
28
/** Get the width of the array.
29
@param t A text array.
30
@return The width of the array.
32
int text_array_width( struct text_array *t );
34
/** Get the height of the array.
35
@param t A text array.
36
@return The height of the array.
38
int text_array_height( struct text_array *t );
40
/** Look up one cell in the array.
41
@param t A text array.
42
@param x The x position of the cell.
43
@param y The y position of the cell.
44
@return The value of the cell, which might be null.
46
const char * text_array_get( struct text_array *t, int x, int y );
48
/** Set one cell in the array.
49
@param t A text array.
50
@param x The x position of the cell.
51
@param y The y position of the cell.
52
@param c A string to place in the cell. If not null, c will be copied with strdup and placed in the data structure. Regardless, the current occupant of the cell will be freed.
54
int text_array_set( struct text_array *t, int x, int y, const char *c );
56
/** Load an array from a file.
57
@param t An array created by @ref text_array_create.
58
@param filename The filename to load from.
60
int text_array_load( struct text_array *t, const char *filename );
62
/** Save an array to a file.
63
@param t An array created by @ref text_array_create.
64
@param filename The filename to write to.
66
int text_array_save( struct text_array *t, const char *filename );
68
/** Save a portion of an array to a file.
69
@param t An array created by @ref text_array_create.
70
@param filename The filename to write to.
71
@param x The starting x position of the range to save.
72
@param y The starting y position of the range to save.
73
@param w The width of the range to save.
74
@param h The height of the range to save.
76
int text_array_save_range( struct text_array *t, const char *filename, int x, int y, int w, int h );