pike.git / src / modules / _Stdio / buffer.cmod

version» Context lines:

pike.git/src/modules/_Stdio/buffer.cmod:1278:       /*! @decl Buffer add_hstring( string(0..255) data, int size_size )    *! @decl Buffer add_hstring( Stdio.Buffer data, int size_size )    *! @decl Buffer add_hstring( System.Memory data, int size_size )    *! @decl Buffer add_hstring( String.Buffer data, int size_size )    *! @decl Buffer add_hstring( array data, int size_size )    *!    *! Adds length of data followed by @[data] to the buffer.    *!    *! This is identical to -  *! @tt{sprintf("%"+size_size+"H",(string)Stdio.IObuffer(data))@} but +  *! @tt{sprintf("%"+size_size+"H",(string)Stdio.Buffer(data))@} but    *! significantly faster.    *!    *! @[size_size] is the number of bytes used to represent the length of the data.    *! It must be less than Int.NATIVE_MAX.    *!    *! The supported @[data] argument types are    *!    *! @mixed    *! @type string(0..255)    *! An eight bit string.
pike.git/src/modules/_Stdio/buffer.cmod:2348:    *!    *! Take some care with these objects, if you create multiple ones    *! at once the results might be somewhat confusing if you do not    *! release them in the reverse order they were created in (then    *! again, you almost certainly really only need one)    *!    *! You can call @[RewindKey.update] in the generated object to    *! change where it will be rewound to.    *!    *! The typical use-case of this functionality is when parsing a -  *! packet protocol with variable length packets where the lenght is +  *! packet protocol with variable length packets where the length is    *! not immediately known. It saves you from keeping track of how    *! much to rewind if you had not actually gotten the whole packet    *! yet.    *!    *! @example    *! @code    *! void parse_packet( Stdio.Buffer b )    *! {    *! Stdio.Buffer.RewindKey rewind = b->rewind_on_error();    *! b->set_error_mode(1);    *!    *! switch( b->read_int8() ) // packet type    *! {    *! case DATA:    *! int channel = b->read_int8();    *! Stdio.Buffer data = b->read_hbuffer( 4 );    *! // we have read the whole packet, so no longer rewind on error.    *! rewind->release(); -  *! return handle_data_packet( chennel, data ); +  *! return handle_data_packet( channel, data );    *! }    *! }    *! @endcode    *! @note    *! Just calling @[rewind_on_error] without assigning the return    *! value to something will not do anything. You need to keep the    *! object around while the rewind-to position is still valid.    *!    *! Keeping the object around forbids the buffer from moving data    *! inside itself, this means that it can only grow. So do not keep