root/haiku/trunk/docs/user/app/Message.dox

Revision 23170, 65.8 kB (checked in by nielx, 5 months ago)
Add a note about using messages for data storage. Thanks to mlotz for telling me this functionality was underexposed in the current docs.
Line 
1 /*
2  * Copyright 2007, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *              Niels Sascha Reedijk, niels.reedijk@gmail.com
7  *
8  * Corresponds to:
9  *              /trunk/headers/os/app/Message.h  rev 21562
10  *              /trunk/src/kits/app/Message.cpp  rev 22240
11  */
12
13
14 /*!
15         \file Message.h
16         \brief Provides the BMessage class.
17 */
18
19 ///// Name lengths and Scripting specifiers /////
20
21 /*!
22         \def B_FIELD_NAME_LENGTH
23         \brief Undocumented...
24 */
25
26
27 /*!
28         \def B_PROPERTY_NAME_LENGTH
29         \brief Undocumented...
30 */
31
32
33 /*!
34         \var B_NO_SPECIFIER
35         \brief Undocumented...
36 */
37
38
39 /*!
40         \var B_DIRECT_SPECIFIER
41         \brief Undocumented...
42 */
43
44
45 /*!
46         \var B_INDEX_SPECIFIER
47         \brief Undocumented...
48 */
49
50
51 /*!
52         \var B_REVERSE_INDEX_SPECIFIER,
53         \brief Undocumented...
54 */
55
56
57 /*!
58         \var B_RANGE_SPECIFIER
59         \brief Undocumented...
60 */
61
62
63 /*!
64         \var B_REVERSE_RANGE_SPECIFIER
65         \brief Undocumented...
66 */
67
68
69 /*!
70         \var B_NAME_SPECIFIER
71         \brief Undocumented...
72 */
73
74
75 /*!     
76         \var B_ID_SPECIFIER
77         \brief Undocumented...
78 */
79
80
81 /*!
82         \var B_SPECIFIERS_END
83         \brief Undocumented...
84 */
85
86
87 ///// Class BMessage /////
88
89
90 /*!
91         \class BMessage
92         \ingroup app
93         \brief A container that can be send and received using the Haiku messaging
94                 subsystem.
95        
96         This class is at the center of the web of messaging classes, in the sense
97         that it defines the actual structure of the messages. Messages have two
98         <b>important elements</b>: the #what identifer, and the data members. The
99         first can be directly manipulated, the latter can be manipulated through
100         AddData(), FindData() and ReplaceData() and their deratives. Neither of
101         these elements are mandatory.
102        
103         The second important role of BMessage is that it stores <b>meta data</b>:
104         who sent the message and with what intention? The methods of BMessage will
105         disclose if the message was a reply (IsReply()), where it came from
106         (IsSourceRemote()), whether a reply is expected (IsSourceWaiting()), and in
107         case the message is a reply, what it's a reply to (Previous()).
108        
109         Mostly, messages are used to pass information between the the objects in
110         your application, but because messages are such flexible data containers,
111         they are also often used for other <b>data storage purposes</b>. Many
112         applications store their settings as messages. Because messages can be
113         flattened to data streams (such as files), they provide an easy but
114         powerful tool for data storage.
115        
116         All methods can be classified in these areas:
117         - Adding, Finding, Replacing and Removing Data.
118         - Statistics and Miscelanous information.
119         - Delivery information.
120         - Utilities to reply to messages.
121        
122         To see how messages fit in with the greater picture, have a look at the
123         \ref app_messaging "Messaging Introduction".
124 */
125
126
127 /*!
128         \var BMessage::what
129         \brief A 4-byte constant that determines the type of message.
130        
131         You can directly manipulate this data member.
132 */
133
134
135 /*!
136         \fn BMessage::BMessage()
137         \brief Construct an empty message, without any data members and with a
138                 \c what constant set to zero (0).
139        
140         \see BMessage(uint32 what)
141         \see BMessage(const BMessage &other)
142 */
143
144
145 /*!
146         \fn BMessage::BMessage(uint32 what)
147         \brief Construct an empty message with the \c what member set tot the
148                 specified value.
149        
150         \see BMessage::BMessage()
151         \see BMessage::BMessage(const BMessage &other)
152 */
153
154
155 /*!
156         \fn BMessage::BMessage(const BMessage &other)
157         \brief Construct a new message that is a copy of another message.
158        
159         The \c what member and the data values are copied. The metadata, such as
160         whether or not the message is a drop message or reply information, is
161         not copied. So if the original message is a reply to a previous message,
162         which will make IsReply() return \c true, calling the same method on a copy
163         of the message will return \c false.
164        
165         \remarks BeOS R5 did keep the metadata of the message. Haiku deviates from
166         this behaviour. Please use the Haiku implementation of message copying as
167         the default behavior. This will keep your applications backwards
168         compatible.
169
170         \see BMessage::BMessage()
171         \see BMessage(uint32 what)
172 */
173
174
175 /*!
176         \fn BMessage::~BMessage()
177         \brief Free the data members associated with the message.
178        
179         If there still is a sender waiting for a reply, the \c B_NO_REPLY message
180         will be sent to inform them that there won't be a reply.
181 */
182
183
184 /*!
185         \fn BMessage &BMessage::operator=(const BMessage &other)
186         \brief Copy one message into another.
187        
188         See the copy constructor, BMessage(const BMessage &other), for details on what is
189         copied, and what isn't.
190 */
191
192
193 /*!
194         \name Statistics and Miscelanous Information
195 */
196
197
198 //! @{
199  
200
201 /*!
202         \fn status_t BMessage::GetInfo(type_code typeRequested, int32 index,
203                 char **nameFound, type_code *typeFound, int32 *countFound) const
204         \brief Retrieve the name, the type and the number of items in a message by
205                 an \a index.
206        
207         \param[in] typeRequested If you want to limit the search to only one type,
208                 pass that type code here. If you don't care which type the data has,
209                 you can pass \c B_ANY_TYPE.
210         \param[in] index The index of the data you want to investigate.
211         \param[out] nameFound The name of the item if it is found. Haiku will fill
212                 in a pointer to the internal name buffer in the message. This means
213                 that you should not manipulate this name. If you are not interested in
214                 the name, you can safely pass \c NULL.
215         \param[out] typeFound The type of the item at \a index. If you are not
216                 interested in the type (because you specifically asked for a type), you
217                 can safely pass NULL.
218         \param[out] countFound The number of items at \a index. If data items have
219                 the same name, they will be placed under the same index.
220                
221         \return If the \a index is found, and matches the requested type, the
222                 other parameters will be filled in. If this is not the case, the method
223                 will return with an error.
224        
225         \retval B_OK An match was found. The values have been filled in.
226         \retval B_BAD_INDEX The \a index was out of range. None of the passed
227                 variables have been altered.
228         \retval B_BAD_TYPE The data field at \a index does not have the requested
229                 type.
230 */
231
232
233 /*!
234         \fn status_t BMessage::GetInfo(const char *name, type_code *typeFound,
235                 int32 *countFound) const
236         \brief Retrieve the type and the number of data items in this message that
237                 are associated with a \a name.
238        
239         \param[in] name The name of the data member that you are looking for.
240         \param[out] typeFound In case of a match, the name of the data member will
241                 be put in this parameter. In case you are not interested, you can pass
242                 \c NULL.
243         \param[out] countFound In case of a match, the number of items at this
244                 label will be in this parameter. In case you are not interested, you
245                 can safely pass \c NULL.
246        
247         \return If the message has data associated with the given \a name, the
248                 other parameters will contain information associated with the data.
249                 Else, the method will return with an error.
250        
251         \retval B_OK A match was found. The other parameters have been filled in.
252         \retval B_BAD_VALUE You passed \c NULL as argument to \a name.
253         \retval B_NAME_NOT_FOUND There is no data with the label \a name.
254 */
255
256
257 /*!
258         \fn status_t BMessage::GetInfo(const char *name, type_code *typeFound,
259                 bool *fixedSize) const
260         \brief Retrieve the type and whether or not the size of the data is fixed
261                 associated with a \a name.
262        
263         This method is the same as GetInfo(const char *,type_code *, int32 *) const , with the difference that you can find out whether or
264         not the size of the data associated with the \a name is fixed. You will
265         get this value in the variable you passed as \a fixedSize parameter.
266 */
267
268
269 /*!
270         \fn int32 BMessage::CountNames(type_code type) const
271         \brief Count the number of names of a certain \a type.
272        
273         This method can be used to count the number of items of a certain type.
274         It's practical use is limited to debugging purposes.
275        
276         \param type The type you want to find. If you pass \c B_ANY_TYPE, this
277                 method will return the total number of data items.
278        
279         \return The number of data items in this message with the specified
280                 \a type, or zero in case no items match the type.
281 */
282
283
284 /*!
285         \fn bool BMessage::IsEmpty() const
286         \brief Check if the message has data members.
287        
288         \return If this message contains data members, this method will return
289                 \c true, else it will return \c false.
290         \see MakeEmpty()
291 */
292
293
294 /*!
295         \fn bool BMessage::IsSystem() const
296         \brief Check if the message is a system message.
297        
298         \return If this message is a system message, the method will return
299                 \c true.
300 */
301
302
303 /*!
304         \fn bool BMessage::IsReply() const
305         \brief Check if the message is a reply to a (previous) message.
306        
307         \return If this message is a reply, this method will return \c true.
308 */
309
310
311 /*!
312         \fn void BMessage::PrintToStream() const
313         \brief Print the message to the standard output.
314        
315         This method can be used to debug your application. It can be used to check
316         if it creates the messages properly, by checking if all the required fields
317         are present, and it can be used to debug your message handling routines,
318         especially the handling of those that are sent by external applications, to
319         see if you understand the semantics correctly.
320 */
321
322
323 /*!
324         \fn status_t BMessage::Rename(const char *oldEntry, const char *newEntry)
325         \brief Rename a data label.
326        
327         \param oldEntry The name of the label you want to rename.
328         \param newEntry The new name of the data entry.
329        
330         \retval B_OK Renaming succeeded.
331         \retval B_BAD_VALUE Either the \a oldEntry or the \a newEntry pointers are
332                 \c NULL.
333         \retval B_NAME_NOT_FOUND There is no data associated with the label
334                 \a oldEntry.
335 */
336
337
338 //! @}
339
340 /*!
341         \name Delivery Info
342 */
343
344 //! @{
345
346
347 /*!
348         \fn bool BMessage::WasDelivered() const
349         \brief Check if this message was delivered through the delivery methods.
350        
351         If this message is passed via a BMessenger or BLooper::PostMessage(), this
352         method will return \c true.
353        
354         \warning This method should not be abused by a thread that sends a message
355                 to track whether or not a message was delivered. This is because the
356                 ownership of the message goes to the receiving looper, which will
357                 delete the message as soon as it is done with it.
358        
359         \warning If you need to check whether a message is delivered, you should
360                 either ask for a reply, or use one of the synchronous
361                 BMessenger::SendMessage() methods.
362 */
363
364
365 /*!
366         \fn bool BMessage::IsSourceWaiting() const
367         \brief Check if the sender expects a reply.
368        
369         This method will return \c true, if the sender flagged that it is waiting
370         for a reply, and such a reply has not yet been sent.
371 */
372
373
374 /*!
375         \fn bool BMessage::IsSourceRemote() const
376         \brief Check if the message is sent by another application.
377 */
378
379
380 /*!
381         \fn BMessenger BMessage::ReturnAddress() const
382         \brief Get a messenger that points to the sender of the message.
383        
384         Using this method, you can fetch a BMessenger that can be used to deliver
385         replies to this message. This method works both for local and remote
386         deliveries.
387        
388         For remote deliveries, this approach is preferred over sending the reply
389         using a standard BMessenger that is created with the signature of the
390         application. A standard BMessenger sends the messages to the main BLooper
391         of the application, the BApplication object. With the delivery data stored
392         in the messages, the reply using this messenger will be directed at a
393         specific looper that is able to handle the replies.
394        
395         If this method is called on a message that has not been delivered (yet),
396         it will return an empty BMessenger object.
397 */
398
399
400 /*!
401         \fn const BMessage *BMessage::Previous() const
402         \brief Get the message to which this message is a reply.
403        
404         \return Returns a new BMessage with the same data stuctures as the message
405                 to which this message is a reply. You get the ownership of this
406                 message, so free it when you're done. If this message isn't a reply to
407                 another message, this method will return \c NULL.
408 */
409
410
411 /*!
412         \fn bool BMessage::WasDropped() const
413         \brief Check if the message was delivered through 'drag and drop'.
414        
415         \return This method returns \c true if the message has been delivered
416                 through drag and drop. It returns \c false if it has been delivered
417                 through the regular messaging functions, or if the message has not
418                 been delivered at all.
419         \see DropPoint()
420 */
421
422
423 /*!
424         \fn BPoint BMessage::DropPoint(BPoint *offset) const
425         \brief Get the coordinates of the drop point of the message.
426        
427         If the message has been delivered because of drag and drop, which can be
428         verified with the WasDropped() method, this method will return a BPoint to
429         where exactly the drop off was made.
430        
431         Because drop messages are delivered to the BWindow in which they were
432         dropped, and BWindow is a subclass of BLooper, you can use BWindow to
433         determine based on the location, how you should react to it.
434        
435         If this message was not delivered through drag and drop, it will return
436         a \c NULL pointer.
437        
438         \see WasDropped()
439 */
440
441
442 //! @}
443
444
445 /*!
446         \name Replying
447 */
448
449
450 //! @{
451
452
453 /*!
454         \fn status_t BMessage::SendReply(uint32 command, BHandler *replyTo)
455         \brief Asynchronously send a reply to this message.
456        
457         This is an overloaded member of SendReply(BMessage *, BMessenger, bigtime_t).
458         Use this variant if you want to send a message without data members.
459 */
460
461
462 /*!
463         \fn status_t BMessage::SendReply(BMessage *reply, BHandler *replyTo,
464                 bigtime_t timeout)
465         \brief Asynchronously send a reply to this message.
466        
467         This is an overloaded member of SendReply(BMessage *, BMessenger, bigtime_t).
468         Use this variant if you want to send the message to a specific handler
469         (instead of a complete messenger).
470 */     
471
472
473 /*!
474         \fn status_t BMessage::SendReply(BMessage *reply, BMessenger replyTo,
475                 bigtime_t timeout)
476         \brief Asynchronously send a reply to this message.
477        
478         This method sends a reply to this message to the sender. On your turn,
479         you specify a messenger that handles a reply back to the message you
480         specify as the \a reply argument. You can set a timeout for the message
481         to be delivered. This method blocks until the message has been received,
482         or the \a timeout has been reached.
483        
484         \param reply The message that is in reply to this message.
485         \param replyTo In case the receiver needs to reply to the message you are
486                 sending, you can specify the return address with this argument.
487         \param timeout The maximum time in microseconds this delivery may take. The
488                 \a timeout is a relative timeout. You can also use
489                 \c B_INFINITE_TIMEOUT if you want to wait infinitely for the message
490                 to be delivered.
491        
492         \retval B_OK The message has been delivered.
493         \retval B_DUPLICATE_REPLY There already has been a reply to this message.
494         \retval B_BAD_PORT_ID The reply address is not valid (anymore).
495         \retval B_WOULD_BLOCK The delivery \a timeout was \c B_INFINITE_TIMEOUT
496                 (zero) and the target port was full when trying to deliver the message.
497         \retval B_TIMED_OUT The timeout expired while trying to deliver the
498           message.
499         \see SendReply(uint32 command, BHandler *replyTo)
500 */
501
502
503 /*!
504         \fn status_t BMessage::SendReply(uint32 command, BMessage *replyToReply)
505         \brief Synchronously send a reply to this message, and wait for a reply
506                 back.
507        
508         This is an overloaded member of SendReply(BMessage *, BMessage *,
509         bigtime_t, bigtime_t) Use this variant if you want to send a message
510         without data members.
511 */
512
513
514 /*!
515         \fn status_t BMessage::SendReply(BMessage *reply, BMessage *replyToReply,
516                 bigtime_t sendTimeout, bigtime_t replyTimeout)
517         \brief  Synchronously send a reply to this message, and wait for a reply
518                  back.
519        
520         This method sends a reply to this message to the sender. The \a reply is
521         delivered, and then the method waits for a reply from the receiver. If a
522         reply is received, that reply is copied into the \a replyToReply argument.
523         If the message was delivered properly, but the receiver did not reply
524         within the specified \a replyTimeout, the \c what member of \a replyToReply
525         will be set to \c B_NO_REPLY.
526        
527         \param reply The message that is in reply to this message.
528         \param[out] replyToReply The reply is copied into this argument.
529         \param sendTimeout The maximum time in microseconds this delivery may take.
530                 The \a timeout is a relative timeout. You can also use
531                 \c B_INFINITE_TIMEOUT if you want to wait infinitely for the message
532                 to be delivered.
533         \param replyTimeout The maximum time in microseconds you want to wait for a
534                 reply. Note that the timer starts when the message has been delivered.
535        
536         \retval B_OK The message has been delivered.
537         \retval B_DUPLICATE_REPLY There already has been a reply to this message.
538         \retval B_BAD_VALUE Either \a reply or \a replyToReply is \c NULL.
539         \retval B_BAD_PORT_ID The reply address is not valid (anymore).
540         \retval B_WOULD_BLOCK The delivery \a timeout was \c B_INFINITE_TIMEOUT
541                 (zero) and the target port was full when trying to deliver the message.
542         \retval B_TIMED_OUT The timeout expired while trying to deliver the
543           message.
544         \retval B_NO_MORE_PORTS All reply ports are in use.
545         \see SendReply(uint32 command, BMessage *replyToReply)
546 */
547
548
549 //! @}
550
551
552 /*!
553         \name Flattening methods
554        
555         Because of historical reasons and for binary compatibility, this class
556         provides a flattening API without inheriting the BFlattenable class. The
557         API is more or less the same, but you are inconvenienced when you want to
558         use messages in methods that handle BFlattenable objects.
559 */
560
561
562 //! @{
563        
564
565 /*!
566         \fn ssize_t BMessage::FlattenedSize() const
567         \brief Return the size in bytes required when you want to flatten this
568                 message to a stream of bytes.
569 */
570
571
572 /*!
573         \fn status_t BMessage::Flatten(char *buffer, ssize_t size) const
574         \brief Flatten the message to a \a buffer.
575        
576         \param buffer The buffer to write the data to.
577         \param size The size of the buffer.
578        
579         \return \c B_OK in case of success, or an error code in case something went
580                 awry.
581        
582         \warning Make sure the buffer is large enough to hold the message. This
583                 method does not double-check for you!
584         \see FlattenedSize()
585         \see Flatten(BDataIO *stream, ssize_t *size) const
586 */
587
588
589 /*!
590         \fn status_t BMessage::Flatten(BDataIO *stream, ssize_t *size) const
591         \brief Flatten the message to a \a stream.
592        
593         \param[in] stream The stream to flatten the message to.
594         \param[out] size The method writes the number of bytes actually written to
595                 this argument.
596         \return \c B_OK in case of success, or an error code in case something went
597                 awry.
598        
599         \warning Make sure the subclass of the BDataIO interface either protects
600                 against buffer overwrites, or check if the number of bytes that is
601                 going to be written isn't larger than it can handle.
602         \see FlattenedSize()
603         \see Flatten(char *buffer, ssize_t size) const
604 */
605
606
607 /*!
608         \fn status_t BMessage::Unflatten(const char *flatBuffer)
609         \brief Unflatten a message from a buffer and put it into the current
610                 object.
611        
612         This action clears the current contents of the message.
613        
614         \param flatBuffer The buffer that contains the message.
615        
616         \retval B_OK The buffer has been unflattened.
617         \retval B_BAD_VALUE The buffer does not contain a valid message.
618         \retval B_NO_MEMORY An error occured whilst allocating memory for the data
619                 members.
620         \see Flatten(char *buffer, ssize_t size) const
621         \see Unflatten(BDataIO *stream)
622 */
623
624
625 /*!
626         \fn status_t BMessage::Unflatten(BDataIO *stream)
627         \brief Unflatten a message from a stream and put it into the current
628                 object.
629        
630         This action clears the current contents of the message.
631        
632         \param stream The stream that contains the message.
633        
634         \retval B_OK The message has been unflattened.
635         \retval B_BAD_VALUE The stream does not contain a valid message.
636         \retval B_NO_MEMORY An error occured whilst allocating memory for the data
637                 members.
638         \see Flatten(BDataIO *stream, ssize_t *size) const
639         \see Unflatten(const char *flatBuffer)
640 */
641
642
643 //! @}
644
645 /*!
646         \name Specifiers (Scripting)
647 */
648        
649 //! @{
650        
651
652 /*!
653         \fn status_t BMessage::AddSpecifier(const char *property)
654         \brief Undocumented.
655 */
656
657
658 /*!
659         \fn status_t BMessage::AddSpecifier(const char *property, int32 index)
660         \brief Undocumented.
661 */
662
663
664 /*!
665         \fn status_t BMessage::AddSpecifier(const char *property, int32 index,
666                 int32 range)
667         \brief Undocumented.
668 */
669
670
671 /*!
672         \fn status_t BMessage::AddSpecifier(const char *property, const char *name)
673         \brief Undocumented.
674 */
675
676
677 /*!
678         \fn status_t BMessage::AddSpecifier(const BMessage *specifier)
679         \brief Undocumented.
680 */
681
682
683 /*!
684         \fn status_t BMessage::SetCurrentSpecifier(int32 index)
685         \brief Undocumented.
686 */
687
688
689 /*!
690         \fn status_t BMessage::GetCurrentSpecifier(int32 *index,
691                 BMessage *specifier, int32 *what, const char **property) const
692         \brief Undocumented.
693 */
694
695
696 /*!
697         \fn bool BMessage::HasSpecifiers() const
698         \brief Undocumented.
699 */
700
701
702 /*!
703         \fn status_t BMessage::PopSpecifier()
704         \brief Undocumented.
705 */
706
707
708 //! @}
709
710
711 /*!
712         \name Adding Data
713 */
714
715
716 //! @{
717        
718
719 /*!
720         \fn status_t BMessage::AddData(const char *name, type_code type,
721                 const void *data, ssize_t numBytes, bool isFixedSize, int32 count)
722         \brief Add \a data of a certain \a type to the message.
723        
724         The amount of \a numBytes is copied into the message. The data is stored
725         at the label specified in \a name. You are responsible for specifying the
726         correct \a type. The Haiku API already specifies many constants, such as
727         B_FLOAT_TYPE or B_RECT_TYPE. See TypeConstants.h for more information on
728         the system-wide defined types.
729        
730         If the field with the \a name already exists, the data is added in an
731         array-like form. If you are adding a certain \a name for the first time,
732         you are able to specify some properties of this array. You can fix the size
733         of each data entry, and you can also instruct BMessage to allocate a
734         \a count of items. The latter does not mean that the number of items is
735         fixed; the array will grow nonetheless. Also, note that every \a name can
736         only be associated with one \a type of data. If consecutive method calls
737         specify a different \a type than the initial, these calls will fail.
738        
739         There is no limit to the number of labels, or the amount of data, but
740         note that searching of data members is linear, as well as that some
741         messages will be copied whilst being passed around, so if the amount of
742         data you need to pass is too big, find another way to pass it.
743        
744         \param name The label to which this data needs to be associated. If the
745                 \a name already exists, the new data will be added in an array-like
746                 style.
747         \param type The type of data. If you are adding data to the same \a name,
748                 make sure it is the same type.
749         \param data The data buffer to copy the bytes from.
750         \param numBytes The number of bytes to be copied. If this is the first call
751                 to this method for this type of data, and you set \a isFixedSize to
752                 \c true, this will specify the size of all consecutive calls to this
753                 method.
754         \param isFixedSize If this is the first call to this method with this
755                 \a name, you can specify the whether or not all items in this array
756                 should have the same fixed size.
757         \param count If this is the first call to this method with this
758                 \a name, you can instruct this message to allocate a number of items in
759                 advance. This does not limit the amount of items though. The array will
760                 grow if needed.
761        
762         \retval B_OK The \a data is succesfully added.
763         \retval B_BAD_VALUE The \a numBytes is less than, or equal to zero (0), or
764                 the size of this item is larger than the \a name allows, since it has
765                 been specified to have a fixed size.
766         \retval B_ERROR There was an error whilst creating the label with your
767                 \a name.
768         \retval B_BAD_TYPE The \a type you specified is different than the one
769                 already associated with \a name.
770 */
771
772
773 /*!
774         \fn status_t BMessage::AddRect(const char *name, BRect aRect)
775         \brief Convenience method to add a BRect to the label \a name.
776        
777         This method calls AddData() with the \c B_RECT_TYPE \a type.
778        
779         \param name The label to associate the data with.
780         \param aRect The rectangle to store in the message.
781         \see AddData() for a more detailed overview of the inner workings.
782         \see FindRect()
783         \see ReplaceRect()
784 */
785
786
787 /*!
788         \fn status_t BMessage::AddPoint(const char *name, BPoint aPoint)
789         \brief Convenience method to add a BPoint to the label \a name.
790        
791         This method calls AddData() with the \c B_POINT_TYPE \a type.
792        
793         \param name The label to associate the data with.
794         \param aPoint The point to store in the message.
795         \see AddData() for a more detailed overview of the inner workings.
796         \see FindPoint()
797         \see ReplacePoint()
798 */
799
800
801 /*!
802         \fn status_t BMessage::AddString(const char *name, const char *aString)
803         \brief Convenience method to add a C-string to the label \a name.
804        
805         This method calls AddData() with the \c B_STRING_TYPE \a type.
806        
807         \param name The label to associate the data with.
808         \param aString The string to copy to the message.
809         \see AddData() for a more detailed overview of the inner workings.
810         \see FindString()
811         \see ReplaceString()
812 */
813
814
815 /*!
816         \fn status_t BMessage::AddString(const char *name, const BString &aString)
817         \brief Convenience method to add a BString to the label \a name.
818        
819         This method calls AddData() with the \c B_STRING_TYPE \a type.
820        
821         \param name The label to associate the data with.
822         \param aString The string to copy to the message.
823         \see AddData() for a more detailed overview of the inner workings.
824         \see FindString()
825         \see ReplaceString()
826 */
827
828
829 /*!
830         \fn status_t BMessage::AddInt8(const char *name, int8 value)
831         \brief Convenience method to add an \c int8 to the label \a name.
832        
833         This method calls AddData() with the \c B_INT8_TYPE \a type.
834        
835         \param name The label to associate the data with.
836         \param value The value to store in the message.
837         \see AddData() for a more detailed overview of the inner workings.
838         \see FindInt8()
839         \see ReplaceInt8()
840 */
841        
842
843 /*!
844         \fn status_t BMessage::AddInt16(const char *name, int16 value)
845         \brief Convenience method to add an \c int16 to the label \a name.
846        
847         This method calls AddData() with the \c B_INT16_TYPE \a type.
848        
849         \param name The label to associate the data with.
850         \param value The value to store in the message.
851         \see AddData() for a more detailed overview of the inner workings.
852         \see FindInt16()
853         \see ReplaceInt16()
854 */
855
856
857 /*!     
858         \fn status_t BMessage::AddInt32(const char *name, int32 value)
859         \brief Convenience method to add an \c int32 to the label \a name.
860        
861         This method calls AddData() with the \c B_INT32_TYPE \a type.
862        
863         \param name The label to associate the data with.
864         \param value The value to store in the message.
865         \see AddData() for a more detailed overview of the inner workings.
866         \see FindInt32()
867         \see ReplaceInt32()
868 */
869
870
871 /*!
872         \fn status_t BMessage::AddInt64(const char *name, int64 value)
873         \brief Convenience method to add an \c int64 to the label \a name.
874        
875         This method calls AddData() with the \c B_INT64_TYPE \a type.
876        
877         \param name The label to associate the data with.
878         \param value The value to store in the message.
879         \see AddData() for a more detailed overview of the inner workings.
880         \see FindInt64()
881         \see ReplaceInt64()
882 */
883
884
885 /*!
886         \fn status_t BMessage::AddBool(const char *name, bool aBoolean)
887         \brief Convenience method to add a \c bool to the label \a name.
888        
889         This method calls AddData() with the \c B_BOOL_TYPE \a type.
890        
891         \param name The label to associate the data with.
892         \param aBoolean The value to store in the message.
893         \see AddData() for a more detailed overview of the inner workings.
894         \see FindBool()
895         \see ReplaceBool()
896 */
897
898 /*!
899         \fn status_t BMessage::AddFloat(const char *name, float aFloat)
900         \brief Convenience method to add a \c float to the label \a name.
901
902         This method calls AddData() with the \c B_FLOAT_TYPE \a type.
903
904         \param name The label to associate the data with.
905         \param aFloat The value to store in the message.
906         \see AddData() for a more detailed overview of the inner workings.
907         \see FindFloat()
908         \see ReplaceFloat()
909 */
910
911
912 /*!
913         \fn status_t BMessage::AddDouble(const char *name, double aDouble)
914         \brief Convenience method to add a \c double to the label \a name.
915
916         This method calls AddData() with the \c B_DOUBLE_TYPE \a type.
917
918         \param name The label to associate the data with.
919         \param aDouble The value to store in the message.
920         \see AddData() for a more detailed overview of the inner workings.
921         \see FindDouble()
922         \see ReplaceDouble()
923 */
924
925
926 /*!
927         \fn status_t BMessage::AddPointer(const char *name, const void *aPointer)
928         \brief Convenience method to add a \c pointer to the label \a name.
929
930         This method calls AddData() with the \c B_POINTER_TYPE \a type.
931        
932         \warning If you want to share objects between applications, please remember
933                 that each application has its own address space, and that it therefore
934                 is useless to try to pass around objects by sending pointers in
935                 messages. You should think about copying the entire object in the
936                 message, or you should consider using shared memory.
937
938         \param name The label to associate the data with.
939         \param aPointer The value to store in the message.
940         \see AddData() for a more detailed overview of the inner workings.
941         \see FindPointer()
942         \see ReplacePointer()
943 */
944
945
946 /*!
947         \fn status_t BMessage::AddMessenger(const char *name, BMessenger messenger)
948         \brief Convenience method to add a messenger to the label \a name.
949
950         This method calls AddData() with the \c B_MESSENGER_TYPE \a type.
951
952         \param name The label to associate the data with.
953         \param messenger The messenger to store in the message.
954         \see AddData() for a more detailed overview of the inner workings.
955         \see FindMessenger()
956         \see ReplaceMessenger()
957 */
958
959
960 /*!
961         \fn status_t BMessage::AddRef(const char *name, const entry_ref *ref)
962         \brief Convenience method to add an \c entry_ref to the label \a name.
963
964         This method calls AddData() with the \c B_REF_TYPE \a type.
965
966         \param name The label to associate the data with.
967         \param ref The reference to store in the message.
968         \see AddData() for a more detailed overview of the inner workings.
969         \see FindRef()
970         \see ReplaceRef()
971 */
972
973
974 /*!
975         \fn status_t BMessage::AddMessage(const char *name, const BMessage *message)
976         \brief Convenience method to add a message to the label \a name.
977
978         This method calls AddData() with the \c B_MESSAGE_TYPE \a type.
979
980         \param name The label to associate the data with.
981         \param message The message to store in this message.
982         \see AddData() for a more detailed overview of the inner workings.
983         \see FindMessage()
984         \see ReplaceMessage()
985 */
986
987
988 /*!
989         \fn status_t BMessage::AddFlat(const char *name, BFlattenable *object,
990                 int32 count = 1)
991         \brief Convenience method to add a flattenable to the label \a name.
992
993         This method uses BFlattenable::TypeCode() to determine the type. It also
994         uses BFlattenable::IsFixedSize() to determine whether or not the size of
995         the object is supposedly always the same. You can specify a \a count, to
996         pre-allocate more entries if you are going to add more than one of this
997         type.
998
999         \param name The label to associate the data with.
1000         \param object The object to flatten into the message.
1001         \param count The number of items to pre-allocate associated with this
1002                 \a name.
1003         \see AddData() for a more detailed overview of the inner workings.
1004         \see FindFlat()
1005         \see ReplaceFlat()
1006 */
1007
1008
1009 //! @}
1010
1011
1012 /*!
1013         \name Removing Data
1014 */
1015
1016
1017 //! @{
1018
1019
1020 /*!
1021         \fn status_t BMessage::RemoveData(const char *name, int32 index)
1022         \brief Remove data associated with \a name at a specified \a index.
1023        
1024         If this is the only instance of the data, then the entire label will be
1025         removed. This means you can recreate it with another type.
1026        
1027         \param name The \a name of which the associated data should be cleared.
1028         \param index The \a index of the item that should be cleared.
1029         \retval B_OK The data has been removed.
1030         \retval B_BAD_VALUE The \a index is less than zero (0).
1031         \retval B_BAD_INDEX The \a index is out of bounds.
1032         \retval B_NAME_NOT_FOUND The \a name does not hava any data associated with
1033                 it.
1034         \see RemoveName()
1035         \see MakeEmpty()
1036 */
1037
1038
1039 /*!
1040         \fn status_t BMessage::RemoveName(const char *name)
1041         \brief Remove all data associated with a \a name.
1042        
1043         This also removes the label, so that you can recreate it with another type,
1044         if you want to.
1045        
1046         \param name The \a name that refers to the data you want to clear out.
1047         \retval B_OK All the data is removed.
1048         \retval B_BAD_VALUE The \a name pointer points to \c NULL.
1049         \retval B_NAME_NOT_FOUND The \a name does not exist in this message.
1050         \see RemoveData()
1051         \see MakeEmpty()
1052 */
1053
1054
1055 /*!
1056         \fn status_t BMessage::MakeEmpty()
1057         \brief Clear all data and metadata in this message.
1058        
1059         Everything is cleared out, all labels and all associated data, as well
1060         as metadata such as reply info.
1061        
1062         \return This method always returns B_OK.
1063         \see RemoveData()
1064         \see RemoveName()
1065 */
1066
1067
1068 //! @}
1069
1070
1071 /*!
1072         \name Finding Data
1073        
1074         Look at FindData() for a general introduction to finding data.
1075 */
1076
1077 /* TODO:       
1078         Quick overview:
1079        
1080         <table>
1081                 <tr><th>Type of data</th><th>Type code</th><th>Method</td></tr>
1082                 <tr><td>BRect</td><td>B_RECT_TYPE</td><td>FindRect()</td></tr>
1083         </table>
1084 */
1085
1086
1087 //! @{
1088
1089
1090 /*!
1091         \fn status_t BMessage::FindData(const char *name, type_code type,
1092                 int32 index, const void **data, ssize_t *numBytes) const
1093         \brief Find \a data that is stored in this message at an \a index.
1094        
1095         This method matches the label \a name with the \a type you are asking for,
1096         and it looks for the data that is stored at a certain \a index number. If
1097         all these things match, you will get a pointer to the internal buffer, and
1098         the method will put the size of the item in \a numBytes.
1099        
1100         Note that only this method, and FindString(const char *, const char **),
1101         pass a pointer to the internal buffer. The other more specific methods,
1102         such as FindBool() and FindRect() copy the data into a buffer you specify.
1103         This means that the data retrieved with this method is valid until the
1104         message is deleted.
1105        
1106         \param name The label the data should be associated with.
1107         \param type The type of data you want to retrieve. You can pass
1108                 \c B_ANY_TYPE if you don't mind which type the data is.
1109         \param index The index in the array of the data that you want to retrieve.
1110                 Note that the array is zero-based.
1111         \param[out] data A pointer to a pointer where the data can point to.
1112         \param[out] numBytes The size of the data will be put in this parameter.
1113         \retval B_OK The \a name was found, matches the type, and the data at
1114                 \a index has been put in \a data.
1115         \retval B_BAD_VALUE One of the output arguments were \c NULL.
1116         \retval B_BAD_INDEX The \a index does not exist.
1117         \retval B_NAME_NOT_FOUND There is no field with this \a name.
1118         \see status_t FindData(const char *, type_code, int32,
1119                 const void **, ssize_t *) const
1120 */
1121
1122
1123 /*!
1124         \fn status_t BMessage::FindData(const char *name, type_code type,
1125                 const void **data, ssize_t *numBytes) const
1126         \brief Find \a data that is stored in this message.
1127        
1128         This is an overloaded method of FindData(const char *, type_code, int32,
1129         const void **, ssize_t *) const, where data is sought at \a index 0.
1130 */
1131
1132
1133 /*!
1134         \fn status_t BMessage::FindRect(con