Differences From Artifact [4dfb1471ce]:
- File
src/OFStream.h
— part of check-in
[d526d938d7]
at
2015-11-21 18:35:39
on branch trunk
— Remove OF_NULLABLE / OF_NONNULL
Now that Clang switched to use _Nullable and _Nonnull instead of
__nullable / __nonnull, there is no longer a conflict with glibc, which
means we can just define _Nullable / _Nonnull to nothing if they are not
understood by the compiler (which did not work with __nullable /
__nonnull due to this conflict).This also defines _Null_unspecified to nothing if unavailable. (user: js, size: 39577) [annotate] [blame] [check-ins using]
To Artifact [eaef7f1c66]:
- File src/OFStream.h — part of check-in [650b4be224] at 2015-11-28 19:47:01 on branch trunk — Minor documentation improvements (user: js, size: 39637) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
40 41 42 43 44 45 46 | #if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_BLOCKS) /*! * @brief A block which is called when data was read from the stream. * * @param stream The stream on which data was read * @param buffer A buffer with the data that has been read * @param length The length of the data that has been read | | > | | > | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | #if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_BLOCKS) /*! * @brief A block which is called when data was read from the stream. * * @param stream The stream on which data was read * @param buffer A buffer with the data that has been read * @param length The length of the data that has been read * @param exception An exception which occurred while reading or `nil` on * success * @return A bool whether the same block should be used for the next read */ typedef bool (^of_stream_async_read_block_t)(OFStream *stream, void *buffer, size_t length, OFException *_Nullable exception); /*! * @brief A block which is called when a line was read from the stream. * * @param stream The stream on which a line was read * @param line The line which has been read or `nil` when the end of stream * occurred * @param exception An exception which occurred while reading or `nil` on * success * @return A bool whether the same block should be used for the next read */ typedef bool (^of_stream_async_read_line_block_t)(OFStream *stream, OFString *_Nullable line, OFException *_Nullable exception); #endif /*! |
︙ | ︙ | |||
558 559 560 561 562 563 564 | * stream until the end of the stream is reached. */ - (OFDataArray*)readDataArrayTillEndOfStream; /*! * @brief Reads a string with the specified length from the stream. * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 | * stream until the end of the stream is reached. */ - (OFDataArray*)readDataArrayTillEndOfStream; /*! * @brief Reads a string with the specified length from the stream. * * If `\0` appears in the stream, the string will be truncated at the `\0` and * the rest of the bytes of the string will be lost. This way, reading from the * stream will not break because of a `\0` because the specified number of * bytes is still being read and only the string gets truncated. * * @warning Only call this when you know that enough data is available! * Otherwise you will get an exception! * * @param length The length (in bytes) of the string to read from the stream * @return A string with the specified length */ - (OFString*)readStringWithLength: (size_t)length; /*! * @brief Reads a string with the specified encoding and length from the stream. * * If a `\0` appears in the stream, the string will be truncated at the `\0` * and the rest of the bytes of the string will be lost. This way, reading from * the stream will not break because of a `\0` because the specified number of * bytes is still being read and only the string gets truncated. * * @warning Only call this when you know that enough data is available! * Otherwise you will get an exception! * * @param encoding The encoding of the string to read from the stream * @param length The length (in bytes) of the string to read from the stream * @return A string with the specified length */ - (OFString*)readStringWithLength: (size_t)length encoding: (of_string_encoding_t)encoding; /*! * @brief Reads until a newline, `\0` or end of stream occurs. * * @return The line that was read, autoreleased, or `nil` if the end of the * stream has been reached. */ - (nullable OFString*)readLine; /*! * @brief Reads with the specified encoding until a newline, `\0` or end of * stream occurs. * * @param encoding The encoding used by the stream * @return The line that was read, autoreleased, or `nil` if the end of the * stream has been reached. */ - (nullable OFString*)readLineWithEncoding: (of_string_encoding_t)encoding; #ifdef OF_HAVE_SOCKETS /*! * @brief Asyncronously reads until a newline, `\0`, end of stream or an * exception occurs. * * @note The stream must implement @ref fileDescriptorForReading and return a * valid file descriptor in order for this to work! * * @param target The target on which to call the selector when the data has * been received. If the method returns true, it will be called * again when the next line has been received. If you want the * next method in the queue to handle the next line, you need to * return false from the method * @param selector The selector to call on the target. The signature must be * `bool (OFStream *stream, OFString *line, * OFException *exception)`. */ - (void)asyncReadLineWithTarget: (id)target selector: (SEL)selector; /*! * @brief Asyncronously reads with the specified encoding until a newline, * `\0`, end of stream or an exception occurs. * * @note The stream must implement @ref fileDescriptorForReading and return a * valid file descriptor in order for this to work! * * @param encoding The encoding used by the stream * @param target The target on which to call the selector when the data has * been received. If the method returns true, it will be called * again when the next line has been received. If you want the * next method in the queue to handle the next line, you need to * return false from the method * @param selector The selector to call on the target. The signature must be * `bool (OFStream *stream, OFString *line, * OFException *exception)`. */ - (void)asyncReadLineWithEncoding: (of_string_encoding_t)encoding target: (id)target selector: (SEL)selector; # ifdef OF_HAVE_BLOCKS /*! * @brief Asyncronously reads until a newline, `\0`, end of stream or an * exception occurs. * * @note The stream must implement @ref fileDescriptorForReading and return a * valid file descriptor in order for this to work! * * @param block The block to call when the data has been received. * If the block returns true, it will be called again when the next * line has been received. If you want the next block in the queue * to handle the next line, you need to return false from the * block. */ - (void)asyncReadLineWithBlock: (of_stream_async_read_line_block_t)block; /*! * @brief Asyncronously reads with the specified encoding until a newline, * `\0`, end of stream or an exception occurs. * * @note The stream must implement @ref fileDescriptorForReading and return a * valid file descriptor in order for this to work! * * @param encoding The encoding used by the stream * @param block The block to call when the data has been received. * If the block returns true, it will be called again when the next * line has been received. If you want the next block in the queue * to handle the next line, you need to return false from the * block. */ - (void)asyncReadLineWithEncoding: (of_string_encoding_t)encoding block: (of_stream_async_read_line_block_t)block; # endif #endif /*! * @brief Tries to read a line from the stream (see readLine) and returns `nil` * if no complete line has been received yet. * * @return The line that was read, autoreleased, or `nil` if the line is not * complete yet */ - (nullable OFString*)tryReadLine; /*! * @brief Tries to read a line from the stream with the specified encoding (see * @ref readLineWithEncoding:) and returns `nil` if no complete line has * been received yet. * * @param encoding The encoding used by the stream * @return The line that was read, autoreleased, or `nil` if the line is not * complete yet */ - (nullable OFString*)tryReadLineWithEncoding: (of_string_encoding_t)encoding; /*! * @brief Reads until the specified string or `\0` is found or the end of * stream occurs. * * @param delimiter The delimiter * @return The line that was read, autoreleased, or `nil` if the end of the * stream has been reached. */ - (nullable OFString*)readTillDelimiter: (OFString*)delimiter; /*! * @brief Reads until the specified string or `\0` is found or the end of * stream occurs. * * @param delimiter The delimiter * @param encoding The encoding used by the stream * @return The line that was read, autoreleased, or `nil` if the end of the * stream has been reached. */ - (nullable OFString*)readTillDelimiter: (OFString*)delimiter encoding: (of_string_encoding_t)encoding; /*! * @brief Tries to reads until the specified string or `\0` is found or the end * of stream (see @ref readTillDelimiter:) and returns `nil` if not * enough data has been received yet. * * @param delimiter The delimiter * @return The line that was read, autoreleased, or `nil` if the end of the * stream has been reached. */ - (nullable OFString*)tryReadTillDelimiter: (OFString*)delimiter; /*! * @brief Tries to read until the specified string or `\0` is found or the end * of stream occurs (see @ref readTillDelimiter:encoding:) and returns * `nil` if not enough data has been received yet. * * @param delimiter The delimiter * @param encoding The encoding used by the stream * @return The line that was read, autoreleased, or `nil` if the end of the * stream has been reached. */ - (nullable OFString*)tryReadTillDelimiter: (OFString*)delimiter encoding: (of_string_encoding_t)encoding; /*! * @brief Returns a boolen whether writes are buffered. |
︙ | ︙ |