You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by ve...@apache.org on 2012/08/02 15:20:51 UTC

svn commit: r1368460 [1/3] - in /incubator/etch/trunk/binding-cpp/runtime: include/common/ include/serialization/ src/main/ src/main/common/ src/main/serialization/ src/test/ src/test/common/ src/test/serialization/

Author: veithm
Date: Thu Aug  2 13:20:50 2012
New Revision: 1368460

URL: http://svn.apache.org/viewvc?rev=1368460&view=rev
Log:
ETCH-181 EtchBinaryTaggedData Implementation

BinaryTaggedData Implementation and Tests
EtchNoneValidator Implementation

Change-Id: I553f6d6705ebd1491fbc4b4b83cb12358337eb42

Added:
    incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchBinaryTaggedData.h
    incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchBinaryTaggedDataInput.h
    incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchBinaryTaggedDataOutput.h
    incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchTaggedData.h
    incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchValidatorNone.h
    incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchNativeArray.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchBinaryTaggedData.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchBinaryTaggedDataInput.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchBinaryTaggedDataOutput.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchTaggedData.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchValidatorNone.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/test/common/EtchObjectTest.cpp
      - copied, changed from r1345149, incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchValueFactory.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchBinaryTaggedDataInputOutputTest.cpp
Modified:
    incubator/etch/trunk/binding-cpp/runtime/include/common/EtchArrayValue.h
    incubator/etch/trunk/binding-cpp/runtime/include/common/EtchError.h
    incubator/etch/trunk/binding-cpp/runtime/include/common/EtchNativeArray.h
    incubator/etch/trunk/binding-cpp/runtime/include/common/EtchObjectType.h
    incubator/etch/trunk/binding-cpp/runtime/include/common/EtchString.h
    incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchTaggedDataInput.h
    incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchValueFactory.h
    incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt
    incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchArrayValue.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchObjectType.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchString.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchValidatorStructValue.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchValueFactory.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/test/CMakeLists.txt
    incubator/etch/trunk/binding-cpp/runtime/src/test/common/EtchArrayValueTest.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/test/common/EtchNativeArrayTest.cpp

Modified: incubator/etch/trunk/binding-cpp/runtime/include/common/EtchArrayValue.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/common/EtchArrayValue.h?rev=1368460&r1=1368459&r2=1368460&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/common/EtchArrayValue.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/common/EtchArrayValue.h Thu Aug  2 13:20:50 2012
@@ -51,7 +51,7 @@ public:
    * @param typeCode
    *
    */
-  EtchArrayValue(EtchObject* array, capu::int32_t size, capu::int8_t typeCode, EtchType* customStructType, capu::int32_t dim);
+  EtchArrayValue(capu::SmartPointer<EtchNativeArrayBase> array, capu::int32_t size, capu::int8_t typeCode, EtchType* customStructType, capu::int32_t dim);
 
   /**
    * Constructs an array value with no type info. This is used perhaps
@@ -59,7 +59,7 @@ public:
    * @param array
    * @param size
    */
-  EtchArrayValue(EtchObject* array, capu::int32_t size);
+  EtchArrayValue(capu::SmartPointer<EtchNativeArrayBase> array, capu::int32_t size);
 
   virtual ~EtchArrayValue();
 
@@ -102,7 +102,8 @@ public:
    * @param index
    * @return the element at the specified index.
    */
-  capu::int32_t get(capu::uint32_t index, capu::SmartPointer<EtchObject> &result);
+  status_t get(capu::uint32_t index, capu::SmartPointer<EtchObject> &result);
+
   /**
    * Adds the value to the end of the array, making more space
    * available if needed.
@@ -113,10 +114,10 @@ public:
   /**
    * @return the array value.
    */
-  EtchNativeArray<capu::SmartPointer<EtchObject> >* getArray();
+  capu::SmartPointer<EtchNativeArrayBase> getArray();
 
 private:
-  EtchNativeArray<capu::SmartPointer<EtchObject> >* mArray;
+  capu::SmartPointer<EtchNativeArrayBase> mArray;
   capu::int8_t mTypeCode;
   EtchType* mCustomStructType;
   capu::int32_t mDim;

