Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 1539

Show
Ignore:
Timestamp:
05/22/10 21:04:09 (15 years ago)
Author:
walter
Message:

tabs to spaces

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/phobos-1.x/phobos/std/socketstream.d

    r295 r1539  
    4141 * <b>SocketStream</b> is a stream for a blocking, 
    4242 * connected <b>Socket</b>. 
    4343 */ 
    4444class SocketStream: Stream 
    4545{ 
    4646    private: 
    4747    Socket sock; 
    4848     
    4949    public: 
    5050 
    51     /** 
    52      * Constructs a SocketStream with the specified Socket and FileMode flags. 
    53      */ 
    54     this(Socket sock, FileMode mode) 
    55     { 
    56         if(mode & FileMode.In) 
    57             readable = true; 
    58         if(mode & FileMode.Out) 
    59             writeable = true; 
    60          
    61         this.sock = sock; 
    62     } 
    63      
    64     /** 
    65      * Uses mode <b>FileMode.In | FileMode.Out</b>. 
    66      */ 
    67     this(Socket sock) 
    68     { 
    69         writeable = readable = true; 
    70         this.sock = sock; 
    71     } 
    72      
    73     /** 
    74      * Property to get the <b>Socket</b> that is being streamed. 
    75      */ 
    76     Socket socket() 
    77     { 
    78         return sock; 
    79     } 
    80      
    81     /** 
    82      * Attempts to read the entire block, waiting if necessary. 
    83      */ 
    84     override size_t readBlock(void* _buffer, size_t size) 
    85     { 
    86       ubyte* buffer = cast(ubyte*)_buffer; 
    87       assertReadable(); 
    88        
    89       if (size == 0) 
    90         return size; 
    91        
    92       auto len = sock.receive(buffer[0 .. size]); 
    93       readEOF = cast(bool)(len == 0); 
    94       if (len == sock.ERROR) 
    95         len = 0; 
    96       return len; 
    97     } 
    98      
    99     /** 
    100      * Attempts to write the entire block, waiting if necessary. 
    101      */ 
    102     override size_t writeBlock(void* _buffer, size_t size) 
    103     { 
    104       ubyte* buffer = cast(ubyte*)_buffer; 
    105       assertWriteable(); 
     51        /** 
     52         * Constructs a SocketStream with the specified Socket and FileMode flags. 
     53         */ 
     54        this(Socket sock, FileMode mode) 
     55        { 
     56                if(mode & FileMode.In) 
     57                        readable = true; 
     58                if(mode & FileMode.Out) 
     59                        writeable = true; 
    10660 
    107       if (size == 0) 
    108         return size; 
    109        
    110       auto len = sock.send(buffer[0 .. size]); 
    111       readEOF = cast(bool)(len == 0); 
    112       if (len == sock.ERROR)  
    113         len = 0; 
    114       return len; 
    115     } 
    116      
    117     /** 
    118      * 
    119      */ 
    120     override ulong seek(long offset, SeekPos whence) 
    121     { 
    122         throw new SeekException("Cannot seek a socket."); 
    123     } 
    124      
    125     /** 
    126      * Does not return the entire stream because that would 
    127      * require the remote connection to be closed. 
    128      */ 
    129     override char[] toString() 
    130     { 
    131         return sock.toString(); 
    132     } 
    133      
    134     /** 
    135      * Close the <b>Socket</b>. 
    136      */ 
    137     override void close() 
    138     { 
    139         sock.close(); 
    140     } 
     61                this.sock = sock; 
     62        } 
     63 
     64        /** 
     65         * Uses mode <b>FileMode.In | FileMode.Out</b>. 
     66         */ 
     67        this(Socket sock) 
     68        { 
     69                writeable = readable = true; 
     70                this.sock = sock; 
     71        } 
     72 
     73        /** 
     74         * Property to get the <b>Socket</b> that is being streamed. 
     75         */ 
     76        Socket socket() 
     77        { 
     78                return sock; 
     79        } 
     80 
     81        /** 
     82         * Attempts to read the entire block, waiting if necessary. 
     83         */ 
     84        override size_t readBlock(void* _buffer, size_t size) 
     85        { 
     86          ubyte* buffer = cast(ubyte*)_buffer; 
     87          assertReadable(); 
     88 
     89          if (size == 0) 
     90            return size; 
     91 
     92          auto len = sock.receive(buffer[0 .. size]); 
     93          readEOF = cast(bool)(len == 0); 
     94          if (len == sock.ERROR) 
     95            len = 0; 
     96          return len; 
     97        } 
     98 
     99        /** 
     100         * Attempts to write the entire block, waiting if necessary. 
     101         */ 
     102        override size_t writeBlock(void* _buffer, size_t size) 
     103        { 
     104          ubyte* buffer = cast(ubyte*)_buffer; 
     105          assertWriteable(); 
     106 
     107          if (size == 0) 
     108            return size; 
     109 
     110          auto len = sock.send(buffer[0 .. size]); 
     111          readEOF = cast(bool)(len == 0); 
     112          if (len == sock.ERROR) 
     113            len = 0; 
     114          return len; 
     115        } 
     116 
     117        /** 
     118         * 
     119         */ 
     120        override ulong seek(long offset, SeekPos whence) 
     121        { 
     122                throw new SeekException("Cannot seek a socket."); 
     123        } 
     124 
     125        /** 
     126         * Does not return the entire stream because that would 
     127         * require the remote connection to be closed. 
     128         */ 
     129        override char[] toString() 
     130        { 
     131                return sock.toString(); 
     132        } 
     133 
     134        /** 
     135         * Close the <b>Socket</b>. 
     136         */ 
     137        override void close() 
     138        { 
     139                sock.close(); 
     140        } 
    141141} 
    142142 
  • branches/phobos-1.x/phobos/win32.mak

    r1484 r1539  
    933933 
    934934clean: 
    935935    del $(OBJS) 
    936936    del $(DOCS) 
    937937    del phobos.json 
    938938    del phobos.lib 
    939939 
    940940cleanhtml: 
    941941    del $(DOCS) 
    942942 
     943detab: 
     944    detab $(SRCS) 
     945 
    943946install: 
    944947    $(CP) phobos.lib gcstub.obj $(DIR)\windows\lib 
    945948    $(CP) $(MAKEFILES) phoboslicense.txt minit.obj std.ddoc $(DIR)\src\phobos 
    946949    $(CP) $(SRC) $(DIR)\src\phobos 
    947950    $(CP) $(SRC_STD) $(DIR)\src\phobos\std 
    948951    $(CP) $(SRC_STD_C) $(DIR)\src\phobos\std\c 
    949952    $(CP) $(SRC_TI) $(DIR)\src\phobos\std\typeinfo 
    950953    $(CP) $(SRC_INT) $(DIR)\src\phobos\internal 
    951954    $(CP) $(SRC_STD_WIN) $(DIR)\src\phobos\std\windows 
    952955    $(CP) $(SRC_STD_C_WIN) $(DIR)\src\phobos\std\c\windows