IOExtensions.cs revision 324c4644fee44b9898524c09511bd33c3f12e2df
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * [The "BSD licence"]
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Copyright (c) 2005-2008 Terence Parr
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * All rights reserved.
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Conversion to C#:
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Copyright (c) 2008-2009 Sam Harwell, Pixel Mine, Inc.
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * All rights reserved.
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Redistribution and use in source and binary forms, with or without
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * modification, are permitted provided that the following conditions
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * are met:
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 1. Redistributions of source code must retain the above copyright
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *    notice, this list of conditions and the following disclaimer.
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * 2. Redistributions in binary form must reproduce the above copyright
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *    notice, this list of conditions and the following disclaimer in the
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *    documentation and/or other materials provided with the distribution.
1868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) * 3. The name of the author may not be used to endorse or promote products
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *    derived from this software without specific prior written permission.
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) */
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if !DEBUG
3468043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
3568043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)using System;
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)using TextReader = System.IO.TextReader;
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)using TextWriter = System.IO.TextWriter;
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace Antlr.Runtime.JavaExtensions
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles){
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    public static class IOExtensions
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    {
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        [Obsolete]
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        public static void close( this TextReader reader )
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        {
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            reader.Close();
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        }
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        [Obsolete]
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        public static void close( this TextWriter writer )
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        {
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            writer.Close();
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        }
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        [Obsolete]
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        public static void print<T>( this TextWriter writer, T value )
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        {
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            writer.Write( value );
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        }
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        [Obsolete]
633551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)        public static void println( this TextWriter writer )
64a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)        {
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            writer.WriteLine();
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        }
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        [Obsolete]
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        public static void println<T>( this TextWriter writer, T value )
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        {
712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            writer.WriteLine( value );
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        }
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        [Obsolete]
752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        public static void write<T>( this TextWriter writer, T value )
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        {
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            writer.Write( value );
7868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)        }
7968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
8068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)        [Obsolete]
8168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)        public static int read( this TextReader reader, char[] buffer, int index, int count )
8268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)        {
8368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)            return reader.Read( buffer, index, count );
8468043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)        }
8568043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
8668043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)        [Obsolete]
8768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)        public static string readLine( this TextReader reader )
8868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)        {
8968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)            return reader.ReadLine();
9068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)        }
9168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)    }
9268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)}
9368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
9468043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)#endif
9568043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)