1 /* 2 * Copyright 2017, Andrew Lindesay <apl@lindesay.co.nz> 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _JSON_STRING_STREAM_WRITER_H 6 #define _JSON_STRING_STREAM_WRITER_H 7 8 9 #include "JsonWriter.h" 10 11 #include <DataIO.h> 12 #include <String.h> 13 14 15 namespace BPrivate { 16 17 class BJsonTextWriterStackedEventListener; 18 19 class BJsonTextWriter : public BJsonWriter { 20 friend class BJsonTextWriterStackedEventListener; 21 public: 22 BJsonTextWriter(BDataIO* dataIO); 23 virtual ~BJsonTextWriter(); 24 25 bool Handle(const BJsonEvent& event); 26 void Complete(); 27 28 private: 29 void SetStackedListener( 30 BJsonTextWriterStackedEventListener* 31 stackedListener); 32 33 status_t StreamNumberNode(const BJsonEvent& event); 34 35 status_t StreamStringVerbatim(const char* string); 36 status_t StreamStringVerbatim(const char* string, 37 off_t offset, size_t length); 38 39 status_t StreamStringEncoded(const char* string); 40 status_t StreamStringEncoded(const char* string, 41 off_t offset, size_t length); 42 43 status_t StreamQuotedEncodedString(const char* string); 44 status_t StreamQuotedEncodedString(const char* string, 45 off_t offset, size_t length); 46 47 status_t StreamChar(char c); 48 49 BDataIO* fDataIO; 50 BJsonTextWriterStackedEventListener* 51 fStackedListener; 52 53 char fUnicodeAssemblyBuffer[7]; 54 55 }; 56 57 } // namespace BPrivate 58 59 using BPrivate::BJsonTextWriter; 60 61 #endif // _JSON_STRING_STREAM_WRITER_H 62