author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 25 Jan 2016 16:35:43 +0000 | |
changeset 298 | 9696f76605bd |
parent 296 | ea3dbc023c80 |
permissions | -rw-r--r-- |
78 | 1 |
/* |
2 |
* StxXercesInputStream.cpp |
|
3 |
* |
|
4 |
* Created on: Dec 8, 2008 |
|
5 |
* Author: honza |
|
6 |
*/ |
|
7 |
||
8 |
#include "string.h" |
|
9 |
#include "assert.h" |
|
10 |
#include "StxXercesInputStream.hpp" |
|
11 |
||
12 |
#define CHUNK_SIZE 4096 |
|
13 |
#define MIN(a,b) (a < b ? a : b) |
|
14 |
||
15 |
StxXercesInputStream::StxXercesInputStream(OBJ stx_stream) { |
|
91
760f18117fee
Added PSVI handling to XercesCXMLParser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
78
diff
changeset
|
16 |
|
78 | 17 |
stx_stream_refcell = (OBJ*)malloc(sizeof ( OBJ*) ); |
18 |
*stx_stream_refcell = stx_stream; |
|
19 |
__ADD_REFCELL_CPP(stx_stream_refcell); |
|
20 |
||
21 |
/* Create buffer (instance of ByteArray) */ |
|
22 |
stx_buffer_refcell = (OBJ*)malloc(sizeof ( OBJ*) ); |
|
23 |
*stx_buffer_refcell = __BYTEARRAY_UNINITIALIZED_NEW_INT_CPP(CHUNK_SIZE); |
|
24 |
__ADD_REFCELL_CPP(stx_buffer_refcell); |
|
25 |
||
26 |
||
27 |
/* Create nextBytes:into: symbol */ |
|
28 |
stx_symbol_refcell = (OBJ*)malloc(sizeof ( OBJ*) ); |
|
29 |
*stx_symbol_refcell = __MKSYMBOL_CPP("nextBytes:into:"); |
|
30 |
__ADD_REFCELL_CPP(stx_symbol_refcell); |
|
31 |
||
32 |
||
33 |
} |
|
34 |
||
91
760f18117fee
Added PSVI handling to XercesCXMLParser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
78
diff
changeset
|
35 |
StxXercesInputStream::~StxXercesInputStream() { |
78 | 36 |
__REMOVE_REFCELL_CPP ( stx_stream_refcell ); |
37 |
free ( stx_stream_refcell ); |
|
38 |
||
39 |
/* Free buffer */ |
|
40 |
__REMOVE_REFCELL_CPP ( stx_buffer_refcell ); |
|
41 |
free ( stx_buffer_refcell ); |
|
42 |
||
43 |
/* Free nextBytes:into: symbol */ |
|
44 |
__REMOVE_REFCELL_CPP ( stx_symbol_refcell ); |
|
45 |
free ( stx_symbol_refcell ); |
|
46 |
} |
|
47 |
||
48 |
unsigned int StxXercesInputStream::curPos() const { |
|
49 |
//TODO |
|
50 |
return 0; |
|
51 |
} |
|
52 |
||
53 |
||
91
760f18117fee
Added PSVI handling to XercesCXMLParser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
78
diff
changeset
|
54 |
unsigned int StxXercesInputStream::readBytes(XMLByte* const toFill, const unsigned int maxToRead) { |
78 | 55 |
OBJ bytesRead; |
56 |
bytesRead = __SSEND2_CPP(*stx_stream_refcell, *stx_symbol_refcell, 0, __MKINT_CPP(MIN(CHUNK_SIZE, maxToRead)), *stx_buffer_refcell); |
|
57 |
strncpy((char*)toFill, (char*)(__ByteArrayInstPtr(*stx_buffer_refcell)->ba_element), __intVal(bytesRead)); |
|
58 |
return __intVal(bytesRead); |
|
59 |
} |
|
60 |
||
61 |
// takto implementovana by mela postacovat |
|
62 |
const XMLCh* StxXercesInputStream::getContentType() const { |
|
63 |
return 0; |
|
64 |
} |