activemq-cpp-3.8.2
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 
21 #include <decaf/nio/ByteBuffer.h>
29 
30 #include <decaf/nio/CharBuffer.h>
31 #include <decaf/nio/DoubleBuffer.h>
32 #include <decaf/nio/FloatBuffer.h>
33 #include <decaf/nio/ShortBuffer.h>
34 #include <decaf/nio/IntBuffer.h>
35 #include <decaf/nio/LongBuffer.h>
36 
37 #include <decaf/lang/Pointer.h>
38 
39 namespace decaf{
40 namespace internal{
41 namespace nio{
42 
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 
184  ByteArrayBuffer( const ByteArrayBuffer& other );
185 
186  virtual ~ByteArrayBuffer();
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 
247  virtual ByteArrayBuffer* asReadOnlyBuffer() const;
248 
252  virtual ByteArrayBuffer& compact();
253 
257  virtual ByteArrayBuffer* duplicate();
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_*/
This class defines six categories of operations upon byte buffers:
Definition: ByteBuffer.h:97
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
#define NULL
Definition: Config.h:33
This class defines four categories of operations upon float buffers:
Definition: FloatBuffer.h:50
This class defines four categories of operations upon short buffers:
Definition: ShortBuffer.h:50
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 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 char getChar()
Reads the next byte at this buffer&#39;s current position, and then increments the position by one...
Definition: ByteArrayBuffer.h:272
This class defines four categories of operations upon character buffers:
Definition: CharBuffer.h:65
This class defines four categories of operations upon long long buffers:
Definition: LongBuffer.h:50
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
This class adapts primitive type arrays to a base byte array so that the classes can inter-operate on...
Definition: ByteArrayAdapter.h:43
This class defines four categories of operations upon double buffers:
Definition: DoubleBuffer.h:52
This class defines six categories of operations upon byte buffers:
Definition: ByteArrayBuffer.h:104
virtual char getChar(int index) const
Reads one byte at the given index and returns it.The index in the Buffer where the byte is to be read...
Definition: ByteArrayBuffer.h:279
#define DECAF_API
Definition: Config.h:29
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 void setReadOnly(bool value)
Sets this ByteArrayBuffer as Read-Only or not Read-Only.
Definition: ByteArrayBuffer.h:417
Decaf&#39;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 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 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
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25
This class defines four categories of operations upon int buffers:
Definition: IntBuffer.h:50
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