Merged changes from branch build_system_redesign at revision 14573.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14574 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright 2005, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Michael Lotz <[email protected]>
|
||||
*/
|
||||
|
||||
/* BMessageField contains the data for indiviual named fields in BMessageBody */
|
||||
|
||||
#ifndef _MESSAGE_FIELD_H_
|
||||
#define _MESSAGE_FIELD_H_
|
||||
|
||||
#include <List.h>
|
||||
#include <String.h>
|
||||
#include <SupportDefs.h>
|
||||
#include "MessageBody3.h"
|
||||
|
||||
// we only support those
|
||||
#define MSG_FLAG_VALID 0x01
|
||||
#define MSG_FLAG_FIXED_SIZE 0x04
|
||||
#define MSG_FLAG_ALL 0x05
|
||||
|
||||
// these are for R5 compatibility
|
||||
#define MSG_FLAG_MINI_DATA 0x02
|
||||
#define MSG_FLAG_SINGLE_ITEM 0x08
|
||||
|
||||
#define MSG_LAST_ENTRY 0x00
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
struct field_header_s {
|
||||
uint8 flags;
|
||||
type_code type;
|
||||
int32 count;
|
||||
ssize_t dataSize;
|
||||
uint8 nameLength;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
struct item_info_s {
|
||||
item_info_s(int32 _offset)
|
||||
: offset(_offset)
|
||||
{
|
||||
}
|
||||
|
||||
item_info_s(int32 _offset, int32 _length)
|
||||
: offset(_offset),
|
||||
length(_length)
|
||||
{
|
||||
}
|
||||
|
||||
int32 offset;
|
||||
int32 length;
|
||||
int32 paddedLength;
|
||||
};
|
||||
|
||||
typedef field_header_s FieldHeader;
|
||||
typedef item_info_s ItemInfo;
|
||||
|
||||
class BMessageField {
|
||||
public:
|
||||
BMessageField(BMessageBody *parent,
|
||||
int32 offset, const char *name,
|
||||
type_code type);
|
||||
|
||||
// only use this constructor to unflatten
|
||||
BMessageField(BMessageBody *parent);
|
||||
int32 Unflatten(int32 offset);
|
||||
|
||||
uint8 Flags() const { return Header()->flags; };
|
||||
status_t SetFixedSize(int32 itemSize);
|
||||
bool FixedSize() const { return fFixedSize; };
|
||||
|
||||
void SetName(const char *newName);
|
||||
const char *Name() const;
|
||||
uint8 NameLength() const { return Header()->nameLength; };
|
||||
type_code Type() const { return Header()->type; };
|
||||
|
||||
void AddItem(const void *item, ssize_t length);
|
||||
uint8 *AddItem(ssize_t length);
|
||||
|
||||
void ReplaceItem(int32 index, const void *newItem,
|
||||
ssize_t length);
|
||||
uint8 *ReplaceItem(int32 index, ssize_t length);
|
||||
|
||||
void *ItemAt(int32 index, ssize_t *size);
|
||||
|
||||
void RemoveItem(int32 index);
|
||||
int32 CountItems() const { return Header()->count; };
|
||||
|
||||
void PrintToStream() const;
|
||||
|
||||
void SetOffset(int32 offset) { fOffset = offset; };
|
||||
int32 Offset() const { return fOffset; };
|
||||
|
||||
// always do MakeEmpty -> RemoveSelf -> delete
|
||||
void MakeEmpty();
|
||||
void RemoveSelf();
|
||||
|
||||
// hash table support
|
||||
void SetNext(BMessageField *next) { fNext = next; };
|
||||
BMessageField *Next() const { return fNext; };
|
||||
|
||||
private:
|
||||
inline FieldHeader *Header() const { return (FieldHeader *)(fParent->FlatBuffer() + fOffset); };
|
||||
|
||||
BMessageBody *fParent;
|
||||
int32 fOffset;
|
||||
int32 fDataOffset;
|
||||
|
||||
bool fFixedSize;
|
||||
int32 fItemSize;
|
||||
BList fItemInfos;
|
||||
|
||||
BMessageField *fNext;
|
||||
};
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
#endif // _MESSAGE_FIELD_H_
|
||||
Reference in New Issue
Block a user