| 20 | } |
| 21 | |
| 22 | std::vector<ProtocolStreamExtractor::ParseResult> ProtocolStreamExtractor::driveParser() { |
| 23 | std::vector<ParseResult> results; |
| 24 | |
| 25 | if (_plugin) { |
| 26 | if (_plugin->isComponentStreaming()) { |
| 27 | size_t newPos = 0; |
| 28 | bool still = _plugin->continueComponentStreaming( |
| 29 | _dataBuffer, _surfaceId, _version, results, newPos); |
| 30 | if (still) { |
| 31 | return results; |
| 32 | } |
| 33 | _parsePosition = newPos; |
| 34 | } |
| 35 | if (_plugin->isDataModelStreaming()) { |
| 36 | size_t endPos = 0; |
| 37 | bool still = _plugin->continueDataModelStreaming( |
| 38 | _dataBuffer, results, endPos); |
| 39 | if (still) { |
| 40 | return results; |
| 41 | } |
| 42 | _dataBuffer = (endPos < _dataBuffer.length()) |
| 43 | ? _dataBuffer.substr(endPos) : ""; |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | if (_streamState == StreamState::StreamingComponents) { |
| 48 | AGENUI_LOG("In component streaming mode"); |
| 49 | processStreamingData(results); |
| 50 | } else if (_streamState == StreamState::StreamingDataModel) { |
| 51 | AGENUI_LOG("In DataModel streaming mode"); |
| 52 | processStreamingDataModel(results); |
| 53 | } else { |
| 54 | // Otherwise process all complete events in the buffer |
| 55 | processAllCompleteEvents(results); |
| 56 | } |
| 57 | return results; |
| 58 | } |
| 59 | |
| 60 | bool ProtocolStreamExtractor::hasUnprocessedData() const { |
| 61 | return !_dataBuffer.empty(); |
no test coverage detected