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