aboutsummaryrefslogtreecommitdiff
path: root/src/old/xmlfilereader.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-07-03 00:28:59 +0000
committerMike Buland <eichlan@xagasoft.com>2007-07-03 00:28:59 +0000
commitac517a2b7625e0aa0862679e961c6349f859ea3b (patch)
treee3e27a6b9bd5e2be6150088495c91fc91786ad9d /src/old/xmlfilereader.cpp
parentf8d4301e9fa4f3709258505941e37fab2eadadc6 (diff)
parentbd865cee5f89116c1f054cd0e5c275e97c2d0a9b (diff)
downloadlibbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.gz
libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.bz2
libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.xz
libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.zip
The reorg is being put in trunk, I think it's ready. Now we just get to find
out how many applications won't work anymore :)
Diffstat (limited to 'src/old/xmlfilereader.cpp')
-rw-r--r--src/old/xmlfilereader.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/old/xmlfilereader.cpp b/src/old/xmlfilereader.cpp
new file mode 100644
index 0000000..ed674a8
--- /dev/null
+++ b/src/old/xmlfilereader.cpp
@@ -0,0 +1,58 @@
1#include "xmlfilereader.h"
2#include "exceptions.h"
3#include <string.h>
4
5XmlFileReader::XmlFileReader( const char *sFile, bool bStrip )
6 : XmlReader( bStrip )
7{
8 fh = fopen( sFile, "rt" );
9
10 if( fh == NULL )
11 {
12 throw XmlException("Couldn't open file: %s", sFile );
13 //nError = 1;
14 }
15 else
16 {
17 buildDoc();
18 }
19}
20
21XmlFileReader::~XmlFileReader()
22{
23}
24
25char XmlFileReader::getChar( int nIndex )
26{
27 // Make sure we always have a little data left in the buffer
28 if( fbDataIn.getLength() <= nIndex+1 && fh )
29 {
30 int nBytes = fbDataIn.getCapacity()-1;
31 char *buf = new char[nBytes];
32 int nRead = fread( buf, 1, nBytes, fh );
33 fbDataIn.appendData( buf, nRead );
34 delete[] buf;
35
36 if( nRead < nBytes )
37 {
38 fclose( fh );
39 fh = NULL;
40 }
41 }
42 if( fbDataIn.getLength() >= nIndex+1 )
43 {
44 return fbDataIn.getData()[nIndex];
45 }
46 else
47 {
48 throw XmlException("End of XML stream read.");
49 }
50}
51
52void XmlFileReader::usedChar( int nAmnt )
53{
54 if( fbDataIn.getLength()-nAmnt >= 0 )
55 {
56 fbDataIn.usedData( nAmnt );
57 }
58}