activemq-cpp-3.4.0

src/main/decaf/io/DataOutputStream.h

Go to the documentation of this file.
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_DATAOUTPUTSTREAM_H_
00019 #define _DECAF_IO_DATAOUTPUTSTREAM_H_
00020 
00021 #include <decaf/io/FilterOutputStream.h>
00022 #include <decaf/io/IOException.h>
00023 #include <decaf/io/UTFDataFormatException.h>
00024 #include <string>
00025 
00026 namespace decaf{
00027 namespace io{
00028 
00034     class DECAF_API DataOutputStream : public FilterOutputStream {
00035     protected:
00036 
00037         // The number of bytes written to the data output stream so far.
00038         long long written;
00039 
00040         // Buffer used for storing byte values to write to the stream
00041         unsigned char buffer[8];
00042 
00043     private:
00044 
00045         DataOutputStream( const DataOutputStream& );
00046         DataOutputStream& operator= ( const DataOutputStream& );
00047 
00048     public:
00049 
00056         DataOutputStream( OutputStream* outputStream, bool own = false );
00057 
00058         virtual ~DataOutputStream();
00059 
00067         virtual long long size() const {
00068             return written;
00069         }
00070 
00074         virtual void writeBoolean( bool value );
00075 
00079        virtual void writeByte( unsigned char value );
00080 
00084         virtual void writeShort( short value );
00085 
00089         virtual void writeUnsignedShort( unsigned short value );
00090 
00094         virtual void writeChar( char value );
00095 
00099         virtual void writeInt( int value );
00100 
00104         virtual void writeLong( long long value );
00105 
00109         virtual void writeFloat( float value );
00110 
00114         virtual void writeDouble( double value );
00115 
00119         virtual void writeBytes( const std::string& value );
00120 
00124         virtual void writeChars( const std::string& value );
00125 
00129         virtual void writeUTF( const std::string& value );
00130 
00131     protected:
00132 
00133         virtual void doWriteByte( unsigned char value );
00134 
00135         virtual void doWriteArrayBounded( const unsigned char* buffer, int size, int offset, int length );
00136 
00137     private:
00138 
00139         // Determine the encoded length of a string when written as modified UTF-8
00140         unsigned int countUTFLength( const std::string& value );
00141 
00142     };
00143 
00144 }}
00145 
00146 #endif /*_DECAF_IO_DATAOUTPUTSTREAM_H_*/