The IbycusTxtFile class provides an interface to PHI\TLG .TXT files. Like an IbycusIdtFile, each file contains 1 (or possibly more) authors, with 1 or more works divided into 1 or more sections. Each of these may be accessed by index number, which are 0-based. The first section of the first work of the first author is therefore at index 0, 0, 0.
The IbycusTxtFile opens and maintains its own IbycusIdtFile, so it is unnecessary to create one separately. All of the public methods of the IbycusIdtFile are available through equivalent IbycusTxtFile methods, and a pointer to the IbycusIdtFile can be retrieved via the method Idt().
IbycusTxtFile()
IbycusTxtFile(const ibystring_t & id, const ibystring_t & vol) throw(IbycusFileException)
bool Top(const int auth=0, const int work=0, const int sect=0) throw(IbycusException)
bool Start(const int auth=0, const int work=0, const int sect=0) throw(IbycusException)
void Goto(const IbycusId & target) throw(IbycusNoId)
bool Next() throw(IbycusException, IbycusParseException)
const ibystring_t & Text() const throw()
const IbycusId & Id() const throw()
const ibystring_t & Filename() const throw()
int Count(const int auth = -1, const int work = -1)
const ibystring_t & Name(const int auth = 0, const int work = -1)
IbycusIdtFile * Idt() throw()
ibystring_t StripCodes() const throw()
bool eos() const
bool eow() const
bool eoa() const
const IbycusId & EndId(int auth=0, int work=-1, int section = -1)
const IbycusId & StartId(int auth=0, int work=-1, int section = -1)
Default constructor. Constructs an empty IbycusTxtFile
id | The author ID of the file to be opened |
vol | The directory where the file exists |
Creates an IbycusTxtFile, given an author ID (e.g., LAT0500, TLG1010) and a directory. Note that id is not the filename and must not have the .TXT extension. Throws an IbycusFileException if the file cannot be opened or read.
auth | The index of the desired author (default: 0) |
work | The index of the desired work (default: 0) |
sect | The index of the desired section (default: 0) |
Moves to the "top" of author, work and section indicated by the parameters. The "top" as the first line in the section including titles and other prefatory material. This is opposed to Start(), which moves to start of the section as defined by the IbycusIdtFile, which excludes titles.
IbycusTxtFile txt("LAT0960", "D:\"); // Your directory may be different txt.Top() // Go to top of first section of first work cout << txt.Id() << txt.Text() << "\n" txt.Top(0,1) // Go to top of first section of second work cout << txt.Id() << txt.Text() << "\n" txt.Top(0,2,3) // Go to top of fourth section of third work cout << txt.Id() << txt.Text() << "\n"
The output of this would be:
0960.001.t.1 0960.002.2.t 0960.003.3.t
auth | The index of the desired author (default: 0) |
work | The index of the desired work (default: 0) |
sect | The index of the desired section (default: 0) |
Moves to the "start" of author, work and section indicated by the parameters. The "start" is the line indicated by IbycusIdtFile::StartId(), which is generally the first line of text after any titles and other prefatory material. This is opposed to Top(), which moves to the first line of the including titles.
IbycusTxtFile txt("LAT0960", "D:\"); // Your directory may be different txt.Start() // Go to start of first section of first work cout << txt.Id() << txt.Text() << "\n" txt.Start(0,1) // Go to start of first section of second work cout << txt.Id() << txt.Text() << "\n" txt.Start(0,2,3) // Go to start of fourth section of third work cout << txt.Id() << txt.Text() << "\n"
The output of this would be:
0960.001.1.1 0960.002.2.1 0960.003.4.1
auth | The ID of the desired line |
Moves to the line of the indicated ID. Throws an IbycusNoId if the ID cannot be found.
Gets the next line of the file and returns true if possible, false if the end-of-file has been reached. After calling Next() you can call Id() and Text() to get the data from the current line.
Returns the text of the current line.
Returns the ID of the current line.
Returns true if the end of the current section has been reached.
Returns true if the end of the current work has been reached.
Returns true if the end of the current authorhas been reached.
auth | The index of the desired author (default: 0) |
work | The index of the desired work (default: -1) |
sect | The index of the desired section (default: -1) |
auth | The index of the desired author (default: 0) |
work | The index of the desired work (default: -1) |
sect | The index of the desired section (default: -1) |
auth | The index of the desired author (default: -1) |
work | The index of the desired work (default: -1) |
Returns the number of works in the author auth, or the number of sections in the work auth, work.
IbycusTxtFile txt("LAT0960", "D:\"); // Your directory may be different int a = txt.Count(); // number of authors in the file int b = txt.Count(0); // number of works by author 0 int c = txt.Count(0,2); // number of sections in work 2 of author 0
auth | The index of the desired author (default: 0) |
work | The index of the desired work (default: -1) |
Returns the name of the author auth, or of the work auth, work.
Returns the id of the current line.
Returns a pointer to the object's IbycusIdtFile.
Returns the same string as Text(), but with all Beta Code tags stripped out.
auth | The index of the desired author (default: 0) |
work | The index of the desired work (default: -1) |
sect | The index of the desired section (default: -1) |
Returns the start ID of the author with the index auth, work with the index auth, work, or section with the index auth, work, sect.
auth | The index of the desired author (default: 0) |
work | The index of the desired work (default: -1) |
sect | The index of the desired section (default: -1) |
Returns the end ID of the author with the index auth, work with the index auth, work, or section with the index auth, work, sect.