Yate Learning--yateclass.h--class Yate_api Stream

Source: Internet
Author: User

Reprint Description:

All base classes based on stream operations in Yate:

/** * Base class for encapsulating system dependent stream capable objects * encapsulates the base classes of stream objects that can be based on systems * @short an abstract stream c Lass capable of reading and writing * @short able to read and write abstract classes */class YATE_API stream{public:/** * Enumerate seek start P                         Osition * Open Search for Location enumeration */enum Seekpos {seekbegin,//Seek from start of Streamseekend,    Seek from Stream endseekcurrent//seek from current position};    /** * destructor, terminates the stream * destructor, End stream */virtual ~stream (); /** * Get the error code of the last operation in this stream * get the most recent action for this stream of errors * @return Err code generated b    Y the last operation to this stream * @ Returns the error code generated by the most recent operation of this stream */inline int error () const{return m_error;}     /** * Closes the stream * close this stream * @return True if the stream was (already) closed, false if an error occured * @ Returns True if the stream is closed (already closed), FALSE, Error */virtual bool TermiNate () = 0; /** * Check if the last error code indicates a retryable condition * checks for a current code that indicates a re-operation condition * @return True if ER    ROR is temporary and operation should be retried * @ returns TRUE if the error is temporary and re-operable */virtual BOOL Canretry () const;     /** * Check if the last error code indicates a non blocking operation in progress * Check for a recent fault code indicating an ongoing non-blocking operation * @return True if a non blocking operation is in progress * @ Returns TRUE if a non-blocking operation is being performed */virtual bool InProgress (    ) const; /** * Check if this stream is valid * checks if the stream is valid * @return True if the stream is valid, false if it ' s invalid    or Closed * @ returns TRUE if the stream is valid, false, the stream is invalid or has been closed */virtual BOOL Valid () const = 0;  /** * Set the blocking or non-blocking operation mode of the stream * set this stream block or non-blocking mode * @param block True if I/O  Operations should block, FALSE for non-blocking * @ parameter Blcok, true if the I/O operation is blocked, false, non-blocking * @return True if operation Was successfull, false IF An error occured * @ Returns True if the operation succeeded, false, an error occurred */virtual bool Setblocking (bool block = TRUE); /** * Write data to a connected stream * writes to an already connected stream * @param buffer for data transfer * @ parameter buffer The data transfer buffer * @param length length of the buffer * @ parameter length, length of buffer * @return number of bytes transferred, Negat    Ive if an error occurred * @ Returns the bytes that have been transmitted, negative numbers, an error occurred */virtual int writedata (const void* buffer, int length) = 0;     /** * Write a C string to a connected stream * writes a C string to a stream that is already connected * @param str string to send over the stream     * @ parameter str, string to be sent * @return number of bytes transferred, negative if an error occurred * @ return bytes already transferred, negative number, error occurred    */int WriteData (const char* str); /** * Write a string to a connected stream * writes a string to an already connected stream * @param str string to send over the stream * @  Parameter str, string to be sent * @return number of bytes transferred, negative if an error occurred * @ return bytes already transferred, negative number, error occurred   */Inline int writedata (const string& str) {return WriteData (Str.c_str (), str.length ());}     /** * Write a data block to a connected stream * write chunks to an already connected stream * @param buf datablock to send over the stream     * @ parameter buf, data block to be sent * @return number of bytes transferred, negative if an error occurred * @ return bytes already transferred, negative number, error occurred    */Inline int writedata (const datablock& buf) {return WriteData (Buf.data (), buf.length ());} /** * Receive data from a connected stream * received from a connected stream * @param buffer for data transfer * @ parameter BU Ffer, data transfer buffer * @param length length of the buffer * @ parameter length, length of buffer * @return number of bytes transferred, n    Egative If an error occurred * @ Returns the bytes that have been transmitted, negative numbers, an error occurred */virtual int readdata (void* buffer, int length) = 0; /** * Find the length of the stream if it has one * if the stream is present, find out the lengths of the stream * @return Long of the stream or zero if le    Ngth is not defined * @ Returns the length of the stream, 0 if the length of the stream is undefined */Virtual int64_t length (); /** * Set the stream read/write pointer * Set the read/write pointer to the stream * @param pos The Seek start as enumeration * @ parameter Pos,e The address where the jump begins in numeration * @param offset the number of bytes to move the pointer from starting position * @ parameter offset, from the open The number of bytes of the pointer moved by the start address * @return The new position of the stream read/write pointer.    Negative on Failure * @ Returns the new position of the read/write pointer, negative number is failed */virtual int64_t seek (seekpos pos, int64_t offset = 0); /** * Set the read/write pointer from begin of stream * Set the stream's read/write pointer from the position where the stream starts * @param offset the position in Stre AM to move the pointer * @ parameter offset, the number of bytes of pointer moved from the start address * @return The new position of the stream read/write pointer.  Negative on Failure * @ Returns the new position of the read/write pointer, negative number is failed */inline int64_t Seek (int64_t offset) {return Seek (Seekbegin,offset); }/** * Allocate a new pair of unidirectionally pipe connected streams * Assign streams to a one-way pipeline * @param reader Refe Rence of a pointer receiving the newly allocated REading side of the pipe * @ parameter reader, read pointer * @param writer Reference of a pointer receiving the newly allocated WRI Ting side of the pipe * @ parameter writer, write pointer * @return true is the stream pipe was created successfully * @ returns TRUE, stream    Pipeline creation succeeded */static bool Allocpipe (stream*& reader, stream*& writer); /** * Allocate A new pair of bidirectionally connected streams * Assign stream a pair of new bidirectional * @param str1 Reference of a Pointe R receiving the newly allocated 1st end of the pair * @ parameter str1, the first end of the receive reference pointer * @param str2 Reference of a pointer rece Iving the newly allocated 2nd end of the pair * @ parameter str2, receive reference pointer at the end of the section * @return True is the stream pair was created s    Uccessfully * @ returns TRUE, Stream created successfully */static bool Allocpair (stream*& str1, stream*& str2); /** * Check if operating system supports unidirectional stream pairs * checks if the operating system supports unidirectional streams * @return True if UNIDIR Ectional pipes can be created * @ returns TRUE if a one-way pipeline is created */static bool SUpportspipes (); /** * Check if operating system supports bidirectional stream pairs * Checks if the operating system supports bidirectional streams * @return True if Bidirec tional pairs can be created */static bool Supportspairs ();p rotected:/** * Default constructor * defaults to constructor Number */inline Stream (): M_error (0) {}/** * Clear the last error code * Clears the final bug number */inline void CLE    Arerror () {m_error = 0;} int m_error;};


Yate Learning--yateclass.h--class Yate_api Stream

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.