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 13 // message formats 14 #define MESSAGE_FORMAT_R5 'FOB1' 15 #define MESSAGE_FORMAT_R5_SWAPPED '1BOF' 16 #define MESSAGE_FORMAT_DANO 'FOB2' 17 #define MESSAGE_FORMAT_DANO_SWAPPED '2BOF' 18 #define MESSAGE_FORMAT_HAIKU '1FMH' 19 #define MESSAGE_FORMAT_HAIKU_SWAPPED 'HMF1' 20 21 namespace BPrivate { 22 23 class MessageAdapter { 24 public: 25 static ssize_t FlattenedSize(uint32 format, const BMessage *from); 26 27 static status_t Flatten(uint32 format, const BMessage *from, 28 char *buffer, ssize_t *size); 29 static status_t Flatten(uint32 format, const BMessage *from, 30 BDataIO *stream, ssize_t *size); 31 32 static status_t Unflatten(uint32 format, BMessage *into, 33 const char *buffer); 34 static status_t Unflatten(uint32 format, BMessage *into, 35 BDataIO *stream); 36 37 private: 38 static ssize_t _R5FlattenedSize(const BMessage *from); 39 40 static status_t _FlattenR5Message(uint32 format, const BMessage *from, 41 char *buffer, ssize_t *size); 42 43 static status_t _UnflattenR5Message(uint32 format, BMessage *into, 44 BDataIO *stream); 45 static status_t _UnflattenDanoMessage(uint32 format, BMessage *into, 46 BDataIO *stream); 47 }; 48 49 } // namespace BPrivate 50 51 #endif // _MESSAGE_ADAPTER_H_ 52