| 70 | } |
| 71 | |
| 72 | void IfcTokenStream::IfcTokenChunk::Load() |
| 73 | { |
| 74 | _chunkData = new uint8_t[_chunkSize]; |
| 75 | _loaded=true; |
| 76 | if (_fileStream->GetRef()!=_fileStartRef) _fileStream->Go(_fileStartRef); |
| 77 | std::vector<char> temp; |
| 78 | temp.reserve(50); |
| 79 | _currentSize = 0; |
| 80 | while ( !_fileStream->IsAtEnd() && _currentSize < _chunkSize) |
| 81 | { |
| 82 | const char c = _fileStream->Get(); |
| 83 | if (c == ' ' || c == '\n' || c == '\r' || c == '\t') |
| 84 | { |
| 85 | _fileStream->Forward(); |
| 86 | continue; |
| 87 | } |
| 88 | |
| 89 | if (c == '\'') |
| 90 | { |
| 91 | |
| 92 | _fileStream->Forward(); |
| 93 | temp.clear(); |
| 94 | // apparently I dont fully understand strings in IFC yet |
| 95 | // this example from uptown shows that escaping is not used: 'Type G5 - 800kg/m\X2\00B2\X0\'; |
| 96 | // this example from revit shows that double quotes are used as one quote: 'RPC Tree - Deciduous:Scarlet Oak - 42'':946835' |
| 97 | // turns out this is just part of ISO 10303-21, thanks ottosson! |
| 98 | while (true) |
| 99 | { |
| 100 | |
| 101 | temp.push_back(_fileStream->Get()); |
| 102 | // if its a quote, maybe its the end of the string |
| 103 | if (_fileStream->Get() == '\'') |
| 104 | { |
| 105 | // if there's another quote behind it, its not |
| 106 | _fileStream->Forward(); |
| 107 | if (_fileStream->Get() == '\'') |
| 108 | { |
| 109 | // we also bump pos, otherwise we still break next loop... |
| 110 | temp.push_back(_fileStream->Get()); |
| 111 | } |
| 112 | else |
| 113 | { |
| 114 | _fileStream->Back(); |
| 115 | temp.pop_back(); |
| 116 | break; |
| 117 | } |
| 118 | } |
| 119 | _fileStream->Forward(); |
| 120 | } |
| 121 | Push<uint8_t>(IfcTokenType::STRING); |
| 122 | Push<uint16_t>(temp.size()); |
| 123 | if (temp.size() > 0) Push(temp.data(),temp.size()); |
| 124 | } |
| 125 | else if (c == '#') |
| 126 | { |
| 127 | _fileStream->Forward(); |
| 128 | uint32_t num = 0; |
| 129 | char c = _fileStream->Get(); |