summaryrefslogtreecommitdiffstats
path: root/kstars/kstars/ksfilereader.h
blob: 005d698796428e7bb5da7cdad0f6921456c79581 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/***************************************************************************
                          ksfilereader.h  -  description
                             -------------------
    begin                : Tue Jan 28 2003
    copyright            : (C) 2003 by Heiko Evermann
    email                : heiko@evermann.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KSFILEREADER_H
#define KSFILEREADER_H

#include <tqobject.h>
#include <tqstringlist.h>

/**@class KSFileReader
	*This class will read an entire file into a TQStringList, where each item
	*in the list is a line in the file.  It can then access each line in the 
	*list very quickly.
	*@author Heiko Evermann
	*@version 1.0
	*/

class QFile;
class QString;

class KSFileReader : public TQObject  {
	Q_OBJECT
public:
	/**Constructor.  Read an entire file into a TQStringList object.
		*@p file the file to be read
		*/
	KSFileReader( TQFile& file);
	
	/**Destructor*/
	~KSFileReader();

	/**@return TRUE if we are not yet at the end of the file.
		*/
	bool hasMoreLines();
	
	/**Read a line from the file, and increment the "current line" counter.
		*@return the line that we read, as a TQString.
		*/
	TQString& readLine();

	/**Go to a specific line in the file.
		*@p i the line number to skip to.
		*/
	bool setLine(int i);

private:
	/** After loading the whole file, we split it into lines and keep them here. */
	TQStringList lines;
	/** How many lines do we have in the file? */
	int numLines;
	/** Which line are we at? */
	int curLine;
};

#endif