1/* 2 * Copyright 2007-2014 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stefano Ceccherini, burton666@freemail.it 7 * Marc Flerackers, mflerackers@androme.be 8 * Niels Sascha Reedijk, niels.reedijk@gmail.com 9 * John Scipione, jscipione@gmail.com 10 * Oliver Tappe, openbeos@hirschaefer.de 11 * 12 * Corresponds to: 13 * headers/os/support/String.h rev 43319 14 * src/kits/support/String.cpp rev 42682 15 */ 16 17 18/*! 19 \file String.h 20 \ingroup support 21 \ingroup libbe 22 \brief Defines the BString class and global operators and functions for 23 handling strings. 24*/ 25 26 27/*! 28 \class BString String.h 29 \ingroup support 30 \ingroup libbe 31 \brief String class supporting common string operations. 32 33 BString is a string allocation and manipulation class. The object 34 takes care to allocate and free memory for you, so it will always be 35 "big enough" to store your strings. 36 37 While BString is in essence a wrapper around a byte-array, which can always 38 be accessed with the BString::String() method, it does have some 39 understanding of UTF-8 and it can be used for the manipulation of UTF-8 40 strings. For all operations that perform on bytes, there is an equivalent 41 that operates on UTF-8 strings. See for example the BString::CopyInto() and 42 BString::CopyCharsInto() methods. The main difference is that if there are 43 any position argumens, the regular method counts the bytes and the 44 Chars methods counts characters. 45 46 \since BeOS R5 47*/ 48 49 50/*! 51 \fn BString::BString() 52 \brief Creates an empty BString. 53 54 \since BeOS R5 55*/ 56 57 58/*! 59 \fn BString::BString(const char* string) 60 \brief Creates and initializes a BString from \a string. 61 62 \param string The \a string to copy from. 63 64 \since BeOS R5 65*/ 66 67 68/*! 69 \fn BString::BString(const BString& string) 70 \brief Creates and initializes a BString as a copy of another \a string. 71 72 \param string The BString object to copy from. 73 74 \since BeOS R5 75*/ 76 77 78/*! 79 \fn BString::BString(const char* string, int32 maxLength) 80 \brief Creates and initializes a BString from a \a string up to 81 \a maxLength characters. 82 83 If \a maxLength is greater than the length of the source \a string then the 84 entire source \a string is copied. If \a maxLength is less than or equal 85 to 0 then the result is an empty BString. 86 87 \warning In BeOS R5 passing in a negative \a maxLength argument will copy 88 the entire \a string. 89 90 \param string The \a string data to initialize the BString to. 91 \param maxLength Maximum number of characters (bytes) to copy. 92 93 \since BeOS R5 94*/ 95 96 97/*! 98 \fn BString::~BString() 99 \brief Free all resources associated with the object. 100 101 The destructor also frees the internal buffer associated with the string. 102 103 \since BeOS R5 104*/ 105 106 107/*! 108 \name Access 109*/ 110 111 112//! @{ 113 114 115/*! 116 \fn const char* BString::String() const 117 \brief Return a pointer to the object string, \c NUL terminated. 118 119 The pointer to the object string is guaranteed to be \c NUL 120 terminated. You can't modify or free the pointer. Once the BString 121 object is deleted, the pointer becomes invalid. 122 123 If you want to manipulate the internal string of the object directly, 124 have a look at LockBuffer(). 125 126 \return A pointer to the object string. 127 128 \since BeOS R5 129*/ 130 131 132/*! 133 \fn int32 BString::Length() const 134 \brief Get the length of the string in bytes. 135 136 \return An integer with the length of the string, measured in bytes. 137 138 \sa CountChars() 139 140 \since BeOS R5 141*/ 142 143 144/*! 145 \fn int32 BString::CountChars() const 146 \brief Returns the length of the object measured in characters. 147 148 BString is somewhat aware of UTF-8 characters, so this method will count 149 the actual number of characters in the string. 150 151 \return An integer which is the number of characters in the string. 152 153 \sa Length() 154 155 \since BeOS R5 156*/ 157 158 159/*! 160 \fn int32 BString::CountBytes(int32 fromCharOffset, int32 charCount) const 161 \brief Count the number of bytes starting from a specified character 162 163 BString is somewhat aware of UTF-8 characters, which can take up more than 164 one byte. With this method you can count the number of bytes a subset of 165 the string contains. 166 167 \warning This method does not check whether the input is outside of the 168 boundaries, so make sure that you check your input values. 169 170 \param fromCharOffset The index of the character (not the byte!) from 171 which to start the count 172 \param charCount The number of characters to count 173 174 \return An integer with the number of bytes. 175 176 \since Haiku R1 177*/ 178 179 180/*! 181 \fn bool BString::IsEmpty() const 182 \brief Check whether the string is empty. 183 184 \return Returns \c true if the string is empty. 185 186 \since Haiku R1 187*/ 188 189 190/*! 191 \fn uint32 BString::HashValue() const 192 \brief Return a hash value for the current string 193 194 \sa HashValue(const char*) 195 196 \since Haiku R1 197*/ 198 199 200/*! 201 \fn static uint32 BString::HashValue(const char* string) 202 \brief Return the hash value of a specified \c string 203 204 This allows you to use the BString::HashValue() method on any arbitrary 205 \c string. 206 207 \param string The string that you want to have hashed. 208 209 \sa HashValue() 210 211 \since Haiku R1 212*/ 213 214 215//! @} 216 217 218/*! 219 \name Assignment 220 221 To assign a string to the object, thus overriding the previous string 222 that was stored, there are different methods to use. Use one of the 223 overloaded Adopt() methods to take over data from another object. Use 224 one of the assignment operators to copy data from another object, or 225 use one of the SetTo() methods for more advanced copying. 226*/ 227 228 229//! @{ 230 231 232/*! 233 \fn BString& BString::operator=(const BString& string) 234 \brief Re-initialize the object to a copy of the data of a BString. 235 236 \param string The \a string to copy. 237 238 \return The function always returns \c *this. 239 240 \sa Adopt(BString&) 241 \sa SetTo(const BString&, int32) 242 243 \since BeOS R5 244*/ 245 246 247/*! 248 \fn BString& BString::operator=(const char* str) 249 \brief Re-initialize the BString to a copy of the data of a string. 250 251 \param str The string data to re-initialize the BString to. 252 253 \return This method always returns \c *this. 254 255 \sa SetTo(const char*, int32) 256 257 \since BeOS R5 258*/ 259 260 261/*! 262 \fn BString& BString::operator=(char c) 263 \brief Re-initialize the BString to a character. 264 265 \param c The \c char to re-initialize the BString to. 266 267 \return This method always returns \c *this. 268 269 \since BeOS R5 270*/ 271 272 273/*! 274 \fn BString& BString::SetTo(const char* str) 275 \brief Re-initialize the BString to a copy of the data of a string. 276 277 This method calls operator=(const char*). 278 279 \param str The string data to re-initialize the BString to. 280 281 \return This method always returns \c *this. 282 283 \sa SetTo(const char*, int32) 284 285 \since BeOS R5 286*/ 287 288 289/*! 290 \fn BString& BString::SetTo(const char* str, int32 maxLength) 291 \brief Re-initialize the BString to a copy of the data of a string. 292 293 \param str The string data to re-initialize the BString to. 294 \param maxLength Maximum number of characters (bytes) to copy. 295 296 \return This method always returns \c *this. 297 298 \sa operator=(const char*) 299 300 \since BeOS R5 301*/ 302 303 304/*! 305 \fn BString& BString::SetTo(const BString& from) 306 \brief Re-initialize the BString to a copy of the data of a BString. 307 308 \param from The string data to re-initialize the BString to. 309 310 \return The function always returns \c *this. 311 312 \sa SetTo(const BString&, int32) 313 \sa Adopt(BString&) 314 315 \since BeOS R5 316*/ 317 318 319/*! 320 \fn BString& BString::SetTo(const BString& string, int32 maxLength) 321 \brief Re-initialize the string to a copy of the given BString object. 322 323 \param string The string data to re-initialize the BString to. 324 \param maxLength Maximum number of characters (bytes) to copy. 325 326 \return The function always returns \c *this. 327 328 \sa operator=(const BString&) 329 \sa Adopt(BString&, int32) 330 331 \since BeOS R5 332*/ 333 334 335/*! 336 \fn BString& BString::Adopt(BString& from) 337 \brief Adopt the data of the given BString object. 338 339 This method adopts the data from a BString removing the data from \a from 340 and putting it into the BString. 341 342 \warning The object that is adopted from is not deleted, only its private 343 data is initialized to a \c NULL string. If the \a from object 344 was created on the heap you need to clean it up yourself. 345 346 \param from The string data to adopt. 347 348 \return The function always returns \c *this. 349 350 \sa operator=(const BString&) 351 352 \since BeOS R5 353*/ 354 355 356/*! 357 \fn BString& BString::Adopt(BString& from, int32 maxLength) 358 \brief Adopt the data of the given BString object up to \a maxLength 359 characters. 360 361 This method adopts the data from a BString removing the data from \a from 362 and putting it into the BString. 363 364 \param from The string object to adopt. 365 \param maxLength Maximum number of characters (bytes) to adopt. 366 367 \return The function always returns \c *this. 368 369 \sa SetTo(const BString&, int32) 370 371 \since BeOS R5 372*/ 373 374 375/*! 376 \fn BString& BString::SetTo(char c, int32 count) 377 \brief Re-initialize the object to a string composed of a character you 378 specify. 379 380 This method lets you specify the length of a string and what character 381 you want the string to contain repeatedly. 382 383 \param c The character you want to initialize the BString. 384 \param count The length of the string. 385 386 \return The function always returns \c *this. 387 388 \sa operator=(char c) 389 390 \since BeOS R5 391*/ 392 393 394/*! 395 \fn BString& BString::SetToChars(const char* string, int32 charCount) 396 \brief UTF-8 aware version of SetTo(const char*, int32) 397 398 \param string The \a string to copy. 399 \param charCount The number of UTF-8 characters to copy. 400 401 \see SetTo(const char*, int32) 402 403 \since Haiku R1 404*/ 405 406 407/*! 408 \fn BString& BString::SetToChars(const BString& string, int32 charCount) 409 \brief UTF-8 aware version of SetTo(BString&, int32) 410 411 \param string The \a string to copy. 412 \param charCount The number of UTF-8 characters to copy. 413 414 \see SetTo(BString&, int32) 415 416 \return This method always returns \c *this. 417 418 \since Haiku R1 419*/ 420 421 422/*! 423 \fn BString& BString::AdoptChars(BString& from, int32 charCount) 424 \brief UTF-8 aware version of Adopt(BString&, int32) 425 426 \param from The string data to start adopting from. 427 \param charCount Number of UTF-8 characters to adopt. 428 429 \return This method always returns \c *this. 430 431 \since Haiku R1 432*/ 433 434 435/*! 436 \fn BString& BString::SetToFormat(const char* format, ...) 437 \brief Sets the string to a formatted string ala <tt>sprintf()</tt>. 438 439 \param format The \a format string to use. 440 \param ... The rest of the parameters that are filled into \a format. 441 442 \return This method always returns \c *this. 443 444 \since Haiku R1 445*/ 446 447 448//! @} 449 450 451/*! 452 \name Substring Copying 453*/ 454 455 456//! @{ 457 458 459/*! 460 \fn BString& BString::CopyInto(BString& into, int32 fromOffset, 461 int32 length) const 462 \brief Copy the object's data (or part of it) into another BString. 463 464 This methods makes sure you don't copy more bytes than are available 465 in the string. If the length exceeds the length of the string, it only 466 copies the number of characters that are actually available. 467 468 \param into The BString to copy into. 469 \param fromOffset The (zero-based) offset where to begin the copy. 470 \param length The number of bytes to copy. 471 472 \return This method always returns a pointer to the string passed as the 473 \c into parameter. 474 475 \since BeOS R5 476*/ 477 478 479/*! 480 \fn void BString::CopyInto(char* into, int32 fromOffset, int32 length) const 481 \brief Copy the BString data (or part of it) into the supplied buffer. 482 483 This methods makes sure you don't copy more bytes than are available 484 in the string. If the length exceeds the length of the string, it only 485 copies the number of characters that are actually available. 486 487 It's up to you to make sure your buffer is large enough. 488 489 \param into The buffer where to copy the object. 490 \param fromOffset The (zero-based) offset where to begin the copy. 491 \param length The number of bytes to copy. 492 493 \since BeOS R5 494*/ 495 496 497/*! 498 \fn BString& BString::CopyCharsInto(BString& into, int32 fromOffset, 499 int32 charCount) const 500 \brief UTF-8 aware version of CopyInto(BString&, int32, int32) const. 501 502 \param into The BString to copy into. 503 \param fromOffset The (zero-based) offset in bytes where to begin the copy. 504 \param charCount The number of UTF-8 characters to copy. 505 506 \return This method always returns a pointer to the string passed as the 507 \c into parameter. 508 509 \see CopyInto(BString&, int32, int32) const 510 511 \since Haiku R1 512*/ 513 514 515/*! 516 \fn bool BString::CopyCharsInto(char* into, int32* intoLength, 517 int32 fromCharOffset, int32 charCount) const 518 \brief UTF-8 aware version of CopyInto(char*, int32, int32) const. 519 520 \param into The buffer where to copy the object. 521 \param intoLength The length of \a into in bytes. 522 \param fromCharOffset The (zero-based) offset UTF-8 characters where to 523 begin the copy. 524 \param charCount The number of UTF-8 characters to copy. 525 526 \see CopyInto(char*, int32, int32) const 527 528 \return \c false if \a into was \c NULL, \c true otherwise. 529 530 \since Haiku R1 531*/ 532 533 534/*! 535 \fn bool BString::Split(const char* separator, bool noEmptyStrings, 536 BStringList& _list) const 537 \brief Split the string by the \a separator chars into \a _list. 538 539 \param separator The list of \a separator characters to split on. 540 \param noEmptyStrings If \c true, do not add empty strings to \a _list. 541 \param _list The BStringList to add the strings into. 542 543 \since Haiku R1 544*/ 545 546 547//! @} 548 549 550/*! 551 \name Appending 552*/ 553 554 555//! @{ 556 557 558/*! 559 \fn BString& BString::operator+=(const BString& string) 560 \brief Append the given \a string to the end of the BString 561 562 \param string The string to append. 563 564 \return This method always returns \c *this. 565 566 \sa Append(const BString&, int32) 567 568 \since BeOS R5 569*/ 570 571 572/*! 573 \fn BString& BString::operator+=(const char* str) 574 \brief Append the given string to the end of the BString. 575 576 \param str A pointer to the NULL-terminated string to append. 577 578 \return This method always returns \c *this. 579 580 \sa Append(const char*, int32) 581 582 \since BeOS R5 583*/ 584 585 586/*! 587 \fn BString& BString::operator+=(char c) 588 \brief Append the given character to the end of the BString. 589 590 \param c The character to append. 591 592 \return This method always returns \c *this. 593 594 \sa Append(char, int32) 595*/ 596 597 598/*! 599 \fn BString& BString::operator+=(const BString& string) 600 \brief Append the given \a string to the end of the BString. 601 602 \param string The string to append. 603 604 \return This method always returns \c *this. 605 606 \sa Append(const BString&, int32) 607*/ 608 609 610/*! 611 \fn BString& BString::Append(const BString& string) 612 \brief Append the given \a string to the end of the BString. 613 614 \param string The string to append. 615 616 \return This method always returns \c *this. 617 618 \sa Append(const BString&, int32) 619 620 \since BeOS R5 621*/ 622 623 624/*! 625 \fn BString& BString::Append(const char* str) 626 \brief Append the string data to the end of the BString. 627 628 This method calls operator+=(const char *str). 629 630 \sa Append(const char*, int32) 631 632 \since BeOS R5 633*/ 634 635 636/*! 637 \fn BString& BString::Append(const BString& string, int32 length) 638 \brief Append a part of the given \a string to the end of the BString. 639 640 \param string The BString to append. 641 \param length The maximum number of bytes to append. 642 643 \return This method always returns \c *this. 644 645 \sa operator+=(const BString&) 646 647 \since BeOS R5 648*/ 649 650 651/*! 652 \fn BString& BString::Append(const char* str, int32 length) 653 \brief Append a part of the given string to end of the BString. 654 655 \param str A pointer to the string to append. 656 \param length The maximum number of bytes to append. 657 658 \return This method always returns \c *this. 659 660 \sa operator+=(const char*) 661 662 \since BeOS R5 663*/ 664 665 666/*! 667 \fn BString& BString::Append(char c, int32 count) 668 \brief Append the given character repeatedly to the end of the BString. 669 670 \param c The character to append. 671 \param count The number of times this character should be appended. 672 673 \return This method always returns \c *this. 674 675 \sa operator+=(char c) 676 677 \since BeOS R5 678*/ 679 680 681/*! 682 \fn BString& BString::AppendChars(const BString& string, int32 charCount) 683 \brief UTF-8 aware version of Append(const BString&, int32). 684 685 \param string The \a string to append. 686 \param charCount The maximum number of UTF-8 characters to append. 687 688 \return This method always returns \c *this. 689 690 \see Append(const BString&, int32) 691 692 \since Haiku R1 693*/ 694 695 696/*! 697 \fn BString& BString::AppendChars(const char* string, int32 charCount) 698 \brief UTF-8 aware version of Append(const char*, int32). 699 700 \param string The \a string to append. 701 \param charCount The maximum number of UTF-8 characters to append. 702 703 \return This method always returns \c *this. 704 705 \see Append(const char*, int32) 706 707 \since Haiku R1 708*/ 709 710 711//! @} 712 713 714/*! 715 \name Prepending 716*/ 717 718 719//! @{ 720 721 722/*! 723 \fn BString& BString::Prepend(const char* str) 724 \brief Prepend the given string to the beginning of the BString. 725 726 \param str The \a string to prepend. 727 728 \return This method always returns \c *this. 729 730 \sa Prepend(const char*, int32) 731 732 \since BeOS R5 733*/ 734 735 736/*! 737 \fn BString& BString::Prepend(const BString& string) 738 \brief Prepend the given BString to the beginning of the BString. 739 740 \param string The \a string to prepend. 741 742 \return This method always returns \c *this. 743 744 \sa Prepend(const BString&, int32) 745 746 \since BeOS R5 747*/ 748 749 750/*! 751 \fn BString& BString::Prepend(const char* str, int32 length) 752 \brief Prepend the given string to the beginning of the BString. 753 754 \param str The \a string to prepend. 755 \param length The maximum number of bytes to prepend. 756 757 \return This method always returns \c *this. 758 759 \sa Prepend(const char*) 760 761 \since BeOS R5 762*/ 763 764 765/*! 766 \fn BString& BString::Prepend(const BString& string, int32 length) 767 \brief Prepend the given BString to the beginning of the BString. 768 769 \param string The \a string to prepend. 770 \param length The maximum number of bytes to prepend. 771 772 \return This method always returns \c *this. 773 774 \sa Prepend(const BString&) 775 776 \since BeOS R5 777*/ 778 779 780/*! 781 \fn BString& BString::Prepend(char c, int32 count) 782 \brief Prepend the given character \a count times to the beginning of the 783 BString. 784 785 \param c The character to prepend. 786 \param count The number of times this character should be prepended. 787 788 \return This method always returns \c *this. 789 790 \since BeOS R5 791*/ 792 793 794/*! 795 \fn BString& BString::PrependChars(const char* string, int32 charCount) 796 \brief UTF-8 aware version of Prepend(const char*, int32). 797 798 \param string The \a string to prepend. 799 \param charCount The maximum number of UTF-8 characters to prepend. 800 801 \return This method always returns \c *this. 802 803 \see Prepend(const char*, int32) 804 805 \since Haiku R1 806*/ 807 808 809/*! 810 \fn BString& BString::PrependChars(const BString& string, int32 charCount) 811 \brief UTF-8 aware version of Prepend(const BString&, int32). 812 813 \param string The \a string to prepend. 814 \param charCount The maximum number of UTF-8 characters to prepend. 815 816 \return This method always returns \c *this. 817 818 \see Prepend(const BString&, int32) 819 820 \since Haiku R1 821*/ 822 823 824//! @} 825 826 827/*! 828 \name Inserting 829*/ 830 831 832//! @{ 833 834 835/*! 836 \fn BString& BString::Insert(const char* string, int32 position) 837 \brief Inserts the given string at the given position into the BString 838 data. 839 840 \param string The \a string to insert. 841 \param position The offset in bytes where to insert the \a string into 842 the BString's data. 843 844 \return This method always returns \c *this. 845 846 \sa Insert(const char*, int32, int32) 847 \sa Insert(const char*, int32, int32, int32) 848 849 \since BeOS R5 850*/ 851 852 853/*! 854 \fn BString& BString::Insert(const char* string, int32 length, 855 int32 position) 856 \brief Inserts the given string at the given position into the BString 857 data. 858 859 \param string The \a string to insert. 860 \param length The number of bytes to insert. 861 \param position The offset in bytes into the data of the BString where to 862 insert the string. 863 864 \return This method always returns \c *this. 865 866 \sa Insert(const char*, int32) 867 \sa Insert(const char*, int32, int32, int32) 868 869 \since BeOS R5 870*/ 871 872 873/*! 874 \fn BString& BString::Insert(const char* string, int32 fromOffset, 875 int32 length, int32 position) 876 \brief Inserts the given string at the given position into the BString 877 data. 878 879 \param string The \a string to insert. 880 \param fromOffset The offset in bytes in the \a string to be inserted. 881 \param length The number of bytes to insert. 882 \param position The offset in bytes into the data of the BString where to 883 insert the string. 884 885 \return This method always returns \c *this. 886 887 \sa Insert(const char*, int32) 888 \sa Insert(const char*, int32, int32) 889 890 \since BeOS R5 891*/ 892 893 894/*! 895 \fn BString& BString::Insert(const BString& string, int32 position) 896 \brief Inserts the given BString at the given position into the BString 897 data. 898 899 \param string The \a string to insert. 900 \param position The offset in bytes into the data of the BString where to 901 insert the string. 902 903 \return This method always returns \c *this. 904 905 \sa Insert(const BString&, int32, int32) 906 \sa Insert(const BString&, int32, int32, int32) 907 908 \since BeOS R5 909*/ 910 911 912/*! 913 \fn BString& BString::Insert(const BString& string, int32 length, int32 position) 914 \brief Inserts the given BString at the given position into the BString 915 data. 916 917 \param string The \a string to insert. 918 \param length The number of bytes to insert. 919 \param position The offset in bytes into the data of the BString where to 920 insert the string. 921 922 \return This method always returns \c *this. 923 924 \sa Insert(const BString&, int32) 925 \sa Insert(const BString&, int32, int32, int32) 926 927 \since BeOS R5 928*/ 929 930 931/*! 932 \fn BString& BString::Insert(const BString& string, int32 fromOffset, 933 int32 length, int32 position) 934 \brief Inserts the given string at the given position into the BString 935 data. 936 937 \param string The \a string to insert. 938 \param fromOffset The offset in bytes of the string to be inserted. 939 \param length The amount of bytes to insert. 940 \param position The offset in bytes into the data of the BString where to 941 insert the string. 942 943 \return This method always returns \c *this. 944 945 \sa Insert(const BString&, int32) 946 \sa Insert(const BString&, int32, int32) 947 948 \since BeOS R5 949*/ 950 951 952/*! 953 \fn BString& BString::Insert(char c, int32 count, int32 pos) 954 \brief Inserts the given character repeatedly at the given position 955 into the BString data. 956 957 \param c The character to insert. 958 \param count The number of times to insert the character. 959 \param pos The offset in bytes into the data of the BString where to 960 insert the string. 961 962 \return This method always returns \c *this. 963 964 \since BeOS R5 965*/ 966 967 968/*! 969 \fn BString& BString::InsertChars(const char* string, int32 charPosition) 970 \brief UTF-8 aware version of Insert(const char*, int32). 971 972 \param string The \a string to insert. 973 \param charPosition The offset in UTF-8 characters where to insert 974 the string into the data of the BString. 975 976 \return This method always returns \c *this. 977 978 \see Insert(const char*, int32) 979 980 \since Haiku R1 981*/ 982 983 984/*! 985 \fn BString& BString::InsertChars(const char* string, int32 charCount, 986 int32 charPosition) 987 \brief UTF-8 aware version of Insert(const char*, int32, int32). 988 989 \param string The \a string to insert. 990 \param charCount The number of UTF-8 characters to insert. 991 \param charPosition The offset in UTF-8 characters where to insert 992 the string into the data of the BString. 993 994 \return This method always returns \c *this. 995 996 \see Insert(const char*, int32, int32) 997 998 \since Haiku R1 999*/ 1000 1001 1002/*! 1003 \fn BString& BString::InsertChars(const char* string, int32 fromCharOffset, 1004 int32 charCount, int32 charPosition) 1005 \brief UTF-8 aware version of Insert(const char*, int32, int32, int32). 1006 1007 \param string The \a string to insert. 1008 \param fromCharOffset The offset in UTF-8 characters of the string to be 1009 inserted. 1010 \param charCount The number of UTF-8 characters to insert. 1011 \param charPosition The offset in UTF-8 characters where to insert 1012 the string into the data of the BString. 1013 1014 \return This method always returns \c *this. 1015 1016 \see Insert(const char*, int32, int32, int32) 1017 1018 \since Haiku R1 1019*/ 1020 1021 1022/*! 1023 \fn BString& BString::InsertChars(const BString& string, int32 charPosition) 1024 \brief UTF-8 aware version of Insert(const BString&, int32). 1025 1026 \param string The \a string to insert. 1027 \param charPosition The offset in UTF-8 characters where to insert 1028 the string into the data of the BString. 1029 1030 \return This method always returns \c *this. 1031 1032 \see Insert(const BString&, int32) 1033 1034 \since Haiku R1 1035*/ 1036 1037 1038/*! 1039 \fn BString& BString::InsertChars(const BString& string, int32 charCount, 1040 int32 charPosition) 1041 \brief UTF-8 aware version of Insert(const BString&, int32, int32). 1042 1043 \param string The \a string to insert. 1044 \param charCount The number of UTF-8 characters to insert. 1045 \param charPosition The offset in UTF-8 characters where to insert 1046 the string into the data of the BString. 1047 1048 \return This method always returns \c *this. 1049 1050 \see Insert(const BString&, int32, int32) 1051 1052 \since Haiku R1 1053*/ 1054 1055 1056/*! 1057 \fn BString& BString::InsertChars(const BString& string, int32 fromCharOffset, 1058 int32 charCount, int32 charPosition) 1059 \brief UTF-8 aware version of Insert(const BString&, int32, int32, int32). 1060 1061 \param string The \a string to insert. 1062 \param fromCharOffset The offset in UTF-8 characters of the string to be 1063 inserted. 1064 \param charCount The number of UTF-8 characters to insert. 1065 \param charPosition The offset in UTF-8 characters where to insert 1066 the string into the data of the BString. 1067 1068 \return This method always returns \c *this. 1069 1070 \see Insert(const BString&, int32, int32, int32) 1071 1072 \since Haiku R1 1073*/ 1074 1075 1076//! @} 1077 1078 1079/*! 1080 \name Removing 1081*/ 1082 1083 1084//! @{ 1085 1086 1087/*! 1088 \fn BString& BString::Trim() 1089 \brief Removes spaces from the beginning and end of the string. 1090 1091 The definition of a space is set by the <tt>isspace()</tt> function. 1092 1093 \return This method always returns \c *this. 1094 1095 \since Haiku R1 1096*/ 1097 1098 1099 1100/*! 1101 \fn BString& BString::Truncate(int32 newLength, bool lazy) 1102 \brief Truncate the string to the new length. 1103 1104 \param newLength The new length of the string in bytes. 1105 \param lazy If true, the memory-optimization is postponed until later. 1106 1107 \return This method always returns \c *this. 1108 1109 \since BeOS R5 1110*/ 1111 1112 1113/*! 1114 \fn BString& BString::TruncateChars(int32 newCharCount, bool lazy) 1115 \brief UTF-8 aware version of Truncate(int32, bool). 1116 1117 \param newCharCount The new length of the string in UTF-8 characters. 1118 \param lazy If true, the memory-optimization is postponed until later. 1119 1120 \see Truncate(int32, bool) 1121 1122 \since Haiku R1 1123*/ 1124 1125 1126/*! 1127 \fn BString& BString::Remove(int32 from, int32 length) 1128 \brief Remove some bytes, starting at the given offset 1129 1130 \param from The offset in bytes to start removing. 1131 \param length The number of bytes to remove. 1132 1133 \return This function always returns \c *this. 1134 1135 \since BeOS R5 1136*/ 1137 1138 1139/*! 1140 \fn BString& BString::RemoveChars(int32 fromCharOffset, int32 charCount) 1141 \brief UTF-8 aware version of Remove(int32, int32). 1142 1143 \param fromCharOffset The offset in UTF-8 characters to start removing. 1144 \param charCount The number of UTF-8 characters to remove. 1145 1146 \return This function always returns \c *this. 1147 1148 \see Remove(int32, int32) 1149 1150 \since Haiku R1 1151*/ 1152 1153 1154/*! 1155 \fn BString& BString::RemoveFirst(const BString& string) 1156 \brief Remove the first occurrence of the given BString. 1157 1158 \param string The BString to remove. 1159 1160 \return This function always returns \c *this. 1161 1162 \since BeOS R5 1163*/ 1164 1165 1166/*! 1167 \fn BString& BString::RemoveLast(const BString& string) 1168 \brief Remove the last occurrence of the given BString. 1169 1170 \param string The BString to remove. 1171 1172 \return This function always returns \c *this. 1173 1174 \since BeOS R5 1175*/ 1176 1177 1178/*! 1179 \fn BString& BString::RemoveAll(const BString& string) 1180 \brief Remove all occurrences of the given BString. 1181 1182 \param string The BString to remove. 1183 1184 \return This function always returns \c *this. 1185 1186 \since BeOS R5 1187*/ 1188 1189 1190/*! 1191 \fn BString& BString::RemoveFirst(const char* string) 1192 \brief Remove the first occurrence of the given string. 1193 1194 \param string A pointer to the string to remove. 1195 1196 \return This function always returns \c *this. 1197 1198 \since BeOS R5 1199*/ 1200 1201 1202/*! 1203 \fn BString& BString::RemoveLast(const char* string) 1204 \brief Remove the last occurrence of the given string. 1205 1206 \param string A pointer to the string to remove. 1207 1208 \return This function always returns \c *this. 1209 1210 \since BeOS R5 1211*/ 1212 1213 1214/*! 1215 \fn BString& BString::RemoveAll(const char* str) 1216 \brief Remove all occurrences of the given string. 1217 1218 \param str A pointer to the string to remove. 1219 1220 \return This function always returns \c *this. 1221 1222 \since BeOS R5 1223*/ 1224 1225 1226/*! 1227 \fn BString& BString::RemoveSet(const char* setOfCharsToRemove) 1228 \brief Remove all the characters specified. 1229 1230 \param setOfCharsToRemove The set of characters to remove. 1231 1232 \return This function always returns \c *this. 1233 1234 \since BeOS R5 1235*/ 1236 1237 1238/*! 1239 \fn BString& BString::RemoveCharsSet(const char* setOfCharsToRemove) 1240 \brief UTF-8 aware version of RemoveSet(const char*). 1241 1242 \param setOfCharsToRemove The set of characters to remove. 1243 1244 \return This function always returns \c *this. 1245 1246 \see RemoveSet(const char*) 1247 1248 \since Haiku R1 1249*/ 1250 1251 1252/*! 1253 \fn BString& BString::MoveInto(BString& into, int32 from, int32 length) 1254 \brief Move the BString data (or part of it) into another BString. 1255 1256 \param into The BString to move the string into. 1257 \param from The offset (zero-based) in bytes where to begin the move. 1258 \param length The number of bytes to move. 1259 1260 \return This method always returns \c into. 1261 1262 \since BeOS R5 1263*/ 1264 1265 1266/*! 1267 \fn void BString::MoveInto(char* into, int32 from, int32 length) 1268 \brief Move the BString data (or part of it) into the given buffer. 1269 1270 \param into The buffer to move the string into. 1271 \param from The offset (zero-based) in bytes where to begin the move. 1272 \param length The number of bytes to move. 1273 1274 \since BeOS R5 1275*/ 1276 1277 1278/*! 1279 \fn BString& BString::MoveCharsInto(BString& into, int32 fromCharOffset, 1280 int32 charCount) 1281 \brief UTF-8 aware version of MoveInto(BString&, int32, int32) 1282 1283 \param into The BString where to move the string into. 1284 \param fromCharOffset The offset (zero-based) in UTF-8 characters where to 1285 begin the move. 1286 \param charCount The number of UTF-8 characters to move. 1287 1288 \see MoveInto(BString&, int32, int32) 1289 1290 \since Haiku R1 1291*/ 1292 1293 1294/*! 1295 \fn bool BString::MoveCharsInto(char* into, int32* intoLength, 1296 int32 fromCharOffset, int32 charCount) 1297 \brief UTF-8 aware version of MoveInto(char*, int32*, int32, int32). 1298 1299 \param into The buffer to move the string into. 1300 \param intoLength The offset (zero-based) in bytes where to begin the move. 1301 \param fromCharOffset The offset (zero-based) in UTF-8 characters where to 1302 begin the move. 1303 \param charCount The number of UTF-8 characters to move. 1304 1305 \returns \c false if \a into was \c NULL, \c true otherwise. 1306 1307 \see MoveInto(char*, int32*, int32, int32) 1308 1309 \since Haiku R1 1310*/ 1311 1312 1313//! @} 1314 1315 1316/*! 1317 \name Comparison 1318 1319 There are two different comparison methods. First of all there 1320 is the whole range of operators that return a boolean value, secondly 1321 there are methods that return an integer value, both case sensitive 1322 and case insensitive. 1323 1324 There are also global comparison operators and global compare functions. 1325 You might need these in case you have a sort routine that takes a generic 1326 comparison function, such as BList::SortItems(). 1327 See the String.h documentation file to see the specifics, though basically 1328 there are the same as implemented in this class. 1329*/ 1330 1331 1332//! @{ 1333 1334 1335/*! 1336 \fn bool BString::operator<(const BString& string) const 1337 \brief Lexicographically compare if this BString is less than the given 1338 \a string. 1339 1340 \param string The \a string to compare against. 1341 1342 \since BeOS R5 1343*/ 1344 1345 1346/*! 1347 \fn bool BString::operator<=(const BString& string) const 1348 \brief Lexicographically compare if this BString is less than or equal to 1349 the given \a string. 1350 1351 \param string The \a string to compare against. 1352 1353 \since BeOS R5 1354*/ 1355 1356 1357/*! 1358 \fn bool BString::operator==(const BString& string) const 1359 \brief Lexicographically compare if this BString is equal to the given 1360 \a string. 1361 1362 \param string The \a string to compare against. 1363 1364 \since BeOS R5 1365*/ 1366 1367 1368/*! 1369 \fn bool BString::operator>=(const BString& string) const 1370 \brief Lexicographically compare if this BString is greater than or equal 1371 to the given \a string. 1372 1373 \param string The string to compare against. 1374 1375 \since BeOS R5 1376*/ 1377 1378 1379/*! 1380 \fn bool BString::operator>(const BString& string) const 1381 \brief Lexicographically compare if this BString is greater than the given 1382 \a string. 1383 1384 \param string The string to compare against. 1385 1386 \since BeOS R5 1387*/ 1388 1389 1390/*! 1391 \fn bool BString::operator!=(const BString& string) const 1392 \brief Lexicographically compare if this BString is not equal to the given 1393 \a string. 1394 1395 \param string The string to compare against. 1396 1397 \since BeOS R5 1398*/ 1399 1400 1401/*! 1402 \fn bool BString::operator<(const char* string) const 1403 \brief Lexicographically compare if this BString is less than the given 1404 \a string. 1405 1406 \param string The string to compare against. 1407 1408 \since BeOS R5 1409*/ 1410 1411 1412/*! 1413 \fn bool BString::operator<=(const char* string) const 1414 \brief Lexicographically compare if this BString is less than or equal to 1415 the given \a string. 1416 1417 \param string The \a string to compare against. 1418 1419 \since BeOS R5 1420*/ 1421 1422 1423/*! 1424 \fn bool BString::operator==(const char* string) const 1425 \brief Lexicographically compare if this BString is equal to the given 1426 \a string. 1427 1428 \param string The \a string to compare against. 1429 1430 \since BeOS R5 1431*/ 1432 1433 1434/*! 1435 \fn bool BString::operator>=(const char* string) const 1436 \brief Lexicographically compare if this string is more than or equal 1437 to a given \a string. 1438 1439 \param string The \a string to compare against. 1440 1441 \since BeOS R5 1442*/ 1443 1444 1445/*! 1446 \fn bool BString::operator>(const char* string) const 1447 \brief Lexicographically compare if this string is more than a given string. 1448 1449 \param string The \a string to compare against. 1450 1451 \since BeOS R5 1452*/ 1453 1454 1455/*! 1456 \fn bool BString::operator!=(const char* string) const 1457 \brief Lexicographically compare if this string is not equal to a given 1458 string. 1459 1460 \param string The \a string to compare against. 1461 1462 \since BeOS R5 1463*/ 1464 1465 1466/*! 1467 \fn BString::operator const char*() const 1468 \brief Return an empty string. 1469 1470 \return An empty string. 1471 1472 \since Haiku R1 1473*/ 1474 1475 1476/*! 1477 \fn int BString::Compare(const BString& string) const 1478 \brief Lexicographically compare this BString to another \a string. 1479 1480 \param string The \a string to compare against. 1481 1482 \return An int representing the strings relationship to each other. 1483 \retval >0 The BString sorts lexicographically after \a string. 1484 \retval =0 The BString is equal to \a string. 1485 \retval <0 The BString sorts lexicographically before \a string. 1486 1487 \since BeOS R5 1488*/ 1489 1490 1491/*! 1492 \fn int BString::Compare(const char* string) const 1493 \brief Lexicographically compare this BString to another \a string. 1494 1495 \param string The \a string to compare against. 1496 1497 \return An int representing the strings relationship to each other. 1498 \retval >0 The BString sorts lexicographically after \a string. 1499 \retval =0 The BString is equal to \a string. 1500 \retval <0 The BString sorts lexicographically before \a string. 1501 1502 \sa Compare(const BString&) const 1503 1504 \since BeOS R5 1505*/ 1506 1507 1508/*! 1509 \fn int BString::Compare(const BString& string, int32 length) const 1510 \brief Lexicographically compare \a length characters of this BString to 1511 another \a string. 1512 1513 \param string The \a string to compare against. 1514 \param length The number of bytes to compare. 1515 1516 \return An int representing the strings relationship to each other. 1517 \retval >0 The BString sorts lexicographically after \a string. 1518 \retval =0 The BString is equal to \a string. 1519 \retval <0 The BString sorts lexicographically before \a string. 1520 1521 \since BeOS R5 1522*/ 1523 1524 1525/*! 1526 \fn int BString::Compare(const char* string, int32 length) const 1527 \brief Lexicographically compare \a length characters of this BString to 1528 another \a string. 1529 1530 \param string The \a string to compare against. 1531 \param length The number of bytes to compare. 1532 1533 \return An int representing the strings relationship to each other. 1534 \retval >0 The BString sorts lexicographically after \a string. 1535 \retval =0 The BString is equal to \a string. 1536 \retval <0 The BString sorts lexicographically before \a string. 1537 1538 \sa Compare(const BString&, int32) const 1539 1540 \since BeOS R5 1541*/ 1542 1543 1544/*! 1545 \fn int BString::CompareChars(const BString& string, int32 charCount) const 1546 \brief UTF-8 aware version of Compare(const BString&, int32). 1547 1548 \param string The \a string to compare against. 1549 \param charCount The number of UTF-8 characters to compare. 1550 1551 \return An int representing the strings relationship to each other. 1552 \retval >0 The BString sorts lexicographically after \a string. 1553 \retval =0 The BString is equal to \a string. 1554 \retval <0 The BString sorts lexicographically before \a string. 1555 1556 \see Compare(const BString&, int32) 1557 1558 \since Haiku R1 1559*/ 1560 1561 1562/*! 1563 \fn int BString::CompareChars(const char* string, int32 charCount) const 1564 \brief UTF-8 aware version of Compare(const char*, int32). 1565 1566 \param string The \a string to compare against. 1567 \param charCount The number of UTF-8 characters to compare. 1568 1569 \return An int representing the strings relationship to each other. 1570 \retval >0 The BString sorts lexicographically after \a string. 1571 \retval =0 The BString is equal to \a string. 1572 \retval <0 The BString sorts lexicographically before \a string. 1573 1574 \see Compare(const char*, int32) 1575 1576 \since Haiku R1 1577*/ 1578 1579 1580/*! 1581 \fn int BString::ICompare(const BString& string) const 1582 \brief Lexicographically compare this BString to another \a string 1583 case-insensitively. 1584 1585 \param string The \a string to compare against. 1586 1587 \return An int representing the strings relationship to each other. 1588 \retval >0 The BString sorts lexicographically after \a string. 1589 \retval =0 The BString is equal to \a string. 1590 \retval <0 The BString sorts lexicographically before \a string. 1591 1592 \sa Compare(const BString&) const 1593 1594 \since BeOS R5 1595*/ 1596 1597 1598/*! 1599 \fn int BString::ICompare(const char* string) const 1600 \brief Lexicographically compare this BString to another \a string 1601 case-insensitively. 1602 1603 \param string The \a string to compare against. 1604 1605 \return An int representing the strings relationship to each other. 1606 \retval >0 The BString sorts lexicographically after \a string. 1607 \retval =0 The BString is equal to \a string. 1608 \retval <0 The BString sorts lexicographically before \a string. 1609 1610 \sa Compare(const BString&) const 1611 1612 \since BeOS R5 1613*/ 1614 1615 1616/*! 1617 \fn int BString::ICompare(const BString& string, int32 length) const 1618 \brief Lexicographically compare \a length characters of this BString 1619 to another \a string. 1620 1621 \param string The \a string to compare against. 1622 \param length The number of characters to compare. 1623 1624 \return An int representing the strings relationship to each other. 1625 \retval >0 The BString sorts lexicographically after \a string. 1626 \retval =0 The BString is equal to \a string. 1627 \retval <0 The BString sorts lexicographically before \a string. 1628 1629 \sa Compare(const BString&, int32) const 1630 1631 \since BeOS R5 1632*/ 1633 1634 1635/*! 1636 \fn int BString::ICompare(const char* string, int32 length) const 1637 \brief Lexicographically compare \a length characters of this BString 1638 to another \a string. 1639 1640 \param string The \a string to compare against. 1641 \param length The number of characters to compare 1642 1643 \return An int representing the strings relationship to each other. 1644 \retval >0 The BString sorts lexicographically after \a string. 1645 \retval =0 The BString is equal to \a string. 1646 \retval <0 The BString sorts lexicographically before \a string. 1647 1648 \sa Compare(const BString&, int32) const 1649 1650 \since BeOS R5 1651*/ 1652 1653 1654//! @} 1655 1656 1657/*! 1658 \name Searching 1659*/ 1660 1661 1662//! @{ 1663 1664 1665/*! 1666 \fn int32 BString::FindFirst(const BString& string) const 1667 \brief Find the first occurrence of the given \a string. 1668 1669 \param string The \a string to search for. 1670 1671 \return The offset (zero-based) into the data where the given BString 1672 was found or \c B_ERROR if we could not find \c string. 1673 1674 \sa IFindFirst(const BString&) const 1675 1676 \since BeOS R5 1677*/ 1678 1679 1680/*! 1681 \fn int32 BString::FindFirst(const char* string) const 1682 \brief Find the first occurrence of the given \a string. 1683 1684 \param string The \a string to search for. 1685 1686 \return The offset (zero-based) into the data where the given string 1687 was found, \c B_BAD_VALUE if the \c string pointer is invalid, 1688 or \c B_ERROR if we could not find \c string. 1689 1690 \sa IFindFirst(const char*) const 1691 \sa StartsWith(const char*) const 1692 \sa StartsWith(const char*, int32) const 1693 1694 \since BeOS R5 1695*/ 1696 1697 1698/*! 1699 \fn int32 BString::FindFirst(const BString& string, int32 fromOffset) const 1700 \brief Find the first occurrence of the given \a string starting from 1701 the given offset. 1702 1703 \param string The \a string to search for. 1704 \param fromOffset The offset in bytes to start the search. 1705 1706 \return An integer which is the offset (zero-based) into the data 1707 where the given BString was found or \c B_ERROR if we could 1708 not find the \c string. 1709 1710 \sa IFindFirst(const BString&, int32) const 1711 \sa StartsWith(const char*, int32) const 1712 1713 \since BeOS R5 1714*/ 1715 1716 1717/*! 1718 \fn int32 BString::FindFirst(const char* string, int32 fromOffset) const 1719 \brief Find the first occurrence of the given \a string, starting from the 1720 given offset. 1721 1722 \param string The \a string to search for. 1723 \param fromOffset The offset in bytes to start the search. 1724 1725 \return The offset (zero-based) into the data where the given string 1726 was found, \c B_BAD_VALUE if the \c string pointer is invalid, 1727 or \c B_ERROR if we could not find the \c string. 1728 1729 \sa IFindFirst(const char*, int32) const 1730 1731 \since BeOS R5 1732*/ 1733 1734 1735/*! 1736 \fn int32 BString::FindFirst(char c) const 1737 \brief Find the first occurrence of the given character. 1738 1739 \param c The character to search for. 1740 1741 \return The offset (zero-based) into the data where the given character 1742 was found, or \c B_ERROR if we could not find the character. 1743 1744 \since BeOS R5 1745*/ 1746 1747 1748/*! 1749 \fn int32 BString::FindFirst(char c, int32 fromOffset) const 1750 \brief Find the first occurrence of the given character, starting from the 1751 given offset. 1752 1753 \param c The character to search for. 1754 \param fromOffset The offset where to start the search. 1755 1756 \return The offset (zero-based) into the data where the given character 1757 was found, or \c B_ERROR if we could not find the character. 1758 1759 \since BeOS R5 1760*/ 1761 1762 1763/*! 1764 \fn int32 BString::FindFirstChars(const BString& string, 1765 int32 fromCharOffset) const 1766 \brief UTF-8 aware version of FindFirst(const BString&, int32). 1767 1768 \param string The \a string to search for. 1769 \param fromCharOffset The offset in UTF-8 characters to start the search. 1770 1771 \return An integer which is the offset (zero-based) into the data 1772 where the given BString was found or \c B_ERROR if we could 1773 not find the \c string. 1774 1775 \see FindFirst(const BString&, int32) 1776 1777 \since Haiku R1 1778*/ 1779 1780 1781/*! 1782 \fn int32 BString::FindFirstChars(const char* string, 1783 int32 fromCharOffset) const 1784 \brief UTF-8 aware version of FindFirst(const char*, int32). 1785 1786 \param string The \a string to search for. 1787 \param fromCharOffset The offset in UTF-8 characters to start the search. 1788 1789 \see FindChars(const char*, int32) 1790 1791 \since Haiku R1 1792*/ 1793 1794 1795/*! 1796 \fn int32 BString::FindLast(const BString& string) const 1797 \brief Find the last occurrence of the given \a string. 1798 1799 \param string The \a string to search for. 1800 1801 \return The offset (zero-based) into the data where the given BString 1802 was found, or \c B_ERROR if we could not find the \c string. 1803 1804 \sa IFindLast(const BString&) const 1805 \sa EndsWith(const BString&) const 1806 1807 \since BeOS R5 1808*/ 1809 1810 1811/*! 1812 \fn int32 BString::FindLast(const char* string) const 1813 \brief Find the last occurrence of the given string. 1814 1815 \param string The string to search for. 1816 1817 \return The offset in bytes (zero-based) into the data where the given 1818 string was found, \c B_BAD_VALUE if the \c string pointer is invalid, 1819 or \c B_ERROR if we could not find the \c string. 1820 1821 \sa IFindLast(const char*) const 1822 \sa EndsWith(const char*) const 1823 \sa EndsWith(const char*, int32) const 1824 1825 \since BeOS R5 1826*/ 1827 1828 1829/*! 1830 \fn int32 BString::FindLast(const BString& string, int32 beforeOffset) const 1831 \brief Find the last occurrence of the given BString, 1832 starting from the given offset, and going backwards. 1833 1834 \param string The BString to search for. 1835 \param beforeOffset The offset in bytes to start the search. 1836 1837 \return The offset (zero-based) into the data where the given BString 1838 was found, or \c B_ERROR if we could not find the \c string. 1839 1840 \sa IFindLast(const BString&, int32) const 1841 1842 \since BeOS R5 1843*/ 1844 1845 1846/*! 1847 \fn int32 BString::FindLast(const char* string, int32 beforeOffset) const 1848 \brief Find the last occurrence of the given string, 1849 starting from the given offset, and going backwards. 1850 1851 \param string The string to search for. 1852 \param beforeOffset The offset in bytes to start the search. 1853 1854 \return The offset (zero-based) into the data where the given string 1855 was found, \c B_BAD_VALUE if the \c string pointer is invalid, 1856 or \c B_ERROR if we could not find the \c string. 1857 1858 \sa IFindLast(const char*, int32) const 1859 1860 \since BeOS R5 1861*/ 1862 1863 1864/*! 1865 \fn int32 BString::FindLast(char c) const 1866 \brief Find the last occurrence of the given character. 1867 1868 \param c The character to search for. 1869 \return The offset (zero-based) into the data where the given BString 1870 was found, or \c B_ERROR if we could not find the character. 1871 1872 \since BeOS R5 1873*/ 1874 1875 1876/*! 1877 \fn int32 BString::FindLast(char c, int32 beforeOffset) const 1878 \brief Find the last occurrence of the given character, 1879 starting from the given offset going backwards from the end. 1880 1881 \param c The character to search for. 1882 \param beforeOffset The offset in bytes to start the search. 1883 1884 \return The offset (zero-based) into the data where the given character 1885 was found, or \c B_ERROR Could not find the character. 1886 1887 \since BeOS R5 1888*/ 1889 1890 1891/*! 1892 \fn int32 BString::FindLastChars(const BString& string, 1893 int32 beforeCharOffset) const 1894 \brief UTF-8 aware version of FindLast(const BString&, int32). 1895 1896 \param string The BString to search for. 1897 \param beforeCharOffset The offset in UTF-8 characters to start the search. 1898 1899 \return The offset in bytes (zero-based) into the data where the given 1900 BString was found, or \c B_ERROR if we could not find the 1901 \c string. 1902 1903 \see FindLast(const BString&, int32) 1904 1905 \since Haiku R1 1906*/ 1907 1908 1909/*! 1910 \fn int32 BString::FindLastChars(const char* string, 1911 int32 beforeCharOffset) const 1912 \brief UTF-8 aware version of FindLast(const char*, int32). 1913 1914 \param string The string to search for. 1915 \param beforeCharOffset The offset in UTF-8 characters to start the search. 1916 1917 \return The offset in bytes (zero-based) into the data where the given 1918 string was found, \c B_BAD_VALUE if the \c string pointer is 1919 invalid, or \c B_ERROR if we could not find the \c string. 1920 1921 \see FindLast(const char*, int32) 1922 1923 \since Haiku R1 1924*/ 1925 1926 1927/*! 1928 \fn int32 BString::IFindFirst(const BString& string) const 1929 \brief Find the first occurrence of the given \a string case-insensitively. 1930 1931 \copydetails FindFirst(const BString&) const 1932*/ 1933 1934 1935/*! 1936 \fn int32 BString::IFindFirst(const char* string) const 1937 \brief Find the first occurrence of the given \a string case-insensitively. 1938 1939 \param string The \a string to search for. 1940 1941 \copydetails FindFirst(const char*) const 1942*/ 1943 1944 1945/*! 1946 \fn int32 BString::IFindFirst(const BString& string, int32 fromOffset) const 1947 \brief Find the first occurrence of the given BString case-insensitively, 1948 starting from the given offset. 1949 1950 \copydetails FindFirst(const BString&, int32) const 1951*/ 1952 1953 1954/*! 1955 \fn int32 BString::IFindFirst(const char* string, int32 fromOffset) const 1956 \brief Find the first occurrence of the given string case-insensitively, 1957 starting from the given offset. 1958 1959 \copydetails FindFirst(const char*, int32) const 1960*/ 1961 1962 1963/*! 1964 \fn int32 BString::IFindLast(const BString& string) const 1965 \brief Find the last occurrence of the given BString case-insensitively. 1966 1967 \copydetails FindLast(const BString&) const 1968*/ 1969 1970 1971/*! 1972 \fn int32 BString::IFindLast(const char* string) const 1973 \brief Find the last occurrence of the given string case-insensitively. 1974 1975 \copydetails FindLast(const char*) const 1976*/ 1977 1978 1979/*! 1980 \fn int32 BString::IFindLast(const BString& string, int32 beforeOffset) const 1981 \brief Find the last occurrence of the given BString case-insensitively, 1982 starting from the given offset going backwards. 1983 1984 \copydetails FindLast(const BString&, int32) const 1985*/ 1986 1987 1988/*! 1989 \fn int32 BString::IFindLast(const char* string, int32 beforeOffset) const 1990 \brief Find the last occurrence of the given string case-insensitively, 1991 starting from the given offset going backwards. 1992 1993 \copydetails FindLast(const char*, int32) const 1994*/ 1995 1996 1997/*! 1998 \fn bool BString::StartsWith(const BString& string) const 1999 \brief Returns whether or not the BString starts with \a string. 2000 2001 \param string The \a string to search for. 2002 2003 \return \c true if the BString started with \a string, \c false otherwise. 2004 2005 \since Haiku R1 2006*/ 2007 2008 2009/*! 2010 \fn bool BString::StartsWith(const char* string) const 2011 \brief Returns whether or not the BString starts with \a string. 2012 2013 \param string The \a string to search for. 2014 2015 \return \c true if the BString started with \a string, \c false otherwise. 2016 2017 \since Haiku R1 2018*/ 2019 2020 2021/*! 2022 \fn bool BString::StartsWith(const char* string, int32 length) const 2023 \brief Returns whether or not the BString starts with \a length characters 2024 of \a string. 2025 2026 \param string The \a string to search for. 2027 \param length The number of characters (bytes) of \a string to search for. 2028 2029 \return \c true if the BString started with \a length characters of 2030 \a string, \c false otherwise. 2031 2032 \since Haiku R1 2033*/ 2034 2035 2036/*! 2037 \fn bool BString::EndsWith(const BString& string) const 2038 \brief Returns whether or not the BString ends with \a string. 2039 2040 \param string The \a string to search for. 2041 2042 \return \c true if the BString ended with \a string, \c false otherwise. 2043 2044 \since Haiku R1 2045*/ 2046 2047 2048/*! 2049 \fn bool BString::EndsWith(const char* string) const 2050 \brief Returns whether or not the BString ends with \a string. 2051 2052 \param string The \a string to search for. 2053 2054 \return \c true if the BString ended with \a string, \c false otherwise. 2055 2056 \since Haiku R1 2057*/ 2058 2059 2060/*! 2061 \fn bool BString::EndsWith(const char* string, int32 length) const 2062 \brief Returns whether or not the BString ends with \a length characters 2063 of \a string. 2064 2065 \param string The \a string to search for. 2066 \param length The number of characters (bytes) of \a string to search for. 2067 2068 \return \c true if the BString ended with \a length characters of 2069 \a string, \c false otherwise. 2070 2071 \since Haiku R1 2072*/ 2073 2074 2075//! @} 2076 2077 2078/*! 2079 \name Replacing 2080*/ 2081 2082 2083//! @{ 2084 2085 2086/*! 2087 \fn BString& BString::ReplaceFirst(char replaceThis, char withThis) 2088 \brief Replace the first occurrence of a character with another character. 2089 2090 \param replaceThis The character to replace. 2091 \param withThis The character to put in its place. 2092 2093 \return This method always returns \c *this. 2094 2095 \sa IReplaceFirst(char, char) 2096 2097 \since BeOS R5 2098*/ 2099 2100 2101/*! 2102 \fn BString& BString::ReplaceLast(char replaceThis, char withThis) 2103 \brief Replace the last occurrence of a character with another character. 2104 2105 \param replaceThis The character to replace. 2106 \param withThis The character to put in its place 2107 2108 \return This method always returns \c *this. 2109 2110 \sa IReplaceLast(char, char) 2111 2112 \since BeOS R5 2113*/ 2114 2115 2116/*! 2117 \fn BString& BString::ReplaceAll(char replaceThis, char withThis, 2118 int32 fromOffset) 2119 \brief Replace all occurrences of a character with another character. 2120 2121 \param replaceThis The character to replace. 2122 \param withThis The character to put in its place 2123 \param fromOffset The offset in bytes to start looking for the character. 2124 2125 \return This method always returns \c *this. 2126 2127 \sa IReplaceAll(char, char, int32) 2128 2129 \since BeOS R5 2130*/ 2131 2132 2133/*! 2134 \fn BString& BString::Replace(char replaceThis, char withThis, 2135 int32 maxReplaceCount, int32 fromOffset) 2136 \brief Replace a number of occurrences of a character with another 2137 character. 2138 2139 \param replaceThis The character to replace. 2140 \param withThis The character to put in its place 2141 \param maxReplaceCount The maximum number of characters that should be 2142 replaced. 2143 \param fromOffset The offset in bytes to start looking for the character 2144 2145 \return This method always returns \c *this. 2146 2147 \sa IReplace(char, char, int32, int32) 2148 2149 \since BeOS R5 2150*/ 2151 2152 2153/*! 2154 \fn BString& BString::ReplaceFirst(const char* replaceThis, 2155 const char* withThis) 2156 \brief Replace the first occurrence of a string with another string. 2157 2158 \param replaceThis The string to replace. 2159 \param withThis The string to put in its place 2160 2161 \return This method always returns \c *this. 2162 2163 \sa IReplaceFirst(const char*, const char*) 2164 2165 \since BeOS R5 2166*/ 2167 2168 2169/*! 2170 \fn BString& BString::ReplaceLast(const char* replaceThis, 2171 const char* withThis) 2172 \brief Replace the last occurrence of a string with another string. 2173 2174 \param replaceThis The string to replace. 2175 \param withThis The string to put in its place 2176 2177 \return This method always returns \c *this. 2178 2179 \sa IReplaceLast(const char*, const char*) 2180 2181 \since BeOS R5 2182*/ 2183 2184 2185/*! 2186 \fn BString& BString::ReplaceAll(const char* replaceThis, 2187 const char* withThis, int32 fromOffset) 2188 \brief Replace all occurrences of a string with another string. 2189 2190 \param replaceThis The string to replace. 2191 \param withThis The string to put in its place 2192 \param fromOffset The offset in bytes to start looking for the string. 2193 2194 \return This method always returns \c *this. 2195 2196 \sa IReplaceAll(const char*, const char*, int32) 2197 2198 \since BeOS R5 2199*/ 2200 2201 2202/*! 2203 \fn BString& BString::Replace(const char* replaceThis, 2204 const char* withThis, int32 maxReplaceCount, int32 fromOffset) 2205 \brief Replace a number of occurrences of a string with another string. 2206 2207 \param replaceThis The string to replace. 2208 \param withThis The string to put in its place 2209 \param maxReplaceCount The maximum number of occurrences that should 2210 be replaced. 2211 \param fromOffset The offset in bytes to start looking for the string. 2212 2213 \return This method always returns \c *this. 2214 2215 \sa IReplace(const char*, const char*, int32, int32) 2216 2217 \since BeOS R5 2218*/ 2219 2220 2221/*! 2222 \fn BString& BString::ReplaceAllChars(const char* replaceThis, 2223 const char* withThis, int32 fromCharOffset) 2224 \brief UTF-8 aware version of ReplaceAll(const char*, const char*, int32). 2225 2226 \param replaceThis The string to replace. 2227 \param withThis The string to put in its place 2228 \param fromCharOffset The offset in UTF-8 characters to start looking for 2229 the string. 2230 2231 \return This method always returns \c *this. 2232 2233 \see ReplaceAll(const char*, const char*, int32) 2234 2235 \since Haiku R1 2236*/ 2237 2238 2239/*! 2240 \fn BString& BString::ReplaceChars(const char* replaceThis, 2241 const char* withThis, int32 maxReplaceCount, int32 fromCharOffset) 2242 \brief UTF-8 aware version of 2243 ReplaceAll(const char*, const char*, int32, int32). 2244 2245 \param replaceThis The string to replace. 2246 \param withThis The string to put in its place 2247 \param maxReplaceCount The maximum number of occurrences that should 2248 be replaced. 2249 \param fromCharOffset The offset in UTF-8 characters to start looking for 2250 the string. 2251 2252 \return This method always returns \c *this. 2253 2254 \see ReplaceAll(const char*, const char*, int32, int32) 2255 2256 \since Haiku R1 2257*/ 2258 2259 2260/*! 2261 \fn BString& BString::IReplaceFirst(char replaceThis, char withThis) 2262 \brief Replace the first occurrence of a character with another 2263 character case-insensitively. 2264 2265 \param replaceThis The string to replace. 2266 \param withThis The string to put in its place 2267 2268 \sa ReplaceFirst(char, char) 2269 2270 \since BeOS R5 2271*/ 2272 2273 2274/*! 2275 \fn BString& BString::IReplaceLast(char replaceThis, char withThis) 2276 \brief Replace the last occurrence of a character with another 2277 character case-insensitively. 2278 2279 \param replaceThis The string to replace. 2280 \param withThis The string to put in its place 2281 2282 \sa ReplaceLast(char, char) 2283 2284 \since BeOS R5 2285*/ 2286 2287 2288/*! 2289 \fn BString& BString::IReplaceAll(char replaceThis, char withThis, 2290 int32 fromOffset) 2291 \brief Replace all occurrences of a character with another character 2292 case-insensitively. 2293 2294 \param replaceThis The string to replace. 2295 \param withThis The string to put in its place 2296 \param fromOffset The offset where to start looking for the string 2297 2298 \sa ReplaceAll(char, char, int32) 2299 2300 \since BeOS R5 2301*/ 2302 2303 2304/*! 2305 \fn BString& BString::IReplace(char replaceThis, char withThis, 2306 int32 maxReplaceCount, int32 fromOffset) 2307 \brief Replace a number of occurrences of a character with another 2308 character case-insensitively. 2309 2310 \param replaceThis The char to replace. 2311 \param withThis The char to put in its place 2312 \param maxReplaceCount The maximum number of occurrences that should 2313 be replaced. 2314 \param fromOffset The offset where to start looking for the string 2315 2316 \sa Replace(char, char, int32, int32) 2317 2318 \since BeOS R5 2319*/ 2320 2321 2322/*! 2323 \fn BString& BString::IReplaceFirst(const char* replaceThis, 2324 const char* withThis) 2325 \brief Replace the first occurrence of a string with another string 2326 case-insensitively. 2327 2328 \param replaceThis The string to replace. 2329 \param withThis The string to put in its place. 2330 2331 \sa ReplaceFirst(const char*, const char*) 2332 2333 \since BeOS R5 2334*/ 2335 2336 2337/*! 2338 \fn BString& BString::IReplaceLast(const char* replaceThis, 2339 const char* withThis) 2340 \brief Replace the last occurrence of a string with another string. Case-insensitive. 2341 2342 \param replaceThis The string to replace. 2343 \param withThis The string to put in its place. 2344 2345 \sa ReplaceLast(const char*, const char*) 2346 2347 \since BeOS R5 2348*/ 2349 2350 2351/*! 2352 \fn BString& BString::IReplaceAll(const char* replaceThis, 2353 const char* withThis, int32 fromOffset) 2354 \brief Replace all occurrences of a string with another string 2355 case-insensitively. 2356 2357 \param replaceThis The string to replace. 2358 \param withThis The string to put in its place. 2359 \param fromOffset The offset where to start looking for the string. 2360 2361 \sa ReplaceAll(const char*, const char*, int32) 2362 2363 \since BeOS R5 2364*/ 2365 2366 2367/*! 2368 \fn BString& BString::IReplace(const char* replaceThis, 2369 const char* withThis, int32 maxReplaceCount, int32 fromOffset) 2370 \brief Replace a number of occurrences of a string with another string 2371 case-insensitively. 2372 2373 \param replaceThis The string to replace. 2374 \param withThis The string to put in its place 2375 \param maxReplaceCount The maximum number of occurrences that should 2376 be replaced. 2377 \param fromOffset The offset where to start looking for the string 2378 2379 \sa Replace(const char*, const char*, int32, int32) 2380 2381 \since BeOS R5 2382*/ 2383 2384 2385/*! 2386 \fn BString& BString::ReplaceSet(const char* setOfBytes, char with) 2387 \brief Replaces characters that are in a certain set with a chosen 2388 character. 2389 2390 \param setOfBytes The set of characters that need to be replaced. 2391 \param with The character to replace the occurrences with. 2392 2393 \return This method always returns \c *this. 2394 2395 \since BeOS R5 2396*/ 2397 2398 2399/*! 2400 \fn BString& BString::ReplaceSet(const char* setOfBytes, const char* with) 2401 \brief Replaces characters that are in a certain set with a chosen string. 2402 2403 \param setOfBytes The set of chars that need to be replaced. 2404 \param with The string to replace the occurrences with. 2405 2406 \return This method always returns \c *this. 2407 2408 \since BeOS R5 2409*/ 2410 2411 2412/*! 2413 \fn BString& BString::ReplaceCharsSet(const char* setOfChars, 2414 const char* with) 2415 \brief UTF-8 aware version of ReplaceSet(const char*, const char*) 2416 2417 \param setOfChars The set of UTF-8 characters that need to be replaced. 2418 \param with The string to replace the occurrences with. 2419 2420 \return This method always returns \c *this. 2421 2422 \since Haiku R1 2423*/ 2424 2425 2426// @} 2427 2428 2429/*! 2430 \name Indexing 2431*/ 2432 2433 2434//! @{ 2435 2436 2437/*! 2438 \fn char& BString::operator[](int32 index) 2439 \brief Return a reference to the data at the given offset. 2440 2441 This function can be used to read a byte. 2442 There is no bounds checking though, so make sure the \c index 2443 you supply is valid. 2444 2445 \param index The index (zero-based) of the byte to get. 2446 2447 \return Returns a reference to the specified byte. 2448 2449 \sa ByteAt(int32 index) for a safer version. 2450 2451 \since BeOS R5 2452*/ 2453 2454 2455/*! 2456 \fn char BString::operator[](int32 index) const 2457 \brief Returns the character in the string at the given offset. 2458 2459 This function can be used to read a byte. There is no bound checking 2460 though, use ByteAt() if you don't know if the \c index parameter is 2461 valid. 2462 2463 \param index The index (zero-based) of the byte to get. 2464 2465 \return Returns a reference to the specified byte. 2466 2467 \since BeOS R5 2468*/ 2469 2470 2471/*! 2472 \fn char BString::ByteAt(int32 index) const 2473 \brief Returns the character in the string at the given offset. 2474 2475 This function can be used to read a single byte. 2476 2477 \param index The index (zero-based) of the byte to get. 2478 2479 \return A reference to the specified byte, if out of bounds return 0. 2480 2481 \since BeOS R5 2482*/ 2483 2484 2485/*! 2486 \fn const char* BString::CharAt(int32 charIndex, int32* bytes) const 2487 \brief UTF-8 aware version of ByteAt(int32). 2488 2489 \param charIndex The index (zero-based) of the UTF-8 character to get. 2490 \param bytes An int32 pointer to hold the UTF-8 character. 2491 2492 \return A reference to the specified UTF-8 character, if out of bounds 2493 return 0. 2494 2495 \see ByteAt(int32) 2496 2497 \since Haiku R1 2498*/ 2499 2500 2501/*! 2502 \fn bool BString::CharAt(int32 charIndex, char* buffer, 2503 int32* bytes) const 2504 \brief UTF-8 aware version of ByteAt(int32) with a \a buffer parameter. 2505 2506 \param charIndex The index (zero-based) of the UTF-8 character to get. 2507 \param buffer Set to the position in the string where the character is 2508 found. 2509 \param bytes An int32 pointer to hold the UTF-8 character. 2510 2511 \see ByteAt(int32, char*, int32*) 2512 2513 \since Haiku R1 2514*/ 2515 2516 2517//! @} 2518 2519 2520/*! 2521 \name Low-Level Manipulation 2522*/ 2523 2524 2525//! @{ 2526 2527 2528/*! 2529 \fn char* BString::LockBuffer(int32 maxLength) 2530 \brief Locks the buffer and return the internal string for manipulation. 2531 2532 If you want to do any low-level string manipulation on the internal buffer, 2533 you should call this method. This method includes the possibility to grow 2534 the buffer so that you don't have to worry about that yourself. 2535 2536 Make sure you call UnlockBuffer() when you're done with the manipulation. 2537 2538 \param maxLength The size of the buffer in bytes. If you don't want a 2539 bigger buffer, passing anything under the length of the string will 2540 simply return it as is. 2541 2542 \return A pointer to the buffer to manipulate. 2543 2544 \sa UnlockBuffer() 2545 2546 \since BeOS R5 2547*/ 2548 2549 2550/*! 2551 \fn BString& BString::UnlockBuffer(int32 length) 2552 \brief Unlocks the buffer after you are done with low-level manipulation. 2553 2554 \param length The length in bytes to trim the string to in order to keep 2555 the internal buffer sane. If you don't pass a value in it, 2556 <tt>strlen()</tt> will be used to determine the length. 2557 2558 \return This method always returns \c *this. 2559 2560 \since BeOS R5 2561*/ 2562 2563 2564//! @} 2565 2566 2567/*! 2568 \name Case Manipulation 2569*/ 2570 2571 2572//! @{ 2573 2574 2575/*! 2576 \fn BString& BString::ToLower() 2577 \brief Convert each of the characters in the BString to lowercase. 2578 2579 \return This method always returns \c *this. 2580 2581 \since BeOS R5 2582*/ 2583 2584 2585/*! 2586 \fn BString& BString::ToUpper() 2587 \brief Convert each of the characters in the BString to uppercase. 2588 2589 \return This method always returns \c *this. 2590 2591 \since BeOS R5 2592*/ 2593 2594 2595/*! 2596 \fn BString& BString::Capitalize() 2597 \brief Convert the first character to uppercase, and the rest to lowercase. 2598 2599 \return This method always returns \c *this. 2600 2601 \since BeOS R5 2602*/ 2603 2604 2605/*! 2606 \fn BString& BString::CapitalizeEachWord() 2607 \brief Convert the first character of every word to uppercase, and the rest 2608 to lowercase. 2609 2610 Converts the first character of every "word" (series of alphabetical 2611 characters separated by non alphabetical characters) to uppercase, and 2612 the rest to lowercase. 2613 2614 \return This method always returns \c *this. 2615 2616 \since BeOS R5 2617*/ 2618 2619 2620//! @} 2621 2622 2623/*! 2624 \name Escaping and De-escaping 2625 2626 This class contains some methods to help you with escaping and 2627 de-escaping certain characters. Note that this is the C-style of 2628 escaping, where you place a character before the character that is 2629 to be escaped, and not HTML style escaping, where certain characters 2630 are replaced by something else. 2631*/ 2632 2633 2634//! @{ 2635 2636 2637/*! 2638 \fn BString& BString::CharacterEscape(const char* original, 2639 const char* setOfCharsToEscape, char escapeWith) 2640 \brief Escape selected characters on a given string. 2641 2642 This version sets itself to the string supplied in the \c original 2643 parameter, and then escapes the selected characters with a supplied 2644 character. 2645 2646 \param original The string to be escaped. 2647 \param setOfCharsToEscape The set of characters that need to be escaped. 2648 \param escapeWith The character to escape with. 2649 2650 \return This method always returns \c *this. 2651 2652 \sa CharacterDeescape(char) 2653 \sa CharacterDeescape(const char*, char) 2654 2655 \since BeOS R5 2656*/ 2657 2658 2659/*! 2660 \fn BString& BString::CharacterEscape(const char* setOfCharsToEscape, 2661 char escapeWith) 2662 \brief Escape selected characters of this string. 2663 2664 \param setOfCharsToEscape The set of characters that need to be escaped. 2665 \param escapeWith The character to escape with. 2666 2667 \return This method always returns \c *this. 2668 2669 \sa CharacterDeescape(char) 2670 2671 \since BeOS R5 2672*/ 2673 2674 2675/*! 2676 \fn BString& BString::CharacterDeescape(const char* original, 2677 char escapeChar) 2678 \brief Remove the character to escape with from a given string. 2679 2680 This version sets itself to the string supplied in the \c original 2681 parameter, and then removes the escape characters. 2682 2683 \param original The string to be escaped. 2684 \param escapeChar The character that was used to escape with. 2685 2686 \return This method always returns \c *this. 2687 2688 \sa CharacterEscape(const char*, const char*, char) 2689 2690 \since BeOS R5 2691*/ 2692 2693 2694/*! 2695 \fn BString& BString::CharacterDeescape(char escapeChar) 2696 \brief Remove the character to escape with from this string. 2697 2698 \param escapeChar The character that was used to escape with. 2699 2700 \return This method always returns \c *this. 2701 2702 \sa CharacterEscape(const char*, char) 2703*/ 2704 2705 2706//! @} 2707 2708 2709/*! 2710 \name <tt>sprintf()</tt> Replacement Methods 2711 2712 These methods may be slower than <tt>sprintf()</tt>, but they are overflow safe. 2713*/ 2714 2715 2716//! @{ 2717 2718 2719/*! 2720 \fn BString& BString::operator<<(const char* string) 2721 \brief Append \a string to the BString. 2722 2723 \param string The \a string to append. 2724 2725 \return This method always returns \c *this. 2726 2727 \since BeOS R5 2728*/ 2729 2730 2731/*! 2732 \fn BString& BString::operator<<(const BString& string) 2733 \brief Append \a string to the BString. 2734 2735 \param string The \a string to append. 2736 2737 \return This method always returns \c *this. 2738*/ 2739 2740 2741/*! 2742 \fn BString& BString::operator<<(char c) 2743 \brief Append \a c to the BString. 2744 2745 \param c The character to append. 2746 2747 \return This method always returns \c *this. 2748 2749 \since BeOS R5 2750*/ 2751 2752 2753/*! 2754 \fn BString& BString::operator<<(bool value) 2755 \brief Convert the \c bool \c value to a string and append it. 2756 2757 In case the \a value is true, the string "true" is appended to the string. 2758 Otherwise, the string "false" is appended. 2759 2760 \param value The boolean \c value ("true" of "false") to append. 2761 2762 \return This method always returns \c *this. 2763 2764 \since BeOS R5 2765*/ 2766 2767 2768/*! 2769 \fn BString& BString::operator<<(int value) 2770 \brief Convert the \c int \a value to a string and append it. 2771 2772 \param value The \c int \a value to append. 2773 2774 \return This method always returns \c *this. 2775 2776 \since BeOS R5 2777*/ 2778 2779 2780/*! 2781 \fn BString& BString::operator<<(unsigned int value) 2782 \brief Convert the <tt>unsigned int</tt> \a value to a string and append it. 2783 2784 \param value The <tt>unsigned int</tt> \a value to append. 2785 2786 \return This method always returns \c *this. 2787 2788 \since BeOS R5 2789*/ 2790 2791 2792/*! 2793 \fn BString& BString::operator<<(unsigned long value) 2794 \brief Convert the <tt>unsigned long</tt> \a value to a string and append it. 2795 2796 \param value The <tt>unsigned long</tt> \a value to append. 2797 2798 \return This method always returns \c *this. 2799 2800 \since BeOS R5 2801*/ 2802 2803 2804/*! 2805 \fn BString& BString::operator<<(long value) 2806 \brief Convert the \c long \a value to a string and append it. 2807 2808 \param value The \c long \a value to append. 2809 2810 \return This method always returns \c *this. 2811 2812 \since BeOS R5 2813*/ 2814 2815 2816/*! 2817 \fn BString& BString::operator<<(unsigned long long value) 2818 \brief Convert the <tt>unsigned long long</tt> \a value to a string and 2819 append it. 2820 2821 \param value The <tt>unsigned long long</tt> \a value to append. 2822 2823 \return This method always returns \c *this. 2824 2825 \since BeOS R5 2826*/ 2827 2828 2829/*! 2830 \fn BString& BString::operator<<(long long value) 2831 \brief Convert the <tt>long long</tt> \a value to a string and append it. 2832 2833 \param value The <tt>long long</tt> \a value to append. 2834 2835 \return This method always returns \c *this. 2836 2837 \since BeOS R5 2838*/ 2839 2840 2841/*! 2842 \fn BString& BString::operator<<(float value) 2843 \brief Convert the \c float \a value to a string and append it. 2844 2845 Using this operator will append using <tt>%.2f</tt> formatting. 2846 2847 \param value The \c float \a value to append. 2848 2849 \return This method always returns \c *this. 2850 2851 \since BeOS R5 2852*/ 2853 2854 2855/*! 2856 \fn BString& BString::operator<<(double value) 2857 \brief Convert the \c double \a value to a string and append it. 2858 2859 Using this operator will append using <tt>%.2f</tt> formatting. 2860 2861 \param value The \c double \a value to append. 2862 2863 \return This method always returns \c *this. 2864 2865 \since BeOS R5 2866*/ 2867 2868 2869//! @} 2870 2871 2872/************* end of BString class, start of general operators ************/ 2873/*! 2874 \addtogroup support_globals 2875*/ 2876 2877 2878//! @{ 2879 2880 2881/*! 2882 \fn bool operator<(const char* a, const BString& b) 2883 \brief Lexicographically compare if \c a is less than the given BString \a b. 2884 2885 From String.h and in libbe.so. 2886 2887 \param a The first string to compare. 2888 \param b The second string to compare. 2889 2890 \return \c true if \a a is less than \a b, \c false otherwise. 2891 2892 \sa BString::operator<(const char*) const 2893 2894 \since BeOS R5 2895*/ 2896 2897 2898/*! 2899 \fn bool operator<=(const char* a, const BString& b) 2900 \brief Lexicographically compare if \c a is less than or equal to a 2901 given BString \a b. 2902 2903 From String.h and in libbe.so. 2904 2905 \param a The first string to compare. 2906 \param b The second string to compare. 2907 2908 \return \c true if \a a is less than or equal to \a b, 2909 \c false otherwise. 2910 2911 \sa BString::operator<=(const char*) const 2912 2913 \since BeOS R5 2914*/ 2915 2916 2917/*! 2918 \fn bool operator==(const char* a, const BString& b) 2919 \brief Lexicographically compare if \c a is equal to a given BString \a b. 2920 2921 From String.h and in libbe.so. 2922 2923 \param a The first string to compare. 2924 \param b The second string to compare. 2925 2926 \sa BString::operator==(const char*) const 2927 2928 \return \c true if \a a is equal to \a b, \c false otherwise. 2929 2930 \since BeOS R5 2931*/ 2932 2933 2934/*! 2935 \fn bool operator>(const char* a, const BString& b) 2936 \brief Lexicographically compare if \c a is greater than a given BString \a b. 2937 2938 From String.h and in libbe.so. 2939 2940 \param a The first string to compare. 2941 \param b The second string to compare. 2942 2943 \sa BString::operator>(const char*) const 2944 2945 \return \c true if \a a is greater than \a b, \c false otherwise. 2946 2947 \since BeOS R5 2948*/ 2949 2950 2951/*! 2952 \fn bool operator>=(const char* a, const BString& b) 2953 \brief Lexicographically compare if \c a is greater than or equal to a 2954 given BString \a b. 2955 2956 From String.h and in libbe.so. 2957 2958 \param a The first string to compare. 2959 \param b The second string to compare. 2960 2961 \return \c true if \a a is greater than or equal to \a b, 2962 \c false otherwise. 2963 2964 \sa BString::operator>=(const char*) const 2965 2966 \since BeOS R5 2967*/ 2968 2969 2970/*! 2971 \fn bool operator!=(const char* a, const BString& b) 2972 \brief Lexicographically compare if \c a is not equal to given BString \a b. 2973 2974 From String.h and in libbe.so. 2975 2976 \param a The first string to compare. 2977 \param b The second string to compare. 2978 2979 \return \c true if \a a is NOT equal to \a b, \c false otherwise. 2980 2981 \sa BString::operator!=(const char*) const 2982 2983 \since BeOS R5 2984*/ 2985 2986 2987/*! 2988 \fn int Compare(const BString& a, const BString& b) 2989 \brief Lexicographically compare two strings. 2990 2991 This function is useful if you need a global compare function to feed to 2992 BList::SortItems(). 2993 2994 \param a The first string to compare. 2995 \param b The second string to compare. 2996 2997 From String.h and in libbe.so. 2998 2999 \return An int representing the strings relationship to each other. 3000 \retval >0 \a a sorts lexicographically after \a b. 3001 \retval =0 \a a is equal to \a b. 3002 \retval <0 \a a sorts lexicographically before \a b. 3003 3004 \sa BString::Compare(const BString&) const 3005 3006 \since BeOS R5 3007*/ 3008 3009 3010/*! 3011 \fn int ICompare(const BString& a, const BString& b) 3012 \brief Lexicographically compare two strings case-insensitively. 3013 3014 This function is useful if you need a global compare function to feed to 3015 BList::SortItems(). 3016 3017 From String.h and in libbe.so. 3018 3019 \param a The first string to compare. 3020 \param b The second string to compare. 3021 3022 \return An int representing the strings relationship to each other. 3023 \retval >0 \a a sorts lexicographically after \a b. 3024 \retval =0 \a a is equal to \a b. 3025 \retval <0 \a a sorts lexicographically before \a b. 3026 3027 \sa BString::Compare(const BString&) const 3028 3029 \since BeOS R5 3030*/ 3031 3032 3033/*! 3034 \fn int Compare(const BString* a, const BString* b) 3035 \brief Lexicographically compare two strings. 3036 3037 This function is useful if you need a global compare function to feed to 3038 BList::SortItems(). 3039 3040 From String.h and in libbe.so. 3041 3042 \param a The first string to compare. 3043 \param b The second string to compare. 3044 3045 \return An int representing the strings relationship to each other. 3046 \retval >0 \a a sorts lexicographically after \a b. 3047 \retval =0 \a a is equal to \a b. 3048 \retval <0 \a a sorts lexicographically before \a b. 3049 3050 \sa BString::Compare(const BString&) const 3051 3052 \since BeOS R5 3053*/ 3054 3055 3056/*! 3057 \fn int ICompare(const BString* a, const BString* b) 3058 \brief Lexicographically compare two strings case-insensitively. 3059 3060 This function is useful if you need a global compare function to feed to 3061 BList::SortItems(). 3062 3063 From String.h and in libbe.so. 3064 3065 \param a The first string to compare. 3066 \param b The second string to compare. 3067 3068 \return An int representing the strings relationship to each other. 3069 \retval >0 \a a sorts lexicographically after \a b. 3070 \retval =0 \a a is equal to \a b. 3071 \retval <0 \a a sorts lexicographically before \a b. 3072 3073 \sa BString::Compare(const BString&) const 3074 3075 \since BeOS R5 3076*/ 3077 3078 3079//! @} 3080