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 * headers/os/app/Message.h rev 21562 10 * src/kits/app/Message.cpp rev 22240 11 */ 12 13 14/*! 15 \file Message.h 16 \ingroup app 17 \ingroup libroot 18 \brief Provides the BMessage class. 19*/ 20 21///// Name lengths and Scripting specifiers ///// 22 23/*! 24 \def B_FIELD_NAME_LENGTH 25 \brief Undocumented... 26*/ 27 28 29/*! 30 \def B_PROPERTY_NAME_LENGTH 31 \brief Undocumented... 32*/ 33 34 35/*! 36 \var B_NO_SPECIFIER 37 \brief Undocumented... 38*/ 39 40 41/*! 42 \var B_DIRECT_SPECIFIER 43 \brief Undocumented... 44*/ 45 46 47/*! 48 \var B_INDEX_SPECIFIER 49 \brief Undocumented... 50*/ 51 52 53/*! 54 \var B_REVERSE_INDEX_SPECIFIER, 55 \brief Undocumented... 56*/ 57 58 59/*! 60 \var B_RANGE_SPECIFIER 61 \brief Undocumented... 62*/ 63 64 65/*! 66 \var B_REVERSE_RANGE_SPECIFIER 67 \brief Undocumented... 68*/ 69 70 71/*! 72 \var B_NAME_SPECIFIER 73 \brief Undocumented... 74*/ 75 76 77/*! 78 \var B_ID_SPECIFIER 79 \brief Undocumented... 80*/ 81 82 83/*! 84 \var B_SPECIFIERS_END 85 \brief Undocumented... 86*/ 87 88 89///// Class BMessage ///// 90 91 92/*! 93 \class BMessage 94 \ingroup app 95 \ingroup libroot 96 \brief A container that can be send and received using the Haiku messaging 97 subsystem. 98 99 This class is at the center of the web of messaging classes, in the sense 100 that it defines the actual structure of the messages. Messages have two 101 <b>important elements</b>: the #what identifier, and the data members. The 102 first can be directly manipulated, the latter can be manipulated through 103 AddData(), FindData() and ReplaceData() and their derivatives. Neither of 104 these elements are mandatory. 105 106 The second important role of BMessage is that it stores <b>meta data</b>: 107 who sent the message and with what intention? The methods of BMessage will 108 disclose if the message was a reply (IsReply()), where it came from 109 (IsSourceRemote()), whether a reply is expected (IsSourceWaiting()), and in 110 case the message is a reply, what it's a reply to (Previous()). 111 112 Mostly, messages are used to pass information between the the objects in 113 your application, but because messages are such flexible data containers, 114 they are also often used for other <b>data storage purposes</b>. Many 115 applications store their settings as messages. Because messages can be 116 flattened to data streams (such as files), they provide an easy but 117 powerful tool for data storage. 118 119 All methods can be classified in these areas: 120 - Adding, Finding, Replacing and Removing Data. 121 - Statistics and Miscellaneous information. 122 - Delivery information. 123 - Utilities to reply to messages. 124 125 To see how messages fit in with the greater picture, have a look at the 126 \ref app_messaging "Messaging Introduction". 127*/ 128 129 130/*! 131 \var BMessage::what 132 \brief A 4-byte constant that determines the type of message. 133 134 You can directly manipulate this data member. 135*/ 136 137 138/*! 139 \fn BMessage::BMessage() 140 \brief Construct an empty message, without any data members and with a 141 \a what constant set to \c 0. 142 143 \see BMessage(uint32 what) 144 \see BMessage(const BMessage &other) 145*/ 146 147 148/*! 149 \fn BMessage::BMessage(uint32 what) 150 \brief Construct an empty message with the \a what member set to the 151 specified value. 152 153 \see BMessage::BMessage() 154 \see BMessage::BMessage(const BMessage &other) 155*/ 156 157 158/*! 159 \fn BMessage::BMessage(const BMessage &other) 160 \brief Construct a new message that is a copy of another message. 161 162 The \a what member and the data values are copied. The metadata, such as 163 whether or not the message is a drop message or reply information, is 164 not copied. So if the original message is a reply to a previous message, 165 which will make IsReply() return \c true, calling the same method on a copy 166 of the message will return \c false. 167 168 \remarks BeOS R5 did keep the metadata of the message. Haiku deviates from 169 this behavior. Please use the Haiku implementation of message copying as 170 the default behavior. This will keep your applications backwards 171 compatible. 172 173 \see BMessage::BMessage() 174 \see BMessage(uint32 what) 175*/ 176 177 178/*! 179 \fn BMessage::~BMessage() 180 \brief Free the data members associated with the message. 181 182 If there still is a sender waiting for a reply, the \c B_NO_REPLY message 183 will be sent to inform them that there won't be a reply. 184*/ 185 186 187/*! 188 \fn BMessage &BMessage::operator=(const BMessage &other) 189 \brief Copy one message into another. 190 191 See the copy constructor, BMessage(const BMessage &other), for details on 192 what is copied, and what isn't. 193*/ 194 195 196/*! 197 \name Statistics and Miscellaneous Information 198*/ 199 200 201//! @{ 202 203 204/*! 205 \fn status_t BMessage::GetInfo(type_code typeRequested, int32 index, 206 char **nameFound, type_code *typeFound, int32 *countFound) const 207 \brief Retrieve the name, the type and the number of items in a message by 208 an \a index. 209 210 \param[in] typeRequested If you want to limit the search to only one type, 211 pass that type code here. If you don't care which type the data has, 212 you can pass \c B_ANY_TYPE. 213 \param[in] index The index of the data you want to investigate. 214 \param[out] nameFound The name of the item if it is found. Haiku will fill 215 in a pointer to the internal name buffer in the message. This means 216 that you should not manipulate this name. If you are not interested in 217 the name, you can safely pass \c NULL. 218 \param[out] typeFound The type of the item at \a index. If you are 219 not interested in the type (because you specifically asked for a type), 220 you can safely pass \c NULL. 221 \param[out] countFound The number of items at \a index. If data 222 items have the same name, they will be placed under the same index. 223 224 \return If the \a index is found, and matches the requested type, 225 then the other parameters will be filled in. If this is not the case, 226 the method will return with an error. 227 228 \retval B_OK An match was found. The values have been filled in. 229 \retval B_BAD_INDEX The \a index was out of range. None of the 230 passed variables have been altered. 231 \retval B_BAD_TYPE The data field at \a index does not have the 232 requested type. 233*/ 234 235 236/*! 237 \fn status_t BMessage::GetInfo(const char *name, type_code *typeFound, 238 int32 *countFound) const 239 \brief Retrieve the type and the number of data items in this message that 240 are associated with a \a name. 241 242 \param[in] name The name of the data member that you are looking for. 243 \param[out] typeFound In case of a match, the name of the data member will 244 be put in this parameter. In case you are not interested, you can pass 245 \c NULL. 246 \param[out] countFound In case of a match, the number of items at this 247 label will be in this parameter. In case you are not interested, you 248 can safely pass \c NULL. 249 250 \return If the message has data associated with the given \a name, 251 the other parameters will contain information associated with the data, 252 else, the method will return with an error. 253 254 \retval B_OK A match was found. The other parameters have been filled in. 255 \retval B_BAD_VALUE You passed \c NULL as argument to \a name. 256 \retval B_NAME_NOT_FOUND There is no data with the label \a name. 257*/ 258 259 260/*! 261 \fn status_t BMessage::GetInfo(const char *name, type_code *typeFound, 262 bool *fixedSize) const 263 \brief Retrieve the type and whether or not the size of the data is fixed 264 associated with a \a name. 265 266 This method is the same as GetInfo(const char *,type_code *, int32 *) const, 267 with the difference that you can find out whether or not the size of the 268 data associated with the \a name is fixed. You will get this value 269 in the variable you passed as \a fixedSize parameter. 270*/ 271 272 273/*! 274 \fn int32 BMessage::CountNames(type_code type) const 275 \brief Count the number of names of a certain \a type. 276 277 This method can be used to count the number of items of a certain type. 278 It's practical use is limited to debugging purposes. 279 280 \param type The type you want to find. If you pass \c B_ANY_TYPE, this 281 method will return the total number of data items. 282 283 \return The number of data items in this message with the specified 284 \a type, or \c 0 in case no items match the type. 285*/ 286 287 288/*! 289 \fn bool BMessage::IsEmpty() const 290 \brief Check if the message has data members. 291 292 \return If this message contains data members, this method will return 293 \c true, else it will return \c false. 294 \see MakeEmpty() 295*/ 296 297 298/*! 299 \fn bool BMessage::IsSystem() const 300 \brief Check if the message is a system message. 301 302 \return If this message is a system message, the method will return 303 \c true. 304*/ 305 306 307/*! 308 \fn bool BMessage::IsReply() const 309 \brief Check if the message is a reply to a (previous) message. 310 311 \return If this message is a reply, this method will return \c true. 312*/ 313 314 315/*! 316 \fn void BMessage::PrintToStream() const 317 \brief Print the message to the standard output. 318 319 This method can be used to debug your application. It can be used to check 320 if it creates the messages properly, by checking if all the required fields 321 are present, and it can be used to debug your message handling routines, 322 especially the handling of those that are sent by external applications, to 323 see if you understand the semantics correctly. 324*/ 325 326 327/*! 328 \fn status_t BMessage::Rename(const char *oldEntry, const char *newEntry) 329 \brief Rename a data label. 330 331 \param oldEntry The name of the label you want to rename. 332 \param newEntry The new name of the data entry. 333 334 \retval B_OK Renaming succeeded. 335 \retval B_BAD_VALUE Either the \a oldEntry or the 336 \a newEntry pointers are \c NULL. 337 \retval B_NAME_NOT_FOUND There is no data associated with the label 338 \a oldEntry. 339*/ 340 341 342//! @} 343 344/*! 345 \name Delivery Info 346*/ 347 348//! @{ 349 350 351/*! 352 \fn bool BMessage::WasDelivered() const 353 \brief Check if this message was delivered through the delivery methods. 354 355 If this message is passed via a BMessenger or BLooper::PostMessage(), this 356 method will return \c true. 357 358 \warning This method should not be abused by a thread that sends a message 359 to track whether or not a message was delivered. This is because the 360 ownership of the message goes to the receiving looper, which will 361 delete the message as soon as it is done with it. 362 363 \warning If you need to check whether a message is delivered, you should 364 either ask for a reply, or use one of the synchronous 365 BMessenger::SendMessage() methods. 366*/ 367 368 369/*! 370 \fn bool BMessage::IsSourceWaiting() const 371 \brief Check if the sender expects a reply. 372 373 This method will return \c true, if the sender flagged that it is waiting 374 for a reply, and such a reply has not yet been sent. 375*/ 376 377 378/*! 379 \fn bool BMessage::IsSourceRemote() const 380 \brief Check if the message is sent by another application. 381*/ 382 383 384/*! 385 \fn BMessenger BMessage::ReturnAddress() const 386 \brief Get a messenger that points to the sender of the message. 387 388 Using this method, you can fetch a BMessenger that can be used to deliver 389 replies to this message. This method works both for local and remote 390 deliveries. 391 392 For remote deliveries, this approach is preferred over sending the reply 393 using a standard BMessenger that is created with the signature of the 394 application. A standard BMessenger sends the messages to the main BLooper 395 of the application, the BApplication object. With the delivery data stored 396 in the messages, the reply using this messenger will be directed at a 397 specific looper that is able to handle the replies. 398 399 If this method is called on a message that has not been delivered (yet), 400 it will return an empty BMessenger object. 401*/ 402 403 404/*! 405 \fn const BMessage *BMessage::Previous() const 406 \brief Get the message to which this message is a reply. 407 408 \return Returns a new BMessage with the same data stuctures as the message 409 to which this message is a reply. You get the ownership of this 410 message, so free it when you're done. If this message isn't a reply to 411 another message, this method will return \c NULL. 412*/ 413 414 415/*! 416 \fn bool BMessage::WasDropped() const 417 \brief Check if the message was delivered through 'drag and drop'. 418 419 \return This method returns \c true if the message has been delivered 420 through drag and drop. It returns \c false if it has been delivered 421 through the regular messaging functions, or if the message has not 422 been delivered at all. 423 \see DropPoint() 424*/ 425 426 427/*! 428 \fn BPoint BMessage::DropPoint(BPoint *offset) const 429 \brief Get the coordinates of the drop point of the message. 430 431 If the message has been delivered because of drag and drop, which can be 432 verified with the WasDropped() method, this method will return a BPoint to 433 where exactly the drop off was made. 434 435 Because drop messages are delivered to the BWindow in which they were 436 dropped, and BWindow is a subclass of BLooper, you can use BWindow to 437 determine based on the location, how you should react to it. 438 439 If this message was not delivered through drag and drop, it will return 440 a \c NULL pointer. 441 442 \see WasDropped() 443*/ 444 445 446//! @} 447 448 449/*! 450 \name Replying 451*/ 452 453 454//! @{ 455 456 457/*! 458 \fn status_t BMessage::SendReply(uint32 command, BHandler *replyTo) 459 \brief Asynchronously send a reply to this message. 460 461 This is an overloaded member of SendReply(BMessage *, BMessenger, bigtime_t). 462 Use this variant if you want to send a message without data members. 463*/ 464 465 466/*! 467 \fn status_t BMessage::SendReply(BMessage *reply, BHandler *replyTo, 468 bigtime_t timeout) 469 \brief Asynchronously send a reply to this message. 470 471 This is an overloaded member of SendReply(BMessage *, BMessenger, bigtime_t). 472 Use this variant if you want to send the message to a specific handler 473 (instead of a complete messenger). 474*/ 475 476 477/*! 478 \fn status_t BMessage::SendReply(BMessage *reply, BMessenger replyTo, 479 bigtime_t timeout) 480 \brief Asynchronously send a reply to this message. 481 482 This method sends a reply to this message to the sender. On your turn, 483 you specify a messenger that handles a reply back to the message you 484 specify as the \a reply argument. You can set a timeout for the 485 message to be delivered. This method blocks until the message has been 486 received, or the \a timeout has been reached. 487 488 \param reply The message that is in reply to this message. 489 \param replyTo In case the receiver needs to reply to the message you are 490 sending, you can specify the return address with this argument. 491 \param timeout The maximum time in microseconds this delivery may take. The 492 \a timeout is a relative timeout. You can also use 493 \c B_INFINITE_TIMEOUT if you want to wait infinitely for the message 494 to be delivered. 495 496 \retval B_OK The message has been delivered. 497 \retval B_DUPLICATE_REPLY There already has been a reply to this message. 498 \retval B_BAD_PORT_ID The reply address is not valid (anymore). 499 \retval B_WOULD_BLOCK The delivery \a timeout was 500 \c B_INFINITE_TIMEOUT (\c 0) and the target port was full when trying 501 to deliver the message. 502 \retval B_TIMED_OUT The timeout expired while trying to deliver the 503 message. 504 \see SendReply(uint32 command, BHandler *replyTo) 505*/ 506 507 508/*! 509 \fn status_t BMessage::SendReply(uint32 command, BMessage *replyToReply) 510 \brief Synchronously send a reply to this message, and wait for a reply 511 back. 512 513 This is an overloaded member of SendReply(BMessage *, BMessage *, 514 bigtime_t, bigtime_t) Use this variant if you want to send a message 515 without data members. 516*/ 517 518 519/*! 520 \fn status_t BMessage::SendReply(BMessage *reply, BMessage *replyToReply, 521 bigtime_t sendTimeout, bigtime_t replyTimeout) 522 \brief Synchronously send a reply to this message, and wait for a reply 523 back. 524 525 This method sends a reply to this message to the sender. The 526 \a reply is delivered, and then the method waits for a reply from 527 the receiver. If a reply is received, that reply is copied into the 528 \a replyToReply argument. 529 If the message was delivered properly, but the receiver did not reply 530 within the specified \a replyTimeout, the \a what member of 531 \a replyToReply will be set to \c B_NO_REPLY. 532 533 \param reply The message that is in reply to this message. 534 \param[out] replyToReply The reply is copied into this argument. 535 \param sendTimeout The maximum time in microseconds this delivery may take. 536 The \a timeout is a relative timeout. You can also use 537 \c B_INFINITE_TIMEOUT if you want to wait infinitely for the message 538 to be delivered. 539 \param replyTimeout The maximum time in microseconds you want to wait for a 540 reply. Note that the timer starts when the message has been delivered. 541 542 \retval B_OK The message has been delivered. 543 \retval B_DUPLICATE_REPLY There already has been a reply to this message. 544 \retval B_BAD_VALUE Either \a reply or \a replyToReply is 545 \c NULL. 546 \retval B_BAD_PORT_ID The reply address is not valid (anymore). 547 \retval B_WOULD_BLOCK The delivery \a timeout was 548 \c B_INFINITE_TIMEOUT (\c 0) and the target port was full when trying 549 to deliver the message. 550 \retval B_TIMED_OUT The timeout expired while trying to deliver the 551 message. 552 \retval B_NO_MORE_PORTS All reply ports are in use. 553 \see SendReply(uint32 command, BMessage *replyToReply) 554*/ 555 556 557//! @} 558 559 560/*! 561 \name Flattening methods 562 563 Because of historical reasons and for binary compatibility, this class 564 provides a flattening API without inheriting the BFlattenable class. The 565 API is more or less the same, but you are inconvenienced when you want to 566 use messages in methods that handle BFlattenable objects. 567*/ 568 569 570//! @{ 571 572 573/*! 574 \fn ssize_t BMessage::FlattenedSize() const 575 \brief Return the size in bytes required when you want to flatten this 576 message to a stream of bytes. 577*/ 578 579 580/*! 581 \fn status_t BMessage::Flatten(char *buffer, ssize_t size) const 582 \brief Flatten the message to a \a buffer. 583 584 \param buffer The buffer to write the data to. 585 \param size The size of the buffer. 586 587 \return \c B_OK in case of success, or an error code in case something went 588 awry. 589 590 \warning Make sure the buffer is large enough to hold the message. This 591 method does not double-check for you! 592 \see FlattenedSize() 593 \see Flatten(BDataIO *stream, ssize_t *size) const 594*/ 595 596 597/*! 598 \fn status_t BMessage::Flatten(BDataIO *stream, ssize_t *size) const 599 \brief Flatten the message to a \a stream. 600 601 \param[in] stream The stream to flatten the message to. 602 \param[out] size The method writes the number of bytes actually written to 603 this argument. 604 \return \c B_OK in case of success, or an error code in case something went 605 awry. 606 607 \warning Make sure the subclass of the BDataIO interface either protects 608 against buffer overwrites, or check if the number of bytes that is 609 going to be written isn't larger than it can handle. 610 \see FlattenedSize() 611 \see Flatten(char *buffer, ssize_t size) const 612*/ 613 614 615/*! 616 \fn status_t BMessage::Unflatten(const char *flatBuffer) 617 \brief Unflatten a message from a buffer and put it into the current 618 object. 619 620 This action clears the current contents of the message. 621 622 \param flatBuffer The buffer that contains the message. 623 624 \retval B_OK The buffer has been unflattened. 625 \retval B_BAD_VALUE The buffer does not contain a valid message. 626 \retval B_NO_MEMORY An error occured whilst allocating memory for the data 627 members. 628 \see Flatten(char *buffer, ssize_t size) const 629 \see Unflatten(BDataIO *stream) 630*/ 631 632 633/*! 634 \fn status_t BMessage::Unflatten(BDataIO *stream) 635 \brief Unflatten a message from a stream and put it into the current 636 object. 637 638 This action clears the current contents of the message. 639 640 \param stream The stream that contains the message. 641 642 \retval B_OK The message has been unflattened. 643 \retval B_BAD_VALUE The stream does not contain a valid message. 644 \retval B_NO_MEMORY An error occured whilst allocating memory for the data 645 members. 646 \see Flatten(BDataIO *stream, ssize_t *size) const 647 \see Unflatten(const char *flatBuffer) 648*/ 649 650 651//! @} 652 653/*! 654 \name Specifiers (Scripting) 655*/ 656 657//! @{ 658 659 660/*! 661 \fn status_t BMessage::AddSpecifier(const char *property) 662 \brief Undocumented. 663*/ 664 665 666/*! 667 \fn status_t BMessage::AddSpecifier(const char *property, int32 index) 668 \brief Undocumented. 669*/ 670 671 672/*! 673 \fn status_t BMessage::AddSpecifier(const char *property, int32 index, 674 int32 range) 675 \brief Undocumented. 676*/ 677 678 679/*! 680 \fn status_t BMessage::AddSpecifier(const char *property, const char *name) 681 \brief Undocumented. 682*/ 683 684 685/*! 686 \fn status_t BMessage::AddSpecifier(const BMessage *specifier) 687 \brief Undocumented. 688*/ 689 690 691/*! 692 \fn status_t BMessage::SetCurrentSpecifier(int32 index) 693 \brief Undocumented. 694*/ 695 696 697/*! 698 \fn status_t BMessage::GetCurrentSpecifier(int32 *index, 699 BMessage *specifier, int32 *what, const char **property) const 700 \brief Undocumented. 701*/ 702 703 704/*! 705 \fn bool BMessage::HasSpecifiers() const 706 \brief Undocumented. 707*/ 708 709 710/*! 711 \fn status_t BMessage::PopSpecifier() 712 \brief Undocumented. 713*/ 714 715 716//! @} 717 718 719/*! 720 \name Adding Data 721*/ 722 723 724//! @{ 725 726 727/*! 728 \fn status_t BMessage::AddData(const char *name, type_code type, 729 const void *data, ssize_t numBytes, bool isFixedSize, int32 count) 730 \brief Add \a data of a certain \a type to the message. 731 732 The amount of \a numBytes is copied into the message. The data is 733 stored at the label specified in \a name. You are responsible for 734 specifying the correct \a type. The Haiku API already specifies 735 many constants, such as \c B_FLOAT_TYPE or \c B_RECT_TYPE. See 736 TypeConstants.h for more information on the system-wide defined types. 737 738 If the field with the \a name already exists, the data is added in 739 an array-like form. If you are adding a certain \a name for the 740 first time, you are able to specify some properties of this array. You can 741 fix the size of each data entry, and you can also instruct BMessage to 742 allocate a \a count of items. The latter does not mean that the 743 number of items is fixed; the array will grow nonetheless. Also, note that 744 every \a name can only be associated with one \a type of 745 data. 746 747 If consecutive method calls specify a different \a type than the 748 initial, these calls will fail. 749 750 There is no limit to the number of labels, or the amount of data, but 751 note that searching of data members is linear, as well as that some 752 messages will be copied whilst being passed around, so if the amount of 753 data you need to pass is too big, find another way to pass it. 754 755 \param name The label to which this data needs to be associated. If the 756 \a name already exists, the new data will be added in an 757 array-like style. 758 \param type The type of data. If you are adding data to the same 759 \a name, make sure it is the same type. 760 \param data The data buffer to copy the bytes from. 761 \param numBytes The number of bytes to be copied. If this is the first call 762 to this method for this type of data, and you set 763 \a isFixedSize to \c true, this will specify the size of all 764 consecutive calls to this 765 method. 766 \param isFixedSize If this is the first call to this method with this 767 \a name, you can specify the whether or not all items in this 768 array should have the same fixed size. 769 \param count If this is the first call to this method with this 770 \a name, you can instruct this message to allocate a number of 771 items in advance. This does not limit the amount of items though. The 772 array will grow if needed. 773 774 \retval B_OK The \a data is succesfully added. 775 \retval B_BAD_VALUE The \a numBytes is less than, or equal to \c 0, 776 or the size of this item is larger than the \a name allows, 777 since it has been specified to have a fixed size. 778 \retval B_ERROR There was an error whilst creating the label with your 779 \a name. 780 \retval B_BAD_TYPE The \a type you specified is different than the 781 one already associated with \a name. 782*/ 783 784 785/*! 786 \fn status_t BMessage::AddRect(const char *name, BRect aRect) 787 \brief Convenience method to add a BRect to the label \a name. 788 789 This method calls AddData() with the \c B_RECT_TYPE \a type. 790 791 \param name The label to associate the data with. 792 \param aRect The rectangle to store in the message. 793 \see AddData() for a more detailed overview of the inner workings. 794 \see FindRect() 795 \see ReplaceRect() 796*/ 797 798 799/*! 800 \fn status_t BMessage::AddPoint(const char *name, BPoint aPoint) 801 \brief Convenience method to add a BPoint to the label \a name. 802 803 This method calls AddData() with the \c B_POINT_TYPE \a type. 804 805 \param name The label to associate the data with. 806 \param aPoint The point to store in the message. 807 \see AddData() for a more detailed overview of the inner workings. 808 \see FindPoint() 809 \see ReplacePoint() 810*/ 811 812 813/*! 814 \fn status_t BMessage::AddString(const char *name, const char *aString) 815 \brief Convenience method to add a C-string to the label \a name. 816 817 This method calls AddData() with the \c B_STRING_TYPE \a type. 818 819 \param name The label to associate the data with. 820 \param aString The string to copy to the message. 821 \see AddData() for a more detailed overview of the inner workings. 822 \see FindString() 823 \see ReplaceString() 824*/ 825 826 827/*! 828 \fn status_t BMessage::AddString(const char *name, const BString &aString) 829 \brief Convenience method to add a BString to the label \a name. 830 831 This method calls AddData() with the \c B_STRING_TYPE \a type. 832 833 \param name The label to associate the data with. 834 \param aString The string to copy to the message. 835 \see AddData() for a more detailed overview of the inner workings. 836 \see FindString() 837 \see ReplaceString() 838*/ 839 840 841/*! 842 \fn status_t BMessage::AddInt8(const char *name, int8 value) 843 \brief Convenience method to add an \c int8 to the label \a name. 844 845 This method calls AddData() with the \c B_INT8_TYPE \a type. 846 847 \param name The label to associate the data with. 848 \param value The value to store in the message. 849 \see AddData() for a more detailed overview of the inner workings. 850 \see FindInt8() 851 \see ReplaceInt8() 852*/ 853 854 855/*! 856 \fn status_t BMessage::AddInt16(const char *name, int16 value) 857 \brief Convenience method to add an \c int16 to the label \a name. 858 859 This method calls AddData() with the \c B_INT16_TYPE \a type. 860 861 \param name The label to associate the data with. 862 \param value The value to store in the message. 863 \see AddData() for a more detailed overview of the inner workings. 864 \see FindInt16() 865 \see ReplaceInt16() 866*/ 867 868 869/*! 870 \fn status_t BMessage::AddInt32(const char *name, int32 value) 871 \brief Convenience method to add an \c int32 to the label \a name. 872 873 This method calls AddData() with the \c B_INT32_TYPE \a type. 874 875 \param name The label to associate the data with. 876 \param value The value to store in the message. 877 \see AddData() for a more detailed overview of the inner workings. 878 \see FindInt32() 879 \see ReplaceInt32() 880*/ 881 882 883/*! 884 \fn status_t BMessage::AddInt64(const char *name, int64 value) 885 \brief Convenience method to add an \c int64 to the label \a name. 886 887 This method calls AddData() with the \c B_INT64_TYPE \a type. 888 889 \param name The label to associate the data with. 890 \param value The value to store in the message. 891 \see AddData() for a more detailed overview of the inner workings. 892 \see FindInt64() 893 \see ReplaceInt64() 894*/ 895 896 897/*! 898 \fn status_t BMessage::AddBool(const char *name, bool aBoolean) 899 \brief Convenience method to add a \c bool to the label \a name. 900 901 This method calls AddData() with the \c B_BOOL_TYPE \a type. 902 903 \param name The label to associate the data with. 904 \param aBoolean The value to store in the message. 905 \see AddData() for a more detailed overview of the inner workings. 906 \see FindBool() 907 \see ReplaceBool() 908*/ 909 910/*! 911 \fn status_t BMessage::AddFloat(const char *name, float aFloat) 912 \brief Convenience method to add a \c float to the label \a name. 913 914 This method calls AddData() with the \c B_FLOAT_TYPE \a type. 915 916 \param name The label to associate the data with. 917 \param aFloat The value to store in the message. 918 \see AddData() for a more detailed overview of the inner workings. 919 \see FindFloat() 920 \see ReplaceFloat() 921*/ 922 923 924/*! 925 \fn status_t BMessage::AddDouble(const char *name, double aDouble) 926 \brief Convenience method to add a \c double to the label \a name. 927 928 This method calls AddData() with the \c B_DOUBLE_TYPE \a type. 929 930 \param name The label to associate the data with. 931 \param aDouble The value to store in the message. 932 \see AddData() for a more detailed overview of the inner workings. 933 \see FindDouble() 934 \see ReplaceDouble() 935*/ 936 937 938/*! 939 \fn status_t BMessage::AddPointer(const char *name, const void *aPointer) 940 \brief Convenience method to add a \c pointer to the label \a name. 941 942 This method calls AddData() with the \c B_POINTER_TYPE \a type. 943 944 \warning If you want to share objects between applications, please remember 945 that each application has its own address space, and that it therefore 946 is useless to try to pass around objects by sending pointers in 947 messages. You should think about copying the entire object in the 948 message, or you should consider using shared memory. 949 950 \param name The label to associate the data with. 951 \param aPointer The value to store in the message. 952 \see AddData() for a more detailed overview of the inner workings. 953 \see FindPointer() 954 \see ReplacePointer() 955*/ 956 957 958/*! 959 \fn status_t BMessage::AddMessenger(const char *name, BMessenger messenger) 960 \brief Convenience method to add a messenger to the label \a name. 961 962 This method calls AddData() with the \c B_MESSENGER_TYPE \a type. 963 964 \param name The label to associate the data with. 965 \param messenger The messenger to store in the message. 966 \see AddData() for a more detailed overview of the inner workings. 967 \see FindMessenger() 968 \see ReplaceMessenger() 969*/ 970 971 972/*! 973 \fn status_t BMessage::AddRef(const char *name, const entry_ref *ref) 974 \brief Convenience method to add an \c entry_ref to the label 975 \a name. 976 977 This method calls AddData() with the \c B_REF_TYPE \a type. 978 979 \param name The label to associate the data with. 980 \param ref The reference to store in the message. 981 \see AddData() for a more detailed overview of the inner workings. 982 \see FindRef() 983 \see ReplaceRef() 984*/ 985 986 987/*! 988 \fn status_t BMessage::AddMessage(const char *name, const BMessage *message) 989 \brief Convenience method to add a message to the label \a name. 990 991 This method calls AddData() with the \c B_MESSAGE_TYPE \a type. 992 993 \param name The label to associate the data with. 994 \param message The message to store in this message. 995 \see AddData() for a more detailed overview of the inner workings. 996 \see FindMessage() 997 \see ReplaceMessage() 998*/ 999 1000 1001/*! 1002 \fn status_t BMessage::AddFlat(const char *name, BFlattenable *object, 1003 int32 count = 1) 1004 \brief Convenience method to add a flattenable to the label \a name. 1005 1006 This method uses BFlattenable::TypeCode() to determine the type. It also 1007 uses BFlattenable::IsFixedSize() to determine whether or not the size of 1008 the object is supposedly always the same. You can specify a 1009 \a count, to pre-allocate more entries if you are going to add 1010 more than one of this type. 1011 1012 \param name The label to associate the data with. 1013 \param object The object to flatten into the message. 1014 \param count The number of items to pre-allocate associated with this 1015 \a name. 1016 \see AddData() for a more detailed overview of the inner workings. 1017 \see FindFlat() 1018 \see ReplaceFlat() 1019*/ 1020 1021 1022//! @} 1023 1024 1025/*! 1026 \name Removing Data 1027*/ 1028 1029 1030//! @{ 1031 1032 1033/*! 1034 \fn status_t BMessage::RemoveData(const char *name, int32 index) 1035 \brief Remove data associated with \a name at a specified 1036 \a index. 1037 1038 If this is the only instance of the data, then the entire label will be 1039 removed. This means you can recreate it with another type. 1040 1041 \param name The \a name of which the associated data should be cleared. 1042 \param index The \a index of the item that should be cleared. 1043 \retval B_OK The data has been removed. 1044 \retval B_BAD_VALUE The \a index is less than \c 0. 1045 \retval B_BAD_INDEX The \a index is out of bounds. 1046 \retval B_NAME_NOT_FOUND The \a name does not hava any data 1047 associated with it. 1048 \see RemoveName() 1049 \see MakeEmpty() 1050*/ 1051 1052 1053/*! 1054 \fn status_t BMessage::RemoveName(const char *name) 1055 \brief Remove all data associated with a \a name. 1056 1057 This also removes the label, so that you can recreate it with another type, 1058 if you want to. 1059 1060 \param name The \a name that refers to the data you want to clear 1061 out. 1062 \retval B_OK All the data is removed. 1063 \retval B_BAD_VALUE The \a name pointer points to \c NULL. 1064 \retval B_NAME_NOT_FOUND The \a name does not exist in this message. 1065 \see RemoveData() 1066 \see MakeEmpty() 1067*/ 1068 1069 1070/*! 1071 \fn status_t BMessage::MakeEmpty() 1072 \brief Clear all data and metadata in this message. 1073 1074 Everything is cleared out, all labels and all associated data, as well 1075 as metadata such as reply info. 1076 1077 \return This method always returns \c B_OK. 1078 \see RemoveData() 1079 \see RemoveName() 1080*/ 1081 1082 1083//! @} 1084 1085 1086/*! 1087 \name Finding Data 1088 1089 Look at FindData() for a general introduction to finding data. 1090*/ 1091 1092/* TODO: 1093 Quick overview: 1094 1095 <table> 1096 <tr><th>Type of data</th><th>Type code</th><th>Method</td></tr> 1097 <tr><td>BRect</td><td>\c B_RECT_TYPE</td><td>FindRect()</td></tr> 1098 </table> 1099*/ 1100 1101 1102//! @{ 1103 1104 1105/*! 1106 \fn status_t BMessage::FindData(const char *name, type_code type, 1107 int32 index, const void **data, ssize_t *numBytes) const 1108 \brief Find \a data that is stored in this message at an 1109 \a index. 1110 1111 This method matches the label \a name with the \a type you 1112 are asking for, and it looks for the data that is stored at a certain 1113 \a index number. If all these things match, you will get a pointer 1114 to the internal buffer, and the method will put the size of the item in 1115 \a numBytes. 1116 1117 Note that only this method, and FindString(const char *, const char **), 1118 pass a pointer to the internal buffer. The other more specific methods, 1119 such as FindBool() and FindRect() copy the data into a buffer you specify. 1120 This means that the data retrieved with this method is valid until the 1121 message is deleted. 1122 1123 \param name The label the data should be associated with. 1124 \param type The type of data you want to retrieve. You can pass 1125 \c B_ANY_TYPE if you don't mind which type the data is. 1126 \param index The index in the array of the data that you want to retrieve. 1127 Note that the array is zero-based. 1128 \param[out] data A pointer to a pointer where the data can point to. 1129 \param[out] numBytes The size of the data will be put in this parameter. 1130 \retval B_OK The \a name was found, matches the type, and the data 1131 at \a index has been put in \a data. 1132 \retval B_BAD_VALUE One of the output arguments were \c NULL. 1133 \retval B_BAD_INDEX The \a index does not exist. 1134 \retval B_NAME_NOT_FOUND There is no field with this \a name. 1135 \see status_t FindData(const char *, type_code, int32, 1136 const void **, ssize_t *) const 1137*/ 1138 1139 1140/*! 1141 \fn status_t BMessage::FindData(const char *name, type_code type, 1142 const void **data, ssize_t *numBytes) const 1143 \brief Find \a data that is stored in this message. 1144 1145 This is an overloaded method of 1146 FindData(const char *, type_code, int32, const void **, ssize_t *) const 1147 where data is sought at \a index \c 0. 1148*/ 1149 1150 1151/*! 1152 \fn status_t BMessage::FindRect(const char *name, BRect *rect) const 1153 \brief Find a rectangle at the label \a name. 1154 1155 This is an overloaded method of 1156 FindRect(const char *, int32, BRect *) const 1157 where the data is sought at \a index \c 0. 1158*/ 1159 1160 1161/*! 1162 \fn status_t BMessage::FindRect(const char *name, int32 index, BRect *rect) const 1163 \brief Find a rectangle at the label \a name at an \a index. 1164 1165 This method looks for the data with the \c B_RECT_TYPE, and copies it into 1166 a provided buffer. 1167 1168 \param name The label to which the data is associated. 1169 \param index The index from which the data should be copied. 1170 \param rect The object in which the data should be copied. 1171 \retval B_OK The object now contains the requested data. 1172 \retval B_BAD_INDEX The \a index does not exist. 1173 \retval B_NAME_NOT_FOUND There is no field with this \a name. 1174 \see FindRect(const char *, BRect *) const 1175*/ 1176 1177 1178/*! 1179 \fn status_t BMessage::FindPoint(const char *name, BPoint *point) const 1180 \brief Find a point at the label \a name. 1181 1182 This is an overloaded method of 1183 FindPoint(const char *, int32, BPoint *) const 1184 where the data is sought at \a index \c 0. 1185*/ 1186 1187 1188/*! 1189 \fn status_t BMessage::FindPoint(const char *name, int32 index, BPoint *point) const 1190 \brief Find a point at the label \a name at an \a index. 1191 1192 This method looks for the data with the \c B_POINT_TYPE, and copies it into 1193 a provided buffer. 1194 1195 \param name The label to which the data is associated. 1196 \param index The index from which the data should be copied. 1197 \param point The object in which the data should be copied. 1198 \retval B_OK The object now contains the requested data. 1199 \retval B_BAD_INDEX The \a index does not exist. 1200 \retval B_NAME_NOT_FOUND There is no field with this \a name. 1201 \see FindPoint(const char *, BPoint *) const 1202*/ 1203 1204 1205/*! 1206 \fn status_t BMessage::FindString(const char *name, const char **string) const 1207 \brief Find a string at the label \a name. 1208 1209 This is an overloaded method of 1210 FindString(const char *, int32, const char **) const 1211 where the data is sought at \a index \c 0. 1212*/ 1213 1214 1215/*! 1216 \fn status_t BMessage::FindString(const char *name, int32 index, 1217 const char ** string) const 1218 \brief Find a string at the label \a name at an \a index. 1219 1220 This method looks for the data with the \c B_STRING_TYPE, and returns a 1221 pointer to the internal buffer of the message. Note that this pointer is 1222 valid, until the message is deleted. 1223 1224 \param name The label to which the data is associated. 1225 \param index The index from which the data should be copied. 1226 \param string The object in which the data should be copied. 1227 \retval B_OK The object now contains the requested data. 1228 \retval B_BAD_INDEX The \a index does not exist. 1229 \retval B_NAME_NOT_FOUND There is no field with this \a name. 1230 \see FindString(const char *, const char **) const 1231 \see FindString(const char *, int32, BString *) const 1232*/ 1233 1234 1235/*! 1236 \fn status_t BMessage::FindString(const char *name, BString *string) const 1237 \brief Find a string at the label \a name. 1238 1239 This is an overloaded method of 1240 FindString(const char *, int32, BString *) const 1241 where the data is sought at \a index \c 0. 1242*/ 1243 1244 1245/*! 1246 \fn status_t BMessage::FindString(const char *name, int32 index, BString *string) const 1247 \brief Find a string at the label \a name at an \a index. 1248 1249 This method looks for the data with the \c B_STRING_TYPE, and copies it 1250 into the \a string object. 1251 1252 \param name The label to which the data is associated. 1253 \param index The index from which the data should be copied. 1254 \param string The object in which the data should be copied. 1255 \retval B_OK The object now contains the requested data. 1256 \retval B_BAD_INDEX The \a index does not exist. 1257 \retval B_NAME_NOT_FOUND There is no field with this \a name. 1258 \see FindString(const char *, BString *) const 1259 \see FindString(const char *, int32, const char **) const 1260*/ 1261 1262 1263/*! 1264 \fn status_t BMessage::FindInt8(const char *name, int8 *value) const 1265 \brief Find an integer at the label \a name. 1266 1267 This is an overloaded method of FindInt8(const char *, int32, int8 *) const 1268 where the data is sought at \a index \c 0. 1269*/ 1270 1271 1272/*! 1273 \fn status_t BMessage::FindInt8(const char *name, int32 index, int8 *value) const 1274 \brief Find an integer at the label \a name at an \a index. 1275 1276 This method looks for the data with the \c B_INT8_TYPE, and copies it into 1277 a provided buffer. 1278 1279 \param name The label to which the data is associated. 1280 \param index The index from which the data should be copied. 1281 \param value The object in which the data should be copied. 1282 \retval B_OK The object now contains the requested data. 1283 \retval B_BAD_INDEX The \a index does not exist. 1284 \retval B_NAME_NOT_FOUND There is no field with this \a name. 1285 \see FindInt8(const char *, int8 *) const 1286*/ 1287 1288 1289/*! 1290 \fn status_t BMessage::FindInt16(const char *name, int16 *value) const 1291 \brief Find an integer at the label \a name. 1292 1293 This is an overloaded method of FindInt8(const char *, int32, int16 *) const 1294 where the data is sought at \a index \c 0. 1295*/ 1296 1297 1298/*! 1299 \fn status_t BMessage::FindInt16(const char *name, int32 index, int16 *value) const 1300 \brief Find an integer at the label \a name at an \a index. 1301 1302 This method looks for the data with the \c B_INT16_TYPE, and copies it into 1303 a provided buffer. 1304 1305 \param name The label to which the data is associated. 1306 \param index The index from which the data should be copied. 1307 \param value The object in which the data should be copied. 1308 \retval B_OK The object now contains the requested data. 1309 \retval B_BAD_INDEX The \a index does not exist. 1310 \retval B_NAME_NOT_FOUND There is no field with this \a name. 1311 \see FindInt16(const char *, int16 *) const 1312*/ 1313 1314 1315/*! 1316 \fn status_t BMessage::FindInt32(const char *name, int32 *value) const 1317 \brief Find an integer at the label \a name. 1318 1319 This is an overloaded method of 1320 FindInt32(const char *, int32, int32 *) const 1321 where the data is sought at \a index \c 0. 1322*/ 1323 1324 1325/*! 1326 \fn status_t BMessage::FindInt32(const char *name, int32 index, int32 *value) const 1327 \brief Find an integer at the label \a name at an \a index. 1328 1329 This method looks for the data with the \c B_INT32_TYPE, and copies it into 1330 a provided buffer. 1331 1332 \param name The label to which the data is associated. 1333 \param index The index from which the data should be copied. 1334 \param value The object in which the data should be copied. 1335 \retval B_OK The object now contains the requested data. 1336 \retval B_BAD_INDEX The \a index does not exist. 1337 \retval B_NAME_NOT_FOUND There is no field with this \a name. 1338 \see FindInt32(const char *, int32 *) const 1339*/ 1340 1341 1342/*! 1343 \fn status_t BMessage::FindInt64(const char *name, int64 *value) const 1344 \brief Find an integer at the label \a name. 1345 1346 This is an overloaded method of 1347 FindInt64(const char *, int32, int64 *) const 1348 where the data is sought at \a index \c 0. 1349*/ 1350 1351 1352/*! 1353 \fn status_t BMessage::FindInt64(const char *name, int32 index, int64 *value) const 1354 \brief Find an integer at the label \a name at an \a index. 1355 1356 This method looks for the data with the \c B_INT64_TYPE, and copies it into 1357 a provided buffer. 1358 1359 \param name The label to which the data is associated. 1360 \param index The index from which the data should be copied. 1361 \param value The object in which the data should be copied. 1362 \retval B_OK The object now contains the requested data. 1363 \retval B_BAD_INDEX The \a index does not exist. 1364 \retval B_NAME_NOT_FOUND There is no field with this \a name. 1365 \see FindInt64(const char *, int64 *) const 1366*/ 1367 1368 1369/*! 1370 \fn status_t BMessage::FindBool(const char *name, bool *value) const 1371 \brief Find a boolean at the label \a name. 1372 1373 This is an overloaded method of 1374 FindBool(const char *, int32, bool *) const 1375 where the data is sought at \a index \c 0. 1376*/ 1377 1378 1379/*! 1380 \fn status_t BMessage::FindBool(const char *name, int32 index, bool *value) const 1381 \brief Find a boolean at the label \a name at an \a index. 1382 1383 This method looks for the data with the \c B_BOOL_TYPE, and copies it into 1384 a provided buffer. 1385 1386 \param name The label to which the data is associated. 1387 \param index The index from which the data should be copied. 1388 \param value The object in which the data should be copied. 1389 \retval B_OK The object now contains the requested data. 1390 \retval B_BAD_INDEX The \a index does not exist. 1391 \retval B_NAME_NOT_FOUND There is no field with this \a name. 1392 \see FindBool(const char *, bool *) const 1393*/ 1394 1395 1396/*! 1397 \fn status_t BMessage::FindFloat(const char *name, float *value) const 1398 \brief Find a float at the label \a name. 1399 1400 This is an overloaded method of 1401 FindFloat(const char *, int32, float *) const 1402 where the data is sought at \a index \c 0. 1403*/ 1404 1405 1406/*! 1407 \fn status_t BMessage::FindFloat(const char *name, int32 index, float *value) const 1408 \brief Find a float at the label \a name at an \a index. 1409 1410 This method looks for the data with the \c B_FLOAT_TYPE, and copies it into 1411 a provided buffer. 1412 1413 \param name The label to which the data is associated. 1414 \param index The index from which the data should be copied. 1415 \param value The object in which the data should be copied. 1416 \retval B_OK The object now contains the requested data. 1417 \retval B_BAD_INDEX The \a index does not exist. 1418 \retval B_NAME_NOT_FOUND There is no field with this \a name. 1419 \see FindFloat(const char *, float *) const 1420*/ 1421 1422 1423/*! 1424 \fn status_t BMessage::FindDouble(const char *name, double *value) const 1425 \brief Find a double at the label \a name. 1426 1427 This is an overloaded method of 1428 FindDouble(const char *, int32, double *) const 1429 where the data is sought at \a index \c 0. 1430*/ 1431 1432 1433/*! 1434 \fn status_t BMessage::FindDouble(const char *name, int32 index, double *value) const 1435 \brief Find a double at the label \a name at an \a index. 1436 1437 This method looks for the data with the \c B_DOUBLE_TYPE, and copies it into 1438 a provided buffer. 1439 1440 \param name The label to which the data is associated. 1441 \param index The index from which the data should be copied. 1442 \param value The object in which the data should be copied. 1443 \retval B_OK The object now contains the requested data. 1444 \retval B_BAD_INDEX The \a index does not exist. 1445 \retval B_NAME_NOT_FOUND There is no field with this \a name. 1446 \see FindDouble(const char *, double *) const 1447*/ 1448 1449 1450/*! 1451 \fn status_t BMessage::FindPointer(const char *name, void **pointer) const 1452 \brief Find a pointer at the label \a name. 1453 1454 This is an overloaded method of 1455 FindPointer(const char *, int32, void *) const 1456 where the data is sought at \a index \c 0. 1457*/ 1458 1459 1460/*! 1461 \fn status_t BMessage::FindPointer(const char *name, int32 index, void **pointer) const 1462 \brief Find a pointer at the label \a name at an \a index. 1463 1464 This method looks for the data with the \c B_POINTER_TYPE, and copies it into 1465 a provided buffer. 1466 1467 \warning If you want to share objects between applications, please remember 1468 that each application has its own address space, and that it therefore 1469 is useless to try to pass around objects by sending pointers in 1470 messages. You should think about copying the entire object in the 1471 message, or you should consider using shared memory. 1472 1473 \param name The label to which the data is associated. 1474 \param index The index from which the data should be copied. 1475 \param pointer The object in which the data should be copied. 1476 \retval B_OK The object now contains the requested data. 1477 \retval B_BAD_INDEX The \a index does not exist. 1478 \retval B_NAME_NOT_FOUND There is no field with this \a name. 1479 \see FindPointer(const char *, double *) const 1480*/ 1481 1482 1483/*! 1484 \fn status_t BMessage::FindMessenger(const char *name, BMessenger *messenger) const 1485 \brief Find a messenger at the label \a name. 1486 1487 This is an overloaded method of 1488 FindMessenger(const char *, int32, BMessenger *) const 1489 where the data is sought at \a index \c 0. 1490*/ 1491 1492 1493/*! 1494 \fn status_t BMessage::FindMessenger(const char *name, int32 index, BMessenger *messenger) const 1495 \brief Find a messenger at the label \a name at an \a index. 1496 1497 This method looks for the data with the \c B_MESSENGER_TYPE, and copies it 1498 into a provided buffer. 1499 1500 \param name The label to which the data is associated. 1501 \param index The index from which the data should be copied. 1502 \param messenger The object in which the data should be copied. 1503 \retval B_OK The object now contains the requested data. 1504 \retval B_BAD_INDEX The \a index does not exist. 1505 \retval B_NAME_NOT_FOUND There is no field with this \a name. 1506 \see FindMessenger(const char *, BMessenger *) const 1507*/ 1508 1509 1510/*! 1511 \fn status_t BMessage::FindRef(const char *name, entry_ref *ref) const 1512 \brief Find a reference to a file at the label \a name. 1513 1514 This is an overloaded method of 1515 FindRef(const char *, int32, entry_ref *) const 1516 where the data is sought at \a index \c 0. 1517*/ 1518 1519 1520/*! 1521 \fn status_t BMessage::FindRef(const char *name, int32 index, entry_ref *ref) const 1522 \brief Find a reference to a file at the label \a name at an 1523 \a index. 1524 1525 This method looks for the data with the \c B_REF_TYPE, and copies it into 1526 a provided buffer. 1527 1528 \param name The label to which the data is associated. 1529 \param index The index from which the data should be copied. 1530 \param ref The object in which the data should be copied. 1531 \retval B_OK The object now contains the requested data. 1532 \retval B_BAD_INDEX The \a index does not exist. 1533 \retval B_NAME_NOT_FOUND There is no field with this \a name. 1534 \see FindRef(const char *, entry_ref *) const 1535*/ 1536 1537 1538/*! 1539 \fn status_t BMessage::FindMessage(const char *name, BMessage *message) const 1540 \brief Find a message at the label \a name. 1541 1542 This is an overloaded method of 1543 FindMessage(const char *, int32, BMessage *) const 1544 where the data is sought at \a index \c 0. 1545*/ 1546 1547 1548/*! 1549 \fn status_t BMessage::FindMessage(const char *name, int32 index, BMessage *message) const 1550 \brief Find a message at the label \a name at an \a index. 1551 1552 This method looks for the data with the \c B_MESSAGE_TYPE, and copies it 1553 into a provided buffer. 1554 1555 \param name The label to which the data is associated. 1556 \param index The index from which the data should be copied. 1557 \param message The object in which the data should be copied. 1558 \retval B_OK The object now contains the requested data. 1559 \retval B_BAD_INDEX The \a index does not exist. 1560 \retval B_NAME_NOT_FOUND There is no field with this \a name. 1561 \see FindMessage(const char *, BMessage *) const 1562*/ 1563 1564 1565/*! 1566 \fn status_t BMessage::FindFlat(const char *name, BFlattenable *object) const 1567 \brief Find a flattened object at the label \a name. 1568 1569 This is an overloaded method of 1570 FindFlat(const char *, int32, BFlattenable *) const 1571 where the data is sought at \a index \c 0. 1572*/ 1573 1574 1575/*! 1576 \fn status_t BMessage::FindFlat(const char *name, int32 index, 1577 BFlattenable *object) const 1578 \brief Find a flattened object at the label \a name at an 1579 \a index. 1580 1581 The type is determined by the type of the passed object. If that type is 1582 available at the specified label, then the Unflatten() method of that 1583 object will be called. 1584 1585 \param name The label to which the data is associated. 1586 \param index The index from which the data should be unflattened. 1587 \param object The object in which the data should be unflattened. 1588 \retval B_OK The object now contains the requested data. 1589 \retval B_BAD_INDEX The \a index does not exist. 1590 \retval B_NAME_NOT_FOUND There is no field with this \a name. 1591 \see FindFlat(const char *, BFlattenable *) const 1592*/ 1593 1594 1595//! @} 1596 1597 1598/*! 1599 \name Replacing Data 1600 1601 Look at ReplaceData() for a general introduction to replacing data. 1602*/ 1603 1604 1605//! @{ 1606 1607 1608/*! 1609 \fn status_t BMessage::ReplaceData(const char *name, type_code type, 1610 const void *data, ssize_t numBytes) 1611 \brief Replace the data at label \a name. 1612 1613 This method is an overloaded method that replaces the data at 1614 \a index \c 0. See 1615 ReplaceData(const char *, type_code, int32, const void *, ssize_t). 1616*/ 1617 1618 1619/*! 1620 \fn status_t BMessage::ReplaceData(const char *name, type_code type, 1621 int32 index, const void *data, ssize_t numBytes) 1622 \brief Replace the data at label \a name at a specified 1623 \a index. 1624 1625 The conditions for replacing data are that the\a name is correct, 1626 the \a type matches and the data entry at \a index 1627 exists. 1628 1629 There is also a collection of convenience methods, that allow you to 1630 efficiently replace rectanges (ReplaceRect()), booleans (ReplaceBool()), 1631 and so on. 1632 1633 \param name The name associated with the data to replace. 1634 \param type The type of the data. 1635 \param index The index in the array to replace. 1636 \param data A pointer to the new data that needs to be copied into the 1637 message. 1638 \param numBytes The size of the new data. 1639 1640 \retval B_OK The operation succeeded. 1641 \retval B_BAD_VALUE One of the input parameters are invalid. Check that 1642 you did not pass \c NULL, and in case the field has fixed sized data, 1643 check that \a numBytes is the same as the specified fixed size. 1644 \retval B_BAD_INDEX The \a index is out of range. 1645*/ 1646 1647 1648/*! 1649 \fn status_t BMessage::ReplaceRect(const char *name, BRect aRect) 1650 \brief Replace a rectangle at the label \a name. 1651 1652 This method is an overloaded method of 1653 ReplaceRect(const char *, int32, BRect). 1654 It replaces the data at \a index \c 0. 1655*/ 1656 1657 1658/*! 1659 \fn status_t BMessage::ReplaceRect(const char *name, int32 index, BRect aRect) 1660 \brief Replace a rectangle at the label \a name at a specified 1661 \a index. 1662 1663 The data at the specified \a name and \a index will be 1664 replaced, if it matches the \c B_RECT_TYPE. 1665 \param name The name associated with the data to replace. 1666 \param index The index in the array to replace. 1667 \param aRect The object to store in the message. 1668 \retval B_OK The operation succeeded. 1669 \retval B_BAD_INDEX The index was out of range. 1670 \see ReplaceRect(const char*, BRect) 1671*/ 1672 1673 1674/*! 1675 \fn status_t BMessage::ReplacePoint(const char *name, BPoint aPoint) 1676 \brief Replace a point at the label \a name. 1677 1678 This method is an overloaded method of 1679 ReplacePoint(const char *, int32, BPoint). 1680 It replaces the data at \a index \c 0. 1681*/ 1682 1683 1684/*! 1685 \fn status_t BMessage::ReplacePoint(const char *name, int32 index, BPoint aPoint) 1686 \brief Replace a point at the label \a name at a specified 1687 \a index. 1688 1689 The data at the specified \a name and \a index will be 1690 replaced, if it matches the \c B_POINT_TYPE. 1691 \param name The name associated with the data to replace. 1692 \param index The index in the array to replace. 1693 \param aPoint The object to store in the message. 1694 \retval B_OK The operation succeeded. 1695 \retval B_BAD_INDEX The index was out of range. 1696 \see ReplacePoint(const char*, aPoint) 1697*/ 1698 1699 1700/*! 1701 \fn status_t BMessage::ReplaceString(const char *name, const char *aString) 1702 \brief Replace a string at the label \a name. 1703 1704 This method is an overloaded method of 1705 ReplaceString(const char *, int32, const char *). 1706 It replaces the data at \a index \c 0. 1707*/ 1708 1709 1710/*! 1711 \fn status_t BMessage::ReplaceString(const char *name, int32 index, const char *aString) 1712 \brief Replace a string at the label \a name at a specified 1713 \a index. 1714 1715 The data at the specified \a name and \a index will be 1716 replaced, if it matches the \c B_STRING_TYPE. 1717 \param name The name associated with the data to replace. 1718 \param index The index in the array to replace. 1719 \param aString The object to store in the message. 1720 \retval B_OK The operation succeeded. 1721 \retval B_BAD_INDEX The index was out of range. 1722 \see ReplaceString(const char*, const char *) 1723*/ 1724 1725 1726/*! 1727 \fn status_t BMessage::ReplaceString(const char *name, const BString &aString) 1728 \brief Replace a string at the label \a name. 1729 1730 This method is an overloaded method of 1731 ReplaceString(const char *, int32, BString &). 1732 It replaces the data at \a index \c 0. 1733*/ 1734 1735 1736/*! 1737 \fn status_t BMessage::ReplaceString(const char *name, int32 index, const BString &aString) 1738 \brief Replace a string at the label \a name at a specified 1739 \a index. 1740 1741 The data at the specified \a name and \a index will be 1742 replaced, if it matches the \c B_STRING_TYPE. 1743 \param name The name associated with the data to replace. 1744 \param index The index in the array to replace. 1745 \param aString The object to store in the message. 1746 \retval B_OK The operation succeeded. 1747 \retval B_BAD_INDEX The index was out of range. 1748 \see ReplaceString(const char*, BString &) 1749*/ 1750 1751 1752/*! 1753 \fn status_t BMessage::ReplaceInt8(const char *name, int8 value) 1754 \brief Replace an integer at the label \a name. 1755 1756 This method is an overloaded method of 1757 ReplaceInt8(const char *, int32, int8). 1758 It replaces the data at \a index \c 0. 1759*/ 1760 1761 1762/*! 1763 \fn status_t BMessage::ReplaceInt8(const char *name, int32 index, int8 value) 1764 \brief Replace an integer at the label \a name at a specified 1765 \a index. 1766 1767 The data at the specified \a name and \a index will be 1768 replaced, if it matches the \c B_INT8_TYPE. 1769 \param name The name associated with the data to replace. 1770 \param index The index in the array to replace. 1771 \param value The object to store in the message. 1772 \retval B_OK The operation succeeded. 1773 \retval B_BAD_INDEX The index was out of range. 1774 \see ReplaceInt8(const char*, int8) 1775*/ 1776 1777 1778/*! 1779 \fn status_t BMessage::ReplaceInt16(const char *name, int16 value) 1780 \brief Replace an integer at the label \a name. 1781 1782 This method is an overloaded method of 1783 ReplaceInt16(const char *, int32, int16). 1784 It replaces the data at \a index \c 0. 1785*/ 1786 1787 1788/*! 1789 \fn status_t BMessage::ReplaceInt16(const char *name, int32 index, int16 value) 1790 \brief Replace an integer at the label \a name at a specified 1791 \a index. 1792 1793 The data at the specified \a name and \a index will be 1794 replaced, if it matches the \c B_INT16_TYPE. 1795 \param name The name associated with the data to replace. 1796 \param index The index in the array to replace. 1797 \param value The object to store in the message. 1798 \retval B_OK The operation succeeded. 1799 \retval B_BAD_INDEX The index was out of range. 1800 \see ReplaceInt16(const char*, int16) 1801*/ 1802 1803 1804/*! 1805 \fn status_t BMessage::ReplaceInt32(const char *name, int32 value) 1806 \brief Replace an integer at the label \a name. 1807 1808 This method is an overloaded method of 1809 ReplaceInt8(const char *, int32, int32). 1810 It replaces the data at \a index \c 0. 1811*/ 1812 1813 1814/*! 1815 \fn status_t BMessage::ReplaceInt32(const char *name, int32 index, int32 value) 1816 \brief Replace an integer at the label \a name at a specified 1817 \a index. 1818 1819 The data at the specified \a name and \a index will be 1820 replaced, if it matches the \c B_INT32_TYPE. 1821 \param name The name associated with the data to replace. 1822 \param index The index in the array to replace. 1823 \param value The object to store in the message. 1824 \retval B_OK The operation succeeded. 1825 \retval B_BAD_INDEX The index was out of range. 1826 \see ReplaceInt32(const char*, int32) 1827*/ 1828 1829 1830/*! 1831 \fn status_t BMessage::ReplaceInt64(const char *name, int64 value) 1832 \brief Replace an integer at the label \a name. 1833 1834 This method is an overloaded method of 1835 ReplaceInt8(const char *, int32, int64). 1836 It replaces the data at \a index \c 0. 1837*/ 1838 1839 1840/*! 1841 \fn status_t BMessage::ReplaceInt64(const char *name, int32 index, int64 value) 1842 \brief Replace an integer at the label \a name at a specified 1843 \a index. 1844 1845 The data at the specified \a name and \a index will be 1846 replaced, if it matches the \c B_INT64_TYPE. 1847 \param name The name associated with the data to replace. 1848 \param index The index in the array to replace. 1849 \param value The object to store in the message. 1850 \retval B_OK The operation succeeded. 1851 \retval B_BAD_INDEX The index was out of range. 1852 \see ReplaceInt64(const char*, int64) 1853*/ 1854 1855 1856/*! 1857 \fn status_t BMessage::ReplaceBool(const char *name, bool aBoolean) 1858 \brief Replace a boolean at the label \a name. 1859 1860 This method is an overloaded method of 1861 ReplaceBool(const char *, int32, bool). 1862 It replaces the data at \a index \c 0. 1863*/ 1864 1865 1866/*! 1867 \fn status_t BMessage::ReplaceBool(const char *name, int32 index, bool aBoolean) 1868 \brief Replace a boolean at the label \a name at a specified 1869 \a index. 1870 1871 The data at the specified \a name and \a index will be 1872 replaced, if it matches the \c B_BOOL_TYPE. 1873 1874 \param name The name associated with the data to replace. 1875 \param index The index in the array to replace. 1876 \param aBoolean The object to store in the message. 1877 \retval B_OK The operation succeeded. 1878 \retval B_BAD_INDEX The index was out of range. 1879 \see ReplaceBool(const char*, bool) 1880*/ 1881 1882 1883/*! 1884 \fn status_t BMessage::ReplaceFloat(const char *name, float aFloat) 1885 \brief Replace a float at the label \a name. 1886 1887 This method is an overloaded method of 1888 ReplaceFloat(const char *, int32, float). 1889 It replaces the data at \a index \c 0. 1890*/ 1891 1892 1893/*! 1894 \fn status_t BMessage::ReplaceFloat(const char *name, int32 index, float aFloat) 1895 \brief Replace a float at the label \a name at a specified 1896 \a index. 1897 1898 The data at the specified \a name and \a index will be 1899 replaced, if it matches the \c B_FLOAT_TYPE. 1900 1901 \param name The name associated with the data to replace. 1902 \param index The index in the array to replace. 1903 \param aFloat The object to store in the message. 1904 \retval B_OK The operation succeeded. 1905 \retval B_BAD_INDEX The index was out of range. 1906 \see ReplaceFloat(const char*, float) 1907*/ 1908 1909 1910/*! 1911 \fn status_t BMessage::ReplaceDouble(const char *name, double aDouble) 1912 \brief Replace a double at the label \a name. 1913 1914 This method is an overloaded method of 1915 ReplaceDouble(const char *, int32, double). 1916 It replaces the data at \a index \c 0. 1917*/ 1918 1919 1920/*! 1921 \fn status_t BMessage::ReplaceDouble(const char *name, int32 index, double aDouble) 1922 \brief Replace a double at the label \a name at a specified 1923 \a index. 1924 1925 The data at the specified \a name and \a index will be 1926 replaced, if it matches the \c B_DOUBLE_TYPE. 1927 1928 \param name The name associated with the data to replace. 1929 \param index The index in the array to replace. 1930 \param aDouble The object to store in the message. 1931 \retval B_OK The operation succeeded. 1932 \retval B_BAD_INDEX The index was out of range. 1933 \see ReplaceDouble(const char*, double) 1934*/ 1935 1936 1937/*! 1938 \fn status_t BMessage::ReplacePointer(const char *name, const void *pointer) 1939 \brief Replace a pointer at the label \a name. 1940 1941 This method is an overloaded method of 1942 ReplacePointer(const char *, int32, const void *). 1943 It replaces the data at \a index \c 0. 1944*/ 1945 1946 1947/*! 1948 \fn status_t BMessage::ReplacePointer(const char *name,int32 index, const void *pointer) 1949 \brief Replace a pointer at the label \a name at a specified \a index. 1950 1951 The data at the specified \a name and \a index will be 1952 replaced, if it matches the \c B_POINTER_TYPE. 1953 1954 \param name The name associated with the data to replace. 1955 \param index The index in the array to replace. 1956 \param pointer The object to store in the message. 1957 \retval B_OK The operation succeeded. 1958 \retval B_BAD_INDEX The index was out of range. 1959 \see ReplacePointer(const char*, const void *) 1960*/ 1961 1962 1963/*! 1964 \fn status_t BMessage::ReplaceMessenger(const char *name, BMessenger messenger) 1965 \brief Replace a messenger at the label \a name. 1966 1967 This method is an overloaded method of 1968 ReplaceMessenger(const char *, int32, BMessenger). 1969 It replaces the data at \a index \c 0. 1970*/ 1971 1972 1973/*! 1974 \fn status_t BMessage::ReplaceMessenger(const char *name, int32 index, BMessenger messenger) 1975 \brief Replace a messenger at the label \a name at a specified 1976 \a index. 1977 1978 The data at the specified \a name and \a index will be 1979 replaced, if it matches the \c B_MESSENGER_TYPE. 1980 1981 \param name The name associated with the data to replace. 1982 \param index The index in the array to replace. 1983 \param messenger The object to store in the message. 1984 \retval B_OK The operation succeeded. 1985 \retval B_BAD_INDEX The index was out of range. 1986 \see ReplaceMessenger(const char*, BMessenger) 1987*/ 1988 1989 1990/*! 1991 \fn status_t BMessage::ReplaceRef(const char *name,const entry_ref *ref) 1992 \brief Replace a reference to a file at the label \a name. 1993 1994 This method is an overloaded method of 1995 ReplaceRef(const char *, int32, entry_ref *). 1996 It replaces the data at \a index \c 0. 1997*/ 1998 1999 2000/*! 2001 \fn status_t BMessage::ReplaceRef( const char *name, int32 index, const entry_ref *ref) 2002 \brief Replace a reference to a file at the label \a name at a 2003 specified \a index. 2004 2005 The data at the specified \a name and \a index will be 2006 replaced, if it matches the \c B_REF_TYPE. 2007 2008 \param name The name associated with the data to replace. 2009 \param index The index in the array to replace. 2010 \param ref The object to store in the message. 2011 \retval B_OK The operation succeeded. 2012 \retval B_BAD_INDEX The index was out of range. 2013 \see ReplaceRef(const char*, entry_ref *) 2014*/ 2015 2016 2017/*! 2018 \fn status_t BMessage::ReplaceMessage(const char *name, const BMessage *message) 2019 \brief Replace a message at the label \a name. 2020 2021 This method is an overloaded method of 2022 ReplaceMessage(const char *, int32, BMessage *). 2023 It replaces the data at \a index \c 0. 2024*/ 2025 2026 2027/*! 2028 \fn status_t BMessage::ReplaceMessage(const char *name, int32 index, const BMessage *message) 2029 \brief Replace a message at the label \a name at a specified 2030 \a index. 2031 2032 The data at the specified \a name and \a index will be 2033 replaced, if it matches the \c B_MESSAGE_TYPE. 2034 2035 \param name The name associated with the data to replace. 2036 \param index The index in the array to replace. 2037 \param message The object to store in the message. 2038 \retval B_OK The operation succeeded. 2039 \retval B_BAD_INDEX The index was out of range. 2040 \see ReplaceMessage(const char*, BMessage *) 2041*/ 2042 2043 2044/*! 2045 \fn status_t BMessage::ReplaceFlat(const char *name, BFlattenable *object) 2046 \brief Replace a flattened object at the label \a name. 2047 2048 This method is an overloaded method of 2049 ReplaceFlat(const char *, int32, BFlattenable *). 2050 2051 It replaces the data at \a index \c 0. 2052*/ 2053 2054 2055/*! 2056 \fn status_t BMessage::ReplaceFlat(const char *name, int32 index, BFlattenable *object) 2057 \brief Replace a flattened object at the label \a name at a 2058 specified \a index. 2059 2060 The data at the specified \a name and \a index will be 2061 replaced, if it matches the type returned by your object. This method uses 2062 BFlattenable::TypeCode() to determine the type of the object. 2063 2064 \param name The name associated with the data to replace. 2065 \param index The index in the array to replace. 2066 \param object The object to store in the message. 2067 2068 \retval B_OK The operation succeeded. 2069 \retval B_BAD_INDEX The index was out of range. 2070 2071 \see ReplaceFlat(const char*, BFlattenable *) 2072*/ 2073 2074 2075//! @} 2076 2077 2078/*! 2079 \name Deprecated methods 2080 2081 These methods are \e very likely to disappear, and they have been replaced 2082 by safer and more powerful methods. These methods are still implemented 2083 for binary compatibility, but they are not documented. 2084*/ 2085 2086 2087//! @{ 2088 2089 2090/*! 2091 \fn void *BMessage::operator new(size_t size) 2092 \brief Internal operator. 2093*/ 2094 2095 2096/*! 2097 \fn void *BMessage::operator new(size_t, void *pointer) 2098 \brief Internal operator. 2099*/ 2100 2101 2102/*! 2103 \fn void BMessage::operator delete(void *pointer, size_t size) 2104 \brief Internal operator. 2105*/ 2106 2107 2108/*! 2109 \fn bool BMessage::HasRect(const char *, int32) const 2110 \brief Deprecated. 2111*/ 2112 2113 2114/*! 2115 \fn bool BMessage::HasPoint(const char *, int32) const 2116 \brief Deprecated. 2117*/ 2118 2119 2120/*! 2121 \fn bool BMessage::HasString(const char *, int32) const 2122 \brief Deprecated. 2123*/ 2124 2125 2126/*! 2127 \fn bool BMessage::HasInt8(const char *, int32) const 2128 \brief Deprecated. 2129*/ 2130 2131 2132/*! 2133 \fn bool BMessage::HasInt16(const char *, int32) const 2134 \brief Deprecated. 2135*/ 2136 2137 2138/*! 2139 \fn bool BMessage::HasInt32(const char *, int32) const 2140 \brief Deprecated. 2141*/ 2142 2143 2144/*! 2145 \fn bool BMessage::HasInt64(const char *, int32) const 2146 \brief Deprecated. 2147*/ 2148 2149 2150/*! 2151 \fn bool BMessage::HasBool(const char *, int32) const 2152 \brief Deprecated. 2153*/ 2154 2155 2156/*! 2157 \fn bool BMessage::HasFloat(const char *, int32) const 2158 \brief Deprecated. 2159*/ 2160 2161 2162/*! 2163 \fn bool BMessage::HasDouble(const char *, int32) const 2164 \brief Deprecated. 2165*/ 2166 2167 2168/*! 2169 \fn bool BMessage::HasPointer(const char *, int32) const 2170 \brief Deprecated. 2171*/ 2172 2173 2174/*! 2175 \fn bool BMessage::HasMessenger(const char *, int32) const 2176 \brief Deprecated. 2177*/ 2178 2179 2180/*! 2181 \fn bool BMessage::HasRef(const char *, int32) const 2182 \brief Deprecated. 2183*/ 2184 2185 2186/*! 2187 \fn bool BMessage::HasMessage(const char *, int32) const 2188 \brief Deprecated. 2189*/ 2190 2191 2192/*! 2193 \fn bool BMessage::HasFlat(const char *, const BFlattenable *) const 2194 \brief Deprecated. 2195*/ 2196 2197 2198/*! 2199 \fn bool BMessage::HasFlat(const char *, int32, const BFlattenable *) const 2200 \brief Deprecated. 2201*/ 2202 2203 2204/*! 2205 \fn bool BMessage::HasData(const char *, type_code , int32) const 2206 \brief Deprecated. 2207*/ 2208 2209 2210/*! 2211 \fn BRect BMessage::FindRect(const char *, int32) const 2212 \brief Deprecated. 2213*/ 2214 2215 2216/*! 2217 \fn BPoint BMessage::FindPoint(const char *, int32) const 2218 \brief Deprecated. 2219*/ 2220 2221 2222/*! 2223 \fn const char *BMessage::FindString(const char *, int32) const 2224 \brief Deprecated. 2225*/ 2226 2227 2228/*! 2229 \fn int8 BMessage::FindInt8(const char *, int32) const 2230 \brief Deprecated. 2231*/ 2232 2233 2234/*! 2235 \fn int16 BMessage::FindInt16(const char *, int32) const 2236 \brief Deprecated. 2237*/ 2238 2239 2240/*! 2241 \fn int32 BMessage::FindInt32(const char *, int32) const 2242 \brief Deprecated. 2243*/ 2244 2245 2246/*! 2247 \fn int64 BMessage::FindInt64(const char *, int32) const 2248 \brief Deprecated. 2249*/ 2250 2251 2252/*! 2253 \fn bool BMessage::FindBool(const char *, int32) const 2254 \brief Deprecated. 2255*/ 2256 2257 2258/*! 2259 \fn float BMessage::FindFloat(const char *, int32) const 2260 \brief Deprecated. 2261*/ 2262 2263 2264/*! 2265 \fn double BMessage::FindDouble(const char *, int32) const 2266 \brief Deprecated. 2267*/ 2268 2269 2270//! @} 2271