cctools
|
A two dimensional array of strings. More...
Go to the source code of this file.
Functions | |
struct text_array * | text_array_create (int w, int h) |
Create a new text array. More... | |
void | text_array_delete (struct text_array *t) |
Delete a text array and all of its contents. More... | |
int | text_array_width (struct text_array *t) |
Get the width of the array. More... | |
int | text_array_height (struct text_array *t) |
Get the height of the array. More... | |
const char * | text_array_get (struct text_array *t, int x, int y) |
Look up one cell in the array. More... | |
int | text_array_set (struct text_array *t, int x, int y, const char *c) |
Set one cell in the array. More... | |
int | text_array_load (struct text_array *t, const char *filename) |
Load an array from a file. More... | |
int | text_array_save (struct text_array *t, const char *filename) |
Save an array to a file. More... | |
int | text_array_save_range (struct text_array *t, const char *filename, int x, int y, int w, int h) |
Save a portion of an array to a file. More... | |
A two dimensional array of strings.
Each cell may contain either a null pointer or a pointer to an ordinary string. A simple external representation is used to load, store, and subset arrays between processes.
struct text_array* text_array_create | ( | int | w, |
int | h | ||
) |
Create a new text array.
w | Width of the array. |
h | Height of the array. |
void text_array_delete | ( | struct text_array * | t | ) |
Delete a text array and all of its contents.
t | The text array to deleted. |
int text_array_width | ( | struct text_array * | t | ) |
Get the width of the array.
t | A text array. |
int text_array_height | ( | struct text_array * | t | ) |
Get the height of the array.
t | A text array. |
const char* text_array_get | ( | struct text_array * | t, |
int | x, | ||
int | y | ||
) |
Look up one cell in the array.
t | A text array. |
x | The x position of the cell. |
y | The y position of the cell. |
int text_array_set | ( | struct text_array * | t, |
int | x, | ||
int | y, | ||
const char * | c | ||
) |
Set one cell in the array.
t | A text array. |
x | The x position of the cell. |
y | The y position of the cell. |
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. |
int text_array_load | ( | struct text_array * | t, |
const char * | filename | ||
) |
Load an array from a file.
t | An array created by text_array_create. |
filename | The filename to load from. |
int text_array_save | ( | struct text_array * | t, |
const char * | filename | ||
) |
Save an array to a file.
t | An array created by text_array_create. |
filename | The filename to write to. |
int text_array_save_range | ( | struct text_array * | t, |
const char * | filename, | ||
int | x, | ||
int | y, | ||
int | w, | ||
int | h | ||
) |
Save a portion of an array to a file.
t | An array created by text_array_create. |
filename | The filename to write to. |
x | The starting x position of the range to save. |
y | The starting y position of the range to save. |
w | The width of the range to save. |
h | The height of the range to save. |