activemq-cpp-3.8.2
CharBuffer.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_NIO_CHARBUFFER_H_
19 #define _DECAF_NIO_CHARBUFFER_H_
20 
21 #include <decaf/nio/Buffer.h>
22 #include <decaf/lang/Comparable.h>
29 #include <decaf/lang/Appendable.h>
30 
31 namespace decaf{
32 namespace nio{
33 
65  class DECAF_API CharBuffer : public Buffer,
66  public lang::CharSequence,
67  public lang::Appendable,
68  public lang::Comparable<CharBuffer> {
69  protected:
70 
81  CharBuffer( int capacity );
82 
83  public:
84 
85  virtual ~CharBuffer() {}
86 
90  virtual std::string toString() const;
91 
103  CharBuffer& append( char value );
104 
117  CharBuffer& append( const lang::CharSequence* value );
118 
136  CharBuffer& append( const lang::CharSequence* value, int start, int end );
137 
152  virtual char* array() = 0;
153 
166  virtual int arrayOffset() = 0;
167 
185  virtual CharBuffer* asReadOnlyBuffer() const = 0;
186 
197  char charAt( int index ) const;
198 
217  virtual CharBuffer& compact() = 0;
218 
232  virtual CharBuffer* duplicate() = 0;
233 
242  virtual char get() = 0;
243 
255  virtual char get( int index ) const = 0;
256 
271  CharBuffer& get( std::vector<char> buffer );
272 
302  CharBuffer& get( char* buffer, int size, int offset, int length );
303 
313  virtual bool hasArray() const = 0;
314 
320  int length() const {
321  return this->remaining();
322  }
323 
343  CharBuffer& put( CharBuffer& src );
344 
372  CharBuffer& put( const char* buffer, int size, int offset, int length );
373 
386  CharBuffer& put( std::vector<char>& buffer );
387 
401  virtual CharBuffer& put( char value ) = 0;
402 
417  virtual CharBuffer& put( int index, char value ) = 0;
418 
446  CharBuffer& put( std::string& src, int start, int end );
447 
463  CharBuffer& put( const std::string& src );
464 
480  virtual int read( CharBuffer* target );
481 
504  virtual lang::CharSequence* subSequence( int start, int end ) const = 0;
505 
519  virtual CharBuffer* slice() const = 0;
520 
521  public: // Comparable
522 
526  virtual int compareTo( const CharBuffer& value ) const;
527 
531  virtual bool equals( const CharBuffer& value ) const;
532 
536  virtual bool operator==( const CharBuffer& value ) const;
537 
541  virtual bool operator<( const CharBuffer& value ) const;
542 
543  public: // Statics
544 
559  static CharBuffer* allocate( int capacity );
560 
584  static CharBuffer* wrap( char* array, int size, int offset, int length );
585 
601  static CharBuffer* wrap( std::vector<char>& buffer );
602 
624 // TODO
625 // static CharBuffer* wrap( lang::CharSequence* csq, int start, int end );
626 
642 // TODO
643 // static CharBuffer* wrap( lang::CharSequence* csq );
644 
645  };
646 
647 }}
648 
649 #endif /*_DECAF_NIO_CHARBUFFER_H_*/
A container for data of a specific primitive type.
Definition: Buffer.h:125
A CharSequence is a readable sequence of char values.
Definition: CharSequence.h:36
An object to which char sequences and values can be appended.
Definition: Appendable.h:47
virtual ~CharBuffer()
Definition: CharBuffer.h:85
This class defines four categories of operations upon character buffers:
Definition: CharBuffer.h:65
#define DECAF_API
Definition: Config.h:29
int length() const
Returns the length of this character buffer.
Definition: CharBuffer.h:320
bool operator==(const ArrayPointer< T > &left, const U *right)
Definition: ArrayPointer.h:379
This interface imposes a total ordering on the objects of each class that implements it...
Definition: Comparable.h:33
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25