summaryrefslogtreecommitdiffstats
path: root/src/kile/outputfilter.cpp
blob: b9570c56dbdb7b2709cbb5440a23e7e48a1f220d (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/***************************************************************************
    begin                : Die Sep 16 2003
    copyright            : (C) 2003 by Jeroen Wijnhout
    email                : wijnhout@science.uva.nl
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#include "outputfilter.h"

#include <tqfile.h>
#include <tqregexp.h>
#include <tqfileinfo.h>

#include "kiledebug.h"
#include <ktextedit.h>
#include <tdelocale.h>

#include "kiletool_enums.h"

using namespace std;

OutputFilter::OutputFilter() :
	m_log(TQString())
{
}

OutputFilter::~ OutputFilter()
{
}

short OutputFilter::parseLine(const TQString & /*strLine*/, short /*dwCookie*/)
{
    return 0;
}


bool OutputFilter::OnTerminate()
{
    return true;
}

void OutputFilter::setSource(const TQString &src)
{
	m_source = src;
	m_srcPath = TQFileInfo(src).dirPath();
}

bool OutputFilter::Run(const TQString & logfile)
{
	short sCookie = 0;
	TQString s;
	TQFile f(logfile);

	m_log = TQString();
	m_nOutputLines = 0;

	if ( f.open(IO_ReadOnly) )
	{
		TQTextStream t( &f );
		while ( !t.eof() )
		{
// 			KILE_DEBUG() << "line " << m_nOutputLines << endl;
			s = t.readLine() + '\n';
			sCookie = parseLine(s.stripWhiteSpace(), sCookie);
			++m_nOutputLines;

			m_log += s;
		}
		f.close();
	}
	else
	{
		emit(problem(KileTool::Warning, i18n("Cannot open log file; did you run LaTeX?")));
		return false;
	}

	return OnTerminate();
}


int OutputFilter::GetCurrentOutputLine() const
{
    return m_nOutputLines;
}

#include "outputfilter.moc"