[prev in list] [next in list] [prev in thread] [next in thread] 

List:       activemq-commits
Subject:    svn commit: r599649 - in
From:       tabish () apache ! org
Date:       2007-11-30 0:07:57
Message-ID: 20071130000758.85FB41A9832 () eris ! apache ! org
[Download RAW message or body]

Author: tabish
Date: Thu Nov 29 16:07:55 2007
New Revision: 599649

URL: http://svn.apache.org/viewvc?rev=599649&view=rev
Log:
http://issues.apache.org/activemq/browse/AMQCPP-103

Working on the NIO package

Added:
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/CharBuffer.cpp
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/CharBuffer.h

Added: activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/CharBuffer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/CharBuffer.cpp?rev=599649&view=auto
 ==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/CharBuffer.cpp (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/CharBuffer.cpp Thu Nov 29 \
16:07:55 2007 @@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "CharBuffer.h"
+#include "decaf/lang/Short.h"
+#include "decaf/lang/Integer.h"
+#include "decaf/lang/Long.h"
+#include "decaf/lang/Float.h"
+#include "decaf/lang/Double.h"
+
+using namespace std;
+using namespace decaf;
+using namespace decaf::nio;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+using namespace decaf::internal::nio;
+
+////////////////////////////////////////////////////////////////////////////////
+CharBuffer::CharBuffer( std::size_t capacity, bool readOnly )
+ :  ByteBuffer( capacity, readOnly ) {
+
+}
\ No newline at end of file

Added: activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/CharBuffer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/CharBuffer.h?rev=599649&view=auto
 ==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/CharBuffer.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/CharBuffer.h Thu Nov 29 \
16:07:55 2007 @@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_NIO_CHARBUFFER_H_
+#define _DECAF_NIO_CHARBUFFER_H_
+
+#include <decaf/nio/Buffer.h>
+#include <decaf/lang/Comparable.h>
+#include <decaf/lang/exceptions/NullPointerException.h>
+#include <decaf/lang/exceptions/IndexOutOfBoundsException.h>
+#include <decaf/nio/BufferUnderflowException.h>
+#include <decaf/nio/BufferOverflowException.h>
+#include <decaf/nio/ReadOnlyBufferException.h>
+
+namespace decaf{
+namespace nio{
+
+    /**
+     * This class defines four categories of operations upon character buffers:
+     *
+     * o Absolute and relative get and put methods that read and write single \
characters; +     * o Relative bulk get methods that transfer contiguous sequences of \
characters from +     *   this buffer into an array; and
+     * o Relative bulk put methods that transfer contiguous sequences of characters \
from +     *   a character array, a string, or some other character buffer into this \
buffer. +     * o Methods for compacting, duplicating, and slicing a character \
buffer. +     *
+     * Character buffers can be created either by allocation, which allocates space \
for +     * the buffer's content, by wrapping an existing character array or string \
into a +     * buffer, or by creating a view of an existing byte buffer
+     *
+     * This class implements the CharSequence interface so that character buffers \
may +     * be used wherever character sequences are accepted, for example in the
+     * regular-expression package decaf.util.regex.
+     *
+     * Methods in this class that do not otherwise have a value to return are \
specified +     * to return the buffer upon which they are invoked. This allows \
method invocations +     * to be chained. The sequence of statements
+     *
+     *     cb.put("text/");
+     *     cb.put(subtype);
+     *     cb.put("; charset=");
+     *     cb.put(enc);
+     *
+     * can, for example, be replaced by the single statement
+     *
+     *     cb.put("text/").put(subtype).put("; charset=").put(enc);
+     */
+    class CharBuffer : public Buffer {
+    public:
+
+        /**
+         * Creates a CharBuffer object that has its backing array allocated \
internally +         * and is then owned and deleted when this object is deleted.  \
The array is +         * initially created with all elements initialized to zero.
+         * @param capacity - size of the array, this is the limit we read and write \
to. +         * @param readOnly - should this buffer be read-only, default as false
+         */
+        CharBuffer( std::size_t capacity, bool readOnly );
+
+        virtual ~CharBuffer() {}
+
+    public:
+
+        /**
+         * Appends the specified character to this buffer
+         * @param value - the char to append.
+         * @returns a reference to this modified CharBuffer
+         * @throws BufferOverflowException if there is no more space
+         * @throws ReadOnlyBufferException if this Buffer is read only.
+         */
+        CharBuffer& append( char value )
+            throw ( BufferOverflowException, ReadOnlyBufferException );
+
+        /**
+         * Appends the specified character sequence to this buffer.
+         * If value is Null the the string "null" is appended to the buffer.
+         * @param value - the CharSequence to append.
+         * @returns a reference to this modified CharBuffer
+         * @throws BufferOverflowException if there is no more space
+         * @throws ReadOnlyBufferException if this Buffer is read only.
+         */
+        CharBuffer& append( const CharSequence* value )
+            throw ( BufferOverflowException, ReadOnlyBufferException );
+
+        /**
+         * Appends a subsequence of the specified character sequence to this buffer
+         * If value is Null the the string "null" is appended to the buffer.
+         * @param value - the CharSequence to append.
+         * @param start - the index to start appending from.
+         * @param end - the index to append to.
+         * @returns a reference to this modified CharBuffer
+         * @throws BufferOverflowException if there is no more space
+         * @throws ReadOnlyBufferException if this Buffer is read only.
+         * @throws IndexOutOfBoundsException if start > end, or > length of \
sequence. +         */
+        CharBuffer& append( const CharSequence* value, std::size_t start, \
std::size_t end ) +            throw ( \
decaf::lang::exceptions::IndexOutOfBoundsException, +                    \
BufferOverflowException, ReadOnlyBufferException ); +
+        /**
+         * Returns the character array that backs this buffer  (optional operation).
+         * <p>
+         * Modifications to this buffer's content will cause the returned array's \
content +         * to be modified, and vice versa.
+         * <p>
+         * Invoke the hasArray method before invoking this method in order to ensure \
that +         * this buffer has an accessible backing array.
+         * @returns the array that backs this Buffer
+         * @throws ReadOnlyBufferException if this Buffer is read only.
+         * @throws UnsupportedOperationException if the underlying store has no \
array. +         */
+        char* array()
+            throw( decaf::lang::exceptions::UnsupportedOperationException,
+                   ReadOnlyBufferException );
+
+        /**
+         * Returns the offset within this buffer's backing array of the first \
element of +         * the buffer  (optional operation).
+         * <p>
+         * Invoke the hasArray method before invoking this method in order to ensure \
that +         * this buffer has an accessible backing array.
+         * @returns The offset into the backing array where index zero starts.
+         * @throws ReadOnlyBufferException if this Buffer is read only.
+         * @throws UnsupportedOperationException if the underlying store has no \
array. +         */
+        std::size_t arrayOffset()
+            throw( decaf::lang::exceptions::UnsupportedOperationException,
+                   ReadOnlyBufferException );
+
+        /**
+         * Creates a new, read-only char buffer that shares this buffer's content.
+         * <p>
+         * The content of the new buffer will be that of this buffer. Changes to \
this +         * buffer's content will be visible in the new buffer; the new buffer \
itself, +         * however, will be read-only and will not allow the shared content \
to be +         * modified. The two buffers' position, limit, and mark values will be
+         * independent.
+         * <p>
+         * If this buffer is itself read-only then this method behaves in exactly \
the +         * same way as the duplicate method.
+         * <p>
+         * The new buffer's capacity, limit, position, and mark values will be
+         * identical to those of this buffer.
+         * @return The new, read-only char buffer which the caller then owns.
+         */
+        virtual CharBuffer* asReadOnlyBuffer() const;
+
+        /**
+         * Reads the character at the given index relative to the current position.
+         * <p>
+         * @param index - The index of the character to be read relative to position
+         * @returns The character at index position() + index
+         * @throws IndexOutOfBoundsException
+         */
+        virtual char charAt( std::size_t index )
+            throw( decaf::lang::exceptions::IndexOutOfBoundsException );
+
+        /**
+         * Creates a new char buffer that shares this buffer's content.
+         * <p>
+         * The content of the new buffer will be that of this buffer. Changes to \
this +         * buffer's content will be visible in the new buffer, and vice versa; \
the two +         * buffers' position, limit, and mark values will be independent.
+         * <p>
+         * The new buffer's capacity, limit, position, and mark values will be \
identical +         * to those of this buffer. The new buffer will be read-only if, \
and only if, +         * this buffer is read-only.
+         * @returns a new char Buffer which the caller owns.
+         */
+        virtual ByteBuffer* duplicate();
+
+        /**
+         * Compacts this buffer
+         * <p>
+         * The bytes between the buffer's current position and its limit, if any, \
are +         * copied to the beginning of the buffer. That is, the byte at index
+         * p = position() is copied to index zero, the byte at index p + 1 is copied
+         * to index one, and so forth until the byte at index limit() - 1 is copied
+         * to index n = limit() - 1 - p. The buffer's position is then set to n+1 \
and +         * its limit is set to its capacity. The mark, if defined, is discarded.
+         * <p>
+         * The buffer's position is set to the number of bytes copied, rather than \
to +         * zero, so that an invocation of this method can be followed immediately \
by +         * an invocation of another relative put method.
+         * @returns a reference to this CharBuffer
+         * @throws ReadOnlyBufferException - If this buffer is read-only
+         */
+        virtual CharBuffer& compact() throw( ReadOnlyBufferException );
+
+    public:   // Statics
+
+        /**
+         * Allocates a new character buffer.
+         * <p>
+         * The new buffer's position will be zero, its limit will be its capacity, \
and +         * its mark will be undefined. It will have a backing array, and its \
array offset +         * will be zero.
+         * @param capacity - The size of the Char buffer in chars ( 1 byte ).
+         * @returns the CharBuffer that was allocated, caller owns.
+         */
+        static CharBuffer* allocate( std::size_t capacity );
+
+    };
+
+}}
+
+#endif /*_DECAF_NIO_CHARBUFFER_H_*/


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic