|
activemq-cpp-3.4.0
|
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 #ifndef _DECAF_IO_WRITER_H 00018 #define _DECAF_IO_WRITER_H 00019 00020 #include <string> 00021 #include <vector> 00022 #include <decaf/io/IOException.h> 00023 #include <decaf/io/Closeable.h> 00024 #include <decaf/io/Flushable.h> 00025 #include <decaf/lang/Appendable.h> 00026 #include <decaf/lang/exceptions/NullPointerException.h> 00027 #include <decaf/lang/exceptions/IndexOutOfBoundsException.h> 00028 00029 namespace decaf{ 00030 namespace io{ 00031 00032 /* 00033 * Abstract class for writing to character streams. The only methods that a 00034 * subclass must implement are write( char*, size_t, size_t ), flush(), and 00035 * close(). Most subclasses, however, will override some of the methods 00036 * defined here in order to provide higher efficiency, additional functionality, 00037 * or both. 00038 * 00039 * @since 1.0 00040 */ 00041 class DECAF_API Writer : public decaf::io::Closeable, 00042 public decaf::io::Flushable, 00043 public decaf::lang::Appendable { 00044 private: 00045 00046 Writer( const Writer& ); 00047 Writer& operator= ( const Writer& ); 00048 00049 public: 00050 00051 Writer(); 00052 00053 virtual ~Writer(); 00054 00063 virtual void write( char v ); 00064 00073 virtual void write( const std::vector<char>& buffer ); 00074 00086 virtual void write( const char* buffer, int size ); 00087 00104 virtual void write( const char* buffer, int size, int offset, int length ); 00105 00114 virtual void write( const std::string& str ); 00115 00129 virtual void write( const std::string& str, int offset, int length ); 00130 00131 virtual decaf::lang::Appendable& append( char value ); 00132 00133 virtual decaf::lang::Appendable& append( const decaf::lang::CharSequence* csq ); 00134 00135 virtual decaf::lang::Appendable& append( const decaf::lang::CharSequence* csq, int start, int end ); 00136 00137 protected: 00138 00146 virtual void doWriteArrayBounded( const char* buffer, int size, int offset, int length ) = 0; 00147 00148 protected: 00149 00150 virtual void doWriteChar( char v ); 00151 00152 virtual void doWriteVector( const std::vector<char>& buffer ); 00153 00154 virtual void doWriteArray( const char* buffer, int size ); 00155 00156 virtual void doWriteString( const std::string& str ); 00157 00158 virtual void doWriteStringBounded( const std::string& str, int offset, int length ); 00159 00160 virtual decaf::lang::Appendable& doAppendChar( char value ); 00161 00162 virtual decaf::lang::Appendable& doAppendCharSequence( const decaf::lang::CharSequence* csq ); 00163 00164 virtual decaf::lang::Appendable& doAppendCharSequenceStartEnd( const decaf::lang::CharSequence* csq, 00165 int start, int end ); 00166 00167 }; 00168 00169 }} 00170 00171 #endif /*_DECAF_IO_WRITER_H*/