2007-06-28 00:22:53 +04:00
|
|
|
/*
|
2015-04-29 11:44:36 +03:00
|
|
|
* Copyright 2007-2015, Haiku Inc. All rights reserved.
|
2007-06-28 00:22:53 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Michael Lotz <mmlr@mlotz.ch>
|
|
|
|
*/
|
|
|
|
#ifndef _MESSAGE_ADAPTER_H_
|
|
|
|
#define _MESSAGE_ADAPTER_H_
|
|
|
|
|
2015-04-29 11:44:36 +03:00
|
|
|
|
2007-06-28 00:22:53 +04:00
|
|
|
#include <Message.h>
|
|
|
|
#include <util/KMessage.h>
|
|
|
|
|
2015-04-29 11:44:36 +03:00
|
|
|
|
2007-06-28 00:22:53 +04:00
|
|
|
// message formats
|
|
|
|
#define MESSAGE_FORMAT_R5 'FOB1'
|
|
|
|
#define MESSAGE_FORMAT_R5_SWAPPED '1BOF'
|
|
|
|
#define MESSAGE_FORMAT_DANO 'FOB2'
|
|
|
|
#define MESSAGE_FORMAT_DANO_SWAPPED '2BOF'
|
|
|
|
#define MESSAGE_FORMAT_HAIKU '1FMH'
|
|
|
|
#define MESSAGE_FORMAT_HAIKU_SWAPPED 'HMF1'
|
|
|
|
|
2015-04-29 11:44:36 +03:00
|
|
|
|
2007-06-28 00:22:53 +04:00
|
|
|
namespace BPrivate {
|
|
|
|
|
2015-04-29 11:44:36 +03:00
|
|
|
|
2007-06-28 00:22:53 +04:00
|
|
|
class MessageAdapter {
|
|
|
|
public:
|
2015-04-29 11:44:36 +03:00
|
|
|
static ssize_t FlattenedSize(uint32 format,
|
|
|
|
const BMessage* from);
|
2007-06-28 00:22:53 +04:00
|
|
|
|
2015-04-29 11:44:36 +03:00
|
|
|
static status_t Flatten(uint32 format, const BMessage* from,
|
|
|
|
char* buffer, ssize_t* size);
|
|
|
|
static status_t Flatten(uint32 format, const BMessage* from,
|
|
|
|
BDataIO* stream, ssize_t* size);
|
2007-06-28 00:22:53 +04:00
|
|
|
|
2015-04-29 11:44:36 +03:00
|
|
|
static status_t Unflatten(uint32 format, BMessage* into,
|
|
|
|
const char* buffer);
|
|
|
|
static status_t Unflatten(uint32 format, BMessage* into,
|
|
|
|
BDataIO* stream);
|
2007-06-28 00:22:53 +04:00
|
|
|
|
2015-04-21 19:52:13 +03:00
|
|
|
static status_t ConvertToKMessage(const BMessage* from,
|
|
|
|
KMessage& to);
|
|
|
|
|
2007-06-28 00:22:53 +04:00
|
|
|
private:
|
2015-04-29 11:44:36 +03:00
|
|
|
static status_t _ConvertFromKMessage(const KMessage* from,
|
|
|
|
BMessage* to);
|
2007-06-28 00:22:53 +04:00
|
|
|
|
2015-04-29 11:44:36 +03:00
|
|
|
static ssize_t _R5FlattenedSize(const BMessage* from);
|
2007-06-28 00:22:53 +04:00
|
|
|
|
2015-04-29 11:44:36 +03:00
|
|
|
static status_t _FlattenR5Message(uint32 format,
|
|
|
|
const BMessage* from, char* buffer,
|
|
|
|
ssize_t* size);
|
2007-06-28 00:22:53 +04:00
|
|
|
|
2015-04-29 11:44:36 +03:00
|
|
|
static status_t _UnflattenR5Message(uint32 format,
|
|
|
|
BMessage* into, BDataIO* stream);
|
|
|
|
static status_t _UnflattenDanoMessage(uint32 format,
|
|
|
|
BMessage* into, BDataIO* stream);
|
2007-06-28 00:22:53 +04:00
|
|
|
};
|
|
|
|
|
2015-04-29 11:44:36 +03:00
|
|
|
|
2007-06-28 00:22:53 +04:00
|
|
|
} // namespace BPrivate
|
|
|
|
|
2015-04-29 11:44:36 +03:00
|
|
|
|
2007-06-28 00:22:53 +04:00
|
|
|
#endif // _MESSAGE_ADAPTER_H_
|