~ubuntu-branches/ubuntu/vivid/cctools/vivid

« back to all changes in this revision

Viewing changes to dttools/src/text_array.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Hanke
  • Date: 2011-05-07 09:05:00 UTC
  • Revision ID: james.westby@ubuntu.com-20110507090500-lqpmdtwndor6e7os
Tags: upstream-3.3.2
ImportĀ upstreamĀ versionĀ 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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.
 
5
*/
 
6
 
 
7
#ifndef TEXT_ARRAY_H
 
8
#define TEXT_ARRAY_H
 
9
 
 
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.
 
14
*/
 
15
 
 
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.
 
20
*/
 
21
struct text_array * text_array_create( int w, int h );
 
22
 
 
23
/** Delete a text array and all of its contents.
 
24
@param t The text array to deleted.
 
25
*/
 
26
void text_array_delete( struct text_array *t );
 
27
 
 
28
/** Get the width of the array.
 
29
@param t A text array.
 
30
@return The width of the array.
 
31
*/
 
32
int text_array_width( struct text_array *t );
 
33
 
 
34
/** Get the height of the array.
 
35
@param t A text array.
 
36
@return The height of the array.
 
37
*/
 
38
int text_array_height( struct text_array *t );
 
39
 
 
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.
 
45
*/
 
46
const char * text_array_get( struct text_array *t, int x, int y );
 
47
 
 
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.
 
53
*/
 
54
int text_array_set( struct text_array *t, int x, int y, const char *c );
 
55
 
 
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.
 
59
*/
 
60
int text_array_load( struct text_array *t, const char *filename );
 
61
 
 
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.
 
65
*/
 
66
int text_array_save( struct text_array *t, const char *filename );
 
67
 
 
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.
 
75
*/
 
76
int text_array_save_range( struct text_array *t, const char *filename, int x, int y, int w, int h );
 
77
 
 
78
#endif