comparison anagram/agcore/textfile.h @ 0:13d2b8934445

Import AnaGram (near-)release tree into Mercurial.
author David A. Holland
date Sat, 22 Dec 2007 17:52:45 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:13d2b8934445
1 /*
2 * AnaGram, A System for Syntax Directed Programming
3 * Copyright 1993-2002 Parsifal Software. All Rights Reserved.
4 * See the file COPYING for license and usage terms.
5 *
6 * textfile.h
7 */
8
9 #ifndef TEXTFILE_H
10 #define TEXTFILE_H
11
12 #include "agarray.h"
13 #include "agstring.h"
14 #include "cint.h"
15 #include "search.h"
16
17 class text_file {
18 public:
19 AgString name; /* name of file */
20 AgString text; /* body of file */
21 AgArray<int> lx; /* array of line indices */
22 unsigned width; /* length of longest line? */
23 unsigned stringLength;
24 int truncated;
25 int readFlags;
26
27 // Constructors
28
29 text_file(void) : lx(), width(0) {}
30 text_file(const char *);
31 text_file(const AgString s);
32 text_file(const char *, int flags /* = O_TEXT|O_RDONLY */);
33 text_file(const AgString s, int flags /* = O_TEXT|O_RDONLY */);
34
35 text_file(const text_file &t);
36
37 text_file &operator = (const text_file &t);
38 void find_lines(void);
39 void read_file(int flags);
40 void read_file();
41 cint size() const { return cint(width, lx.size()); }
42 operator char * (void) const { return text.pointer(); }
43 operator unsigned char * (void) const {
44 return (unsigned char *) text.pointer();
45 }
46 char *line(const unsigned ln) const { return text.pointer() + lx[ln]; }
47
48 SearchProcess searchProcess;
49 int findNext(cint &loc, AgString s);
50 int findPrev(cint &loc, AgString s);
51 };
52
53 #endif /* TEXTFILE_H */