|
Revision 13041, 2.5 kB
(checked in by robert, 14 months ago)
|
|
Ran script to remove trailing spaces and tabs
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | #include <iostream> |
|---|
| 21 | #include "Opcodes.h" |
|---|
| 22 | #include "Registry.h" |
|---|
| 23 | #include "Document.h" |
|---|
| 24 | #include "RecordInputStream.h" |
|---|
| 25 | |
|---|
| 26 | using namespace flt; |
|---|
| 27 | using namespace std; |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | RecordInputStream::RecordInputStream(std::streambuf* sb): |
|---|
| 31 | DataInputStream(sb), |
|---|
| 32 | _recordSize(0) |
|---|
| 33 | {} |
|---|
| 34 | |
|---|
| 35 | bool RecordInputStream::readRecord(Document& document) |
|---|
| 36 | { |
|---|
| 37 | opcode_type opcode = (opcode_type)readUInt16(); |
|---|
| 38 | size_type size = (size_type)readUInt16(); |
|---|
| 39 | |
|---|
| 40 | return readRecordBody(opcode, size, document); |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | bool RecordInputStream::readRecordBody(opcode_type opcode, size_type size, Document& document) |
|---|
| 44 | { |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | const uint16 LITTLE_ENDIAN_POP_LEVEL_OP = 0x0B00; |
|---|
| 48 | if (opcode==LITTLE_ENDIAN_POP_LEVEL_OP) |
|---|
| 49 | { |
|---|
| 50 | OSG_INFO << "Little endian pop-level record" << std::endl; |
|---|
| 51 | opcode=POP_LEVEL_OP; |
|---|
| 52 | size=4; |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | _recordSize = size; |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | Record* prototype = Registry::instance()->getPrototype((int)opcode); |
|---|
| 59 | |
|---|
| 60 | if (prototype) |
|---|
| 61 | { |
|---|
| 62 | #if 0 // for debugging |
|---|
| 63 | { |
|---|
| 64 | for (int i=0; i<document.level(); i++) |
|---|
| 65 | cout << " "; |
|---|
| 66 | cout << "opcode=" << opcode << " size=" << size; |
|---|
| 67 | if (prototype) std::cout << " " << typeid(*prototype).name(); |
|---|
| 68 | cout << endl; |
|---|
| 69 | } |
|---|
| 70 | #endif |
|---|
| 71 | |
|---|
| 72 | osg::ref_ptr<Record> record = prototype->cloneType(); |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | record->read(*this,document); |
|---|
| 76 | } |
|---|
| 77 | else |
|---|
| 78 | { |
|---|
| 79 | OSG_WARN << "Unknown record, opcode=" << opcode << " size=" << size << std::endl; |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | Registry::instance()->addPrototype(opcode,new DummyRecord); |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | return good(); |
|---|
| 86 | } |
|---|