You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2007/11/18 20:45:59 UTC
svn commit: r596121 - in /activemq/activemq-cpp/decaf/trunk/src/main:
Makefile.am decaf/internal/nio/ByteArray.cpp decaf/internal/nio/ByteArray.h
decaf/internal/util/ByteArray.cpp decaf/internal/util/ByteArray.h
Author: tabish
Date: Sun Nov 18 11:45:58 2007
New Revision: 596121
URL: http://svn.apache.org/viewvc?rev=596121&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/internal/util/ByteArray.cpp
- copied, changed from r596095, activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArray.cpp
activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/util/ByteArray.h
- copied, changed from r596095, activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArray.h
Removed:
activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArray.cpp
activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArray.h
Modified:
activemq/activemq-cpp/decaf/trunk/src/main/Makefile.am
Modified: activemq/activemq-cpp/decaf/trunk/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/Makefile.am?rev=596121&r1=596120&r2=596121&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/Makefile.am (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/Makefile.am Sun Nov 18 11:45:58 2007
@@ -23,7 +23,7 @@
decaf/internal/util/NumberConverter.cpp \
decaf/internal/util/FloatingPointParser.cpp \
decaf/internal/util/HexStringParser.cpp \
- decaf/internal/nio/ByteArray.cpp \
+ decaf/internal/util/ByteArray.cpp \
decaf/net/ServerSocket.cpp \
decaf/net/SocketOutputStream.cpp \
decaf/net/BufferedSocket.cpp \
@@ -186,7 +186,7 @@
decaf/internal/util/HexStringParser.h \
decaf/internal/util/BitOps.h \
decaf/internal/util/BigInt.h \
- decaf/internal/nio/ByteArray.h \
+ decaf/internal/util/ByteArray.h \
decaf/nio/Buffer.h \
decaf/nio/ByteBuffer.h \
decaf/nio/BufferOverflowException.h \
Copied: activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/util/ByteArray.cpp (from r596095, activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArray.cpp)
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/util/ByteArray.cpp?p2=activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/util/ByteArray.cpp&p1=activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArray.cpp&r1=596095&r2=596121&rev=596121&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArray.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/util/ByteArray.cpp Sun Nov 18 11:45:58 2007
@@ -22,7 +22,7 @@
using namespace decaf;
using namespace decaf::nio;
using namespace decaf::internal;
-using namespace decaf::internal::nio;
+using namespace decaf::internal::util;
using namespace decaf::lang;
using namespace decaf::lang::exceptions;
@@ -150,4 +150,40 @@
////////////////////////////////////////////////////////////////////////////////
void ByteArray::clear() {
memset( this->array, this->capacity, 0 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+unsigned char& ByteArray::operator[]( std::size_t index )
+ throw ( IndexOutOfBoundsException ) {
+
+ try{
+
+ if( index > this->capacity ) {
+ throw IndexOutOfBoundsException(
+ __FILE__, __LINE__,
+ "ByteArray::operator[] - Index %d is out of bounds", index );
+ }
+
+ return this->array[index];
+ }
+ DECAF_CATCH_RETHROW( InvalidStateException )
+ DECAF_CATCHALL_THROW( InvalidStateException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+const unsigned char& ByteArray::operator[]( std::size_t index ) const
+ throw ( decaf::lang::exceptions::IndexOutOfBoundsException ) {
+
+ try{
+
+ if( index > this->capacity ) {
+ throw IndexOutOfBoundsException(
+ __FILE__, __LINE__,
+ "ByteArray::operator[] - Index %d is out of bounds", index );
+ }
+
+ return this->array[index];
+ }
+ DECAF_CATCH_RETHROW( InvalidStateException )
+ DECAF_CATCHALL_THROW( InvalidStateException )
}
Copied: activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/util/ByteArray.h (from r596095, activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArray.h)
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/util/ByteArray.h?p2=activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/util/ByteArray.h&p1=activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArray.h&r1=596095&r2=596121&rev=596121&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArray.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/util/ByteArray.h Sun Nov 18 11:45:58 2007
@@ -15,19 +15,18 @@
* limitations under the License.
*/
-#ifndef _DECAF_INTERNAL_NIO_BYTEARRAY_H_
-#define _DECAF_INTERNAL_NIO_BYTEARRAY_H_
+#ifndef _DECAF_INTERNAL_UTIL_BYTEARRAY_H_
+#define _DECAF_INTERNAL_UTIL_BYTEARRAY_H_
#include <decaf/lang/exceptions/InvalidStateException.h>
+#include <decaf/lang/exceptions/IndexOutOfBoundsException.h>
#include <decaf/lang/exceptions/NullPointerException.h>
#include <decaf/nio/BufferUnderflowException.h>
#include <decaf/nio/BufferOverflowException.h>
namespace decaf{
namespace internal{
-namespace nio{
-
- class Perspective;
+namespace util{
/**
* Wrapper around an unsigned char* that allows perspectives to be created
@@ -46,9 +45,6 @@
// Wether this object owns the buffer
bool own;
- // Number of Perspectives that reference this ByteArray
- std::size_t numPerspectives;
-
public:
/**
@@ -138,8 +134,19 @@
*/
virtual void clear();
+ /**
+ * Allows the ByteArray to be indexed as a standard array. calling the
+ * non const version allows the user to change the value at index
+ * @param index - the position in the array to access
+ * @throws IndexOutOfBoundsException
+ */
+ unsigned char& operator[]( std::size_t index )
+ throw ( decaf::lang::exceptions::IndexOutOfBoundsException );
+ const unsigned char& operator[]( std::size_t index ) const
+ throw ( decaf::lang::exceptions::IndexOutOfBoundsException );
+
};
}}}
-#endif /*_DECAF_INTERNAL_NIO_BYTEARRAY_H_*/
+#endif /*_DECAF_INTERNAL_UTIL_BYTEARRAY_H_*/