activemq-cpp-3.4.0

src/main/decaf/nio/ShortBuffer.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_NIO_SHORTBUFFER_H_
00019 #define _DECAF_NIO_SHORTBUFFER_H_
00020 
00021 #include <decaf/nio/Buffer.h>
00022 #include <decaf/lang/Comparable.h>
00023 #include <decaf/lang/exceptions/NullPointerException.h>
00024 #include <decaf/lang/exceptions/IndexOutOfBoundsException.h>
00025 #include <decaf/nio/BufferUnderflowException.h>
00026 #include <decaf/nio/BufferOverflowException.h>
00027 #include <decaf/nio/ReadOnlyBufferException.h>
00028 
00029 namespace decaf{
00030 namespace nio{
00031 
00050     class DECAF_API ShortBuffer : public Buffer,
00051                                   public lang::Comparable<ShortBuffer> {
00052     protected:
00053 
00064         ShortBuffer( int capacity );
00065 
00066     public:
00067 
00068         virtual ~ShortBuffer() {}
00069 
00073         virtual std::string toString() const;
00074 
00089         virtual short* array() = 0;
00090 
00103         virtual int arrayOffset() = 0;
00104 
00122         virtual ShortBuffer* asReadOnlyBuffer() const = 0;
00123 
00142         virtual ShortBuffer& compact() = 0;
00143 
00157         virtual ShortBuffer* duplicate() = 0;
00158 
00167         virtual short get() = 0;
00168 
00180         virtual short get( int index ) const = 0;
00181 
00196         ShortBuffer& get( std::vector<short> buffer );
00197 
00227         ShortBuffer& get( short* buffer, int size, int offset, int length );
00228 
00238         virtual bool hasArray() const = 0;
00239 
00260         ShortBuffer& put( ShortBuffer& src );
00261 
00289         ShortBuffer& put( const short* buffer, int size, int offset, int length );
00290 
00303         ShortBuffer& put( std::vector<short>& buffer );
00304 
00318         virtual ShortBuffer& put( short value ) = 0;
00319 
00334         virtual ShortBuffer& put( int index, short value ) = 0;
00335 
00349         virtual ShortBuffer* slice() const = 0;
00350 
00351     public:  // Comparable
00352 
00356         virtual int compareTo( const ShortBuffer& value ) const;
00357 
00361         virtual bool equals( const ShortBuffer& value ) const;
00362 
00366         virtual bool operator==( const ShortBuffer& value ) const;
00367 
00371         virtual bool operator<( const ShortBuffer& value ) const;
00372 
00373     public:   // Statics
00374 
00387         static ShortBuffer* allocate( int capacity );
00388 
00413         static ShortBuffer* wrap( short* array, int size, int offset, int length );
00414 
00430         static ShortBuffer* wrap( std::vector<short>& buffer );
00431 
00432     };
00433 
00434 }}
00435 
00436 #endif /*_DECAF_NIO_SHORTBUFFER_H_*/