xref: /haiku/headers/os/app/PropertyInfo.h (revision bb17b6b92ffa8beb0c6cad7e7b7e0f4490154c37)
1 /*******************************************************************************
2 /
3 /	File:			PropertyInfo.h
4 /
5 /	Description:	Utility class for maintain scripting information
6 /
7 /	Copyright 1997-98, Be Incorporated, All Rights Reserved
8 /   Modified for use with OpenBeOS.
9 /
10 *******************************************************************************/
11 
12 #ifndef _PROPERTY_INFO_H
13 #define _PROPERTY_INFO_H
14 
15 #include <BeBuild.h>
16 #include <SupportDefs.h>
17 #include <Flattenable.h>
18 #include <TypeConstants.h>	/* For convenience */
19 
20 /*
21  * The following define is used to turn off a number of member functions
22  * and member variables in BPropertyInfo which are only there to faciliate
23  * BeOS R3 compatibility.  Be changed the property_info structure between
24  * R3 and R4 and these functions ensure that BPropertyInfo is backward
25  * compatible.  However, between R3 and R4, Be changed the Intel executable
26  * format so R4 was not backward compatible with R3.
27  *
28  * Because OpenBeOS is only targetting Intel platform compatibility at this
29  * time, there is no need for R3 compatibility in OpenBeOS.  By default
30  * these members will be turned off with the R3_COMPATIBLE define.
31  */
32 #undef R3_COMPATIBLE
33 
34 #ifdef R3_COMPATIBLE
35 struct _oproperty_info_;
36 #endif
37 
38 
39 /*----------------------------------------------------------------*/
40 /*----- the property_info structure ------------------------------*/
41 
42 struct compound_type {
43 	struct field_pair {
44 #if __GNUC__ > 2
45 		const
46 #endif
47 		char		*name;			// name of entry in message
48 		type_code	type;			// type_code of entry in message
49 	};
50 	field_pair	pairs[5];
51 };
52 
53 struct property_info {
54 #if __GNUC__ > 2
55 	const
56 #endif
57 	char			*name;
58 	uint32			commands[10];
59 	uint32			specifiers[10];
60 #if __GNUC__ > 2
61 	const
62 #endif
63 	char 			*usage;
64 	uint32			extra_data;
65 	uint32			types[10];
66 	compound_type	ctypes[3];
67 	uint32			_reserved[10];
68 };
69 
70 enum value_kind {
71 	B_COMMAND_KIND = 0,
72 	B_TYPE_CODE_KIND = 1
73 };
74 
75 struct value_info {
76 #if __GNUC__ > 2
77 	const
78 #endif
79 	char			*name;
80 	uint32			value;
81 	value_kind		kind;
82 #if __GNUC__ > 2
83 	const
84 #endif
85 	char			*usage;
86 	uint32			extra_data;
87 	uint32			_reserved[10];
88 };
89 
90 /*----------------------------------------------------------------*/
91 /*----- BPropertyInfo class --------------------------------------*/
92 
93 class BPropertyInfo : public BFlattenable {
94 public:
95 								BPropertyInfo(property_info *p = NULL,
96 												value_info *ci = NULL,
97 												bool free_on_delete = false);
98 virtual							~BPropertyInfo();
99 
100 virtual	int32					FindMatch(BMessage *msg,
101 											int32 index,
102 											BMessage *spec,
103 											int32 form,
104 											const char *prop,
105 											void *data = NULL) const;
106 
107 virtual	bool					IsFixedSize() const;
108 virtual	type_code				TypeCode() const;
109 virtual	ssize_t					FlattenedSize() const;
110 virtual	status_t				Flatten(void *buffer, ssize_t size) const;
111 virtual	bool					AllowsTypeCode(type_code code) const;
112 virtual	status_t				Unflatten(type_code c,
113 											const void *buf,
114 											ssize_t s);
115 		const property_info		*Properties() const;
116 		const value_info		*Values() const;
117 		int32					CountProperties() const;
118 		int32					CountValues() const;
119 
120 		void					PrintToStream() const;
121 
122 /*----- Private or reserved -----------------------------------------*/
123 protected:
124 static	bool					FindCommand(uint32, int32, property_info *);
125 static	bool					FindSpecifier(uint32, property_info *);
126 
127 private:
128 virtual	void					_ReservedPropertyInfo1();
129 virtual	void					_ReservedPropertyInfo2();
130 virtual	void					_ReservedPropertyInfo3();
131 virtual	void					_ReservedPropertyInfo4();
132 
133 							BPropertyInfo(const BPropertyInfo &);
134 		BPropertyInfo		&operator=(const BPropertyInfo &);
135 		void				FreeMem();
136 
137 		property_info		*fPropInfo;
138 		value_info			*fValueInfo;
139 		int32				fPropCount;
140 		bool				fInHeap;
141 		uint16				fValueCount;
142 #ifndef R3_COMPATIBLE
143 		uint32				_reserved[4];
144 #else
145 		_oproperty_info_	*fOldPropInfo;
146 		bool				fOldInHeap;
147 		uint32				_reserved[2]; /* was 4 */
148 
149 		/* Deprecated */
150 private:
151 static	property_info		*ConvertToNew(const _oproperty_info_ *p);
152 static	_oproperty_info_	*ConvertFromNew(const property_info *p);
153 		const property_info		*PropertyInfo() const;
154 								BPropertyInfo(property_info *p,
155 												bool free_on_delete);
156 static	bool					MatchCommand(uint32, int32, property_info *);
157 static	bool					MatchSpecifier(uint32, property_info *);
158 
159 #endif
160 };
161 
162 /*-------------------------------------------------------------*/
163 /*-------------------------------------------------------------*/
164 
165 #endif /* _PROPERTY_INFO_H */
166