Modified: incubator/etch/trunk/binding-cpp/runtime/include/common/EtchError.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/common/EtchError.h?rev=1368460&r1=1368459&r2=1368460&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/common/EtchError.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/common/EtchError.h Thu Aug  2 13:20:50 2012
@@ -40,7 +40,8 @@ enum {
     ETCH_ENO_MEMORY = 11,
     ETCH_TIMEOUT = 12,
     ETCH_ENOT_EXIST = 13,
-    ETCH_ENOT_SUPPORTED = 14
+    ETCH_ENOT_SUPPORTED = 14,
+    ETCH_EIO = 15
 
   //RANGE BETWEEN 0XFFFF TO OXFFFFFFF ARE ERROR CODES FOR ONLY ETCH
 

Modified: incubator/etch/trunk/binding-cpp/runtime/include/common/EtchNativeArray.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/common/EtchNativeArray.h?rev=1368460&r1=1368459&r2=1368460&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/common/EtchNativeArray.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/common/EtchNativeArray.h Thu Aug  2 13:20:50 2012
@@ -156,9 +156,9 @@ public:
     virtual status_t createArray(Pos pos, capu::int32_t index, capu::int32_t length, capu::int32_t dim) = 0;
 
     /**
-     * copies the array into the given new array
+     * resizes the array to the given size
      */
-    virtual status_t copyToArray(capu::SmartPointer<EtchArrayBase<T> > newArray) = 0;
+    virtual status_t resize(capu::int32_t newSize) = 0;
 
     
   protected:
@@ -279,12 +279,17 @@ public:
     /**
      *@see EtchArrayBase
      */
-    status_t copyToArray(capu::SmartPointer<EtchArrayBase<T> > newArray) {
-      //TODO: replace with capu memory abstraction
-      capu::SmartPointer<EtchArrayData<T> > temp = capu::smartpointer_cast<EtchArrayData<T> >(newArray);
-      for(capu::int32_t i = 0; i < EtchArrayBase<T>::mLength; i++) {
-        temp->mData[i] = mData[i];
+    status_t resize(capu::int32_t newSize) {
+      if (newSize <= EtchArrayBase<T>::mLength) {
+        return ETCH_ERANGE;
+      }
+      T *newData = new T[newSize];
+      for (capu::int32_t i = 0; i<EtchArrayBase<T>::mLength; i++) {
+        newData[i] = mData[i];
       }
+      delete[] mData;
+      mData = newData;
+      EtchArrayBase<T>::mLength = newSize;
       return ETCH_OK;
     }
   private:
@@ -317,7 +322,7 @@ public:
       if(mData[pos.pos[index]].get() != NULL) {
         return mData[pos.pos[index]]->set(pos, index+1, data);
       }
-      return ETCH_OK;
+      return ETCH_ERANGE;
     }
 
   /**
@@ -329,7 +334,16 @@ public:
       }
 
       if(mData[pos.pos[index]].get() != NULL) {
-        return mData[pos.pos[index]]->set(pos, index+1, data, dataSize, offset, length, written);
+        if ((pos.size -1) == index) {
+          //set subarray
+          //TODO: enhance performance avoiding for-loop-copy
+          for (capu::int8_t i = 0; i < length; i++) {
+            mData[pos.pos[index]]->set(i,0,data[i]);
+          } 
+        } else {
+          //redirect to next sub array
+          return mData[pos.pos[index]]->set(pos, index+1, data, dataSize, offset, length, written);
+        }
       } else {
         return ETCH_EINVAL;
       }
@@ -340,7 +354,7 @@ public:
      *@see EtchArrayBase
      */
     status_t set(Pos pos, capu::int32_t index, const capu::SmartPointer<EtchArray<T> > &data) {
-      if(pos.size < index || pos.pos[index] > EtchArrayBase<T>::mLength || mData[pos.pos[index]].get() == NULL) {
+      if(pos.size < index || pos.pos[index] > EtchArrayBase<T>::mLength) {
         return ETCH_ERANGE;
       }
 
@@ -430,22 +444,70 @@ public:
     /**
      *@see EtchArrayBase
      */
-    status_t copyToArray(capu::SmartPointer<EtchArrayBase<T> > newArray) {
-      capu::SmartPointer<EtchArray<T> > temp = capu::smartpointer_cast<EtchArray<T> >(newArray);
-      for(capu::int32_t i = 0; i < EtchArrayBase<T>::mLength; i++) {
-        temp->mData[i] = mData[i];
+    status_t resize(capu::int32_t newSize) {
+      if (newSize <= EtchArrayBase<T>::mLength) {
+        return ETCH_ERANGE;
+      }
+      capu::SmartPointer<EtchArrayBase<T> > *newData = new capu::SmartPointer<EtchArrayBase<T> >[newSize];
+      for (capu::int32_t i = 0; i<EtchArrayBase<T>::mLength; i++) {
+        newData[i] = mData[i];
       }
+      delete[] mData;
+      mData = newData;
+      EtchArrayBase<T>::mLength = newSize;
       return ETCH_OK;
     }
   private:
     capu::SmartPointer<EtchArrayBase<T> > *mData;
   };
 
+template<class T>
+class EtchNativeArray;
+
+class EtchNativeArrayBase :
+public EtchObject {
+public:
 
+  EtchNativeArrayBase(const EtchObjectType* type)
+    : EtchObject(type) {
+  }
+
+  /**
+   * gets the EtchObject at index i in result
+   * returns ETCH_ERANGE, if out of bounds.
+   * returns ETCH_OK otherwise
+   */
+  status_t getBase(Pos pos, capu::SmartPointer<EtchObject> &result);
+
+  /**
+   * sets the EtchObject at index i
+   * returns ETCH_ERANGE, if out of bounds.
+   * returns ETCH_OK otherwise
+   */
+  status_t setBase(Pos pos, capu::SmartPointer<EtchObject> data);
+
+  /**
+   * resize current array to newSize
+   * returns ETCH_ERANGE, if newSize is smaller then current size
+   * returns ETCH_OK otherwise
+   */
+  virtual status_t resize(capu::int32_t newSize) = 0;
+
+  /**
+   * Returns the length of array
+   */
+  virtual capu::int32_t getLength() = 0;
+
+  /**
+   * Returns the dim of array
+   */
+  virtual capu::int32_t getDim() = 0;
+
+};
 
 template<class T>
 class EtchNativeArray :
-public EtchObject {
+public EtchNativeArrayBase {
 public:
 
   /**
@@ -459,7 +521,7 @@ public:
   EtchNativeArray(capu::int32_t length, capu::int32_t dim = 1);
 
   /**
-   * Constructs a EtchNativeArray object.
+   * Constructs a EtchNativeArray object from native array.
    */
   EtchNativeArray(capu::int32_t length, capu::int32_t dim, T* array);
 
@@ -483,7 +545,7 @@ public:
    * returns ETCH_ERANGE, if out of bounds.
    * returns ETCH_OK otherwise
    */
-  status_t get(Pos pos, EtchNativeArray *&subarray);
+  status_t get(Pos pos, capu::SmartPointer<EtchNativeArray> &subarray);
 
   /**
    * sets the EtchObject at index i in result
@@ -522,14 +584,9 @@ public:
   status_t createArray(Pos pos, capu::int32_t length);
 
   /**
-   * Copies the array into the given array
-   * @pos of the neseted array
-   * @length length of the nested array
+   * @see EtchNativeArrayBase
    */
-  status_t copyToArray(EtchNativeArray *newArray);
-
-private:
-
+  status_t resize(capu::int32_t newSize);
 
 private:
   capu::SmartPointer<EtchArrayBase<T> > mData;
@@ -538,19 +595,20 @@ private:
    * private constructor
    * creates a new native array from an existing subarray
    */
-  EtchNativeArray(capu::SmartPointer<EtchArray<T> > *array);
+  EtchNativeArray(capu::SmartPointer<EtchArray<T> > array);
 
 };
 
 template<class T>
 const EtchObjectType* EtchNativeArray<T>::TYPE() {
-  const static EtchObjectType TYPE(EOTID_NATIVE_ARRAY, EtchObjectType::getType<T>());
+  const static EtchObjectType TYPE(EOTID_NATIVE_ARRAY, EtchObjectType::getType<T>(), EtchObjectType::getTypeTrait<T>());
+
   return &TYPE;
 }
 
 template<class T>
 EtchNativeArray<T>::EtchNativeArray(capu::int32_t length, capu::int32_t dim)
-  : EtchObject(EtchNativeArray::TYPE()) {
+: EtchNativeArrayBase(EtchNativeArray<T>::TYPE()) {
   if (dim == 1) {
     mData = new EtchArrayData<T>(length);
   } else {
@@ -559,9 +617,30 @@ EtchNativeArray<T>::EtchNativeArray(capu
 }
 
 template<class T>
-EtchNativeArray<T>::EtchNativeArray(capu::SmartPointer<EtchArray<T> > *array) 
-: EtchObject(EtchNativeArray::TYPE()){
-  mData = capu::smartpointer_cast<EtchArrayBase<T> > (*array);
+EtchNativeArray<T>::EtchNativeArray(capu::int32_t length, capu::int32_t dim, T* array)
+: EtchNativeArrayBase(EtchNativeArray<T>::TYPE()) {
+  capu::int32_t bytesWritten;
+  if (dim == 1) {
+    mData = new EtchArrayData<T>(length);
+    mData->set(0, 0, array, length, 0, length, &bytesWritten);
+  } else if (dim == 2) {
+    mData = new EtchArray<T>(length, dim);
+    capu::int32_t dimCount = dim;
+    capu::int32_t offset = 0;
+    for (capu::int32_t i = 0; i < length; i++) {
+      mData->createArray(i, 0, 2,dim-1); 
+      mData->set(i, 0, &array[offset], length, 0, length, &bytesWritten);
+      offset += length;
+    }
+  } else if (dim >= 3 || dim <= 9) {
+    //the construction of EtchNativeArrays of more than 2 dimensions is not supported
+  }
+}
+
+template<class T>
+EtchNativeArray<T>::EtchNativeArray(capu::SmartPointer<EtchArray<T> > array) 
+: EtchNativeArrayBase(EtchNativeArray<T>::TYPE()){
+  mData = capu::smartpointer_cast<EtchArrayBase<T> > (array);
 }
 
 template<class T>
@@ -579,14 +658,14 @@ status_t EtchNativeArray<T>::get(Pos pos
 }
 
 template <class T>
-status_t EtchNativeArray<T>::get(Pos pos, EtchNativeArray<T> *&subarray) {
+status_t EtchNativeArray<T>::get(Pos pos, capu::SmartPointer<EtchNativeArray<T> > &subarray) {
   capu::SmartPointer<EtchArray<T> > temp = NULL;
   status_t res = mData->get(pos, 0, &temp);
   if (res != ETCH_OK) {
     return res;
   }
 
-  subarray = new EtchNativeArray<T>(&temp);
+  subarray = new EtchNativeArray(temp);
   return ETCH_OK;
 }
 
@@ -626,12 +705,108 @@ status_t EtchNativeArray<T>::createArray
 }
 
 template<class T>
-status_t EtchNativeArray<T>::copyToArray(EtchNativeArray *newArray) {
-  if (newArray == NULL) {
-    return ETCH_EINVAL;
-  }
-
-  return mData->copyToArray(newArray->mData);
+status_t EtchNativeArray<T>::resize(capu::int32_t newSize) {
+  return mData->resize(newSize);
+}
 
+//getBaseMacro used in NativeArrayBase::getBase()
+#define GETBASE_CAST_OBJECT_TO_NA(type) { \
+  switch(trait) { \
+    case EtchObjectType::VALUE: { \
+      EtchNativeArray<type>* na = (EtchNativeArray<type>*)(this); \
+      if(dims == 1) { \
+        type value; \
+        ret = na->get(pos, &value); \
+        if (ret == ETCH_OK) { \
+          result = new type(value); \
+        } \
+      } else { \
+        capu::SmartPointer<EtchNativeArray<type> > subarray; \
+        ret = na->get(pos,subarray); \
+        if (ret == ETCH_OK) { \
+          result = subarray; \
+        } \
+      } \
+      break; \
+    } \
+    case EtchObjectType::POINTER: { \
+      EtchNativeArray<type*>* na = (EtchNativeArray<type*>*)(this); \
+      if(dims == 1) { \
+        type* value = NULL; \
+        ret = na->get(pos, &value); \
+        if(ret == ETCH_OK && value != NULL) { \
+          result = new type(*value); \
+        } \
+      } else { \
+        capu::SmartPointer<EtchNativeArray<type*> > subarray; \
+        ret = na->get(pos,subarray); \
+        if (ret == ETCH_OK) { \
+          result = subarray; \
+        } \
+      } \
+      break; \
+    } \
+    case EtchObjectType::SMART_POINTER: { \
+      EtchNativeArray<capu::SmartPointer<type> >* na = (EtchNativeArray<capu::SmartPointer<type> >*)(this); \
+      if(dims == 1) { \
+        capu::SmartPointer<type> value = NULL; \
+        ret = na->get(pos, &value); \
+        if (ret == ETCH_OK) { \
+          result = value; \
+        } \
+      } else { \
+        capu::SmartPointer<EtchNativeArray<capu::SmartPointer<type> > > subarray; \
+        ret = na->get(pos,subarray); \
+        if (ret == ETCH_OK) { \
+          result = subarray; \
+        } \
+      } \
+      break; \
+    } \
+  } \
+}
+
+//setBaseMacro used in NativeArrayBase::setBase()
+#define SETBASE_CAST_OBJECT_TO_NA(type) { \
+  switch(trait) { \
+    case EtchObjectType::VALUE: { \
+      EtchNativeArray<type>* na = (EtchNativeArray<type>*)(this); \
+      if(dims == 1) { \
+        capu::SmartPointer<type> value = capu::smartpointer_cast<type> (data); \
+        type *newValue = value.get(); \
+        if (newValue != NULL) { \
+          return na->set(pos, *newValue); \
+        } \
+      } else { \
+        capu::SmartPointer<EtchNativeArray<type> > subarray = capu::smartpointer_cast<EtchNativeArray<type> >(data); \
+        return na->set(pos,subarray.get()); \
+      } \
+      break; \
+    } \
+    case EtchObjectType::POINTER: { \
+      EtchNativeArray<type*>* na = (EtchNativeArray<type*>*)(this); \
+      if(dims == 1) { \
+        capu::SmartPointer<type> value = capu::smartpointer_cast<type> (data); \
+        type *newValue = value.get(); \
+        return na->set(pos, newValue); \
+      } else { \
+        capu::SmartPointer<EtchNativeArray<type*> > subarray = capu::smartpointer_cast<EtchNativeArray<type*> >(data); \
+        return na->set(pos,subarray.get()); \
+      } \
+      break; \
+    } \
+    case EtchObjectType::SMART_POINTER: \
+      EtchNativeArray<capu::SmartPointer<type> >* na = (EtchNativeArray<capu::SmartPointer<type> >*)(this); \
+      if(dims == 1) { \
+        capu::SmartPointer<type> value = capu::smartpointer_cast<type> (data); \
+        return na->set(pos, value); \
+      } else { \
+        capu::SmartPointer<EtchNativeArray<capu::SmartPointer<type> > > subarray = capu::smartpointer_cast<EtchNativeArray<capu::SmartPointer<type> > >(data); \
+        return na->set(pos,subarray.get()); \
+      } \
+      break; \
+    } \
+  break; \
 }
 #endif //__ETCHNATIVEARRAY_H__
+

Modified: incubator/etch/trunk/binding-cpp/runtime/include/common/EtchObjectType.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/common/EtchObjectType.h?rev=1368460&r1=1368459&r2=1368460&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/common/EtchObjectType.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/common/EtchObjectType.h Thu Aug  2 13:20:50 2012
@@ -26,7 +26,8 @@
 #include "capu/util/SmartPointer.h"
 
 enum EtchObjectTypeIds {
-  EOTID_INT32 = 0,
+  EOTID_OBJECT = 0,
+  EOTID_INT32,
   EOTID_BOOL,
   EOTID_BYTE,
   EOTID_SHORT,
@@ -53,7 +54,6 @@ enum EtchObjectTypeIds {
   EOTID_VALIDATOR_OBJECT,
   EOTID_VALIDATOR_RUNTIME_EXCEPTION,
   EOTID_FIELD,
-  EOTID_OBJECT,
   EOTID_OBJECT_TYPE,
   EOTID_VALUE_FACTORY,
   EOTID_TYPE,
@@ -63,17 +63,7 @@ enum EtchObjectTypeIds {
   EOTID_RUNTIME_EXCEPTION,
   EOTID_ARRAY_VALUE,
   EOTID_VALIDATOR_STRUCT_VALUE,
-
-  EOTID_NATIVE_INT8,
-  EOTID_NATIVE_INT16,
-  EOTID_NATIVE_INT32,
-  EOTID_NATIVE_INT64,
-  EOTID_NATIVE_DOUBLE,
-  EOTID_NATIVE_FLOAT,
-  EOTID_NATIVE_LONG,
-  EOTID_NATIVE_SHORT,
-  EOTID_NATIVE_BOOL,
-  EOTID_NATIVE_BYTE,
+  EOTID_VALIDATOR_NONE
 };
 
 class EtchObjectType : public EtchObject {
@@ -90,14 +80,19 @@ public:
   static const EtchObjectType NATIVE_BOOL;
 
   /**
-   * EtchObjectType for EtchString.
+   * TypeTraits
+   */
+  enum EtchObjectTypeTrait {NONE, VALUE, POINTER, SMART_POINTER};
+
+  /**
+   * EtchObjectType.
    */
   static const EtchObjectType* TYPE();
 
   /**
    * Constructor
    */
-  EtchObjectType(capu::int32_t typeId, const EtchObjectType* componentTypes);
+  EtchObjectType(capu::int32_t typeId, const EtchObjectType* componentType, const EtchObjectTypeTrait componentTypeTrait = NONE);
 
   /**
    * to get the type ids
@@ -109,6 +104,15 @@ public:
   }
 
   /**
+   * to get the type trait
+   * @return
+   */
+  template<class T>
+  static const EtchObjectTypeTrait getTypeTrait() {
+    return __Wrapper__<T>::getTypeTrait();
+  }
+
+  /**
    * get object type
    * @return object type
    */
@@ -128,6 +132,12 @@ public:
   const EtchObjectType* getObjectComponentType() const;
 
   /**
+   * @return NONE if this is not a collection type trait
+   *         otherwise component type trait of collection such VALUE, POINTER, SMART_POINTER
+   */
+  const EtchObjectTypeTrait getObjectComponentTypeTrait() const;
+
+  /**
    * @return true if two type is equal
    *         false otherwise
    */
@@ -136,6 +146,8 @@ public:
 private:
   capu::int32_t mTypeId;
   const EtchObjectType* mComponentType;
+  const EtchObjectTypeTrait mComponentTypeTrait;
+
 
   template <class T>
   struct __Wrapper__ {
@@ -143,6 +155,11 @@ private:
     static const EtchObjectType * getType() {
       return T::TYPE();
     }
+
+    static const EtchObjectTypeTrait getTypeTrait() {
+      return EtchObjectType::VALUE;
+    }
+
   };
 
   template <class T>
@@ -151,13 +168,21 @@ private:
     static const EtchObjectType * getType() {
       return T::TYPE();
     }
+
+    static const EtchObjectTypeTrait getTypeTrait() {
+      return EtchObjectType::POINTER;
+    }
   };
   
   template <class T>
   struct __Wrapper__<capu::SmartPointer<T> > {
 
     static const EtchObjectType * getType() {
-      return T::TYPE();
+      return EtchObjectType::getType<T>();
+    }
+
+    static const EtchObjectTypeTrait getTypeTrait() {
+      return EtchObjectType::SMART_POINTER;
     }
   };
 
@@ -169,6 +194,10 @@ struct EtchObjectType::__Wrapper__<capu:
   static const EtchObjectType * getType() {
     return &EtchObjectType::NATIVE_INT32;
   }
+
+  static const EtchObjectTypeTrait getTypeTrait() {
+    return EtchObjectType::VALUE;
+  }
 };
 
 template <>
@@ -177,6 +206,11 @@ struct EtchObjectType::__Wrapper__<capu:
   static const EtchObjectType * getType() {
     return &EtchObjectType::NATIVE_INT16;
   }
+  
+  static const EtchObjectTypeTrait getTypeTrait() {
+    return EtchObjectType::VALUE;
+  }
+
 };
 
 template <>
@@ -185,6 +219,10 @@ struct EtchObjectType::__Wrapper__<capu:
   static const EtchObjectType * getType() {
     return &EtchObjectType::NATIVE_INT8;
   }
+
+  static const EtchObjectTypeTrait getTypeTrait() {
+    return EtchObjectType::VALUE;
+  }
 };
 
 template <>
@@ -193,6 +231,10 @@ struct EtchObjectType::__Wrapper__<capu:
   static const EtchObjectType * getType() {
     return &EtchObjectType::NATIVE_INT64;
   }
+
+  static const EtchObjectTypeTrait getTypeTrait() {
+    return EtchObjectType::VALUE;
+  }
 };
 
 template <>
@@ -201,6 +243,11 @@ struct EtchObjectType::__Wrapper__<capu:
   static const EtchObjectType * getType() {
     return &EtchObjectType::NATIVE_FLOAT;
   }
+
+  static const EtchObjectTypeTrait getTypeTrait() {
+    return EtchObjectType::VALUE;
+  }
+
 };
 
 template <>
@@ -209,6 +256,11 @@ struct EtchObjectType::__Wrapper__<capu:
   static const EtchObjectType * getType() {
     return &EtchObjectType::NATIVE_DOUBLE;
   }
+
+  static const EtchObjectTypeTrait getTypeTrait() {
+    return EtchObjectType::VALUE;
+  }
+
 };
 
 template <>
@@ -217,6 +269,11 @@ struct EtchObjectType::__Wrapper__<capu:
   static const EtchObjectType * getType() {
     return &EtchObjectType::NATIVE_BOOL;
   }
+  
+  static const EtchObjectTypeTrait getTypeTrait() {
+    return EtchObjectType::VALUE;
+  }
+
 };
 
 template <>
@@ -225,6 +282,11 @@ struct EtchObjectType::__Wrapper__<capu:
   static const EtchObjectType * getType() {
     return &EtchObjectType::NATIVE_INT32;
   }
+
+  static const EtchObjectTypeTrait getTypeTrait() {
+    return EtchObjectType::POINTER;
+  }
+
 };
 
 template <>
@@ -233,6 +295,11 @@ struct EtchObjectType::__Wrapper__<capu:
   static const EtchObjectType * getType() {
     return &EtchObjectType::NATIVE_INT16;
   }
+  
+  static const EtchObjectTypeTrait getTypeTrait() {
+    return EtchObjectType::POINTER;
+  }
+
 };
 
 template <>
@@ -241,6 +308,11 @@ struct EtchObjectType::__Wrapper__<capu:
   static const EtchObjectType * getType() {
     return &EtchObjectType::NATIVE_INT8;
   }
+
+  static const EtchObjectTypeTrait getTypeTrait() {
+    return EtchObjectType::POINTER;
+  }
+
 };
 
 template <>
@@ -249,6 +321,11 @@ struct EtchObjectType::__Wrapper__<capu:
   static const EtchObjectType * getType() {
     return &EtchObjectType::NATIVE_INT64;
   }
+
+  static const EtchObjectTypeTrait getTypeTrait() {
+    return EtchObjectType::POINTER;
+  }
+
 };
 
 template <>
