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 status_t StreamStringUnicodeCharacter(uint32 c); 43 44 status_t StreamQuotedEncodedString(const char* string); 45 status_t StreamQuotedEncodedString(const char* string, 46 off_t offset, size_t length); 47 48 status_t StreamChar(char c); 49 50 BDataIO* fDataIO; 51 BJsonTextWriterStackedEventListener* 52 fStackedListener; 53 54 char fUnicodeAssemblyBuffer[7]; 55 56 }; 57 58 } // namespace BPrivate 59 60 using BPrivate::BJsonTextWriter; 61 62 #endif // _JSON_STRING_STREAM_WRITER_H 63