blob: ed674a89a8f4ab5978b33d708f99893b4469e7d8 (
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
|
#include "xmlfilereader.h"
#include "exceptions.h"
#include <string.h>
XmlFileReader::XmlFileReader( const char *sFile, bool bStrip )
: XmlReader( bStrip )
{
fh = fopen( sFile, "rt" );
if( fh == NULL )
{
throw XmlException("Couldn't open file: %s", sFile );
//nError = 1;
}
else
{
buildDoc();
}
}
XmlFileReader::~XmlFileReader()
{
}
char XmlFileReader::getChar( int nIndex )
{
// Make sure we always have a little data left in the buffer
if( fbDataIn.getLength() <= nIndex+1 && fh )
{
int nBytes = fbDataIn.getCapacity()-1;
char *buf = new char[nBytes];
int nRead = fread( buf, 1, nBytes, fh );
fbDataIn.appendData( buf, nRead );
delete[] buf;
if( nRead < nBytes )
{
fclose( fh );
fh = NULL;
}
}
if( fbDataIn.getLength() >= nIndex+1 )
{
return fbDataIn.getData()[nIndex];
}
else
{
throw XmlException("End of XML stream read.");
}
}
void XmlFileReader::usedChar( int nAmnt )
{
if( fbDataIn.getLength()-nAmnt >= 0 )
{
fbDataIn.usedData( nAmnt );
}
}
|