@@ -257,6 +334,11 @@ struct EtchObjectType::__Wrapper__<capu:
   static const EtchObjectType * getType() {
     return &EtchObjectType::NATIVE_FLOAT;
   }
+
+  static const EtchObjectTypeTrait getTypeTrait() {
+    return EtchObjectType::POINTER;
+  }
+
 };
 
 template <>
@@ -265,6 +347,11 @@ struct EtchObjectType::__Wrapper__<capu:
   static const EtchObjectType * getType() {
     return &EtchObjectType::NATIVE_DOUBLE;
   }
+
+  static const EtchObjectTypeTrait getTypeTrait() {
+    return EtchObjectType::POINTER;
+  }
+
 };
 
 template <>
@@ -273,6 +360,99 @@ struct EtchObjectType::__Wrapper__<capu:
   static const EtchObjectType * getType() {
     return &EtchObjectType::NATIVE_BOOL;
   }
+
+  static const EtchObjectTypeTrait getTypeTrait() {
+    return EtchObjectType::POINTER;
+  }
+
+};
+
+template <>
+struct EtchObjectType::__Wrapper__<capu::SmartPointer<capu::int32_t> > {
+
+  static const EtchObjectType * getType() {
+    return &EtchObjectType::NATIVE_INT32;
+  }
+
+  static const EtchObjectTypeTrait getTypeTrait() {
+    return EtchObjectType::SMART_POINTER;
+  }
+};
+
+template <>
+struct EtchObjectType::__Wrapper__<capu::SmartPointer<capu::int16_t> > {
+
+  static const EtchObjectType * getType() {
+    return &EtchObjectType::NATIVE_INT16;
+  }
+  
+  static const EtchObjectTypeTrait getTypeTrait() {
+    return EtchObjectType::SMART_POINTER;
+  }
+
+};
+
+template <>
+struct EtchObjectType::__Wrapper__<capu::SmartPointer<capu::int8_t> > {
+
+  static const EtchObjectType * getType() {
+    return &EtchObjectType::NATIVE_INT8;
+  }
+
+  static const EtchObjectTypeTrait getTypeTrait() {
+    return EtchObjectType::SMART_POINTER;
+  }
+};
+
+template <>
+struct EtchObjectType::__Wrapper__<capu::SmartPointer<capu::int64_t> > {
+
+  static const EtchObjectType * getType() {
+    return &EtchObjectType::NATIVE_INT64;
+  }
+
+  static const EtchObjectTypeTrait getTypeTrait() {
+    return EtchObjectType::SMART_POINTER;
+  }
+};
+
+template <>
+struct EtchObjectType::__Wrapper__<capu::SmartPointer<capu::float_t> > {
+
+  static const EtchObjectType * getType() {
+    return &EtchObjectType::NATIVE_FLOAT;
+  }
+
+  static const EtchObjectTypeTrait getTypeTrait() {
+    return EtchObjectType::SMART_POINTER;
+  }
+
+};
+
+template <>
+struct EtchObjectType::__Wrapper__<capu::SmartPointer<capu::double_t> > {
+
+  static const EtchObjectType * getType() {
+    return &EtchObjectType::NATIVE_DOUBLE;
+  }
+
+  static const EtchObjectTypeTrait getTypeTrait() {
+    return EtchObjectType::SMART_POINTER;
+  }
+
+};
+
+template <>
+struct EtchObjectType::__Wrapper__<capu::SmartPointer<capu::bool_t> > {
+
+  static const EtchObjectType * getType() {
+    return &EtchObjectType::NATIVE_BOOL;
+  }
+  
+  static const EtchObjectTypeTrait getTypeTrait() {
+    return EtchObjectType::SMART_POINTER;
+  }
+
 };
 
 #endif /* ETCHOBJECTTYPE_H */

