xref: /haiku/headers/private/app/MessageAdapter.h (revision 5ce80a78c976c96d3afe4e9bd9eb473cb54c362c)
15dc45eb4SMichael Lotz /*
24d50aa32SAxel Dörfler  * Copyright 2007-2015, Haiku Inc. All rights reserved.
35dc45eb4SMichael Lotz  * Distributed under the terms of the MIT License.
45dc45eb4SMichael Lotz  *
55dc45eb4SMichael Lotz  * Authors:
65dc45eb4SMichael Lotz  *		Michael Lotz <mmlr@mlotz.ch>
75dc45eb4SMichael Lotz  */
85dc45eb4SMichael Lotz #ifndef _MESSAGE_ADAPTER_H_
95dc45eb4SMichael Lotz #define _MESSAGE_ADAPTER_H_
105dc45eb4SMichael Lotz 
114d50aa32SAxel Dörfler 
125dc45eb4SMichael Lotz #include <Message.h>
135dc45eb4SMichael Lotz #include <util/KMessage.h>
145dc45eb4SMichael Lotz 
154d50aa32SAxel Dörfler 
165dc45eb4SMichael Lotz // message formats
175dc45eb4SMichael Lotz #define MESSAGE_FORMAT_R5				'FOB1'
185dc45eb4SMichael Lotz #define MESSAGE_FORMAT_R5_SWAPPED		'1BOF'
195dc45eb4SMichael Lotz #define MESSAGE_FORMAT_DANO				'FOB2'
205dc45eb4SMichael Lotz #define MESSAGE_FORMAT_DANO_SWAPPED		'2BOF'
215dc45eb4SMichael Lotz #define MESSAGE_FORMAT_HAIKU			'1FMH'
225dc45eb4SMichael Lotz #define MESSAGE_FORMAT_HAIKU_SWAPPED	'HMF1'
235dc45eb4SMichael Lotz 
244d50aa32SAxel Dörfler 
255dc45eb4SMichael Lotz namespace BPrivate {
265dc45eb4SMichael Lotz 
274d50aa32SAxel Dörfler 
285dc45eb4SMichael Lotz class MessageAdapter {
295dc45eb4SMichael Lotz public:
304d50aa32SAxel Dörfler 	static	ssize_t				FlattenedSize(uint32 format,
314d50aa32SAxel Dörfler 									const BMessage* from);
325dc45eb4SMichael Lotz 
335dc45eb4SMichael Lotz 	static	status_t			Flatten(uint32 format, const BMessage* from,
345dc45eb4SMichael Lotz 									char* buffer, ssize_t* size);
355dc45eb4SMichael Lotz 	static	status_t			Flatten(uint32 format, const BMessage* from,
365dc45eb4SMichael Lotz 									BDataIO* stream, ssize_t* size);
375dc45eb4SMichael Lotz 
385dc45eb4SMichael Lotz 	static	status_t			Unflatten(uint32 format, BMessage* into,
395dc45eb4SMichael Lotz 									const char* buffer);
405dc45eb4SMichael Lotz 	static	status_t			Unflatten(uint32 format, BMessage* into,
415dc45eb4SMichael Lotz 									BDataIO* stream);
425dc45eb4SMichael Lotz 
43*5ce80a78SAxel Dörfler 	static	status_t			ConvertToKMessage(const BMessage* from,
44*5ce80a78SAxel Dörfler 									KMessage& to);
45*5ce80a78SAxel Dörfler 
465dc45eb4SMichael Lotz private:
474d50aa32SAxel Dörfler 	static	status_t			_ConvertFromKMessage(const KMessage* from,
484d50aa32SAxel Dörfler 									BMessage* to);
495dc45eb4SMichael Lotz 
505dc45eb4SMichael Lotz 	static	ssize_t				_R5FlattenedSize(const BMessage* from);
515dc45eb4SMichael Lotz 
524d50aa32SAxel Dörfler 	static	status_t			_FlattenR5Message(uint32 format,
534d50aa32SAxel Dörfler 									const BMessage* from, char* buffer,
544d50aa32SAxel Dörfler 									ssize_t* size);
555dc45eb4SMichael Lotz 
564d50aa32SAxel Dörfler 	static	status_t			_UnflattenR5Message(uint32 format,
574d50aa32SAxel Dörfler 									BMessage* into, BDataIO* stream);
584d50aa32SAxel Dörfler 	static	status_t			_UnflattenDanoMessage(uint32 format,
594d50aa32SAxel Dörfler 									BMessage* into, BDataIO* stream);
605dc45eb4SMichael Lotz };
615dc45eb4SMichael Lotz 
624d50aa32SAxel Dörfler 
635dc45eb4SMichael Lotz } // namespace BPrivate
645dc45eb4SMichael Lotz 
654d50aa32SAxel Dörfler 
665dc45eb4SMichael Lotz #endif // _MESSAGE_ADAPTER_H_
67