Changeset 574

Show
Ignore:
Timestamp:
08/28/08 17:48:20 (3 months ago)
Author:
Mike Wey
Message:

part of the out params in glib

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wrap/APILookupGLib.txt

    r552 r574  
    190190#import: glib.PollFD 
    191191#structWrap: GPollFD* PollFD 
     192 
     193out: g_main_context_prepare priority 
     194out: g_main_context_query timeout_ 
     195 
    192196outFile: MainContext 
    193197 
     
    564568structWrap: GSource* Source 
    565569structWrap: GIOChannel* IOChannel 
     570 
     571out: g_io_channel_read_chars bytes_read 
     572out: g_io_channel_read_unichar thechar 
     573out: g_io_channel_read_line_string terminator_pos 
     574out: g_io_channel_write_chars bytes_written 
     575out: g_io_channel_get_line_term length 
     576out: g_io_channel_read bytes_read 
     577out: g_io_channel_write bytes_written 
     578 
     579code: start 
     580/** 
     581     * Reads a line, including the terminating character(s), 
     582     * from a GIOChannel into a newly-allocated string. 
     583     * str_return will contain allocated memory if the return 
     584     * is G_IO_STATUS_NORMAL. 
     585     * Params: 
     586     * strReturn =  The line read from the GIOChannel, including the 
     587     *  line terminator. This data should be freed with g_free() 
     588     *  when no longer needed. This is a nul-terminated string. 
     589     *  If a length of zero is returned, this will be NULL instead. 
     590     * length =  location to store length of the read data, or NULL 
     591     * terminatorPos =  location to store position of line terminator, or NULL 
     592     * Returns: the status of the operation. 
     593     * Throws: GException on failure. 
     594     */ 
     595    public GIOStatus readLine(out string strReturn, out uint terminatorPos) 
     596    { 
     597        // GIOStatus g_io_channel_read_line (GIOChannel *channel,  gchar **str_return,  gsize *length,  gsize *terminator_pos,  GError **error); 
     598        GError* err = null; 
     599        char* str = null; 
     600        uint len; 
     601         
     602        auto p = g_io_channel_read_line(gIOChannel, &str, &len, &terminatorPos, &err); 
     603         
     604        if (err !is null) 
     605        { 
     606            throw new GException( new ErrorG(err) ); 
     607        } 
     608 
     609        if ( str !is null ) 
     610            strReturn = str[0 .. len-1]; 
     611         
     612        return p; 
     613    } 
     614 
     615    /** 
     616     * Reads all the remaining data from the file. 
     617     * Params: 
     618     * strReturn =  Location to store a pointer to a string holding 
     619     *  the remaining data in the GIOChannel. This data should 
     620     *  be freed with g_free() when no longer needed. This 
     621     *  data is terminated by an extra nul character, but there 
     622     *  may be other nuls in the intervening data. 
     623     * Returns: G_IO_STATUS_NORMAL on success.  This function never returns G_IO_STATUS_EOF. 
     624     * Throws: GException on failure. 
     625     */ 
     626    public GIOStatus readToEnd(out string strReturn) 
     627    { 
     628        // GIOStatus g_io_channel_read_to_end (GIOChannel *channel,  gchar **str_return,  gsize *length,  GError **error); 
     629        GError* err = null; 
     630        char* str = null; 
     631        uint len; 
     632 
     633        auto p = g_io_channel_read_to_end(gIOChannel, &str, &len, &err); 
     634         
     635        if (err !is null) 
     636        { 
     637            throw new GException( new ErrorG(err) ); 
     638        } 
     639 
     640     
     641        if ( str !is null ) 
     642            strReturn = str[0 .. len-1]; 
     643         
     644        return p; 
     645    } 
     646code: end 
    566647outFile: IOChannel 
    567648