Modified: incubator/etch/trunk/binding-cpp/runtime/include/common/EtchString.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/common/EtchString.h?rev=1368460&r1=1368459&r2=1368460&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/common/EtchString.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/common/EtchString.h Thu Aug  2 13:20:50 2012
@@ -54,6 +54,14 @@ public:
   EtchString(const char* string);
 
   /**
+   * Constructs the String from given buffer
+   * @param buffer as bytes
+   * @param bufferSize size of the buffer
+   * @param encoding of the string
+   */
+  EtchString(const capu::int8_t* buffer, const capu::int32_t bufferSize, EtchString encoding);
+
+  /**
    * Destructure.
    */
   virtual ~EtchString();
@@ -117,6 +125,14 @@ public:
   const char* c_str() const;
 
   /**
+   * Returns the bytes of the string.
+   * @param buffer out parameter for bytes
+   * @param bufferSize size of buffer
+   * @param encoding of the string
+   */
+  status_t getBytes(capu::int8_t** buffer, capu::int32_t *bufferSize, EtchString encoding = "utf-8");
+
+  /**
    * Assignment operator overloading
    */
   EtchString& operator=(const EtchString &str);

Added: incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchBinaryTaggedData.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchBinaryTaggedData.h?rev=1368460&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchBinaryTaggedData.h (added)
+++ incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchBinaryTaggedData.h Thu Aug  2 13:20:50 2012
@@ -0,0 +1,102 @@
+/* $Id$
+ *
+ * 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 __ETCHBINARYTAGGEDDATA_H__
+#define __ETCHBINARYTAGGEDDATA_H__
+
+#include "capu/util/SmartPointer.h"
+#include "common/EtchObject.h"
+#include "common/EtchBool.h"
+#include "common/EtchByte.h"
+#include "common/EtchShort.h"
+#include "common/EtchInt32.h"
+#include "common/EtchLong.h"
+#include "common/EtchFloat.h"
+#include "common/EtchDouble.h"
+#include "common/EtchNativeArray.h"
+#include "serialization/EtchValueFactory.h"
+#include "serialization/EtchTypeCodes.h"
+#include "serialization/EtchTaggedData.h"
+
+class EtchBinaryTaggedData : public EtchTaggedData {
+public:
+
+  /**
+   * This is the current version of the protocol.
+   */
+  const static capu::int8_t VERSION = 3;
+
+  /**
+   * sentinel that marks the end of array or struct element
+   */
+  static capu::SmartPointer<EtchObject> NONE;
+
+  /**
+   * Constructs the BinaryTaggedData.
+   *
+   * @param vf ValueFactory
+   */
+  EtchBinaryTaggedData(EtchValueFactory* vf);
+
+  /**
+   * Destructor
+   */
+  virtual ~EtchBinaryTaggedData();
+
+  /**
+   * @param value
+   * @return return a type code for the specified value.
+   */
+  capu::int8_t checkValue(capu::SmartPointer<EtchObject> value);
+
+  /**
+   * Returns the type code for the specified class. This
+   * is needed when we have an array and we have determine
+   * the base type and now we're fixing to serialize it.
+   * We use the base type code to reconstitute it on the
+   * other side. So we don't return a perfect code the way
+   * checkValue does, but rather just something that let's
+   * us recreate the appropriate array type on import.
+   * @param c
+   * @return a type code for the specified class.
+   */
+  capu::int8_t getNativeTypeCode(const EtchObjectType *c);
+
+  /**
+   * @param c           typeid
+   * @param result      out buffet 
+   */
+  status_t getCustomStructType(const EtchObjectType* c, EtchType*& result);
+
+  /**
+   * @param type
+   * @return the class for a specified (native) type code.
+   */
+  const EtchObjectType* getNativeType(capu::int8_t type);
+
+private:
+
+  static capu::int8_t checkByte(capu::int8_t v);
+  static capu::int8_t checkShort(capu::int16_t v);
+  static capu::int8_t checkInteger(capu::int32_t v);
+  static capu::int8_t checkLong(capu::int64_t v);
+
+};
+
+#endif /* ETCHBINARYTAGGEDDATA_H */
+

Added: incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchBinaryTaggedDataInput.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchBinaryTaggedDataInput.h?rev=1368460&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchBinaryTaggedDataInput.h (added)
+++ incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchBinaryTaggedDataInput.h Thu Aug  2 13:20:50 2012
@@ -0,0 +1,87 @@
+/* $Id$
+ *
+ * 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 __ETCHBINARYTAGGEDDATAINPUT_H__
+#define __ETCHBINARYTAGGEDDATAINPUT_H__
+
+#include "capu/os/StringUtils.h"
+#include "serialization/EtchTaggedDataInput.h"
+#include "serialization/EtchBinaryTaggedData.h"
+#include "serialization/EtchValidatorInt.h"
+#include "serialization/EtchValidatorString.h"
+#include "serialization/EtchValidatorObject.h"
+
+
+class EtchBinaryTaggedDataInput : public EtchBinaryTaggedData, public EtchTaggedDataInput {
+public:
+
+  /**
+   * Constructs the BinaryTaggedDataInput with a null buffer.
+   * 
+   * @param vf the value factory for the service.
+   */
+  EtchBinaryTaggedDataInput(EtchValueFactory *vf);
+
+  /**
+   * Destructor
+   */
+  virtual ~EtchBinaryTaggedDataInput();
+
+  /////////////////////////////
+  // TaggedDataInput methods //
+  /////////////////////////////
+
+  //overriden method
+  status_t readMessage(EtchFlexBuffer *buf, EtchMessage *&message);
+
+private:
+
+  EtchFlexBuffer *mBuffer;
+  capu::int32_t mLengthBudget;
+  capu::SmartPointer<EtchValidator> mIntOrStrValidator;
+  capu::SmartPointer<EtchValidator> mIntValidator;
+
+  status_t readStruct(EtchStructValue*& result);
+  status_t readArray(capu::SmartPointer<EtchValidator> v, EtchArrayValue *& result);
+  status_t readKeysAndValues(EtchStructValue* sv);
+  status_t readValues(EtchArrayValue *av, capu::SmartPointer<EtchValidator> v);
+  status_t startMessage(EtchMessage *& result);
+  status_t endMessage(EtchMessage* msg);
+  status_t startStruct(EtchStructValue *& result);
+  status_t endStruct(EtchStructValue * result);
+  status_t startArray(EtchArrayValue *& result);
+  status_t endArray(EtchArrayValue *array);
+  status_t readType(EtchType *&type);
+  status_t readField(EtchType *type, EtchField& field);
+  status_t readLength(capu::int32_t& result);
+  status_t readIntegerValue(capu::int32_t& result);
+
+  ///////////////////////////
+  // LOCAL UTILITY METHODS //
+  ///////////////////////////
+  status_t validate(capu::SmartPointer<EtchValidator> v, capu::SmartPointer<EtchObject> value);
+  status_t validateValue(capu::SmartPointer<EtchValidator> v, capu::SmartPointer<EtchObject> value, capu::SmartPointer<EtchObject>& result);
+  status_t validateValue(capu::SmartPointer<EtchValidator> v, capu::bool_t noneOk, capu::SmartPointer<EtchObject> value, capu::SmartPointer<EtchObject>& result);
+  status_t readValue(capu::SmartPointer<EtchValidator> v, capu::SmartPointer<EtchObject>& result);
+  status_t readValue(capu::SmartPointer<EtchValidator> v, capu::bool_t noneOk, capu::SmartPointer<EtchObject>& result);
+  status_t readBytes(capu::int8_t*& array, capu::uint32_t &length);
+};
+
+
+#endif
+

