activemq-cpp-3.8.2
DataOutputStream.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _DECAF_IO_DATAOUTPUTSTREAM_H_
19 #define _DECAF_IO_DATAOUTPUTSTREAM_H_
20 
22 #include <decaf/io/IOException.h>
24 #include <string>
25 
26 namespace decaf{
27 namespace io{
28 
35  protected:
36 
37  // The number of bytes written to the data output stream so far.
38  long long written;
39 
40  // Buffer used for storing byte values to write to the stream
41  unsigned char buffer[8];
42 
43  private:
44 
46  DataOutputStream& operator=(const DataOutputStream&);
47 
48  public:
49 
56  DataOutputStream(OutputStream* outputStream, bool own = false);
57 
58  virtual ~DataOutputStream();
59 
67  virtual long long size() const {
68  return written;
69  }
70 
74  virtual void writeBoolean(bool value);
75 
79  virtual void writeByte(unsigned char value);
80 
84  virtual void writeShort(short value);
85 
89  virtual void writeUnsignedShort(unsigned short value);
90 
94  virtual void writeChar(char value);
95 
99  virtual void writeInt(int value);
100 
104  virtual void writeLong(long long value);
105 
109  virtual void writeFloat(float value);
110 
114  virtual void writeDouble(double value);
115 
119  virtual void writeBytes(const std::string& value);
120 
124  virtual void writeChars(const std::string& value);
125 
129  virtual void writeUTF(const std::string& value);
130 
131  protected:
132 
133  virtual void doWriteByte(unsigned char value);
134 
135  virtual void doWriteArrayBounded(const unsigned char* buffer, int size, int offset, int length);
136 
137  private:
138 
139  // Determine the encoded length of a string when written as modified UTF-8
140  unsigned int countUTFLength(const std::string& value);
141 
142  };
143 
144 }}
145 
146 #endif /*_DECAF_IO_DATAOUTPUTSTREAM_H_*/
virtual long long size() const
Returns the current value of the counter written, the number of bytes written to this data output str...
Definition: DataOutputStream.h:67
long long written
Definition: DataOutputStream.h:38
A data output stream lets an application write primitive Java data types to an output stream in a por...
Definition: DataOutputStream.h:34
This class is the superclass of all classes that filter output streams.
Definition: FilterOutputStream.h:49
#define DECAF_API
Definition: Config.h:29
Base interface for any class that wants to represent an output stream of bytes.
Definition: OutputStream.h:39
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25