activemq-cpp-3.9.5
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>
30
31namespace decaf{
32namespace 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
82
83 public:
84
85 virtual ~CharBuffer() {}
86
90 virtual std::string toString() const;
91
103 CharBuffer& append( char value );
104
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
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
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_*/
An object to which char sequences and values can be appended.
Definition Appendable.h:42
A CharSequence is a readable sequence of char values.
Definition CharSequence.h:36
This interface imposes a total ordering on the objects of each class that implements it.
Definition Comparable.h:33
virtual int remaining() const
Returns the number of elements between the current position and the limit.
Definition Buffer.h:263
virtual int capacity() const
Definition Buffer.h:145
Buffer(int capactiy)
virtual CharBuffer * asReadOnlyBuffer() const =0
Creates a new, read-only char buffer that shares this buffer's content.
CharBuffer & append(const lang::CharSequence *value)
Appends the specified character sequence to this buffer.
virtual bool operator<(const CharBuffer &value) const
virtual bool operator==(const CharBuffer &value) const
virtual char get()=0
Relative get method.
CharBuffer & put(CharBuffer &src)
This method transfers the chars remaining in the given source buffer into this buffer.
virtual std::string toString() const
virtual lang::CharSequence * subSequence(int start, int end) const =0
Creates a new character buffer that represents the specified subsequence of this buffer,...
virtual bool equals(const CharBuffer &value) const
virtual CharBuffer & put(char value)=0
Writes the given char into this buffer at the current position, and then increments the position.
CharBuffer & append(const lang::CharSequence *value, int start, int end)
Appends a subsequence of the specified character sequence to this buffer If value is Null the the str...
virtual char get(int index) const =0
Absolute get method.
CharBuffer & get(std::vector< char > buffer)
Relative bulk get method.
virtual ~CharBuffer()
Definition CharBuffer.h:85
CharBuffer(int capacity)
Creates a CharBuffer object that has its backing array allocated internally and is then owned and del...
char charAt(int index) const
Reads the character at the given index relative to the current position.
static CharBuffer * wrap(std::vector< char > &buffer)
Wraps the passed STL char Vector in a CharBuffer.
int length() const
Returns the length of this character buffer.
Definition CharBuffer.h:320
virtual char * array()=0
Returns the character array that backs this buffer (optional operation).
virtual bool hasArray() const =0
Tells whether or not this buffer is backed by an accessible char array.
virtual int arrayOffset()=0
Returns the offset within this buffer's backing array of the first element of the buffer (optional op...
virtual CharBuffer * slice() const =0
Creates a new CharBuffer whose content is a shared subsequence of this buffer's content.
static CharBuffer * wrap(char *array, int size, int offset, int length)
Wraps the passed buffer with a new CharBuffer.
CharBuffer & append(char value)
Appends the specified character to this buffer.
CharBuffer & get(char *buffer, int size, int offset, int length)
Relative bulk get method.
CharBuffer & put(const char *buffer, int size, int offset, int length)
This method transfers chars into this buffer from the given source array.
CharBuffer & put(std::vector< char > &buffer)
This method transfers the entire content of the given source char array into this buffer.
virtual CharBuffer * duplicate()=0
Creates a new char buffer that shares this buffer's content.
static CharBuffer * allocate(int capacity)
Allocates a new character buffer.
CharBuffer & put(std::string &src, int start, int end)
Relative bulk put method (optional operation).
virtual CharBuffer & put(int index, char value)=0
Writes the given char into this buffer at the given index.
virtual int compareTo(const CharBuffer &value) const
virtual CharBuffer & compact()=0
Compacts this buffer.
virtual int read(CharBuffer *target)
Attempts to read characters into the specified character buffer.
CharBuffer & put(const std::string &src)
Relative bulk put method (optional operation).
#define DECAF_API
Definition Config.h:29
Definition Readable.h:28
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25