activemq-cpp-3.9.5
ByteArrayBuffer.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_INTERNAL_NIO_BYTEBUFFER_H_
19#define _DECAF_INTERNAL_NIO_BYTEBUFFER_H_
20
29
34#include <decaf/nio/IntBuffer.h>
36
37#include <decaf/lang/Pointer.h>
38
39namespace decaf{
40namespace internal{
41namespace nio{
42
43 using decaf::internal::util::ByteArrayAdapter;
44
105 private:
106
107 // The reference array object that backs this buffer.
109
110 // Offset into the array that we are to start from
111 int offset;
112
113 // The number of bytes we are limited to.
114 int length;
115
116 // Read / Write flag
117 bool readOnly;
118
119 public:
120
133 ByteArrayBuffer( int capacity, bool readOnly = false );
134
153 ByteArrayBuffer( unsigned char* array, int size, int offset, int length,
154 bool readOnly = false );
155
174 int offset, int length, bool readOnly = false );
175
185
187
188 public:
189
193 virtual bool isReadOnly() const {
194 return this->readOnly;
195 }
196
200 virtual unsigned char* array();
201
205 virtual int arrayOffset() const;
206
210 virtual bool hasArray() const { return true; }
211
212 public: // Abstract Methods
213
217 virtual decaf::nio::CharBuffer* asCharBuffer() const { return NULL; } //TODO
218
222 virtual decaf::nio::DoubleBuffer* asDoubleBuffer() const { return NULL; } //TODO
223
227 virtual decaf::nio::FloatBuffer* asFloatBuffer() const { return NULL; } //TODO
228
232 virtual decaf::nio::IntBuffer* asIntBuffer() const { return NULL; } //TODO
233
237 virtual decaf::nio::LongBuffer* asLongBuffer() const { return NULL; } //TODO
238
242 virtual decaf::nio::ShortBuffer* asShortBuffer() const { return NULL; } //TODO
243
248
253
258
262 virtual unsigned char get() const;
263
267 virtual unsigned char get( int index ) const;
268
272 virtual char getChar() {
273 return (char)this->get();
274 }
275
279 virtual char getChar( int index ) const {
280
281 return (char)this->get( index );
282 }
283
287 virtual double getDouble();
288
292 virtual double getDouble( int index ) const;
293
297 virtual float getFloat();
298
302 virtual float getFloat( int index ) const;
303
307 virtual long long getLong();
308
312 virtual long long getLong( int index ) const;
313
317 virtual int getInt();
318
322 virtual int getInt( int index ) const;
323
327 virtual short getShort();
328
332 virtual short getShort( int index ) const;
333
337 virtual ByteArrayBuffer& put( unsigned char value );
338
342 virtual ByteArrayBuffer& put( int index, unsigned char value );
343
347 virtual ByteArrayBuffer& putChar( char value );
348
352 virtual ByteArrayBuffer& putChar( int index, char value );
353
357 virtual ByteArrayBuffer& putDouble( double value );
358
362 virtual ByteArrayBuffer& putDouble( int index, double value );
363
367 virtual ByteArrayBuffer& putFloat( float value );
368
372 virtual ByteArrayBuffer& putFloat( int index, float value );
373
377 virtual ByteArrayBuffer& putLong( long long value );
378
382 virtual ByteArrayBuffer& putLong( int index, long long value );
383
387 virtual ByteArrayBuffer& putInt( int value );
388
392 virtual ByteArrayBuffer& putInt( int index, int value );
393
397 virtual ByteArrayBuffer& putShort( short value );
398
402 virtual ByteArrayBuffer& putShort( int index, short value );
403
407 virtual ByteArrayBuffer* slice() const;
408
409 protected:
410
417 virtual void setReadOnly( bool value ) {
418 this->readOnly = value;
419 }
420
421 };
422
423}}}
424
425#endif /*_DECAF_INTERNAL_NIO_BYTEBUFFER_H_*/
virtual unsigned char * array()
Returns the byte array that backs this buffer.Modifications to this buffer's content will cause the r...
virtual decaf::nio::DoubleBuffer * asDoubleBuffer() const
Creates a view of this byte buffer as a double buffer.The content of the new buffer will start at thi...
Definition ByteArrayBuffer.h:222
virtual long long getLong()
Reads the next eight bytes at this buffer's current position, and then increments the position by tha...
virtual int arrayOffset() const
Returns the offset within this buffer's backing array of the first element of the buffer....
virtual void setReadOnly(bool value)
Sets this ByteArrayBuffer as Read-Only or not Read-Only.
Definition ByteArrayBuffer.h:417
virtual double getDouble()
Reads the next eight bytes at this buffer's current position, and then increments the position by tha...
virtual ByteArrayBuffer & putFloat(int index, float value)
Writes four bytes containing the given value, into this buffer at the given index....
virtual ByteArrayBuffer & put(unsigned char value)
Writes the given byte into this buffer at the current position, and then increments the position....
ByteArrayBuffer(int capacity, bool readOnly=false)
Creates a ByteArrayBuffer object that has its backing array allocated internally and is then owned an...
virtual ByteArrayBuffer & putShort(short value)
Writes two bytes containing the given value, into this buffer at the current position,...
ByteArrayBuffer(unsigned char *array, int size, int offset, int length, bool readOnly=false)
Creates a ByteArrayBuffer object that wraps the given array.
virtual ByteArrayBuffer & putFloat(float value)
Writes four bytes containing the given value, into this buffer at the current position,...
virtual decaf::nio::CharBuffer * asCharBuffer() const
Creates a view of this byte buffer as a char buffer.The content of the new buffer will start at this ...
Definition ByteArrayBuffer.h:217
virtual ByteArrayBuffer & compact()
Compacts this buffer.The bytes between the buffer's current position and its limit,...
virtual ByteArrayBuffer & putChar(char value)
Writes one byte containing the given value, into this buffer at the current position,...
virtual ByteArrayBuffer & putInt(int value)
Writes four bytes containing the given value, into this buffer at the current position,...
virtual ByteArrayBuffer & putDouble(int index, double value)
Writes eight bytes containing the given value, into this buffer at the given index....
ByteArrayBuffer(const ByteArrayBuffer &other)
Create a ByteArrayBuffer that mirrors this one, meaning it shares a reference to this buffers ByteArr...
virtual float getFloat(int index) const
Reads four bytes at the given index and returns it.the float at the given index in the buffer.
virtual ByteArrayBuffer & putShort(int index, short value)
Writes two bytes containing the given value, into this buffer at the given index.a reference to this ...
virtual bool isReadOnly() const
Tells whether or not this buffer is read-only.true if, and only if, this buffer is read-only
Definition ByteArrayBuffer.h:193
virtual char getChar(int index) const
Reads one byte at the given index and returns it.the char at the given index in the buffer
Definition ByteArrayBuffer.h:279
virtual int getInt(int index) const
Reads four bytes at the given index and returns it.the int at the given index in the buffer.
virtual decaf::nio::ShortBuffer * asShortBuffer() const
Creates a view of this byte buffer as a short buffer.The content of the new buffer will start at this...
Definition ByteArrayBuffer.h:242
ByteArrayBuffer(const decaf::lang::Pointer< ByteArrayAdapter > &array, int offset, int length, bool readOnly=false)
Creates a byte buffer that wraps the passed ByteArrayAdapter and start at the given offset.
virtual ByteArrayBuffer & putChar(int index, char value)
Writes one byte containing the given value, into this buffer at the given index.a reference to this b...
virtual char getChar()
Reads the next byte at this buffer's current position, and then increments the position by one....
Definition ByteArrayBuffer.h:272
virtual ByteArrayBuffer & putLong(long long value)
Writes eight bytes containing the given value, into this buffer at the current position,...
virtual bool hasArray() const
Tells whether or not this buffer is backed by an accessible byte array.If this method returns true th...
Definition ByteArrayBuffer.h:210
virtual unsigned char get(int index) const
Absolute get method.Reads the byte at the given index.the byte that is located at the given index.
virtual ByteArrayBuffer & putDouble(double value)
Writes eight bytes containing the given value, into this buffer at the current position,...
virtual ByteArrayBuffer * duplicate()
Creates a new byte buffer that shares this buffer's content.The content of the new buffer will be tha...
virtual ByteArrayBuffer & put(int index, unsigned char value)
Writes the given byte into this buffer at the given index.a reference to this buffer.
virtual double getDouble(int index) const
Reads eight bytes at the given index and returns it.the double at the given index in the buffer.
virtual short getShort()
Reads the next two bytes at this buffer's current position, and then increments the position by that ...
virtual ByteArrayBuffer & putLong(int index, long long value)
Writes eight bytes containing the given value, into this buffer at the given index....
virtual int getInt()
Reads the next four bytes at this buffer's current position, and then increments the position by that...
virtual ByteArrayBuffer & putInt(int index, int value)
Writes four bytes containing the given value, into this buffer at the given index....
virtual ByteArrayBuffer * slice() const
Creates a new byte buffer whose content is a shared subsequence of this buffer's content....
virtual decaf::nio::LongBuffer * asLongBuffer() const
Creates a view of this byte buffer as a long buffer.The content of the new buffer will start at this ...
Definition ByteArrayBuffer.h:237
virtual float getFloat()
Reads the next four bytes at this buffer's current position, and then increments the position by that...
virtual unsigned char get() const
Relative get method.Reads the byte at this buffer's current position, and then increments the positio...
virtual ByteArrayBuffer * asReadOnlyBuffer() const
Creates a new, read-only byte buffer that shares this buffer's content.The content of the new buffer ...
virtual decaf::nio::IntBuffer * asIntBuffer() const
Creates a view of this byte buffer as a int buffer.The content of the new buffer will start at this b...
Definition ByteArrayBuffer.h:232
virtual long long getLong(int index) const
Reads eight bytes at the given index and returns it.the long long at the given index in the buffer.
virtual decaf::nio::FloatBuffer * asFloatBuffer() const
Creates a view of this byte buffer as a float buffer.The content of the new buffer will start at this...
Definition ByteArrayBuffer.h:227
virtual short getShort(int index) const
Reads two bytes at the given index and returns it.the short at the given index in the buffer.
Decaf's implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition Pointer.h:53
virtual int capacity() const
Definition Buffer.h:145
This class defines six categories of operations upon byte buffers:
Definition ByteBuffer.h:98
This class defines four categories of operations upon character buffers:
Definition CharBuffer.h:68
This class defines four categories of operations upon double buffers:
Definition DoubleBuffer.h:53
This class defines four categories of operations upon float buffers:
Definition FloatBuffer.h:51
This class defines four categories of operations upon int buffers:
Definition IntBuffer.h:51
This class defines four categories of operations upon long long buffers:
Definition LongBuffer.h:51
This class defines four categories of operations upon short buffers:
Definition ShortBuffer.h:51
#define NULL
Definition Config.h:33
#define DECAF_API
Definition Config.h:29
Definition BufferFactory.h:33
Definition AprPool.h:26
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25