1*e6fa1be5SAndrew Lindesay /* 2*e6fa1be5SAndrew Lindesay * Copyright 2017, Andrew Lindesay <apl@lindesay.co.nz> 3*e6fa1be5SAndrew Lindesay * Distributed under the terms of the MIT License. 4*e6fa1be5SAndrew Lindesay */ 5*e6fa1be5SAndrew Lindesay #ifndef _JSON_MESSAGE_WRITER_H 6*e6fa1be5SAndrew Lindesay #define _JSON_MESSAGE_WRITER_H 7*e6fa1be5SAndrew Lindesay 8*e6fa1be5SAndrew Lindesay 9*e6fa1be5SAndrew Lindesay #include "JsonWriter.h" 10*e6fa1be5SAndrew Lindesay 11*e6fa1be5SAndrew Lindesay #include <Message.h> 12*e6fa1be5SAndrew Lindesay #include <String.h> 13*e6fa1be5SAndrew Lindesay 14*e6fa1be5SAndrew Lindesay 15*e6fa1be5SAndrew Lindesay enum json_message_container_what { 16*e6fa1be5SAndrew Lindesay B_JSON_MESSAGE_WHAT_OBJECT = '_JTM', 17*e6fa1be5SAndrew Lindesay B_JSON_MESSAGE_WHAT_ARRAY = '_JTA' 18*e6fa1be5SAndrew Lindesay }; 19*e6fa1be5SAndrew Lindesay 20*e6fa1be5SAndrew Lindesay 21*e6fa1be5SAndrew Lindesay namespace BPrivate { 22*e6fa1be5SAndrew Lindesay 23*e6fa1be5SAndrew Lindesay class BStackedMessageEventListener; 24*e6fa1be5SAndrew Lindesay 25*e6fa1be5SAndrew Lindesay class BJsonMessageWriter : public BJsonWriter { 26*e6fa1be5SAndrew Lindesay friend class BStackedMessageEventListener; 27*e6fa1be5SAndrew Lindesay public: 28*e6fa1be5SAndrew Lindesay BJsonMessageWriter(BMessage& message); 29*e6fa1be5SAndrew Lindesay virtual ~BJsonMessageWriter(); 30*e6fa1be5SAndrew Lindesay 31*e6fa1be5SAndrew Lindesay bool Handle(const BJsonEvent& event); 32*e6fa1be5SAndrew Lindesay void Complete(); 33*e6fa1be5SAndrew Lindesay 34*e6fa1be5SAndrew Lindesay private: 35*e6fa1be5SAndrew Lindesay void SetStackedListener( 36*e6fa1be5SAndrew Lindesay BStackedMessageEventListener* listener); 37*e6fa1be5SAndrew Lindesay 38*e6fa1be5SAndrew Lindesay BMessage* fTopLevelMessage; 39*e6fa1be5SAndrew Lindesay BStackedMessageEventListener* 40*e6fa1be5SAndrew Lindesay fStackedListener; 41*e6fa1be5SAndrew Lindesay }; 42*e6fa1be5SAndrew Lindesay 43*e6fa1be5SAndrew Lindesay 44*e6fa1be5SAndrew Lindesay } // namespace BPrivate 45*e6fa1be5SAndrew Lindesay 46*e6fa1be5SAndrew Lindesay using BPrivate::BJsonMessageWriter; 47*e6fa1be5SAndrew Lindesay 48*e6fa1be5SAndrew Lindesay #endif // _JSON_MESSAGE_WRITER_H 49