00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one or more 00003 * contributor license agreements. See the NOTICE file distributed with 00004 * this work for additional information regarding copyright ownership. 00005 * The ASF licenses this file to You under the Apache License, Version 2.0 00006 * (the "License"); you may not use this file except in compliance with 00007 * the License. You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef _DECAF_IO_FILTEROUTPUTSTREAM_H_ 00019 #define _DECAF_IO_FILTEROUTPUTSTREAM_H_ 00020 00021 #include <decaf/io/OutputStream.h> 00022 #include <decaf/io/IOException.h> 00023 #include <decaf/lang/exceptions/NullPointerException.h> 00024 #include <decaf/lang/exceptions/IndexOutOfBoundsException.h> 00025 00026 namespace decaf{ 00027 namespace io{ 00028 00049 class DECAF_API FilterOutputStream: public OutputStream { 00050 protected: 00051 00052 // The output Stream to wrap 00053 OutputStream* outputStream; 00054 00055 // Indicates if we own the wrapped stream 00056 bool own; 00057 00058 // Indicates that this stream was closed 00059 volatile bool closed; 00060 00061 private: 00062 00063 FilterOutputStream(const FilterOutputStream&); 00064 FilterOutputStream& operator=(const FilterOutputStream&); 00065 00066 public: 00067 00074 FilterOutputStream(OutputStream* outputStream, bool own = false); 00075 00076 virtual ~FilterOutputStream(); 00077 00084 virtual void flush(); 00085 00092 virtual void close(); 00093 00100 virtual std::string toString() const; 00101 00102 protected: 00103 00104 virtual void doWriteByte(unsigned char value); 00105 00106 virtual void doWriteArray(const unsigned char* buffer, int size); 00107 00108 virtual void doWriteArrayBounded(const unsigned char* buffer, int size, int offset, int length); 00109 00110 protected: 00111 00115 virtual bool isClosed() const; 00116 00117 }; 00118 00119 }} 00120 00121 #endif /*_DECAF_IO_FILTEROUTPUTSTREAM_H_*/
1.6.1