geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject [08/51] [partial] geode git commit: Software Grant Agreement (SGA) from Pivotal for Apache Geode
Date Fri, 13 Jan 2017 22:45:52 GMT
http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/DataInput.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/DataInput.hpp b/src/clicache/src/DataInput.hpp
new file mode 100644
index 0000000..546d2b6
--- /dev/null
+++ b/src/clicache/src/DataInput.hpp
@@ -0,0 +1,685 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+#pragma once
+
+#include "gf_defs.hpp"
+#include <gfcpp/DataInput.hpp>
+#include "impl/NativeWrapper.hpp"
+#include "Log.hpp"
+#include "ExceptionTypes.hpp"
+//#include "../../CacheableDate.hpp"
+
+
+using namespace System;
+using namespace System::Collections::Generic;
+
+namespace GemStone
+{
+  namespace GemFire
+  {
+    namespace Cache
+    {
+      namespace Generic
+      {
+
+      interface class IGFSerializable;
+
+      /// <summary>
+      /// Provides operations for reading primitive data values, byte arrays,
+      /// strings, <c>IGFSerializable</c> objects from a byte stream.
+      /// </summary>
+      public ref class DataInput sealed
+				: public Generic::Internal::UMWrap<gemfire::DataInput>
+      {
+      public:
+
+        /// <summary>
+        /// Construct <c>DataInput</c> using an given array of bytes.
+        /// </summary>
+        /// <param name="buffer">
+        /// The buffer to use for reading data values.
+        /// </param>
+        /// <exception cref="IllegalArgumentException">
+        /// if the buffer is null
+        /// </exception>
+        DataInput( array<Byte>^ buffer );
+
+        /// <summary>
+        /// Construct <c>DataInput</c> using a given length of an array of
+        /// bytes.
+        /// </summary>
+        /// <param name="buffer">
+        /// The buffer to use for reading data values.
+        /// </param>
+        /// <param name="len">
+        /// The number of bytes from the start of the buffer to use.
+        /// </param>
+        /// <exception cref="IllegalArgumentException">
+        /// if the buffer is null
+        /// </exception>
+        DataInput( array<Byte>^ buffer, int32_t len );
+
+        /// <summary>
+        /// Dispose: frees the internal buffer.
+        /// </summary>
+        ~DataInput( ) { Cleanup( ); }
+
+        /// <summary>
+        /// Finalizer: frees the internal buffer.
+        /// </summary>
+        !DataInput( ) { Cleanup( ); }      
+
+        /// <summary>
+        /// Read a signed byte from the stream.
+        /// </summary>
+        SByte ReadSByte( );
+
+        /// <summary>
+        /// Read a boolean value from the stream.
+        /// </summary>
+        bool ReadBoolean( );
+
+				/// <summary>
+        /// Read a char value from the stream.
+        /// </summary>
+        Char ReadChar( );
+
+        /// <summary>
+        /// Read an array of bytes from the stream reading the length
+        /// from the stream first.
+        /// </summary>
+        array<Byte>^ ReadBytes( );
+
+        /// <summary>
+        /// Read an array of signed bytes from the stream reading the length
+        /// from the stream first.
+        /// </summary>
+        array<SByte>^ ReadSBytes( );
+
+        /// <summary>
+        /// Read the given number of bytes from the stream.
+        /// </summary>
+        /// <param name="len">Number of bytes to read.</param>
+        array<Byte>^ ReadBytesOnly( uint32_t len );
+
+        void ReadBytesOnly( array<Byte> ^ buffer, int offset, int count );
+
+        /// <summary>
+        /// Read the given number of signed bytes from the stream.
+        /// </summary>
+        /// <param name="len">Number of signed bytes to read.</param>
+        array<SByte>^ ReadSBytesOnly( uint32_t len );
+
+        /// <summary>
+        /// Read a array len based on array size.
+        /// </summary>
+        int ReadArrayLen( );
+
+        /// <summary>
+        /// Read a 16-bit integer from the stream.
+        /// </summary>
+        int16_t ReadInt16( );
+
+        /// <summary>
+        /// Read a 32-bit integer from the stream.
+        /// </summary>
+        int32_t ReadInt32( );
+
+        /// <summary>
+        /// Read a 64-bit integer from the stream.
+        /// </summary>
+        int64_t ReadInt64( );
+
+        /// <summary>
+        /// Read a floating point number from the stream.
+        /// </summary>
+        float ReadFloat( );
+
+        /// <summary>
+        /// Read a double precision number from the stream.
+        /// </summary>
+        double ReadDouble( );
+
+        /// <summary>
+        /// Read a string after java-modified UTF-8 decoding from the stream.
+        /// The maximum length supported is 2^16-1 beyond which the string
+        /// shall be truncated.
+        /// </summary>
+        String^ ReadUTF( );
+
+        /// <summary>
+        /// Read a string after java-modified UTF-8 decoding from the stream.
+        /// </summary>
+        String^ ReadUTFHuge( );
+
+        /// <summary>
+        /// Read a ASCII string from the stream. Where size is more than 2^16-1 
+        /// </summary>
+        String^ ReadASCIIHuge( );
+
+        /// <summary>
+        /// Read a serializable object from the data. Null objects are handled.
+        /// </summary>
+        Object^ ReadObject( );
+        
+        /// <summary>
+        /// Get the count of bytes that have been read from the stream.
+        /// </summary>
+        property uint32_t BytesRead
+        {
+          uint32_t get( );
+        }
+
+        /// <summary>
+        /// Get the count of bytes that are remaining in the buffer.
+        /// </summary>
+        property uint32_t BytesRemaining
+        {
+          uint32_t get();
+        }
+
+        /// <summary>
+        /// Advance the cursor of the buffer by the given offset.
+        /// </summary>
+        /// <param name="offset">
+        /// The offset(number of bytes) by which to advance the cursor.
+        /// </param>
+        void AdvanceCursor( int32_t offset );
+
+        /// <summary>
+        /// Rewind the cursor of the buffer by the given offset.
+        /// </summary>
+        /// <param name="offset">
+        /// The offset(number of bytes) by which to rewind the cursor.
+        /// </param>
+        void RewindCursor( int32_t offset );
+
+        /// <summary>
+        /// Reset the cursor to the start of buffer.
+        /// </summary>
+        void Reset();
+
+        /// <summary>
+        /// Get the underlying native unmanaged pointer.
+        /// </summary>
+        property IntPtr NativeIntPtr
+        {
+          inline IntPtr get()
+          {
+            return IntPtr(_NativePtr);
+          }
+        }
+        
+        /// <summary>
+        /// Read a dictionary from the stream in a given dictionary instance.
+        /// </summary>
+        /// <param name="dictionary">Object which implements System::Collections::IDictionary interface.</param>
+        void ReadDictionary(System::Collections::IDictionary^ dictionary);
+        
+        /// <summary>
+        /// Read a date from the stream.
+        /// </summary>
+				System::DateTime ReadDate( );
+
+        /// <summary>
+        /// Read a collection from the stream in a given collection instance.
+        /// </summary>
+        /// <param name="list">Object which implements System::Collections::IList interface.</param>
+        void ReadCollection(System::Collections::IList^ list);
+        
+        /// <summary>
+        /// Read a char array from the stream.
+        /// </summary>
+        array<Char>^ ReadCharArray( );
+
+        /// <summary>
+        /// Read a bool array from the stream.
+        /// </summary>
+				array<bool>^ ReadBooleanArray( );
+
+        /// <summary>
+        /// Read a short int array from the stream.
+        /// </summary>
+				array<Int16>^ ReadShortArray( );
+
+        /// <summary>
+        /// Read a int array from the stream.
+        /// </summary>
+				array<Int32>^ ReadIntArray();
+
+        /// <summary>
+        /// Read a long array from the stream.
+        /// </summary>
+				array<Int64>^ ReadLongArray();
+
+        /// <summary>
+        /// Read a float array from the stream.
+        /// </summary>
+				array<float>^ ReadFloatArray();
+
+        /// <summary>
+        /// Read a double array from the stream.
+        /// </summary>
+				array<double>^ ReadDoubleArray();
+
+        /// <summary>
+        /// Read a object array from the stream from the stream.
+        /// </summary>
+        List<Object^>^ ReadObjectArray();
+
+        /// <summary>
+        /// Read a array of signed byte array from the stream.
+        /// </summary>
+        array<array<Byte>^>^ ReadArrayOfByteArrays( );
+
+      internal:
+
+        void setPdxdeserialization(bool val)
+        {
+          m_ispdxDesrialization = true;
+        }
+        bool isRootObjectPdx()
+        {
+          return m_isRootObjectPdx;
+        }
+        void setRootObjectPdx(bool val)
+        {
+          m_isRootObjectPdx = val;
+        }
+
+        Object^ readDotNetObjectArray();
+        System::Collections::Generic::IDictionary<Object^, Object^>^ ReadDictionary();
+
+				String^ ReadString();
+
+        const char * GetPoolName()
+        {
+          return _NativePtr->getPoolName();
+        }
+
+        Object^ ReadDotNetTypes(int8_t typeId);
+
+        /// <summary>
+        /// Get the count of bytes that have been read from the stream, for internal use only.
+        /// </summary>
+        property uint32_t BytesReadInternally
+        {
+          uint32_t get( );
+        }
+
+        void ReadObject(bool% obj)
+        {
+          obj = ReadBoolean();
+        }
+
+        void ReadObject(Byte% obj)
+        {
+          obj = ReadByte();
+        }
+
+        void ReadObject(Char% obj)
+        {
+          obj = (Char)ReadUInt16();
+        }
+
+        inline Char decodeChar( )
+        {
+          Char retChar;
+          int b = m_buffer[ m_cursor++ ] & 0xff;
+          int k = b >> 5;
+          switch (  k )
+            {
+            default:
+              retChar = ( Char ) ( b & 0x7f );
+              break;
+            case 6:
+              {
+                // two byte encoding
+                // 110yyyyy 10xxxxxx
+                // use low order 6 bits
+                int y = b & 0x1f;
+                // use low order 6 bits of the next byte
+                // It should have high order bits 10, which we don't check.
+                int x = m_buffer[ m_cursor++ ] & 0x3f;
+                // 00000yyy yyxxxxxx
+                retChar = ( Char ) ( y << 6 | x );
+                break;
+              }
+            case 7:
+              {
+                // three byte encoding
+                // 1110zzzz 10yyyyyy 10xxxxxx
+                //assert ( b & 0x10 )
+                  //     == 0 : "UTF8Decoder does not handle 32-bit characters";
+                // use low order 4 bits
+                int z = b & 0x0f;
+                // use low order 6 bits of the next byte
+                // It should have high order bits 10, which we don't check.
+                int y = m_buffer[ m_cursor++ ] & 0x3f;
+                // use low order 6 bits of the next byte
+                // It should have high order bits 10, which we don't check.
+                int x = m_buffer[ m_cursor++ ] & 0x3f;
+                // zzzzyyyy yyxxxxxx
+                int asint = ( z << 12 | y << 6 | x );
+                retChar = ( Char ) asint;
+                break;
+              }
+            }// end switch
+
+            return retChar;
+        }
+
+        System::Collections::Hashtable^ ReadHashtable()
+        {
+          int len = this->ReadArrayLen();
+
+          if(len == -1)
+            return nullptr;
+          else
+          {
+            System::Collections::Hashtable^ dict = gcnew System::Collections::Hashtable();
+            for(int i =0; i< len; i++)
+            {
+              Object^ key = this->ReadObject();
+              Object^ val = this->ReadObject();
+
+              dict->Add(key, val);
+            }
+            return dict;
+          }
+        }
+
+        /// <summary>
+        /// Read a byte from the stream.
+        /// </summary>
+        Byte ReadByte( );
+
+        /// <summary>
+        /// Read a 16-bit unsigned integer from the stream.
+        /// </summary>
+        uint16_t ReadUInt16( );
+
+        /// <summary>
+        /// Read a 32-bit unsigned integer from the stream.
+        /// </summary>
+        uint32_t ReadUInt32( );
+       
+        /// <summary>
+        /// Read a 64-bit unsigned integer from the stream.
+        /// </summary>
+        uint64_t ReadUInt64( );
+
+        void ReadObject(Double% obj)
+        {
+          obj = ReadDouble();
+        }
+
+        void ReadObject(Single% obj)
+        {
+          obj = ReadFloat();
+        }
+
+        void ReadObject(int16_t% obj)
+        {
+          obj = ReadInt16();
+        }
+
+        void ReadObject(int32_t% obj)
+        {
+          obj = ReadInt32();
+        }
+
+        void ReadObject(int64_t% obj)
+        {
+          obj = ReadInt64();
+        }
+
+				 void ReadObject(array<SByte>^% obj)
+        {
+          obj = ReadSBytes();
+        }        
+
+        void DataInput::ReadObject(array<UInt16>^% obj);
+        void DataInput::ReadObject(array<UInt32>^% obj);
+        void DataInput::ReadObject(array<UInt64>^% obj);
+
+        template <typename mType>
+        void ReadObject(array<mType>^ %objArray)
+        {
+          int arrayLen = ReadArrayLen();
+          if(arrayLen >= 0) {
+            objArray = gcnew array<mType>(arrayLen);
+
+            int i = 0;
+            for( i = 0; i < arrayLen; i++ ){
+              mType tmp;
+              ReadObject(tmp);
+              objArray[i] =  tmp; 
+            }
+          }
+        }
+
+				array<String^>^ ReadStringArray()
+       {
+          int len = this->ReadArrayLen();
+          if ( len == -1)
+          {
+            return nullptr;
+          }
+          else 
+          {
+            array<String^>^ ret = gcnew array<String^>(len);
+            if (len > 0)
+            {
+              for( int i = 0; i < len; i++)
+              {
+                Object^ obj = this->ReadObject();
+                if(obj != nullptr)
+                  ret[i] = static_cast<String^>(obj);
+                else
+                  ret[i] = nullptr;
+              }
+            }
+            return ret;
+          }
+        }
+
+				uint8_t* GetCursor()
+        {
+          return m_buffer + m_cursor;
+        }
+
+        uint8_t* GetBytes(uint8_t* src, uint32_t size)
+        {
+          return NativePtr->getBufferCopyFrom(src, size);
+        }
+
+        
+        void AdvanceUMCursor()
+        {
+					NativePtr->advanceCursor(m_cursor);
+          m_cursor = 0;
+          m_bufferLength = 0;
+        }
+
+				void AdvanceCursorPdx(int offset)
+        {
+          m_cursor += offset;
+        }
+
+        void RewindCursorPdx(int rewind)
+        {
+          m_cursor = 0;
+        }
+
+        void ResetAndAdvanceCursorPdx(int offset)
+        {
+          m_cursor = offset;
+        }
+
+        void ResetPdx(int offset)
+        {
+          NativePtr->reset(offset);
+          SetBuffer();
+        }
+
+        inline array<Byte>^ ReadReverseBytesOnly(int len);
+
+        void SetBuffer()
+        {
+          m_buffer = const_cast<uint8_t*> (NativePtr->currentBufferPosition());
+          m_cursor = 0;
+          m_bufferLength = NativePtr->getBytesRemaining();   
+        }
+
+        String^ DecodeBytes(int length)
+        {
+          //array<Char>^ output = gcnew array<Char>(length);
+        
+          if(m_forStringDecode->Length < length)
+            m_forStringDecode = gcnew array<Char>(length);
+          // index input[]
+          int i = 0;
+          // index output[]
+          int j = 0;
+          while ( i < length )
+          {
+            // get next byte unsigned
+            //Byte b = m_buffer[ m_cursor++ ] & 0xff;
+            Byte b = ReadByte();
+            i++;
+            Byte k = b >> 5;
+            // classify based on the high order 3 bits
+            switch (  k )
+              {
+              default:
+                // one byte encoding
+                // 0xxxxxxx
+                // use just low order 7 bits
+                // 00000000 0xxxxxxx
+                m_forStringDecode[ j++ ] = ( Char ) ( b & 0x7f );
+                break;
+              case 6:
+                {
+                  // two byte encoding
+                  // 110yyyyy 10xxxxxx
+                  // use low order 6 bits
+                  int y = b & 0x1f;
+                  // use low order 6 bits of the next byte
+                  // It should have high order bits 10, which we don't check.
+                  int x = m_buffer[ m_cursor++ ] & 0x3f;
+                  i++;
+                  // 00000yyy yyxxxxxx
+                  m_forStringDecode[ j++ ] = ( Char ) ( y << 6 | x );
+                  break;
+                }
+              case 7:
+                {
+                  // three byte encoding
+                  // 1110zzzz 10yyyyyy 10xxxxxx
+                  //assert ( b & 0x10 )
+                    //     == 0 : "UTF8Decoder does not handle 32-bit characters";
+                  // use low order 4 bits
+                  int z = b & 0x0f;
+                  // use low order 6 bits of the next byte
+                  // It should have high order bits 10, which we don't check.
+                  int y = m_buffer[ m_cursor++ ] & 0x3f;
+                  i++;
+                  // use low order 6 bits of the next byte
+                  // It should have high order bits 10, which we don't check.
+                  int x = m_buffer[ m_cursor++ ] & 0x3f;
+                  i++;
+                  // zzzzyyyy yyxxxxxx
+                  int asint = ( z << 12 | y << 6 | x );
+                  m_forStringDecode[ j++ ] = ( Char ) asint;
+                  break;
+                }
+              }// end switch
+          }// end while
+
+          String^ str = gcnew String(m_forStringDecode, 0, j);
+          return str;
+        }
+
+        void CheckBufferSize(int size);
+       
+
+        Object^ ReadInternalGenericObject();
+
+        Object^ ReadInternalObject();
+
+        DataInput^ GetClone();
+
+        /// <summary>
+        /// Internal constructor to wrap a native object pointer
+        /// </summary>
+        /// <param name="nativeptr">The native object pointer</param>
+        inline DataInput( gemfire::DataInput* nativeptr, bool managedObject )
+          : UMWrap(nativeptr, false)
+        { 
+          m_ispdxDesrialization = false;
+          m_isRootObjectPdx = false;
+          m_cursor = 0;
+          m_isManagedObject = managedObject;
+          m_forStringDecode = gcnew array<Char>(100);
+          m_buffer = const_cast<uint8_t*>(nativeptr->currentBufferPosition());
+          if ( m_buffer != NULL) {
+            m_bufferLength = nativeptr->getBytesRemaining();     
+					}
+          else {
+            m_bufferLength = 0;
+          }
+        }
+
+        DataInput( uint8_t* buffer, int size );
+
+       /* inline DataInput( gemfire::DataInput* nativeptr )
+          : UMWrap(nativeptr, false)
+        { 
+          m_cursor = 0;
+          m_isManagedObject = false;
+          m_buffer = const_cast<uint8_t*>(nativeptr->currentBufferPosition());
+          if ( m_buffer != NULL) {
+            m_bufferLength = nativeptr->getBytesRemaining();            
+          }
+          else {
+            m_bufferLength = 0;
+          }
+        }*/
+
+        bool IsManagedObject()
+        {
+          return m_isManagedObject;
+        }
+
+        int GetPdxBytes()
+        {
+          return m_bufferLength;
+        }
+
+      private:
+
+        /// <summary>
+        /// Internal buffer managed by the class.
+        /// This is freed in the disposer/destructor.
+        /// </summary>
+        bool m_ispdxDesrialization;
+        bool m_isRootObjectPdx;
+        uint8_t* m_buffer;
+        unsigned int m_bufferLength;
+        int m_cursor;
+        bool m_isManagedObject;
+        array<Char>^ m_forStringDecode;
+      
+        void Cleanup( );
+      };
+      } // end namespace generic
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/DataOutput.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/DataOutput.cpp b/src/clicache/src/DataOutput.cpp
new file mode 100644
index 0000000..8c00200
--- /dev/null
+++ b/src/clicache/src/DataOutput.cpp
@@ -0,0 +1,870 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+//#include "gf_includes.hpp"
+#include "DataOutput.hpp"
+#include <GemfireTypeIdsImpl.hpp>
+#include <vcclr.h>
+
+#include "IGFSerializable.hpp"
+#include "CacheableObjectArray.hpp"
+#include "impl/PdxHelper.hpp"
+#include "impl/PdxWrapper.hpp"
+using namespace System;
+using namespace System::Runtime::InteropServices;
+using namespace gemfire;
+
+namespace GemStone
+{
+  namespace GemFire
+  {
+    namespace Cache
+    {
+      namespace Generic
+      {
+
+				void DataOutput::WriteByte( Byte value )
+				{
+					EnsureCapacity(1);
+					m_bytes[m_cursor++] = value;
+				}
+
+				void DataOutput::WriteSByte( SByte value )
+				{
+					EnsureCapacity(1);
+					m_bytes[m_cursor++] = value;
+				}
+
+				void DataOutput::WriteBoolean( bool value )
+				{
+					EnsureCapacity(1);
+					if (value)
+						m_bytes[m_cursor++] = 0x01;
+					else
+						m_bytes[m_cursor++] = 0x00;
+				}
+
+				void DataOutput::WriteChar( Char value )
+				{
+					EnsureCapacity(2);
+					m_bytes[m_cursor++] = (uint8_t)(value >> 8);
+					m_bytes[m_cursor++] = (uint8_t)value;
+				}
+
+				void DataOutput::WriteBytes( array<Byte>^ bytes, int32_t len )
+				{
+					if (bytes != nullptr && bytes->Length >= 0)
+					{
+						if ( len >= 0 && len <= bytes->Length )
+						{
+							WriteArrayLen(len);
+							EnsureCapacity(len);
+							for( int i = 0; i < len; i++ )
+								m_bytes[m_cursor++] = bytes[i];
+						}
+						else
+						{
+							throw gcnew IllegalArgumentException("DataOutput::WriteBytes argument len is not in byte array range." );
+						}
+					}
+					else
+					{
+						WriteByte(0xFF);
+					}
+				}
+
+				void DataOutput::WriteArrayLen( int32_t len )
+				{
+					if (len == -1) {//0xff
+						WriteByte(0xFF);
+					} else if (len <= 252) { // 252 is java's ((byte)-4 && 0xFF) or 0xfc
+						WriteByte((Byte)(len));
+					} else if (len <= 0xFFFF) {
+						WriteByte(0xFE);//0xfe
+						WriteUInt16((len));
+					} else {
+						WriteByte((0xFD));//0xfd
+						WriteUInt32(len);
+					}
+				}
+
+				void DataOutput::WriteSBytes( array<SByte>^ bytes, int32_t len )
+				{
+					if (bytes != nullptr && bytes->Length >= 0)
+					{
+						if ( len >= 0 && len <= bytes->Length )
+						{
+							WriteArrayLen(len);
+							EnsureCapacity(len);
+							for( int i = 0; i < len; i++ )
+								m_bytes[m_cursor++] = bytes[i];
+						}
+						else
+						{
+							throw gcnew IllegalArgumentException("DataOutput::WriteSBytes argument len is not in SByte array range." );
+						}
+					}
+					else
+					{
+						WriteByte(0xFF);
+					}
+				}
+
+				void DataOutput::WriteBytesOnly( array<Byte>^ bytes, uint32_t len )
+				{
+					WriteBytesOnly(bytes, len, 0);
+				}
+
+				void DataOutput::WriteBytesOnly( array<Byte>^ bytes, uint32_t len, uint32_t offset )
+				{
+					if (bytes != nullptr)
+					{
+						if ( len >= 0 && len <= ((uint32_t)bytes->Length - offset) )
+						{
+							EnsureCapacity(len);            
+							for( uint32_t i = 0; i < len; i++ )
+								m_bytes[m_cursor++] = bytes[offset + i];
+						}
+						else
+						{
+							throw gcnew IllegalArgumentException("DataOutput::WriteBytesOnly argument len is not in Byte array range." );
+						}
+					}
+				}
+
+				void DataOutput::WriteSBytesOnly( array<SByte>^ bytes, uint32_t len )
+				{
+					if (bytes != nullptr)
+					{
+						if ( len >= 0 && len <= (uint32_t)bytes->Length )
+						{
+							EnsureCapacity(len);
+							for( uint32_t i = 0; i < len; i++ )
+								m_bytes[m_cursor++] = bytes[i];
+						}
+						else
+						{
+							throw gcnew IllegalArgumentException("DataOutput::WriteSBytesOnly argument len is not in SByte array range." );
+						}
+					}
+				}
+
+				void DataOutput::WriteUInt16( uint16_t value )
+				{
+					EnsureCapacity(2);
+					m_bytes[m_cursor++] = (uint8_t)(value >> 8);
+					m_bytes[m_cursor++] = (uint8_t)value;
+				}
+
+				void DataOutput::WriteUInt32( uint32_t value )
+				{
+					EnsureCapacity(4);
+					m_bytes[m_cursor++] = (uint8_t)(value >> 24);
+					m_bytes[m_cursor++] = (uint8_t)(value >> 16);
+					m_bytes[m_cursor++] = (uint8_t)(value >> 8);
+					m_bytes[m_cursor++] = (uint8_t)value;
+				}
+
+				void DataOutput::WriteUInt64( uint64_t value )
+				{
+					EnsureCapacity(8);
+					m_bytes[m_cursor++] = (uint8_t)(value >> 56);
+					m_bytes[m_cursor++] = (uint8_t)(value >> 48);
+					m_bytes[m_cursor++] = (uint8_t)(value >> 40);
+					m_bytes[m_cursor++] = (uint8_t)(value >> 32);
+					m_bytes[m_cursor++] = (uint8_t)(value >> 24);
+					m_bytes[m_cursor++] = (uint8_t)(value >> 16);
+					m_bytes[m_cursor++] = (uint8_t)(value >> 8);
+					m_bytes[m_cursor++] = (uint8_t)value;
+				}
+
+				void DataOutput::WriteInt16( int16_t value )
+				{
+					WriteUInt16(value);
+				}
+
+				void DataOutput::WriteInt32( int32_t value )
+				{
+					WriteUInt32(value);
+				}
+
+				void DataOutput::WriteInt64( int64_t value )
+				{
+					WriteUInt64(value);
+				}
+
+				void DataOutput::WriteFloat( float value )
+				{
+					array<Byte>^ bytes = BitConverter::GetBytes(value);
+					EnsureCapacity(4);
+					for(int i = 4 - 1; i >=0 ; i--)
+						m_bytes[m_cursor++] = bytes[i];
+				}
+
+				void DataOutput::WriteDouble( double value )
+				{
+					array<Byte>^ bytes = BitConverter::GetBytes(value);
+					EnsureCapacity(8);
+					for(int i = 8 - 1; i >=0 ; i--)
+						m_bytes[m_cursor++] = bytes[i];
+				}
+
+			void DataOutput::WriteDictionary(System::Collections::IDictionary^ dict)
+      {
+        if(dict != nullptr)
+        {
+          this->WriteArrayLen(dict->Count);
+          for each( System::Collections::DictionaryEntry^ entry in dict) 
+          {
+            this->WriteObject(entry->Key);
+            this->WriteObject(entry->Value);
+          }
+        }
+        else
+        {
+          WriteByte( (int8_t) -1);
+        }
+      }
+
+      void DataOutput::WriteCollection(System::Collections::IList^ collection)
+      {
+        if(collection != nullptr)
+        {
+          this->WriteArrayLen(collection->Count);
+          for each (Object^ obj in collection) {
+            this->WriteObject(obj);
+          }
+        }
+        else
+          this->WriteByte((int8_t) -1);
+      }
+
+      void DataOutput::WriteDate(System::DateTime date)
+      {
+        if(date.Ticks != 0L)
+        {
+          CacheableDate^ cd = gcnew CacheableDate(date);
+          cd->ToData(this);
+        }
+        else
+          this->WriteInt64(-1L);
+      }
+
+      void DataOutput::WriteCharArray(array<Char>^ charArray)
+      {
+        if(charArray != nullptr)
+        {
+          this->WriteArrayLen(charArray->Length);
+          for(int i = 0; i < charArray->Length; i++) {
+            this->WriteObject(charArray[i]);
+          }
+        }
+        else
+          this->WriteByte((int8_t) -1);
+      }
+
+      void DataOutput::WriteObjectArray(List<Object^>^ objectArray)
+      {
+        if(objectArray != nullptr)
+        {
+          CacheableObjectArray^ coa = CacheableObjectArray::Create(objectArray);
+          coa->ToData(this);
+        }
+        else
+          this->WriteByte((int8_t) -1);
+      }
+
+      void DataOutput::WriteDotNetObjectArray(Object^ objectArray)
+      {
+        System::Collections::IList^ list = (System::Collections::IList^)objectArray;
+        this->WriteArrayLen(list->Count);
+        WriteByte((int8_t)gemfire::GemfireTypeIdsImpl::Class);
+        String^ pdxDomainClassname = Serializable::GetPdxTypeName(objectArray->GetType()->GetElementType()->FullName);
+        WriteByte((int8_t)gemfire::GemfireTypeIds::CacheableASCIIString);
+        WriteUTF(pdxDomainClassname);
+        for each(Object^ o in list)
+          WriteObject(o);
+      }
+
+      void DataOutput::WriteArrayOfByteArrays(array<array<Byte>^>^ byteArrays)
+      {
+        if(byteArrays != nullptr)
+        {
+          int fdLen = byteArrays->Length;
+          this->WriteArrayLen(byteArrays->Length);
+          for(int i = 0; i < fdLen; i++) {
+						this->WriteBytes(byteArrays[i]);
+          }
+        }
+        else
+          this->WriteByte((int8_t) -1);
+      }
+
+				void DataOutput::WriteUTF( String^ value )
+				{
+					if (value != nullptr) {
+						int len = getEncodedLength(value);
+	          
+						if (len > 0xffff)
+							len = 0xffff;
+
+						WriteUInt16(len);
+						EnsureCapacity(len);
+						EncodeUTF8String(value, len);
+					}
+					else {
+						WriteUInt16(0);
+					}
+				}
+
+        void DataOutput::WriteStringWithType( String^ value )
+				{
+          //value will not be null
+					int len = getEncodedLength(value);
+          						            
+          if (len > 0xffff)
+          {
+            if(len == value->Length)//huge ascii
+            {
+              WriteByte(GemfireTypeIds::CacheableASCIIStringHuge);
+              WriteASCIIHuge(value);
+            }
+            else//huge utf
+            {
+              WriteByte(GemfireTypeIds::CacheableStringHuge);
+              WriteUTFHuge(value);
+            }
+            return;
+          }
+
+		      if(len == value->Length)
+          {
+            WriteByte(GemfireTypeIds::CacheableASCIIString);//ascii string
+          }
+          else
+          {
+            WriteByte(GemfireTypeIds::CacheableString);//utf string
+          }
+          WriteUInt16(len);
+					EnsureCapacity(len);
+					EncodeUTF8String(value, len);
+					
+				}
+
+				void DataOutput::WriteASCIIHuge( String^ value )
+				{
+					if (value != nullptr) {
+						const int strLength = value->Length;
+						WriteUInt32(strLength);
+						EnsureCapacity(strLength);
+						for ( int i = 0; i < strLength; i++ ) {
+							m_bytes[m_cursor++] = (uint8_t)value[i];
+						}
+					}
+					else {
+						WriteUInt32(0);
+					}
+				}
+
+				/* Write UTF-16 */
+				void DataOutput::WriteUTFHuge( String^ value )
+				{
+					if (value != nullptr) {
+						WriteUInt32(value->Length);
+						EnsureCapacity(value->Length * 2);
+						for( int i = 0; i < value->Length; i++)
+						{
+							Char ch = value[i];
+							m_bytes[m_cursor++] = (Byte)((ch & 0xff00) >> 8);
+							m_bytes[m_cursor++] = (Byte)(ch & 0xff);
+						}
+					}
+					else {
+						WriteUInt32(0);
+					}
+				}
+
+				/*void DataOutput::WriteObject( Object^ obj )
+				{
+					 WriteObjectInternal((IGFSerializable^)obj);
+				}*/
+
+				/*void DataOutput::WriteObject( Object^ obj )
+				{
+					WriteObject( (IGFSerializable^)obj );
+				}*/
+
+				int8_t DataOutput::GetTypeId(uint32_t classId )
+				{
+						if (classId >= 0x80000000) {
+							return (int8_t)((classId - 0x80000000) % 0x20000000);
+						}
+						else if (classId <= 0x7F) {
+							return (int8_t)GemfireTypeIdsImpl::CacheableUserData;
+						}
+						else if (classId <= 0x7FFF) {
+							return (int8_t)GemfireTypeIdsImpl::CacheableUserData2;
+						}
+						else {
+							return (int8_t)GemfireTypeIdsImpl::CacheableUserData4;
+						}
+				}
+
+				int8_t DataOutput::DSFID(uint32_t classId)
+				{
+					// convention that [0x8000000, 0xa0000000) is for FixedIDDefault,
+					// [0xa000000, 0xc0000000) is for FixedIDByte,
+					// [0xc0000000, 0xe0000000) is for FixedIDShort
+					// and [0xe0000000, 0xffffffff] is for FixedIDInt
+					// Note: depends on fact that FixedIDByte is 1, FixedIDShort is 2
+					// and FixedIDInt is 3; if this changes then correct this accordingly
+					if (classId >= 0x80000000) {
+						return (int8_t)((classId - 0x80000000) / 0x20000000);
+					}
+					return 0;
+				}
+
+				void DataOutput::WriteObject(Object^ obj)
+				{
+					
+					if ( obj == nullptr ) 
+					{
+						WriteByte( (int8_t) GemfireTypeIds::NullObj );
+						return;
+					}
+          
+         if(m_ispdxSerialization && obj->GetType()->IsEnum)
+         {
+           //need to set             
+           int enumVal = Internal::PdxHelper::GetEnumValue(obj->GetType()->FullName, Enum::GetName(obj->GetType(), obj), obj->GetHashCode());
+           WriteByte(GemFireClassIds::PDX_ENUM); 
+           WriteByte(enumVal >> 24);
+           WriteArrayLen(enumVal & 0xFFFFFF); 
+           return;
+         }
+
+					//GemStone::GemFire::Cache::Generic::Log::Debug("DataOutput::WriteObject " + obj);
+
+					Byte typeId = GemStone::GemFire::Cache::Generic::Serializable::GetManagedTypeMappingGeneric(obj->GetType());
+
+					switch(typeId)
+					{
+					case gemfire::GemfireTypeIds::CacheableByte:
+						{
+							WriteByte(typeId);
+							WriteSByte((SByte)obj);
+							return;
+						}
+					case gemfire::GemfireTypeIds::CacheableBoolean:
+						{
+							WriteByte(typeId);
+							WriteBoolean((bool)obj);
+							return;
+						}
+					case gemfire::GemfireTypeIds::CacheableWideChar:
+						{
+							WriteByte(typeId);
+							WriteObject((Char)obj);
+							return;
+						}
+					case gemfire::GemfireTypeIds::CacheableDouble:
+						{
+							WriteByte(typeId);
+							WriteDouble((Double)obj);
+							return;
+						}
+					case gemfire::GemfireTypeIds::CacheableASCIIString:
+						{
+							//CacheableString^ cStr = CacheableString::Create((String^)obj);
+							////  TODO: igfser mapping between generic and non generic
+							//WriteObjectInternal(cStr);
+              WriteStringWithType((String^)obj);
+							return;
+						}
+					case gemfire::GemfireTypeIds::CacheableFloat:
+						{
+							WriteByte(typeId);
+							WriteFloat((float)obj);
+							return;
+						}
+					case gemfire::GemfireTypeIds::CacheableInt16:
+						{
+							WriteByte(typeId);
+							WriteInt16((Int16)obj);
+							return;
+						}
+					case gemfire::GemfireTypeIds::CacheableInt32:
+						{
+							WriteByte(typeId);
+							WriteInt32((Int32)obj);
+							return;
+						}
+					case gemfire::GemfireTypeIds::CacheableInt64:
+						{
+							WriteByte(typeId);
+							WriteInt64((Int64)obj);
+							return;
+						}
+					case gemfire::GemfireTypeIds::CacheableDate:
+						{
+							//CacheableDate^ cd = gcnew CacheableDate((DateTime)obj);
+							//  TODO: igfser mapping between generic and non generic
+							//WriteObjectInternal(cd);
+							WriteByte(typeId);
+							WriteDate((DateTime)obj);
+							return;
+						}
+					case gemfire::GemfireTypeIds::CacheableBytes:
+						{
+							WriteByte(typeId);
+							WriteBytes((array<Byte>^)obj);
+							return;
+						}
+					case gemfire::GemfireTypeIds::CacheableDoubleArray:
+						{
+							WriteByte(typeId);
+							WriteObject((array<Double>^)obj);
+							return;
+						}
+					case gemfire::GemfireTypeIds::CacheableFloatArray:
+					{
+							WriteByte(typeId);
+							WriteObject((array<float>^)obj);
+							return;
+						}
+					case gemfire::GemfireTypeIds::CacheableInt16Array:
+					{
+							WriteByte(typeId);
+							WriteObject((array<Int16>^)obj);
+							return;
+					}
+					case gemfire::GemfireTypeIds::CacheableInt32Array:
+					{
+							WriteByte(typeId);
+							WriteObject((array<Int32>^)obj);
+							return;
+					}
+					case gemfire::GemfireTypeIds::CacheableInt64Array:
+					{
+							WriteByte(typeId);
+							WriteObject((array<Int64>^)obj);
+							return;
+					}
+					case gemfire::GemfireTypeIds::BooleanArray:
+					{
+							WriteByte(typeId);
+							WriteObject((array<bool>^)obj);
+							return;
+					}
+					case gemfire::GemfireTypeIds::CharArray:
+					{
+							WriteByte(typeId);
+							WriteObject((array<char>^)obj);
+							return;
+					}
+					case gemfire::GemfireTypeIds::CacheableStringArray:
+					{
+							WriteByte(typeId);
+							WriteObject((array<String^>^)obj);
+							return;
+					}
+					case gemfire::GemfireTypeIds::CacheableHashTable:
+					case gemfire::GemfireTypeIds::CacheableHashMap:
+					case gemfire::GemfireTypeIds::CacheableIdentityHashMap:
+					{
+							WriteByte(typeId);
+							WriteDictionary((System::Collections::IDictionary^)obj);
+							return;
+					}
+					case gemfire::GemfireTypeIds::CacheableVector:
+					{
+						//CacheableVector^ cv = gcnew CacheableVector((System::Collections::IList^)obj);
+						////  TODO: igfser mapping between generic and non generic
+						//WriteObjectInternal(cv);
+            WriteByte(gemfire::GemfireTypeIds::CacheableVector);
+            WriteList((System::Collections::IList^)obj);
+						return;
+					}
+          case gemfire::GemfireTypeIds::CacheableLinkedList:
+					{
+						//CacheableArrayList^ cal = gcnew CacheableArrayList((System::Collections::IList^)obj);
+						////  TODO: igfser mapping between generic and non generic
+						//WriteObjectInternal(cal);
+            WriteByte(gemfire::GemfireTypeIds::CacheableLinkedList);
+            System::Collections::ICollection^ linkedList = (System::Collections::ICollection^)obj;
+            this->WriteArrayLen(linkedList->Count);
+            for each (Object^ o in linkedList) 
+						  this->WriteObject(o);
+						return;
+					}
+          case gemfire::GemfireTypeIds::CacheableArrayList:
+					{
+						//CacheableArrayList^ cal = gcnew CacheableArrayList((System::Collections::IList^)obj);
+						////  TODO: igfser mapping between generic and non generic
+						//WriteObjectInternal(cal);
+            WriteByte(gemfire::GemfireTypeIds::CacheableArrayList);
+            WriteList((System::Collections::IList^)obj);
+						return;
+					}
+					case gemfire::GemfireTypeIds::CacheableStack:
+					{
+						CacheableStack^ cs = gcnew CacheableStack((System::Collections::ICollection^)obj);
+						//  TODO: igfser mapping between generic and non generic
+						WriteObjectInternal(cs);
+						return;
+					}
+					default:
+						{
+							IPdxSerializable^ pdxObj = dynamic_cast<IPdxSerializable^>(obj);
+							if(pdxObj !=  nullptr)
+							{
+								WriteByte(GemFireClassIds::PDX);
+								Internal::PdxHelper::SerializePdx(this, pdxObj);
+								return;
+							}
+							else
+							{
+                //pdx serialization and is array of object
+                if(m_ispdxSerialization && obj->GetType()->IsArray)
+                {
+                  WriteByte(gemfire::GemfireTypeIds::CacheableObjectArray);
+                  WriteDotNetObjectArray(obj);
+                  return;
+                }
+
+								IGFSerializable^ ct = dynamic_cast<IGFSerializable^>(obj);
+								if(ct != nullptr) {
+									WriteObjectInternal(ct);
+									return ;
+								}
+
+                if(Serializable::IsObjectAndPdxSerializerRegistered(nullptr))
+                {
+                  pdxObj = gcnew PdxWrapper(obj);
+                  WriteByte(GemFireClassIds::PDX);
+								  Internal::PdxHelper::SerializePdx(this, pdxObj);
+								  return;
+                }
+							}
+						
+              throw gcnew System::Exception("DataOutput not found appropriate type to write it for object: " + obj->GetType());
+						}
+					}
+				}
+
+				void DataOutput::WriteStringArray(array<String^>^ strArray)
+				{
+					if(strArray != nullptr)
+					{
+						this->WriteArrayLen(strArray->Length);
+						for(int i = 0; i < strArray->Length; i++)
+						{
+						 // this->WriteUTF(strArray[i]);
+							WriteObject(strArray[i]);
+						}
+					}
+					else
+						WriteByte(-1);
+				}
+
+				void DataOutput::WriteObjectInternal( IGFSerializable^ obj )
+				{
+					//CacheableKey^ key = gcnew CacheableKey();
+					if ( obj == nullptr ) {
+						WriteByte( (int8_t) GemfireTypeIds::NullObj );
+					} else {
+						int8_t typeId = DataOutput::GetTypeId( obj->ClassId);
+						switch (DataOutput::DSFID(obj->ClassId)) {
+							case GemfireTypeIdsImpl::FixedIDByte:
+								WriteByte((int8_t)GemfireTypeIdsImpl::FixedIDByte);
+								WriteByte( typeId ); // write the type ID.
+								break;
+							case GemfireTypeIdsImpl::FixedIDShort:
+								WriteByte((int8_t)GemfireTypeIdsImpl::FixedIDShort);
+								WriteInt16( (int16_t)typeId ); // write the type ID.
+								break;
+							case GemfireTypeIdsImpl::FixedIDInt:
+								WriteByte((int8_t)GemfireTypeIdsImpl::FixedIDInt);
+								WriteInt32( (int32_t)typeId ); // write the type ID.
+								break;
+							default:
+								WriteByte( typeId ); // write the type ID.
+								break;
+						}
+	          
+						if ( (int32_t)typeId == GemfireTypeIdsImpl::CacheableUserData ) {
+							WriteByte( (int8_t) obj->ClassId );
+						} else if ( (int32_t)typeId == GemfireTypeIdsImpl::CacheableUserData2 ) {
+							WriteInt16( (int16_t) obj->ClassId );
+						} else if ( (int32_t)typeId == GemfireTypeIdsImpl::CacheableUserData4 ) {
+							WriteInt32( (int32_t) obj->ClassId );
+						}
+						obj->ToData( this ); // let the obj serialize itself.
+					}
+				}
+
+				void DataOutput::AdvanceCursor( uint32_t offset )
+				{
+          EnsureCapacity(offset);
+					m_cursor += offset;
+				}
+
+				void DataOutput::RewindCursor( uint32_t offset )
+				{
+					//first set native one
+					WriteBytesToUMDataOutput();
+					NativePtr->rewindCursor(offset);
+					SetBuffer();
+				}
+
+				array<Byte>^ DataOutput::GetBuffer( )
+				{
+					WriteBytesToUMDataOutput();
+					SetBuffer();
+	        
+					int buffLen = NativePtr->getBufferLength();
+					array<Byte>^ buffer = gcnew array<Byte>( buffLen );
+
+					if ( buffLen > 0 ) {
+						pin_ptr<Byte> pin_buffer = &buffer[ 0 ];
+						memcpy( (void*)pin_buffer, NativePtr->getBuffer( ), buffLen );
+					}
+					return buffer;
+				}
+
+				uint32_t DataOutput::BufferLength::get( )
+				{
+					//first set native one
+					WriteBytesToUMDataOutput();
+					SetBuffer();
+
+					return NativePtr->getBufferLength();
+				}
+
+				void DataOutput::Reset( )
+				{
+					WriteBytesToUMDataOutput();
+					NativePtr->reset();
+					SetBuffer();
+				}
+							
+				void DataOutput::WriteString(String^ value)
+				{
+					if(value == nullptr)
+					{
+						this->WriteByte(GemfireTypeIds::CacheableNullString);
+					}
+					else
+					{
+            WriteObject(value);
+						/*CacheableString^ cs = gcnew CacheableString(value);
+
+						this->WriteByte( (Byte)(cs->ClassId - 0x80000000));
+						cs->ToData(this);*/
+					}
+				}
+
+				 void DataOutput::WriteBytesToUMDataOutput()
+        {
+					NativePtr->advanceCursor(m_cursor);
+          m_cursor = 0;
+          m_remainingBufferLength = 0;
+          m_bytes = nullptr;
+        }
+
+        void DataOutput::WriteObject(bool% obj)
+        {
+          WriteBoolean(obj);
+        }
+
+        void DataOutput::WriteObject(Byte% obj)
+        {
+          WriteByte(obj);
+        }
+
+        void DataOutput::WriteObject(Char% obj)
+        {
+          unsigned short us = (unsigned short)obj;
+		  EnsureCapacity(2);
+          m_bytes[m_cursor++] = us >> 8;
+          m_bytes[m_cursor++] = (Byte)us; 
+        }
+
+        void DataOutput::WriteObject(Double% obj)
+        {
+          WriteDouble(obj);
+        }
+
+        void DataOutput::WriteObject(Single% obj)
+        {
+          WriteFloat(obj);
+        }
+
+        void DataOutput::WriteObject(int16_t% obj)
+        {
+          WriteInt16(obj);
+        }
+
+        void DataOutput::WriteObject(int32_t% obj)
+        {
+          WriteInt32(obj);
+        }
+
+        void DataOutput::WriteObject(int64_t% obj)
+        {
+          WriteInt64(obj);
+        }
+
+				void DataOutput::WriteObject(UInt16% obj)
+        {
+          WriteUInt16(obj);
+        }
+
+        void DataOutput::WriteObject(UInt32% obj)
+        {
+          WriteUInt32(obj);
+        }
+
+        void DataOutput::WriteObject(UInt64% obj)
+        {
+          WriteUInt64(obj);
+        }
+
+				void DataOutput::WriteBooleanArray(array<bool>^ boolArray)
+				{
+					WriteObject<bool>(boolArray);
+				}
+
+				void DataOutput::WriteShortArray(array<Int16>^ shortArray)
+				{
+					WriteObject<Int16>(shortArray);
+				}
+
+				void DataOutput::WriteIntArray(array<Int32>^ intArray)
+				{
+					WriteObject<Int32>(intArray);
+				}
+
+				void DataOutput::WriteLongArray(array<Int64>^ longArray)
+				{
+					WriteObject<Int64>(longArray);
+				}
+
+			  void DataOutput::WriteFloatArray(array<float>^ floatArray)
+				{
+					WriteObject<float>(floatArray);
+				}
+
+				void DataOutput::WriteDoubleArray(array<double>^ doubleArray)
+				{
+					WriteObject<double>(doubleArray);
+				}
+      } // end namespace generic
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/DataOutput.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/DataOutput.hpp b/src/clicache/src/DataOutput.hpp
new file mode 100644
index 0000000..c3ef94c
--- /dev/null
+++ b/src/clicache/src/DataOutput.hpp
@@ -0,0 +1,600 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+#pragma once
+
+#include "gf_defs.hpp"
+#include <gfcpp/DataOutput.hpp>
+//#include "impl/NativeWrapper.hpp"
+#include "Log.hpp"
+#include "ExceptionTypes.hpp"
+#include "Serializable.hpp"
+
+#include "CacheableString.hpp"
+#include "CacheableDate.hpp"
+#include "CacheableVector.hpp"
+#include "CacheableArrayList.hpp"
+#include "CacheableStack.hpp"
+
+using namespace System;
+using namespace System::Runtime::CompilerServices;
+
+namespace GemStone
+{
+  namespace GemFire
+  {
+    namespace Cache
+    {
+      namespace Generic
+      {
+
+      interface class IGFSerializable;
+
+      /// <summary>
+      /// Provides operations for writing primitive data values, and
+      /// user-defined objects implementing IGFSerializable, to a byte stream.
+      /// This class is intentionally not thread safe.
+      /// </summary>
+      public ref class DataOutput sealed
+				: public Generic::Internal::UMWrap<gemfire::DataOutput>
+      {
+      private:
+        int32_t m_cursor;
+        bool m_isManagedObject;
+        uint8_t * m_bytes;
+        int32_t m_remainingBufferLength;
+        bool m_ispdxSerialization;
+      public:
+
+        /// <summary>
+        /// Default constructor.
+        /// </summary>
+        inline DataOutput( )
+          : UMWrap( new gemfire::DataOutput( ), true )
+        { 
+          m_isManagedObject = true;
+          m_cursor = 0;
+          m_bytes = const_cast<uint8_t *>(NativePtr->getCursor());
+          m_remainingBufferLength = (int32_t)NativePtr->getRemainingBufferLength();
+          m_ispdxSerialization = false;
+        }
+
+        /// <summary>
+        /// Write length of the array to the <c>DataOutput</c>.
+        /// </summary>
+        /// <param name="len">Array len to write.</param>
+        void WriteArrayLen( int32_t len );
+        
+        /// <summary>
+        /// Write a signed byte to the <c>DataOutput</c>.
+        /// </summary>
+        /// <param name="value">The signed byte to write.</param>
+        void WriteSByte( SByte value );
+
+        /// <summary>
+        /// Write a boolean value to the <c>DataOutput</c>.
+        /// </summary>
+        /// <param name="value">The boolean value to write.</param>
+        void WriteBoolean( bool value );
+
+				/// <summary>
+        /// Write a char value to the <c>DataOutput</c>.
+        /// </summary>
+        /// <param name="value">The char value to write.</param>
+        void WriteChar( Char value );
+
+        /// <summary>
+        /// Write a given length of bytes to the <c>DataOutput</c>.
+        /// </summary>
+        /// <param name="bytes">The array of bytes to write.</param>
+        /// <param name="len">
+        /// The number of bytes from the start of array to write.
+        /// </param>
+        void WriteBytes( array<Byte>^ bytes, int32_t len );
+
+        /// <summary>
+        /// Write an array of bytes to the <c>DataOutput</c>.
+        /// </summary>
+        /// <param name="bytes">The array of bytes to write.</param>
+        inline void WriteBytes( array<Byte>^ bytes )
+        {
+          WriteBytes( bytes, ( bytes == nullptr ? -1 : bytes->Length ) );
+        }
+
+        /// <summary>
+        /// Write a given length of signed bytes to the <c>DataOutput</c>.
+        /// </summary>
+        /// <param name="bytes">The array of signed bytes to write.</param>
+        /// <param name="len">
+        /// The number of bytes from the start of array to write.
+        /// </param>
+        void WriteSBytes( array<SByte>^ bytes, int32_t len );
+
+        /// <summary>
+        /// Write an array of signed bytes to the <c>DataOutput</c>.
+        /// </summary>
+        /// <param name="bytes">The array of signed bytes to write.</param>
+        inline void WriteSBytes( array<SByte>^ bytes )
+        {
+          WriteSBytes( bytes, ( bytes == nullptr ? -1 : bytes->Length )  );
+        }
+
+        /// <summary>
+        /// Write a given length of bytes without its length to the
+        /// <c>DataOutput</c>.
+        /// </summary>
+        /// <param name="bytes">The array of bytes to write.</param>
+        /// <param name="len">
+        /// The number of bytes from the start of array to write.
+        /// </param>
+        void WriteBytesOnly( array<Byte>^ bytes, uint32_t len );
+
+        void WriteBytesOnly( array<Byte>^ bytes, uint32_t len, uint32_t offset );
+
+        /// <summary>
+        /// Write an array of bytes without its length to the
+        /// <c>DataOutput</c>.
+        /// </summary>
+        /// <param name="bytes">The array of bytes to write.</param>
+        inline void WriteBytesOnly( array<Byte>^ bytes )
+        {
+          WriteBytesOnly( bytes, ( bytes == nullptr ? 0 : bytes->Length )  );
+        }
+
+        /// <summary>
+        /// Write a given length of signed bytes without its length
+        /// to the <c>DataOutput</c>.
+        /// </summary>
+        /// <param name="bytes">The array of signed bytes to write.</param>
+        /// <param name="len">
+        /// The number of bytes from the start of array to write.
+        /// </param>
+        void WriteSBytesOnly( array<SByte>^ bytes, uint32_t len );
+
+        /// <summary>
+        /// Write an array of signed bytes without its length
+        /// to the <c>DataOutput</c>.
+        /// </summary>
+        /// <param name="bytes">The array of signed bytes to write.</param>
+        inline void WriteSBytesOnly( array<SByte>^ bytes )
+        {
+          WriteSBytesOnly( bytes, ( bytes == nullptr ? 0 : bytes->Length )  );
+        }        
+
+        /// <summary>
+        /// Write a 16-bit integer to the <c>DataOutput</c>.
+        /// </summary>
+        /// <param name="value">The 16-bit integer to write.</param>
+        void WriteInt16( int16_t value );
+
+        /// <summary>
+        /// Write a 32-bit integer to the <c>DataOutput</c>.
+        /// </summary>
+        /// <param name="value">The 32-bit integer to write.</param>
+        void WriteInt32( int32_t value );
+
+        /// <summary>
+        /// Write a 64-bit integer to the <c>DataOutput</c>.
+        /// </summary>
+        /// <param name="value">The 64-bit integer to write.</param>
+        void WriteInt64( int64_t value );
+
+        /// <summary>
+        /// Write a float to the DataOutput.
+        /// </summary>
+        /// <param name="value">The float value to write.</param>
+        void WriteFloat( float value );
+
+        /// <summary>
+        /// Write a double precision real number to the <c>DataOutput</c>.
+        /// </summary>
+        /// <param name="value">
+        /// The double precision real number to write.
+        /// </param>
+        void WriteDouble( double value );
+
+        /// <summary>
+        /// Write a string using java-modified UTF-8 encoding to
+        /// <c>DataOutput</c>.
+        /// The maximum length supported is 2^16-1 beyond which the string
+        /// shall be truncated.
+        /// </summary>
+        /// <param name="value">The UTF encoded string to write.</param>
+        void WriteUTF( String^ value );
+
+        /// <summary>
+        /// Write a string using java-modified UTF-8 encoding to
+        /// <c>DataOutput</c>.
+        /// Length should be more than 2^16 -1. 
+        /// </summary>
+        /// <param name="value">The UTF encoded string to write.</param>
+        void WriteUTFHuge( String^ value );
+
+        /// <summary>
+        /// Write a string(only ASCII char) to
+        /// <c>DataOutput</c>.
+        /// Length should be more than 2^16 -1.
+        /// </summary>
+        /// <param name="value">The UTF encoded string to write.</param>
+        void WriteASCIIHuge( String^ value );
+
+        /// <summary>
+        /// Write an <c>IGFSerializable</c> object to the <c>DataOutput</c>.
+        /// </summary>
+        /// <param name="obj">The object to write.</param>
+       // void WriteObject( IGFSerializable^ obj );
+
+        /// <summary>
+        /// Write a <c>Serializable</c> object to the <c>DataOutput</c>.
+        /// This is provided to conveniently pass primitive types (like string)
+        /// that shall be implicitly converted to corresponding
+        /// <c>IGFSerializable</c> wrapper types.
+        /// </summary>
+        /// <param name="obj">The object to write.</param>
+        void WriteObject( Object^ obj );
+
+        /// <summary>
+        /// Advance the buffer cursor by the given offset.
+        /// </summary>
+        /// <param name="offset">
+        /// The offset by which to advance the cursor.
+        /// </param>
+        void AdvanceCursor( uint32_t offset );
+
+        /// <summary>
+        /// Rewind the buffer cursor by the given offset.
+        /// </summary>
+        /// <param name="offset">
+        /// The offset by which to rewind the cursor.
+        /// </param>
+        void RewindCursor( uint32_t offset );
+
+        /// <summary>
+        /// Get a copy of the current buffer.
+        /// </summary>
+        array<Byte>^ GetBuffer( );
+
+        /// <summary>
+        /// Get the length of current data in the buffer.
+        /// </summary>
+        property uint32_t BufferLength
+        {
+          uint32_t get( );
+        }
+
+        /// <summary>
+        /// Reset the cursor to the start of the buffer.
+        /// </summary>
+        void Reset( );
+
+        /// <summary>
+        /// Get the underlying native unmanaged pointer.
+        /// </summary>
+        property IntPtr NativeIntPtr
+        {
+          inline IntPtr get()
+          {
+            return IntPtr(_NativePtr);
+          }
+        }
+       
+        /// <summary>
+        /// Write a Dictionary to the DataOutput.
+        /// </summary>
+        /// <param name="value">The object which implements IDictionary to write.</param>
+ 			  void WriteDictionary(System::Collections::IDictionary^ value);              
+
+        /// <summary>
+        /// Write a date to the DataOutput.
+        /// </summary>
+        /// <param name="value">The date value to write.</param>
+        void WriteDate(System::DateTime value);
+
+        /// <summary>
+        /// Write a collection to the DataOutput.
+        /// </summary>
+        /// <param name="value">The object which implements IList to write.</param>
+        void WriteCollection(System::Collections::IList^ value);
+        
+        /// <summary>
+        /// Write a char array to the DataOutput.
+        /// </summary>
+        /// <param name="value">The char array to write.</param>
+        void WriteCharArray(array<Char>^ value);
+
+        /// <summary>
+        /// Write a bool array to the DataOutput.
+        /// </summary>
+        /// <param name="value">The bool array to write.</param>
+				void WriteBooleanArray(array<bool>^ value);
+
+        /// <summary>
+        /// Write a short array to the DataOutput.
+        /// </summary>
+        /// <param name="value">The short array to write.</param>
+				void WriteShortArray(array<Int16>^ value);
+
+        /// <summary>
+        /// Write a int array to the DataOutput.
+        /// </summary>
+        /// <param name="value">The int array to write.</param>
+				void WriteIntArray(array<Int32>^ value);
+
+        /// <summary>
+        /// Write a long array to the DataOutput.
+        /// </summary>
+        /// <param name="value">The long array to write.</param>
+				void WriteLongArray(array<Int64>^ value);
+
+        /// <summary>
+        /// Write a float array to the DataOutput.
+        /// </summary>
+        /// <param name="value">The float array to write.</param>
+				void WriteFloatArray(array<float>^ value);
+
+        /// <summary>
+        /// Write a double array to the DataOutput.
+        /// </summary>
+        /// <param name="value">The double array to write.</param>
+				void WriteDoubleArray(array<double>^ value);
+
+        /// <summary>
+        /// Write a object array to the DataOutput.
+        /// </summary>
+        /// <param name="value">The object array to write.</param>
+        void WriteObjectArray(List<Object^>^ value);
+
+        /// <summary>
+        /// Write a array of sign byte array to the DataOutput.
+        /// </summary>
+        /// <param name="value">The array of sign byte array to write.</param>
+        void WriteArrayOfByteArrays(array<array<Byte>^>^ value);
+               
+      internal:
+
+        void WriteDotNetObjectArray(Object^ objectArray);
+
+        /// <summary>
+        /// Write a byte to the <c>DataOutput</c>.
+        /// </summary>
+        /// <param name="value">The byte to write.</param>
+        void WriteByte( Byte value );
+
+        /// <summary>
+        /// Write an unsigned short integer (int16_t) to the <c>DataOutput</c>.
+        /// </summary>
+        /// <param name="value">The unsigned 16-bit integer to write.</param>
+        void WriteUInt16( uint16_t value );
+
+        /// <summary>
+        /// Write an unsigned 32-bit integer to the <c>DataOutput</c>.
+        /// </summary>
+        /// <param name="value">The unsigned 32-bit integer to write.</param>
+        void WriteUInt32( uint32_t value );
+
+        /// <summary>
+        /// Write an unsigned 64-bit integer to the <c>DataOutput</c>.
+        /// </summary>
+        /// <param name="value">The unsigned 64-bit integer to write.</param>
+        void WriteUInt64( uint64_t value );
+
+
+			  int32_t GetBufferLengthPdx()
+        {
+          return (int32_t)NativePtr->getBufferLength();
+        }
+
+        void WriteString(String^ value);
+
+        int32_t GetCursorPdx()
+        {
+          return m_cursor;
+        }
+
+        const char * GetPoolName()
+        {
+          return _NativePtr->getPoolName();
+        }
+
+        void WriteStringArray(array<String^>^ strArray);
+
+        void EncodeUTF8String( String^ input, int encLength )
+        {
+          const int strLength = input->Length;
+          const int end = m_cursor + encLength;
+          for ( int i = 0; i < strLength && m_cursor < end; i++ )
+          {
+            unsigned short c = (unsigned short)input[i];
+
+            if( c == 0 )
+            {
+                m_bytes[m_cursor++] = 0xc0;
+                m_bytes[m_cursor++] = 0x80;
+            }
+            else if ( c < 0x80 )//ASCII character
+            {
+              // 7-bits done in one byte.
+              m_bytes[m_cursor++] = (uint8_t)c;
+            }
+            else if ( c < 0x800 )
+            {
+              // 8-11 bits done in 2 bytes
+              m_bytes[m_cursor++] = ( 0xC0 | c >> 6 );
+              m_bytes[m_cursor++] = ( 0x80 | c & 0x3F );
+            }
+            else 
+            {
+              // 12-16 bits done in 3 bytes
+              m_bytes[m_cursor++] = ( 0xE0 | c >> 12 );
+              m_bytes[m_cursor++] = ( 0x80 | c >> 6 & 0x3F );
+              m_bytes[m_cursor++] = ( 0x80 | c & 0x3F );
+            }            
+          }
+
+		  // TODO ASSERT end = m_cursor
+        }
+       
+        static int getEncodedLength(String^ input)
+        {
+          int count = 0;
+          for ( int i = 0; i < input->Length; i++ )
+          {
+            unsigned short c = (unsigned short)input[i];
+
+            if( c == 0)
+            {
+              count += 2;
+            }
+            else if ( c < 0x80 )//ASCII character
+            {
+              count++;
+            }
+            else if ( c < 0x800 )
+            {
+              count += 2;
+            }
+            else
+            {
+               count += 3;
+            }
+          }// end for
+
+          return count;
+        }
+
+        void setPdxSerialization(bool val)
+        {
+          m_ispdxSerialization = val;
+        }
+
+        void WriteStringWithType( String^ value );
+
+        static int8_t GetTypeId(uint32_t classId );
+        
+        static int8_t DSFID(uint32_t classId);        
+  
+        void WriteObjectInternal( IGFSerializable^ obj );     
+
+        void WriteBytesToUMDataOutput();
+        
+        void WriteObject(bool% obj);        
+
+        void WriteObject(Byte% obj);        
+
+        void WriteObject(Char% obj);        
+
+        void WriteObject(Double% obj);
+        
+        void WriteObject(Single% obj);
+        
+        void WriteObject(int16_t% obj);
+        
+        void WriteObject(int32_t% obj);
+        
+        void WriteObject(int64_t% obj);
+        
+				void WriteObject(UInt16% obj);
+        
+        void WriteObject(UInt32% obj);       
+
+        void WriteObject(UInt64% obj);
+        
+       // void WriteObject(array<UInt16>^ objArray);
+        //void WriteObject(array<UInt32>^ objArray);
+        //void WriteObject(array<UInt64>^ objArray);
+
+        
+        template <typename mType>
+        void WriteObject(array<mType>^ %objArray)
+        {
+          if(objArray != nullptr) {
+            int arrayLen = objArray->Length;
+            WriteArrayLen(arrayLen);
+            if(arrayLen > 0) {
+              int i = 0;
+              for( i = 0; i < arrayLen; i++ ){
+                WriteObject(objArray[i]);
+              }
+            }
+          }
+          else {
+            WriteByte(0xff);
+          }
+        }
+
+        bool IsManagedObject()
+        {
+          //TODO::
+          return m_isManagedObject;
+        }
+
+        void SetBuffer()
+        {
+          m_cursor = 0;
+          m_bytes = const_cast<uint8_t *>(NativePtr->getCursor());
+          m_remainingBufferLength = (int32_t)NativePtr->getRemainingBufferLength();
+        }
+
+				uint8_t* GetStartBufferPosition()
+        {
+          return const_cast<uint8_t *>( NativePtr->getBuffer());;
+        }
+
+        inline void EnsureCapacity( int32_t size )
+        {
+          int32_t bytesLeft = m_remainingBufferLength - m_cursor;
+          if ( bytesLeft < size ) {
+            try
+            {
+              NativePtr->ensureCapacity(m_cursor + size);
+              m_bytes = const_cast<uint8_t *>( NativePtr->getCursor());
+              m_remainingBufferLength = (int32_t)NativePtr->getRemainingBufferLength();
+            }
+            catch(gemfire::OutOfMemoryException ex )
+            {
+              throw gcnew OutOfMemoryException(ex);
+            }            
+          }
+        }
+
+        //it expects list is not null
+        inline void WriteList(System::Collections::IList^ list)
+        {
+          this->WriteArrayLen(list->Count);
+          for each (Object^ obj in list) 
+						this->WriteObject(obj);
+        }
+
+        uint8_t* GetBytes(uint8_t* src, uint32_t size)
+        {
+          return NativePtr->getBufferCopyFrom(src, size);
+        }
+ 
+        int32_t GetRemainingBufferLength()
+        {
+          return (int32_t) NativePtr->getRemainingBufferLength();
+        }
+
+        /// <summary>
+        /// Internal constructor to wrap a native object pointer
+        /// </summary>
+        /// <param name="nativeptr">The native object pointer</param>
+        inline DataOutput( gemfire::DataOutput* nativeptr, bool managedObject )
+          : UMWrap( nativeptr, false )
+        {
+          m_isManagedObject = managedObject;
+          m_cursor = 0;
+          m_bytes = const_cast<uint8_t *>(nativeptr->getCursor());
+          m_remainingBufferLength = (int32_t)nativeptr->getRemainingBufferLength();
+          m_ispdxSerialization = false;
+        }
+      };
+      } // end namespace generic
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/DiskPolicyType.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/DiskPolicyType.hpp b/src/clicache/src/DiskPolicyType.hpp
new file mode 100644
index 0000000..5484b6d
--- /dev/null
+++ b/src/clicache/src/DiskPolicyType.hpp
@@ -0,0 +1,78 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+#pragma once
+
+
+
+#include "gf_defs.hpp"
+#include <gfcpp/DiskPolicyType.hpp>
+
+
+using namespace System;
+
+namespace GemStone
+{
+  namespace GemFire
+  {
+    namespace Cache { namespace Generic
+    {
+
+      /// <summary>
+      /// Enumerated type for disk policy.
+      /// Contains values for setting the disk policy type.
+      /// </summary>
+      public enum class DiskPolicyType
+      {
+        /// <summary>No policy.</summary>
+        None = 0,
+
+        /// <summary>Overflow to disk.</summary>
+        Overflows
+      };
+
+
+      /// <summary>
+      /// Static class containing convenience methods for <c>DiskPolicyType</c>.
+      /// </summary>
+      /// <seealso cref="RegionAttributes.DiskPolicy" />
+      /// <seealso cref="AttributesFactory.SetDiskPolicy" />
+      public ref class DiskPolicy STATICCLASS
+      {
+      public:
+
+        /// <summary>
+        /// True if the current policy is <c>Overflows</c>.
+        /// </summary>
+        inline static bool IsOverflow( DiskPolicyType type )
+        {
+          return (type == DiskPolicyType::Overflows);
+        }
+
+        /// <summary>
+        /// True if the current policy is <c>None</c>.
+        /// </summary>
+        inline static bool IsNone( DiskPolicyType type )
+        {
+          return (type == DiskPolicyType::None);
+        }
+
+        ///// <summary>
+        ///// True if the current policy is <c>Persist</c>.
+        ///// </summary> -- Persist is NOT YET IMPLEMENTED IN C++
+        //inline static bool IsPersist( DiskPolicyType type )
+        //{
+        //  return (type == DiskPolicyType::Persist);
+        //}
+      };
+
+    }
+  }
+}
+ } //namespace 
+


Mime
View raw message