1/*
2 * Copyright 2014, Augustin Cavalier (waddlesplash)
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef MESSAGE_BUILDER_H
6#define MESSAGE_BUILDER_H
7
8
9#include <Message.h>
10#include <ObjectList.h>
11#include <String.h>
12
13namespace BPrivate {
14
15class BMessageBuilder {
16public:
17								BMessageBuilder(BMessage& message);
18
19			status_t 			PushObject(const char* name);
20			status_t 			PushObject(uint32 name);
21			status_t 			PopObject();
22
23			uint32				What();
24			void				SetWhat(uint32 what);
25
26			uint32				CountNames(type_code type = B_ANY_TYPE);
27
28			// Copied from Message.h
29			status_t			AddString(const char* name, const char* string);
30			status_t			AddString(const char* name,
31									const BString& string);
32			status_t			AddInt8(const char* name, int8 value);
33			status_t			AddUInt8(const char* name, uint8 value);
34			status_t			AddInt16(const char* name, int16 value);
35			status_t			AddUInt16(const char* name, uint16 value);
36			status_t			AddInt32(const char* name, int32 value);
37			status_t			AddUInt32(const char* name, uint32 value);
38			status_t			AddInt64(const char* name, int64 value);
39			status_t			AddUInt64(const char* name, uint64 value);
40			status_t			AddBool(const char* name, bool value);
41			status_t			AddFloat(const char* name, float value);
42			status_t			AddDouble(const char* name, double value);
43			status_t			AddPointer(const char* name,
44									const void* pointer);
45
46private:
47			BObjectList<BMessage>	fStack;
48			BObjectList<BString>	fNameStack;
49			BMessage*			fCurrentMessage;
50};
51
52} // namespace BPrivate
53
54#endif	// MESSAGE_BUILDER_H
55