|
activemq-cpp-3.3.0
|
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_CHARBUFFER_H_ 00019 #define _DECAF_NIO_CHARBUFFER_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 #include <decaf/lang/CharSequence.h> 00029 #include <decaf/lang/Appendable.h> 00030 00031 namespace decaf{ 00032 namespace nio{ 00033 00065 class DECAF_API CharBuffer : public Buffer, 00066 public lang::CharSequence, 00067 public lang::Appendable, 00068 public lang::Comparable<CharBuffer> { 00069 protected: 00070 00081 CharBuffer( int capacity ); 00082 00083 public: 00084 00085 virtual ~CharBuffer() {} 00086 00090 virtual std::string toString() const; 00091 00103 CharBuffer& append( char value ); 00104 00117 CharBuffer& append( const lang::CharSequence* value ); 00118 00136 CharBuffer& append( const lang::CharSequence* value, int start, int end ); 00137 00152 virtual char* array() = 0; 00153 00166 virtual int arrayOffset() = 0; 00167 00185 virtual CharBuffer* asReadOnlyBuffer() const = 0; 00186 00197 char charAt( int index ) const; 00198 00217 virtual CharBuffer& compact() = 0; 00218 00232 virtual CharBuffer* duplicate() = 0; 00233 00242 virtual char get() = 0; 00243 00255 virtual char get( int index ) const = 0; 00256 00271 CharBuffer& get( std::vector<char> buffer ); 00272 00302 CharBuffer& get( char* buffer, int size, int offset, int length ); 00303 00313 virtual bool hasArray() const = 0; 00314 00320 int length() const { 00321 return this->remaining(); 00322 } 00323 00343 CharBuffer& put( CharBuffer& src ); 00344 00372 CharBuffer& put( const char* buffer, int size, int offset, int length ); 00373 00386 CharBuffer& put( std::vector<char>& buffer ); 00387 00401 virtual CharBuffer& put( char value ) = 0; 00402 00417 virtual CharBuffer& put( int index, char value ) = 0; 00418 00446 CharBuffer& put( std::string& src, int start, int end ); 00447 00463 CharBuffer& put( const std::string& src ); 00464 00480 virtual int read( CharBuffer* target ); 00481 00504 virtual lang::CharSequence* subSequence( int start, int end ) const = 0; 00505 00519 virtual CharBuffer* slice() const = 0; 00520 00521 public: // Comparable 00522 00526 virtual int compareTo( const CharBuffer& value ) const; 00527 00531 virtual bool equals( const CharBuffer& value ) const; 00532 00536 virtual bool operator==( const CharBuffer& value ) const; 00537 00541 virtual bool operator<( const CharBuffer& value ) const; 00542 00543 public: // Statics 00544 00559 static CharBuffer* allocate( int capacity ); 00560 00584 static CharBuffer* wrap( char* array, int size, int offset, int length ); 00585 00601 static CharBuffer* wrap( std::vector<char>& buffer ); 00602 00624 // TODO 00625 // static CharBuffer* wrap( lang::CharSequence* csq, int start, int end ); 00626 00642 // TODO 00643 // static CharBuffer* wrap( lang::CharSequence* csq ); 00644 00645 }; 00646 00647 }} 00648 00649 #endif /*_DECAF_NIO_CHARBUFFER_H_*/