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