Added: incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchBinaryTaggedDataOutput.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchBinaryTaggedDataOutput.h?rev=1368460&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchBinaryTaggedDataOutput.h (added)
+++ incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchBinaryTaggedDataOutput.h Thu Aug  2 13:20:50 2012
@@ -0,0 +1,91 @@
+/* $Id$
+ *
+ * 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 __ETCHBINARYTAGGEDDATAOUTPUT_H__
+#define __ETCHBINARYTAGGEDDATAOUTPUT_H__
+
+#include "util/EtchURL.h"
+#include "serialization/EtchTaggedDataOutput.h"
+#include "serialization/EtchBinaryTaggedData.h"
+#include "serialization/EtchValidatorInt.h"
+#include "serialization/EtchValidatorString.h"
+#include "serialization/EtchValidatorNone.h"
+
+class EtchBinaryTaggedDataOutput : public EtchTaggedDataOutput, public EtchBinaryTaggedData {
+public:
+
+  /**
+   * Name of uri parameter which controls whether we write ints or strings
+   * for types and fields.
+   */
+  static const EtchString STRING_TYPE_AND_FIELD;
+
+
+  /**
+   * Constructs the BinaryTaggedDataInput with a null buffer.
+   * 
+   * @param vf the value factory for the service.
+   * @param uri.
+   */
+  EtchBinaryTaggedDataOutput(EtchValueFactory *vf, EtchURL* uri);
+
+  /**
+   * Destructor
+   */
+  virtual ~EtchBinaryTaggedDataOutput();
+
+  //////////////////////////////
+  // TaggedDataOutput methods //
+  //////////////////////////////
+  //overriden method
+  status_t writeMessage(EtchMessage* msg, EtchFlexBuffer *buf);
+
+private:
+  EtchFlexBuffer* mBuffer;
+  EtchLevel mLevel;
+  capu::bool_t mStringTypeAndField;
+  capu::SmartPointer<EtchValidator> mIntValidator;
+  capu::SmartPointer<EtchValidator> mStringValidator;
+  capu::SmartPointer<EtchValidator> mNoneValidator;
+
+  status_t writeStruct(EtchStructValue* sv);
+  status_t writeArray(EtchArrayValue* av, EtchValidator* v);
+  status_t writeKeysAndValues(EtchStructValue* sv);
+  status_t writeValues(EtchArrayValue* av, EtchValidator* v);
+
+  /////////////////////////
+  // Main output methods //
+  /////////////////////////
+
+  status_t startMessage(EtchMessage* msg);
+  status_t endMessage(EtchMessage* msg);
+  status_t startStruct(EtchStructValue* _struct);
+  status_t endStruct(EtchStructValue* _struct);
+  status_t startArray(EtchArrayValue* array);
+  status_t endArray(EtchArrayValue* array);
+  status_t writeType(EtchType* type);
+  status_t writeField(EtchField* field);
+  status_t writeIntValue(capu::int32_t value);
+  status_t writeStringValue(capu::SmartPointer<EtchString> value);
+  status_t writeNoneValue();
+  status_t writeValue(capu::SmartPointer<EtchValidator> v, capu::SmartPointer<EtchObject> value);
+  status_t writeBytes( capu::int8_t* value, capu::int32_t size);
+};
+
+#endif /* ETCHBINARYTAGGEDDATAOUTPUT_H */
+

Added: incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchTaggedData.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchTaggedData.h?rev=1368460&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchTaggedData.h (added)
+++ incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchTaggedData.h Thu Aug  2 13:20:50 2012
@@ -0,0 +1,126 @@
+/* $Id$
+ *
+ * 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 __ETCHTAGGEDDATA_H__
+#define __ETCHTAGGEDDATA_H__
+#include "serialization/EtchValueFactory.h"
+#include "serialization/EtchValidatorStructValue.h"
+#include "serialization/EtchType.h"
+#include "common/EtchArrayValue.h"
+#include "serialization/EtchTypeCodes.h"
+#include "common/EtchObject.h"
+#include "common/EtchNativeArray.h"
+
+class EtchTaggedData {
+protected:
+
+  /**
+   * The value factory to use for tagged input and output.
+   */
+  EtchValueFactory* mVf;
+
+public:
+
+  //Constructor
+  EtchTaggedData(EtchValueFactory* vf);
+
+  //Destructor
+  virtual ~EtchTaggedData();
+
+  /**
+   * @return the value factory to use for tagged input and output.
+   */
+
+  EtchValueFactory* getValueFactory();
+
+protected:
+
+  /**
+   * @param typeCode
+   * @param customStructType
+   * @param dim
+   * @param result the allocated array value.
+   * @return ETCH_OK if array is successfully allocated
+   *         ETCH_ENO_MEMORY if mem allocation fails
+   *         
+   */
+  status_t allocNativeArray(capu::int8_t typeCode, EtchType* customStructType, capu::int32_t dim, capu::int32_t length, capu::SmartPointer<EtchNativeArrayBase> &result);
+
+  /**
+   * @param av
+   * @param result native array converted from an array value.
+   * @return ETCH_OK if successfully converted
+   *         ETCH_EINVAL if av is NULL
+   */
+
+  status_t fromArrayValue(EtchArrayValue* av, capu::SmartPointer<EtchObject> &result);
+
+
+  /**
+   * @param value
+   * @param v
+   * @param result an ArrayValue which models the given array.
+   * @return ETCH_OK if successfully converted
+   *         ETCH_EINVAL if value or v is NULL
+   *         ETCH_ERROR otherwise
+   */
+  status_t toArrayValue(capu::SmartPointer<EtchObject> value, EtchValidator* v, EtchArrayValue*& result);
+
+private:
+
+  const EtchObjectType* getComponentType(capu::int8_t typeCode, EtchType* customStructType,
+          capu::int32_t dim);
+
+  status_t findStructValueValidator(EtchValidator* v, EtchValidatorStructValue*& result);
+
+public:
+  /**
+   * @param value
+   * @return return a type code for the specified value.
+   */
+  virtual capu::int8_t checkValue(capu::SmartPointer<EtchObject> value) = 0;
+
+  /**
+   * Returns the type code for the specified class. This
+   * is needed when we have an array and we have determine
+   * the base type and now we're fixing to serialize it.
+   * We use the base type code to reconstitute it on the
+   * other side. So we don't return a perfect code the way
+   * checkValue does, but rather just something that let's
+   * us recreate the appropriate array type on import.
+   * @param c
+   * @return a type code for the specified class.
+   */
+  virtual capu::int8_t getNativeTypeCode(const EtchObjectType *c) = 0;
+
+  /**
+   * @param c           typeid
+   * @param result      out buffet 
+   */
+  virtual status_t getCustomStructType(const EtchObjectType* c, EtchType*& result) = 0;
+
+  /**
+   * @param type
+   * @return the class for a specified (native) type code.
+   */
+  virtual const EtchObjectType* getNativeType(capu::int8_t type) = 0;
+
+};
+
+#endif /* ETCHTAGGEDDATA_H */
+

Modified: incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchTaggedDataInput.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchTaggedDataInput.h?rev=1368460&r1=1368459&r2=1368460&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchTaggedDataInput.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchTaggedDataInput.h Thu Aug  2 13:20:50 2012
@@ -30,7 +30,7 @@ public:
    * @param buf the flex buffer containing the message.
    * @param a message read from the buf.
    */
-  virtual status_t readMessage(capu::SmartPointer<EtchFlexBuffer> buf, EtchMessage *&message) = 0;
+  virtual status_t readMessage(EtchFlexBuffer *buf, EtchMessage *&message) = 0;
 
   virtual ~EtchTaggedDataInput() {
 

Added: incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchValidatorNone.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchValidatorNone.h?rev=1368460&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchValidatorNone.h (added)
+++ incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchValidatorNone.h Thu Aug  2 13:20:50 2012
@@ -0,0 +1,60 @@
+/* $Id$
+ *
+ * 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 __ETCHVALIDATORNONE_H__
+#define __ETCHVALIDATORNONE_H__
+
+#include "serialization/EtchValidator.h"
+#include "serialization/EtchBinaryTaggedData.h"
+
+class EtchValidatorNone : public EtchValidator {
+public:
+  virtual ~EtchValidatorNone();
+
+  /**
+   * @see EtchValidator
+   */
+  virtual status_t getElementValidator(capu::SmartPointer<EtchValidator> &val);
+
+  /**
+   * @see EtchValidator
+   */
+  virtual capu::bool_t validate(capu::SmartPointer<EtchObject> value);
+
+  /**
+   * @see EtchValidator
+   */
+  virtual status_t validateValue(capu::SmartPointer<EtchObject> value, capu::SmartPointer<EtchObject>& result);
+
+  /**
+   * @see EtchValidator
+   */
+  static status_t Get(capu::SmartPointer<EtchValidator> &val);
+
+  static const EtchObjectType TYPE;
+
+protected:
+  EtchValidatorNone();
+
+private:
+  static capu::SmartPointer<EtchValidator> mValidator;
+
+};
+
+#endif /* ETCHVALIDATORNONE_H */
+

