From d75e8b40b9ba3048272595254451c4a4b01ebc38 Mon Sep 17 00:00:00 2001 From: Alligator Descartes Date: Fri, 2 Dec 2016 10:07:11 +0000 Subject: [PATCH] Added reset() to reuse parser --- JsonStreamingParser.cpp | 4 ++++ JsonStreamingParser.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/JsonStreamingParser.cpp b/JsonStreamingParser.cpp index 5fa2a24..95fd05b 100644 --- a/JsonStreamingParser.cpp +++ b/JsonStreamingParser.cpp @@ -26,6 +26,10 @@ See more at http://blog.squix.ch and https://github.com/squix78/json-streaming-p #include "JsonStreamingParser.h" JsonStreamingParser::JsonStreamingParser() { + reset(); +} + +void JsonStreamingParser::reset() { state = STATE_START_DOCUMENT; bufferPos = 0; unicodeEscapeBufferPos = 0; diff --git a/JsonStreamingParser.h b/JsonStreamingParser.h index 926cd4e..377e846 100644 --- a/JsonStreamingParser.h +++ b/JsonStreamingParser.h @@ -131,5 +131,5 @@ class JsonStreamingParser { JsonStreamingParser(); void parse(char c); void setListener(JsonListener* listener); - + void reset(); };