xref: /haiku/headers/private/app/MessageAdapter.h (revision 2b76973fa2401f7a5edf68e6470f3d3210cbcff3)
1 /*
2  * Copyright 2007, Haiku Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Michael Lotz <mmlr@mlotz.ch>
7  */
8 #ifndef _MESSAGE_ADAPTER_H_
9 #define _MESSAGE_ADAPTER_H_
10 
11 #include <Message.h>
12 #include <util/KMessage.h>
13 
14 // message formats
15 #define MESSAGE_FORMAT_R5				'FOB1'
16 #define MESSAGE_FORMAT_R5_SWAPPED		'1BOF'
17 #define MESSAGE_FORMAT_DANO				'FOB2'
18 #define MESSAGE_FORMAT_DANO_SWAPPED		'2BOF'
19 #define MESSAGE_FORMAT_HAIKU			'1FMH'
20 #define MESSAGE_FORMAT_HAIKU_SWAPPED	'HMF1'
21 
22 namespace BPrivate {
23 
24 class MessageAdapter {
25 public:
26 static	ssize_t			FlattenedSize(uint32 format, const BMessage *from);
27 
28 static	status_t		Flatten(uint32 format, const BMessage *from,
29 							char *buffer, ssize_t *size);
30 static	status_t		Flatten(uint32 format, const BMessage *from,
31 							BDataIO *stream, ssize_t *size);
32 
33 static	status_t		Unflatten(uint32 format, BMessage *into,
34 							const char *buffer);
35 static	status_t		Unflatten(uint32 format, BMessage *into,
36 							BDataIO *stream);
37 
38 private:
39 static	status_t		_ConvertKMessage(const KMessage *from, BMessage *to);
40 
41 static	ssize_t			_R5FlattenedSize(const BMessage *from);
42 
43 static	status_t		_FlattenR5Message(uint32 format, const BMessage *from,
44 							char *buffer, ssize_t *size);
45 
46 static	status_t		_UnflattenR5Message(uint32 format, BMessage *into,
47 							BDataIO *stream);
48 static	status_t		_UnflattenDanoMessage(uint32 format, BMessage *into,
49 							BDataIO *stream);
50 };
51 
52 } // namespace BPrivate
53 
54 #endif // _MESSAGE_ADAPTER_H_
55