Modified: incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchValueFactory.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchValueFactory.h?rev=1368460&r1=1368459&r2=1368460&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchValueFactory.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchValueFactory.h Thu Aug  2 13:20:50 2012
@@ -195,6 +195,12 @@ public:
   virtual status_t getCustomStructType(const EtchObjectType *c, EtchType *&type) = 0;
 
   /**
+   * Returns the current string encoding.
+   * @return string encoding
+   */
+  virtual EtchString getStringEncoding();
+
+  /**
    * @return well-known message type for exception thrown by one-way
    * message.
    */

Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt?rev=1368460&r1=1368459&r2=1368460&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt Thu Aug  2 13:20:50 2012
@@ -79,6 +79,7 @@ SET(MAIN_INCLUDES
     ${PROJECT_SOURCE_DIR}/include/serialization/EtchValidatorDouble.h
     ${PROJECT_SOURCE_DIR}/include/serialization/EtchValidatorLong.h
     ${PROJECT_SOURCE_DIR}/include/serialization/EtchValidatorString.h
+    ${PROJECT_SOURCE_DIR}/include/serialization/EtchValidatorNone.h
     ${PROJECT_SOURCE_DIR}/include/serialization/EtchComboValidator.h
     ${PROJECT_SOURCE_DIR}/include/serialization/EtchField.h
     ${PROJECT_SOURCE_DIR}/include/serialization/EtchValidatorObject.h
@@ -98,8 +99,10 @@ SET(MAIN_INCLUDES
     ${PROJECT_SOURCE_DIR}/include/serialization/EtchDateSerializer.h
     ${PROJECT_SOURCE_DIR}/include/serialization/EtchDefaultValueFactory.h
     ${PROJECT_SOURCE_DIR}/include/serialization/EtchValidatorStructValue.h
-	${PROJECT_SOURCE_DIR}/include/serialization/EtchTaggedDataInput.h
-	${PROJECT_SOURCE_DIR}/include/serialization/EtchTaggedDataOutput.h
+    ${PROJECT_SOURCE_DIR}/include/serialization/EtchTaggedData.h
+    ${PROJECT_SOURCE_DIR}/include/serialization/EtchBinaryTaggedData.h
+    ${PROJECT_SOURCE_DIR}/include/serialization/EtchBinaryTaggedDataInput.h
+    ${PROJECT_SOURCE_DIR}/include/serialization/EtchBinaryTaggedDataOutput.h
     ${PROJECT_SOURCE_DIR}/include/util/EtchUtil.h
     )
 
@@ -121,6 +124,7 @@ SET(MAIN_SOURCES
     common/EtchAuthenticationException.cpp
     common/EtchRuntimeException.cpp
     common/EtchDate.cpp
+    common/EtchNativeArray.cpp
     common/EtchArrayValue.cpp
     util/EtchURL.cpp
     util/EtchResources.cpp
@@ -140,6 +144,7 @@ SET(MAIN_SOURCES
     serialization/EtchValidatorDouble.cpp
     serialization/EtchValidatorLong.cpp
     serialization/EtchValidatorString.cpp
+    serialization/EtchValidatorNone.cpp
     serialization/EtchComboValidator.cpp
     serialization/EtchField.cpp
     serialization/EtchValidatorObject.cpp
@@ -158,6 +163,10 @@ SET(MAIN_SOURCES
     serialization/EtchDateSerializer.cpp
     serialization/EtchDefaultValueFactory.cpp
     serialization/EtchValidatorStructValue.cpp
+    serialization/EtchTaggedData.cpp
+    serialization/EtchBinaryTaggedData.cpp
+    serialization/EtchBinaryTaggedDataInput.cpp
+    serialization/EtchBinaryTaggedDataOutput.cpp
     util/EtchUtil.cpp
     )
 

Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchArrayValue.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchArrayValue.cpp?rev=1368460&r1=1368459&r2=1368460&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchArrayValue.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchArrayValue.cpp Thu Aug  2 13:20:50 2012
@@ -19,19 +19,30 @@
  */
 
 #include "common/EtchArrayValue.h"
+#include "common/EtchObject.h"
+#include "common/EtchInt32.h"
+#include "common/EtchBool.h"
+#include "common/EtchByte.h"
+#include "common/EtchShort.h"
+#include "common/EtchLong.h"
+#include "common/EtchDouble.h"
+#include "common/EtchFloat.h"
+#include "common/EtchString.h"
+#include "common/EtchDate.h"
+#include "common/EtchList.h"
+#include "common/EtchHashTable.h"
+#include "common/EtchHashSet.h"
 
 const EtchObjectType EtchArrayValue::TYPE(EOTID_ARRAY_VALUE, NULL);
 
-EtchArrayValue::EtchArrayValue(EtchObject* array, capu::int32_t size, capu::int8_t typeCode, EtchType* customStructType, capu::int32_t dim)
-: EtchObject(&EtchArrayValue::TYPE), mArray((EtchNativeArray<capu::SmartPointer<EtchObject> > *)array), mTypeCode(typeCode),
+EtchArrayValue::EtchArrayValue(capu::SmartPointer<EtchNativeArrayBase> array, capu::int32_t size, capu::int8_t typeCode, EtchType* customStructType, capu::int32_t dim)
+: EtchObject(&EtchArrayValue::TYPE), mArray(array), mTypeCode(typeCode),
 mCustomStructType(customStructType), mDim(dim), mAddIndex(size), mSize(size) {
-
 }
 
-EtchArrayValue::EtchArrayValue(EtchObject* array, capu::int32_t size)
-: EtchObject(&EtchArrayValue::TYPE), mArray((EtchNativeArray<capu::SmartPointer<EtchObject> > *)array), mTypeCode(0),
+EtchArrayValue::EtchArrayValue(capu::SmartPointer<EtchNativeArrayBase> array, capu::int32_t size)
+: EtchObject(&EtchArrayValue::TYPE), mArray(array), mTypeCode(0),
 mCustomStructType(NULL), mDim(1), mAddIndex(size), mSize(size) {
-
 }
 
 EtchArrayValue::~EtchArrayValue() {
@@ -50,7 +61,7 @@ capu::int8_t EtchArrayValue::getTypeCode
   return mTypeCode;
 }
 
-EtchNativeArray<capu::SmartPointer<EtchObject> >* EtchArrayValue::getArray() {
+capu::SmartPointer<EtchNativeArrayBase> EtchArrayValue::getArray() {
   return mArray;
 }
 
@@ -66,14 +77,11 @@ EtchType * EtchArrayValue::getCustomStru
   return mCustomStructType;
 }
 
-status_t EtchArrayValue::get(capu::uint32_t index, capu::SmartPointer<EtchObject>& result) {
-  if ((index >= getSize()) || (mArray == NULL))
+status_t EtchArrayValue::get(capu::uint32_t index, capu::SmartPointer<EtchObject> &result) {
+  if ((index >= getSize()) || (mArray.get() == NULL)) {
     return ETCH_EINVAL;
-  else {
-    mArray->get(index, &result);
-    return ETCH_OK;
   }
-
+  return mArray->getBase(index,result);
 }
 
 status_t EtchArrayValue::add(capu::SmartPointer<EtchObject> value) {
@@ -89,14 +97,8 @@ status_t EtchArrayValue::add(capu::Smart
     } else {
       n *= 2;
     }
-    capu::SmartPointer<EtchObject> tmp;
-    EtchNativeArray<capu::SmartPointer<EtchObject> > *narray = new EtchNativeArray<capu::SmartPointer<EtchObject> >(n, mDim);
-    mArray->copyToArray(narray);
-    delete mArray;
-    mArray = narray;
+    mArray->resize(n);
     mSize = n;
   }
-  mArray->set(mAddIndex++, value);
-
-  return ETCH_OK;
+  return mArray->setBase(mAddIndex++, value);
 }

Added: incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchNativeArray.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchNativeArray.cpp?rev=1368460&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchNativeArray.cpp (added)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchNativeArray.cpp Thu Aug  2 13:20:50 2012
@@ -0,0 +1,346 @@
+/* $Id$
+ *
+ * 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 "common/EtchNativeArray.h"
+#include "common/EtchInt32.h"
+#include "common/EtchBool.h"
+#include "common/EtchByte.h"
+#include "common/EtchShort.h"
+#include "common/EtchLong.h"
+#include "common/EtchDouble.h"
+#include "common/EtchFloat.h"
+#include "common/EtchString.h"
+#include "common/EtchDate.h"
+#include "common/EtchHashTable.h"
+#include "common/EtchHashSet.h"
+#include "common/EtchList.h"
+
+status_t EtchNativeArrayBase::getBase(Pos pos, capu::SmartPointer<EtchObject> &result) {
+
+  status_t ret = ETCH_OK;
+  const EtchObjectType* type = getObjectType()->getObjectComponentType();
+  const EtchObjectType::EtchObjectTypeTrait trait = getObjectType()->getObjectComponentTypeTrait();
+  const capu::int32_t dims = getDim();
+
+  switch(type->getTypeId()) {
+    case EOTID_BYTE: {
+      switch(trait) {
+        case EtchObjectType::VALUE: {
+          EtchNativeArray<capu::int8_t>* na = (EtchNativeArray<capu::int8_t>*)(this);
+          if(dims == 1) {
+            capu::int8_t value;
+            ret = na->get(pos, &value);
+            if (ret == ETCH_OK) {
+              result = new EtchInt32(value);
+            }
+          } else {
+            //multi
+            capu::SmartPointer<EtchNativeArray<capu::int8_t> > subarray;
+            ret = na->get(pos,subarray);
+            if (ret == ETCH_OK) {
+              result = subarray;
+            }
+          }
+          break;
+        }
+        case EtchObjectType::POINTER: {
+          EtchNativeArray<capu::int8_t*>* na = (EtchNativeArray<capu::int8_t*>*)(this);
+          if(dims == 1) {
+            capu::int8_t* value = NULL;
+            ret = na->get(pos, &value);
+            if(ret == ETCH_OK && value != NULL) {
+              result = new EtchInt32(*value);
+            }
+          } else {
+            // multi
+            capu::SmartPointer<EtchNativeArray<capu::int8_t*> > subarray;
+            ret = na->get(pos,subarray);
+            if (ret == ETCH_OK) {
+              result = subarray;
+            }
+          }
+          break;
+        }
+        case EtchObjectType::SMART_POINTER:
+          EtchNativeArray<capu::SmartPointer<capu::int8_t> >* na = (EtchNativeArray<capu::SmartPointer<capu::int8_t> >*)(this);
+          if(dims == 1) {
+            capu::SmartPointer<capu::int8_t> value = NULL;
+            ret = na->get(pos, &value);
+            if(ret == ETCH_OK && value.get() != NULL) {
+              result = new EtchInt32(*value.get());
+            }
+          } else {
+            capu::SmartPointer<EtchNativeArray<capu::SmartPointer<capu::int8_t> > > subarray;
+            ret = na->get(pos,subarray);
+            if (ret == ETCH_OK) {
+              result = subarray;
+            }
+          }
+          break;
+        }
+      break;
+    }
+
+    case EOTID_OBJECT: {
+      GETBASE_CAST_OBJECT_TO_NA(EtchObject)
+      break;
+    }
+    case EOTID_INT32: {
+      GETBASE_CAST_OBJECT_TO_NA(EtchInt32)
+      break;
+    }
+    case EOTID_BOOL: {
+      GETBASE_CAST_OBJECT_TO_NA(EtchBool)
+      break;
+    }
+    case EOTID_SHORT: {
+      GETBASE_CAST_OBJECT_TO_NA(EtchShort)
+      break;
+    }
+    case EOTID_LONG: {
+      GETBASE_CAST_OBJECT_TO_NA(EtchLong)
+      break;
+    }
+    case EOTID_DOUBLE: {
+      GETBASE_CAST_OBJECT_TO_NA(EtchDouble)
+      break;
+    }
+    case EOTID_FLOAT: {
+      GETBASE_CAST_OBJECT_TO_NA(EtchFloat)
+      break;
+    }
+    case EOTID_STRING: {
+      GETBASE_CAST_OBJECT_TO_NA(EtchString)
+      break;
+    }
+    case EOTID_DATE: {
+      GETBASE_CAST_OBJECT_TO_NA(EtchDate)
+      break;
+    }
+    case EOTID_HASHTABLE: {
+      switch(trait) {
+        case EtchObjectType::VALUE: {
+          EtchNativeArray<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > >* na = (EtchNativeArray<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > >*)(this);
+          if(dims == 1) {
+            EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > value;
+            ret = na->get(pos, &value);
+            if (ret == ETCH_OK) {
+              result = new EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > (value);
+            }
+          } else {
+            capu::SmartPointer<EtchNativeArray<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > > > subarray;
+            ret = na->get(pos,subarray);
+            if (ret == ETCH_OK) {
+              result = subarray;
+            }
+          }
+          break;
+        }
+        case EtchObjectType::POINTER: {
+          EtchNativeArray<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > *>* na = (EtchNativeArray<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > *>*)(this);
+          if(dims == 1) {
+            EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > * value = NULL;
+            ret = na->get(pos, &value);
+            if(ret == ETCH_OK && value != NULL) {
+              result = new EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > (*value);
+            }
+          } else {
+            capu::SmartPointer<EtchNativeArray<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > *> > subarray;
+            ret = na->get(pos,subarray);
+            if (ret == ETCH_OK) {
+              result = subarray;
+            }
+          }
+          break;
+        }
+        case EtchObjectType::SMART_POINTER: {
+          EtchNativeArray<capu::SmartPointer<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > > >* na = (EtchNativeArray<capu::SmartPointer<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > > >*)(this);
+          if(dims == 1) {
+            capu::SmartPointer<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > > value = NULL;
+            ret = na->get(pos, &value);
+            if (ret == ETCH_OK) {
+              result = value;
+            }
+          } else {
+            capu::SmartPointer<EtchNativeArray<capu::SmartPointer<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > > > > subarray;
+            ret = na->get(pos,subarray);
+            if (ret == ETCH_OK) {
+              result = subarray;
+            }
+          }
+          break;
+        }
+      }
+      break;
+    }
+    case EOTID_SET: {
+      GETBASE_CAST_OBJECT_TO_NA(EtchHashSet<capu::SmartPointer<EtchObject> > )
+      break;
+    }
+    case EOTID_LIST: {
+      GETBASE_CAST_OBJECT_TO_NA(EtchList<capu::SmartPointer<EtchObject> > )
+      break;
+    }
+  }
+  return ret;
+}
+
+status_t EtchNativeArrayBase::setBase(Pos pos, capu::SmartPointer<EtchObject> data) {
+
+  status_t ret = ETCH_OK;
+  const EtchObjectType* type = getObjectType()->getObjectComponentType();
+  const EtchObjectType::EtchObjectTypeTrait trait = getObjectType()->getObjectComponentTypeTrait();
+  const capu::int32_t dims = getDim();
+
+  switch(type->getTypeId()) {
+    case EOTID_BYTE: {
+      switch(trait) {
+        case EtchObjectType::VALUE: {
+          EtchNativeArray<capu::int8_t>* na = (EtchNativeArray<capu::int8_t>*)(this);
+          if(dims == 1) {
+            //unboxing of native type
+            capu::SmartPointer<EtchInt32> value = capu::smartpointer_cast<EtchInt32> (data);
+            capu::int8_t nativeValue = value->get();
+            return na->set(pos, nativeValue);
+          } else {
+            //multi
+            capu::SmartPointer<EtchNativeArray<capu::int8_t> > subarray = capu::smartpointer_cast<EtchNativeArray<capu::int8_t> >(data);
+            return na->set(pos,subarray);
+          }
+          break;
+        }
+        case EtchObjectType::POINTER: {
+          EtchNativeArray<capu::int8_t*>* na = (EtchNativeArray<capu::int8_t*>*)(this);
+          if(dims == 1) {
+            capu::SmartPointer<EtchInt32> value = capu::smartpointer_cast<EtchInt32> (data);
+            capu::int32_t native32Value = value->get();
+            capu::int8_t* nativeValue = (capu::int8_t*) &native32Value;
+            return na->set(pos, nativeValue);
+          } else {
+            // multi
+            capu::SmartPointer<EtchNativeArray<capu::int8_t*> > subarray = capu::smartpointer_cast<EtchNativeArray<capu::int8_t*> >(data);
+            return na->set(pos,subarray.get());
+          }
+          break;
+        }
+        case EtchObjectType::SMART_POINTER:
+          EtchNativeArray<capu::SmartPointer<capu::int8_t> >* na = (EtchNativeArray<capu::SmartPointer<capu::int8_t> >*)(this);
+          if(dims == 1) {
+            capu::SmartPointer<EtchInt32> value = capu::smartpointer_cast<EtchInt32> (data);
+            if (value.get() != NULL) {
+              capu::int32_t nativeInt32Value = value->get();
+              //value has to be copied to avoid deletion by smartpointer
+              capu::SmartPointer<capu::int8_t> newValue = new capu::int8_t(nativeInt32Value);
+              return na->set(pos, newValue);
+            }
+          } else {
+            capu::SmartPointer<EtchNativeArray<capu::SmartPointer<capu::int8_t> > > subarray = capu::smartpointer_cast<EtchNativeArray<capu::SmartPointer<capu::int8_t> > >(data);
+            return na->set(pos,subarray.get());
+          }
+          break;
+        }
+      break;
+    }
+    case EOTID_OBJECT: {
+      SETBASE_CAST_OBJECT_TO_NA(EtchObject)
+      break;
+    }
+    case EOTID_INT32: {
+      SETBASE_CAST_OBJECT_TO_NA(EtchInt32)
+      break;
+    }
+    case EOTID_BOOL: {
+      SETBASE_CAST_OBJECT_TO_NA(EtchBool)
+      break;
+    }
+    case EOTID_SHORT: {
+      SETBASE_CAST_OBJECT_TO_NA(EtchShort)
+      break;
+    }
+    case EOTID_LONG: {
+      SETBASE_CAST_OBJECT_TO_NA(EtchLong)
+      break;
+    }
+    case EOTID_DOUBLE: {
+      SETBASE_CAST_OBJECT_TO_NA(EtchDouble)
+      break;
+    }
+    case EOTID_FLOAT: {
+      SETBASE_CAST_OBJECT_TO_NA(EtchFloat)
+      break;
+    }
+    case EOTID_STRING: {
+      SETBASE_CAST_OBJECT_TO_NA(EtchString)
+      break;
+    }
+    case EOTID_DATE: {
+      SETBASE_CAST_OBJECT_TO_NA(EtchDate)
+      break;
+    }case EOTID_HASHTABLE: {
+      switch(trait) {
+        case EtchObjectType::VALUE: {
+          EtchNativeArray<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > >* na = (EtchNativeArray<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > >*)(this);
+          if(dims == 1) {
+            capu::SmartPointer<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > > value = capu::smartpointer_cast<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > > (data);
+            EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> >  *newValue = value.get();
+            if (newValue != NULL) {
+              return na->set(pos, *newValue);
+            }
+          } else {
+            capu::SmartPointer<EtchNativeArray<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > > > subarray = capu::smartpointer_cast<EtchNativeArray<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > > >(data);
+            return na->set(pos,subarray.get());
+          }
+          break;
+        }
+        case EtchObjectType::POINTER: {
+          EtchNativeArray<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > *>* na = (EtchNativeArray<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > *>*)(this);
+          if(dims == 1) {
+            capu::SmartPointer<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > > value = capu::smartpointer_cast<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > > (data);
+            EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > *newValue = value.get();
+            return na->set(pos, newValue);
+          } else {
+            capu::SmartPointer<EtchNativeArray<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > *> > subarray = capu::smartpointer_cast<EtchNativeArray<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > *> >(data);
+            return na->set(pos,subarray.get());
+          }
+          break;
+        }
+        case EtchObjectType::SMART_POINTER:
+          EtchNativeArray<capu::SmartPointer<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > > >* na = (EtchNativeArray<capu::SmartPointer<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > > >*)(this);
+          if(dims == 1) {
+            capu::SmartPointer<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > > value = capu::smartpointer_cast<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > > (data);
+            return na->set(pos, value);
+          } else {
+            capu::SmartPointer<EtchNativeArray<capu::SmartPointer<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > > > > subarray = capu::smartpointer_cast<EtchNativeArray<capu::SmartPointer<EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> > > > >(data);
+            return na->set(pos,subarray.get());
+          }
+          break;
+        }
+      break;
+    }
+    case EOTID_SET: {
+      SETBASE_CAST_OBJECT_TO_NA(EtchHashSet<capu::SmartPointer<EtchObject> > )
+      break;
+    }
+    case EOTID_LIST: {
+      SETBASE_CAST_OBJECT_TO_NA(EtchList<capu::SmartPointer<EtchObject> > )
+      break;
+    }
+  }
+  return ret;
+}
+

Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchObjectType.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchObjectType.cpp?rev=1368460&r1=1368459&r2=1368460&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchObjectType.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchObjectType.cpp Thu Aug  2 13:20:50 2012
@@ -20,6 +20,7 @@
 #include "common/EtchObjectType.h"
 #include "common/EtchObject.h"
 
+// TODO change to correct EOTID
 const EtchObjectType EtchObjectType::NATIVE_INT8(EOTID_BYTE, NULL);
 const EtchObjectType EtchObjectType::NATIVE_INT16(EOTID_SHORT, NULL);
 const EtchObjectType EtchObjectType::NATIVE_INT32(EOTID_INT32, NULL);
@@ -33,8 +34,8 @@ const EtchObjectType* EtchObjectType::TY
   return &TYPE;
 }
 
-EtchObjectType::EtchObjectType(capu::int32_t typeId, const EtchObjectType* componentType)
-: mTypeId(typeId), mComponentType(componentType) {
+EtchObjectType::EtchObjectType(capu::int32_t typeId, const EtchObjectType* componentType, const EtchObjectTypeTrait componentTypeTrait)
+: mTypeId(typeId), mComponentType(componentType), mComponentTypeTrait(componentTypeTrait) {
 
 }
 
@@ -42,6 +43,10 @@ const EtchObjectType* EtchObjectType::ge
   return mComponentType;
 }
 
+const EtchObjectType::EtchObjectTypeTrait EtchObjectType::getObjectComponentTypeTrait() const {
+  return mComponentTypeTrait;
+}
+
 capu::bool_t EtchObjectType::isArray() const {
   return mTypeId == EOTID_NATIVE_ARRAY;
 }

Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchString.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchString.cpp?rev=1368460&r1=1368459&r2=1368460&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchString.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchString.cpp Thu Aug  2 13:20:50 2012
@@ -39,6 +39,16 @@ EtchString::EtchString(const char* strin
   }
 }
 
+EtchString::EtchString(const capu::int8_t* buffer, const capu::int32_t bufferSize, EtchString encoding)
+: EtchObject(EtchString::TYPE())
+, mData(NULL) {
+  if (buffer != NULL) {
+    mData = new char[bufferSize + 1];
+    etch_strcpy_s(mData, bufferSize + 1, (char*)buffer);
+  }
+}
+
+
 EtchString::EtchString(const EtchString &copy)
 : EtchObject(EtchString::TYPE()) {
   if (copy.mData == NULL)
@@ -154,3 +164,16 @@ capu::uint64_t EtchString::getHashCode()
   }
   return result;
 }
+
+status_t EtchString::getBytes(capu::int8_t** buffer, capu::int32_t *bufferSize, EtchString encoding) {
+  //TODO: use encoding
+  if (buffer == NULL || bufferSize == NULL) {
+    return ETCH_EINVAL;
+  }
+
+  *buffer = new capu::int8_t[length() + 1];
+  memcpy(*buffer,mData,length() + 1);
+  *bufferSize = length() + 1;
+
+  return ETCH_OK;
+}

Added: incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchBinaryTaggedData.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchBinaryTaggedData.cpp?rev=1368460&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchBinaryTaggedData.cpp (added)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchBinaryTaggedData.cpp Thu Aug  2 13:20:50 2012
@@ -0,0 +1,194 @@
+/* $Id$
+ *
+ * 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 "capu/os/NumericLimits.h"
+#include "serialization/EtchBinaryTaggedData.h"
+
+capu::SmartPointer<EtchObject> EtchBinaryTaggedData::NONE = new EtchString("NONE");
+
+EtchBinaryTaggedData::EtchBinaryTaggedData(EtchValueFactory* vf)
+: EtchTaggedData(vf) {
+
+}
+
+EtchBinaryTaggedData::~EtchBinaryTaggedData() {
+
+}
+
+capu::int8_t EtchBinaryTaggedData::checkValue(capu::SmartPointer<EtchObject> value) {
+  if (value.get() == NULL) {
+    return EtchTypeCode::Null;
+  }
+  
+  if (value.get() == NONE.get()) {
+    return EtchTypeCode::NONE;
+  }
+
+  if (value->getObjectType()->equals(EtchBool::TYPE())) {
+    capu::SmartPointer<EtchBool> _bool = capu::smartpointer_cast<EtchBool> (value);
+    if (_bool->get()) {
+      return EtchTypeCode::BOOLEAN_TRUE;
+    }
+    return EtchTypeCode::BOOLEAN_FALSE;
+  }
+
+  if (value->getObjectType()->equals(EtchByte::TYPE())) {
+    capu::SmartPointer<EtchByte> _byte = capu::smartpointer_cast<EtchByte> (value);
+    return checkByte(_byte->get());
+  }
+
+  if (value->getObjectType()->equals(EtchShort::TYPE())) {
+    capu::SmartPointer<EtchShort> _short = capu::smartpointer_cast<EtchShort> (value);
+    return checkShort(_short->get());
+  }
+
+  if (value->getObjectType()->equals(EtchInt32::TYPE())) {
+    capu::SmartPointer<EtchInt32> _int = capu::smartpointer_cast<EtchInt32> (value);
+    return checkInteger(_int->get());
+  }
+  
+  if (value->getObjectType()->equals(EtchLong::TYPE())) {
+    capu::SmartPointer<EtchLong> _long = capu::smartpointer_cast<EtchLong> (value);
+    return checkLong(_long->get());
+  }
+  
+  if (value->getObjectType()->equals(EtchFloat::TYPE())) {
+    return EtchTypeCode::FLOAT;
+  }
+  
+  if (value->getObjectType()->equals(EtchDouble::TYPE())) {
+    return EtchTypeCode::DOUBLE;
+  }
+  
+  if (value->getObjectType()->equals(EtchString::TYPE())) {
+    capu::SmartPointer<EtchString> _string = capu::smartpointer_cast<EtchString> (value);
+    if (_string->length() == 0)
+      return EtchTypeCode::EMPTY_STRING;
+    return EtchTypeCode::STRING;
+  } 
+  
+  if (value->getObjectType()->isArray()) {
+    capu::SmartPointer<EtchNativeArrayBase> array = capu::smartpointer_cast<EtchNativeArrayBase> (value);
+    if (array->getObjectType()->getObjectComponentType()->equals(&EtchObjectType::NATIVE_INT8) && array->getDim() == 1) {
+      return EtchTypeCode::BYTES;
+    }
+    return EtchTypeCode::ARRAY;
+  } 
+
+  return EtchTypeCode::CUSTOM;
+}
+
+capu::int8_t EtchBinaryTaggedData::checkByte(capu::int8_t v) {
+  if ((v >= EtchTypeCode::MIN_TINY_INT) && (v <= EtchTypeCode::MAX_TINY_INT)) {
+    return v;
+  }
+
+  return EtchTypeCode::BYTE;
+}
+
+capu::int8_t EtchBinaryTaggedData::checkShort(capu::int16_t v) {
+  if ((v >= capu::NumericLimitMin<capu::int8_t>()) && (v <= capu::NumericLimitMax<capu::int8_t>()))
+    return checkByte((capu::int8_t) v);
+
+  return EtchTypeCode::SHORT;
+}
+
+capu::int8_t EtchBinaryTaggedData::checkInteger(capu::int32_t v) {
+  if ((v >= capu::NumericLimitMin<capu::int16_t>()) && (v <= capu::NumericLimitMax<capu::int16_t>()))
+    return checkShort((capu::int16_t) v);
+
+  return EtchTypeCode::INT;
+}
+
+capu::int8_t EtchBinaryTaggedData::checkLong(capu::int64_t v) {
+  if (v >= capu::NumericLimitMin<capu::int32_t>() && v <= capu::NumericLimitMax<capu::int32_t>())
+    return checkInteger((capu::int32_t) v);
+
+  return EtchTypeCode::LONG;
+}
+
+capu::int8_t EtchBinaryTaggedData::getNativeTypeCode(const EtchObjectType *c) {
+  if ((c->equals(&EtchObjectType::NATIVE_BOOL))|| (c->equals(EtchBool::TYPE())))
+    return EtchTypeCode::BOOLEAN_TRUE;
+
+  if ((c->equals(&EtchObjectType::NATIVE_INT8)) || (c->equals(EtchByte::TYPE())))
+    return EtchTypeCode::BYTE;
+
+  if ((c->equals(&EtchObjectType::NATIVE_INT16)) || (c->equals(EtchShort::TYPE())))
+    return EtchTypeCode::SHORT;
+
+  if ((c->equals(&EtchObjectType::NATIVE_INT32)) || (c->equals(EtchInt32::TYPE())))
+    return EtchTypeCode::INT;
+
+  if ((c->equals(&EtchObjectType::NATIVE_INT64)) || (c->equals(EtchLong::TYPE())))
+    return EtchTypeCode::LONG;
+
+  if ((c->equals(&EtchObjectType::NATIVE_FLOAT)) || (c->equals(EtchFloat::TYPE())))
+    return EtchTypeCode::FLOAT;
+
+  if ((c->equals(&EtchObjectType::NATIVE_DOUBLE)) || (c->equals(EtchDouble::TYPE())))
+    return EtchTypeCode::DOUBLE;
+
+  if (c->equals(EtchString::TYPE()))
+    return EtchTypeCode::STRING;
+
+  if (c->equals(EtchObject::TYPE())) 
+    return EtchTypeCode::ANY;
+
+  return EtchTypeCode::CUSTOM;
+}
+
+status_t EtchBinaryTaggedData::getCustomStructType(const EtchObjectType* c, EtchType*& result) {
+  return mVf->getCustomStructType(c, result);
+}
+
+const EtchObjectType* EtchBinaryTaggedData::getNativeType(capu::int8_t type) {
+  switch (type) {
+    case EtchTypeCode::BOOLEAN_TRUE:
+    case EtchTypeCode::BOOLEAN_FALSE:
+      return EtchBool::TYPE();
+
+    case EtchTypeCode::BYTE:
+      return EtchByte::TYPE();
+
+    case EtchTypeCode::SHORT:
+      return EtchShort::TYPE();
+
+    case EtchTypeCode::INT:
+      return EtchInt32::TYPE();
+
+    case EtchTypeCode::LONG:
+      return EtchLong::TYPE();
+
+    case EtchTypeCode::FLOAT:
+      return EtchFloat::TYPE();
+
+    case EtchTypeCode::DOUBLE:
+      return EtchDouble::TYPE();
+
+    case EtchTypeCode::EMPTY_STRING:
+    case EtchTypeCode::STRING:
+      return EtchString::TYPE();
+
+    case EtchTypeCode::ANY:
+      return EtchObject::TYPE();
+
+    default:
+      return NULL;
+  }
+}
\ No newline at end of file