Salome HOME
Updated copyright comment
[modules/yacs.git] / src / engine / Any.cxx
index 8e1a236f9f992b1e78fa91f163f3550b708a6ba2..cda84b110d7e5bea36988cc02db4039941bdcf9d 100644 (file)
-//  Copyright (C) 2006-2008  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2024  CEA, EDF
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 #include "Any.hxx"
 #include "Runtime.hxx"
 #include "TypeCode.hxx"
 #include "InvalidExtractionException.hxx"
 
+#include <boost/archive/iterators/base64_from_binary.hpp>
+#include <boost/archive/iterators/binary_from_base64.hpp>
+#include <boost/archive/iterators/transform_width.hpp>
+#include <boost/archive/iterators/insert_linebreaks.hpp>
+#include <boost/archive/iterators/remove_whitespace.hpp>
+
+#include <algorithm>
 #include <cstring>
 #include <cstdlib>
 
 using namespace YACS::ENGINE;
 using namespace std;
 
-StringOnHeap::StringOnHeap(const char *val):_dealloc(0),_str(strdup(val))
+// forbidden value int=-269488145 double=-1.54947e+231 bool=239
+const char SeqAlloc::DFT_CHAR_VAR=-17;//0xEF
+
+constexpr unsigned NB_BITS = 6;
+
+constexpr unsigned char TAB[64]={46, 61, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122};
+
+unsigned char BitAtPosSimple(char val, std::size_t bitPos)
+{
+  return (val >> bitPos) & 0x1;
+}
+
+unsigned char BitAtPos(char pt0, char pt1, std::size_t bitPos)
 {
+  if(bitPos<8)
+    return BitAtPosSimple(pt0,bitPos);
+  else
+    return BitAtPosSimple(pt1,bitPos-8);
+}
+
+unsigned char ChunkInternal(char pt0, char pt1, std::size_t startBitIdInByte)
+{
+  unsigned char ret(0);
+  for(unsigned i = 0; i<NB_BITS; ++i)
+    {
+      ret |= BitAtPos(pt0,pt1,startBitIdInByte+i);
+      ret <<= 1;
+    }
+  ret >>= 1;
+  return ret;
 }
 
-StringOnHeap::StringOnHeap(const std::string& val):_dealloc(0),_str(strdup(val.c_str()))
+unsigned char ChunkAtPos(const char *pt, std::size_t len, std::size_t posChunk)
+{
+  std::size_t startByte((posChunk*NB_BITS)/8);
+  std::size_t startBitIdInByte((posChunk*NB_BITS)%8);
+  char pt1(startByte!=len-1?pt[startByte+1]:pt[startByte]);
+  return ChunkInternal(pt[startByte],pt1,startBitIdInByte);
+}
+
+std::size_t OnOff(std::size_t i)
+{
+  if(i!=0)
+    return 1;
+  return 0;
+}
+
+std::string YACS::ENGINE::ToBase64(const std::string& bytes)
+{//64 == 2**6
+  const char *bytesPt(bytes.c_str());
+  std::size_t input_len(bytes.size());
+  std::size_t input_len_bit(input_len*8);
+  std::size_t nb_chunks( input_len_bit/NB_BITS + OnOff((NB_BITS - input_len_bit%NB_BITS)%NB_BITS) );
+  std::string ret(nb_chunks,'\0');
+  for(std::size_t i=0;i<nb_chunks;++i)
+    {
+      unsigned char cp(ChunkAtPos(bytesPt,input_len, i));
+      ret[i] = TAB[cp];
+    }
+  return ret;
+}
+
+constexpr unsigned MAX_VAL_TAB2=123;
+
+constexpr unsigned NOT_OK_VAL = 128;
+
+constexpr unsigned char TAB2[MAX_VAL_TAB2] = { NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, 0, NOT_OK_VAL, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, 1, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63 };
+
+unsigned char BitAtPosSimple2(char val, std::size_t bitPos)
 {
+  return ( val >> (5-bitPos) ) & 0x1;
+}
+
+char BitAtPosOnChunk(char pt0, char pt1, std::size_t bitPos)
+{
+  if(bitPos<6)
+    return BitAtPosSimple2(pt0,bitPos);
+  else
+    return BitAtPosSimple2(pt1,bitPos-6);
+}
+
+unsigned char CheckEntry(char c)
+{
+  if( ((unsigned) c) < MAX_VAL_TAB2 )
+    {
+      unsigned char ret(TAB2[(unsigned char)c]);
+      if(ret != NOT_OK_VAL)
+        return ret;
+      throw YACS::Exception("Invalid character found !");
+    }
+  throw YACS::Exception("Invalid character found !");
+}
+
+char ByteInternal(char c0, char c1, std::size_t startBitIdInByte)
+{
+  unsigned char ret(0);
+  char ct0(CheckEntry(c0)),ct1(CheckEntry(c1));
+  for(int i = 7; i>=0; --i)
+    {
+      ret |= BitAtPosOnChunk(ct0,ct1,startBitIdInByte+i);
+      if(i!=0)
+        ret <<= 1;
+    }
+  return ret;
+}
+
+char ByteAtPos(const char *chunckPt, std::size_t bytePos)
+{
+  std::size_t startChunk((bytePos*8)/NB_BITS);
+  std::size_t startBitId((bytePos*8)%NB_BITS);
+  return ByteInternal(chunckPt[startChunk],chunckPt[startChunk+1],startBitId);
+}
+
+std::string YACS::ENGINE::FromBase64(const std::string& bytes)
+{
+  std::size_t nb_chunks(bytes.size());
+  const char *chunckPt(bytes.c_str());
+  std::size_t nb_bytes_output((nb_chunks*NB_BITS)/8);
+  std::string ret(nb_bytes_output,'\0');
+  for(std::size_t i = 0; i<nb_bytes_output; ++i)
+    {
+      ret[i] = ByteAtPos(chunckPt,i);
+    }
+  return ret;
+}
+
+/*!
+ * Method used at load time in case of non base64 bytes in input (a throw during decoding). If so, the input bytes is returned.
+ */
+std::string YACS::ENGINE::FromBase64Safe(const std::string& bytes)
+{
+  try
+    {
+      return FromBase64(bytes);
+    }
+  catch(const YACS::Exception& e)
+    {
+      return bytes;
+    }
+}
+
+StringOnHeap::StringOnHeap(const char *val):_str(strdup(val)),_len(strlen(val)),_dealloc(0)
+{
+}
+
+StringOnHeap::StringOnHeap(const char *val, std::size_t len):_dealloc(0),_len(len)
+{
+  _str=(char *)malloc(len+1);
+  std::copy(val,val+len,_str);
+  _str[len]='\0';
+}
+
+StringOnHeap::StringOnHeap(const std::string& val):_dealloc(0),_len(val.size()),_str(nullptr)
+{
+  _str=(char *)malloc(val.size()+1);
+  std::copy(val.cbegin(),val.cend(),_str);
+  _str[val.size()]='\0';
 }
 
 /*! 
- * \Note : no copy is performed if a deallocator is given.
+ * \note : no copy is performed if a deallocator is given.
  * \param val     : String in C format that is NOT copied if
  *                  deAlloc != 0
  * \param deAlloc : pointer on function to deallocate val after
  *                  last use.
  */
-StringOnHeap::StringOnHeap(char *val, Deallocator deAlloc):_dealloc(deAlloc)
+StringOnHeap::StringOnHeap(char *val, Deallocator deAlloc):_len(0),_dealloc(deAlloc)
 {
   if(deAlloc)
     _str=val;
@@ -57,7 +216,10 @@ bool StringOnHeap::operator ==(const StringOnHeap& other) const
 
 StringOnHeap *StringOnHeap::deepCopy() const
 {
-  return new StringOnHeap(_str);
+  if(_len==0)
+    return new StringOnHeap(_str);
+  else
+    return new StringOnHeap(_str,_len);
 }
 
 StringOnHeap::~StringOnHeap()
@@ -83,6 +245,16 @@ Any::~Any()
   _type->decrRef();
 }
 
+bool Any::IsNull(char *data)
+{
+  if(!data)
+    return true;
+  bool isNull(true);
+  for(std::size_t i=0;i<sizeof(void *) && isNull;i++)
+    isNull=(data[i]==SeqAlloc::DFT_CHAR_VAR);
+  return isNull;
+}
+
 AtomAny::AtomAny(int val):Any(Runtime::_tc_int)
 {
   _value._i=val;
@@ -108,9 +280,14 @@ AtomAny::AtomAny(const std::string& val):Any(Runtime::_tc_string)
   _value._s=new StringOnHeap(val);
 }
 
+AtomAny::AtomAny(const std::string& val, TypeCode* type):Any(type)
+{
+  _value._s=new StringOnHeap(val);
+}
+
 AtomAny::AtomAny(const AtomAny& other):Any(other)
 {
-  if(_type->isA(Runtime::_tc_string))
+  if(_type->isA(Runtime::_tc_string) || _type->kind()==YACS::ENGINE::Objref)
     {
       StringOnHeap *cpy=(other._value._s)->deepCopy();
       memcpy(&_value._s,&cpy,_type->getSizeInByteOfAnyReprInSeq());
@@ -130,7 +307,7 @@ AtomAny::AtomAny(char *val, Deallocator deAlloc):Any(Runtime::_tc_string)
 
 AtomAny::AtomAny(char *data, TypeCode* type):Any(type)
 {
-  if(type->isA(Runtime::_tc_string))
+  if(type->isA(Runtime::_tc_string) || _type->kind()==YACS::ENGINE::Objref)
     {
       void **tmp=(void **)data;
       StringOnHeap *cpy=((StringOnHeap *)(*tmp))->deepCopy();
@@ -154,12 +331,17 @@ AtomAny *AtomAny::New(char *val,Deallocator dealloc)
   return new AtomAny(val,dealloc);
 }
 
-AnyPtr AtomAny::operator[](int i) const throw(Exception)
+AtomAny *AtomAny::New(const std::string& val, TypeCode *type)
+{
+  return new AtomAny(val,type);
+}
+
+AnyPtr AtomAny::operator[](int i) const
 {
   throw InvalidExtractionException(_type->kind(),Sequence);
 }
 
-AnyPtr AtomAny::operator[](const char *key) const throw(Exception)
+AnyPtr AtomAny::operator[](const char *key) const
 {
   throw Exception("AtomAny::operator[] : try to get a part of a partitionned data whereas atomical.");
 }
@@ -175,13 +357,13 @@ bool AtomAny::operator ==(const Any& other) const
     return _value._i==otherC._value._i;
   else if(_type->isA(Runtime::_tc_bool))
     return _value._b==otherC._value._b;
-  else if(_type->isA(Runtime::_tc_string))
+  else if(_type->isA(Runtime::_tc_string) || _type->kind()==Objref)
     return (*_value._s)==*(otherC._value._s);
   else
     return false;
 }
 
-int AtomAny::getIntValue() const throw(Exception)
+int AtomAny::getIntValue() const
 {
   if(_type->isA(Runtime::_tc_int))
     return _value._i;
@@ -189,7 +371,7 @@ int AtomAny::getIntValue() const throw(Exception)
     throw Exception("Value is not an int");
 }
 
-bool AtomAny::getBoolValue() const throw(Exception)
+bool AtomAny::getBoolValue() const
 {
   if(_type->isA(Runtime::_tc_bool))
     return _value._b;
@@ -197,7 +379,7 @@ bool AtomAny::getBoolValue() const throw(Exception)
     throw Exception("Value is not a bool");
 }
 
-double AtomAny::getDoubleValue() const throw(Exception)
+double AtomAny::getDoubleValue() const
 {
   if(_type->isA(Runtime::_tc_double))
     return _value._d;
@@ -205,10 +387,27 @@ double AtomAny::getDoubleValue() const throw(Exception)
     throw Exception("Value is not a double");
 }
 
-std::string AtomAny::getStringValue() const throw(Exception)
+std::string AtomAny::getStringValue() const
+{
+  if(_type->isA(Runtime::_tc_string) || _type->kind()==YACS::ENGINE::Objref)
+    {
+      std::size_t sz(_value._s->size());
+      if(sz==0)
+        return string(_value._s->cStr());
+      else
+        return string(_value._s->cStr(),sz);
+    }
+  else
+    throw Exception("Value is not a string");
+}
+
+const char *AtomAny::getBytesValue(std::size_t& len) const
 {
-  if(_type->isA(Runtime::_tc_string))
-    return string(_value._s->cStr());
+  if(_type->isA(Runtime::_tc_string) || _type->kind()==YACS::ENGINE::Objref)
+    {
+      len=_value._s->size();
+      return _value._s->cStr();
+    }
   else
     throw Exception("Value is not a string");
 }
@@ -222,7 +421,7 @@ std::string AtomAny::getStringValue() const throw(Exception)
  */
 void AtomAny::putMyReprAtPlace(char *data) const
 {
-  if(_type->isA(Runtime::_tc_string))
+  if(_type->isA(Runtime::_tc_string) || _type->kind()==YACS::ENGINE::Objref)
     {
       StringOnHeap *tmp=_value._s->deepCopy();
       memcpy(data,&tmp,_type->getSizeInByteOfAnyReprInSeq());
@@ -242,10 +441,13 @@ void AtomAny::putMyReprAtPlace(char *data) const
  *         For memory space minimal use, not all of '*this' is pushed at data location.
  *         'deepCpy' param is not used here because by definition of AtomAny deep copy is performed.
  * \param data : already allocated memory zone where to put compressed content of 'this'
+ * \param src :
+ * \param type :
+ * \param deepCpy :
  */
 void AtomAny::putReprAtPlace(char *data, const char *src, const TypeCode *type, bool deepCpy)
 {
-  if(type->isA(Runtime::_tc_string))
+  if(type->isA(Runtime::_tc_string) || type->kind()==YACS::ENGINE::Objref)
     {
       void **tmp1=(void **)src;
       StringOnHeap *tmp=((const StringOnHeap *)(*tmp1))->deepCopy();
@@ -266,10 +468,13 @@ void AtomAny::putReprAtPlace(char *data, const char *src, const TypeCode *type,
 void AtomAny::destroyReprAtPlace(char *data, const TypeCode *type)
 {
   DynType typ=type->kind();
-  if(typ==String)
+  if(typ==String || typ==Objref)
     {
-      void **tmp=(void **)data;
-      delete ((StringOnHeap *)(*tmp));
+      if(!Any::IsNull(data))
+        {
+          void **tmp=(void **)data;
+          delete ((StringOnHeap *)(*tmp));
+        }
     }
 }
 
@@ -288,7 +493,7 @@ bool AtomAny::takeInChargeStorageOf(TypeCode *type)
 
 AtomAny::~AtomAny()
 {
-  if(_type->isA(Runtime::_tc_string))
+  if(_type->kind() == String || _type->kind()==Objref)
     delete _value._s;
 }
 
@@ -302,33 +507,33 @@ ComposedAny::ComposedAny(TypeCode* type, bool isNew):Any(type)
     _type->decrRef();
 }
 
-AnyPtr ComposedAny::operator[](const char *key) const throw(Exception)
+AnyPtr ComposedAny::operator[](const char *key) const
 {
   throw Exception("AtomAny::operator[] : try to get a part of a partitionned data not localizable by a string.");
 }
 
-void ComposedAny::checkTypeOf(const Any *elem) const throw(Exception)
+void ComposedAny::checkTypeOf(const Any *elem) const
 {
   if(!elem->getType()->isA(_type->contentType()))
     throw Exception("ComposedAny::checkTypeOf : invalid type.");
 }
 
-int ComposedAny::getIntValue() const throw(Exception)
+int ComposedAny::getIntValue() const
 {
  throw InvalidExtractionException(_type->kind(),Runtime::_tc_int->kind());
 }
 
-bool ComposedAny::getBoolValue() const throw(Exception)
+bool ComposedAny::getBoolValue() const
 {
   throw InvalidExtractionException(_type->kind(),Runtime::_tc_bool->kind());
 }
 
-double ComposedAny::getDoubleValue() const throw(Exception)
+double ComposedAny::getDoubleValue() const
 {
   throw InvalidExtractionException(_type->kind(),Runtime::_tc_double->kind());
 }
 
-std::string ComposedAny::getStringValue() const throw(Exception)
+std::string ComposedAny::getStringValue() const
 {
   throw InvalidExtractionException(_type->kind(),Runtime::_tc_string->kind());
 }
@@ -378,7 +583,7 @@ void SeqAlloc::initCoarseMemory(char *mem, unsigned int size, Deallocator deallo
         memcpy(_start,mem,sizeInByte);
       else
         {
-          for(unsigned int i=0;i<sizeInByte;i++) _start[i]=0;
+          for(unsigned int i=0;i<sizeInByte;i++) _start[i]=DFT_CHAR_VAR;// see getSetItems
         }
     }
   _finish=_start+sizeInByte;
@@ -392,7 +597,9 @@ void SeqAlloc::construct(char *pt, const Any *val)
 
 /*!
  * \note: This performs the placement new or zip info into pt.
+ * \param pt :
  * \param val     : the source from which the construction will be performed.
+ * \param tc  :
  * \param deepCpy : If true in pt place a deep copy pointed by val will be put.
  */
 void SeqAlloc::construct(char *pt, const char *val, const TypeCode *tc, bool deepCpy)
@@ -433,6 +640,20 @@ unsigned int SeqAlloc::size() const
   return (_finish-_start)/_sizeOf1Elm;
 }
 
+std::vector<unsigned int> SeqAlloc::getSetItems() const
+{
+  std::vector<unsigned int> ret;
+  unsigned int sz(size());
+  for(unsigned int i=0;i<sz;i++)
+    {
+      const char *pt(_start+i*_sizeOf1Elm);
+      for(unsigned j=0;j<_sizeOf1Elm && *pt==DFT_CHAR_VAR;j++,pt++); //see initCoarseMemory
+      if(pt!=_start+(i+1)*_sizeOf1Elm)
+        ret.push_back(i);
+    }
+  return ret;
+}
+
 void SequenceAny::clear()
 {
   for (char *cur=_alloc._start;cur!=_alloc._finish;cur+=_alloc._sizeOf1Elm)
@@ -472,14 +693,14 @@ bool SequenceAny::operator ==(const Any& other) const
   return true;
 }
 
-void SequenceAny::setEltAtRank(int i, const Any *elem) throw(Exception)
+void SequenceAny::setEltAtRank(int i, const Any *elem)
 {
   checkTypeOf(elem);
   _alloc.destroy(_alloc._start+i*_alloc._sizeOf1Elm,_type->contentType());
   _alloc.construct(_alloc._start+i*_alloc._sizeOf1Elm,elem);
 }
 
-AnyPtr SequenceAny::operator[](int i) const throw(Exception)
+AnyPtr SequenceAny::operator[](int i) const
 {
   return _type->contentType()->getOrBuildAnyFromZippedData(_alloc._start+i*_alloc._sizeOf1Elm);
 }
@@ -516,7 +737,7 @@ void SequenceAny::putReprAtPlace(char *data, const char *src, const TypeCode *ty
 void SequenceAny::destroyReprAtPlace(char *data, const TypeCode *type)
 {
   void **tmp=(void **) data;
-  if(*tmp)
+  if(!Any::IsNull(data))
     ((SequenceAny *)(*tmp))->decrRef();
   //((SequenceAny *)data)->~SequenceAny();
 }
@@ -533,25 +754,26 @@ Any *SequenceAny::clone() const
   return new SequenceAny(*this);
 }
 
-SequenceAny *SequenceAny::New(const TypeCode *typeOfContent)
+SequenceAny *SequenceAny::removeUnsetItemsFromThis() const
 {
-  if(typeOfContent->kind() == Objref)
+  std::vector<unsigned int> its(getSetItems());
+  std::size_t sz(its.size());
+  SequenceAny *ret(SequenceAny::New(getType()->contentType(),sz));
+  for(std::size_t i=0;i<sz;i++)
     {
-      //In case of Objref, use a sequence of string
-      return new SequenceAny(Runtime::_tc_string);
+      AnyPtr obj((*this)[its[i]]);
+      ret->setEltAtRank(i,obj);
     }
-  else
+  return ret;
+}
+
+SequenceAny *SequenceAny::New(const TypeCode *typeOfContent)
+{
     return new SequenceAny(typeOfContent);
 }
 
 SequenceAny *SequenceAny::New(const TypeCode *typeOfContent, unsigned lgth)
 {
-  if(typeOfContent->kind() == Objref)
-    {
-      //In case of Objref, use a sequence of string
-      return new SequenceAny(Runtime::_tc_string,lgth);
-    }
-  else
     return new SequenceAny(typeOfContent,lgth);
 }
 
@@ -680,7 +902,7 @@ ArrayAny::ArrayAny(const TypeCode *typeOfContent, unsigned int lgth):ComposedAny
 {
   _data=new char[_type->getSizeInByteOfAnyReprInSeq()];
   for(unsigned int i=0;i<_type->getSizeInByteOfAnyReprInSeq();i++)
-    _data[i]='\0';
+    _data[i]=SeqAlloc::DFT_CHAR_VAR;
 }
 
 ArrayAny::ArrayAny(char *data, TypeCodeArray * type):ComposedAny(type,false),_data(0)
@@ -750,7 +972,7 @@ ArrayAny::ArrayAny(const std::vector<std::string>& val):ComposedAny(new TypeCode
     }
 }
 
-void ArrayAny::setEltAtRank(int i, const Any *elem) throw(Exception)
+void ArrayAny::setEltAtRank(int i, const Any *elem)
 {
   checkTypeOf(elem);
   const TypeCode *subType=_type->contentType();
@@ -769,7 +991,7 @@ bool ArrayAny::operator ==(const Any& other) const
   return true;
 }
 
-AnyPtr ArrayAny::operator[](int i) const throw(Exception)
+AnyPtr ArrayAny::operator[](int i) const
 {
   const TypeCode *subType=_type->contentType();
   unsigned sizePerContent=subType->getSizeInByteOfAnyReprInSeq();
@@ -847,13 +1069,13 @@ bool StructAny::operator ==(const Any& other) const
   return true;
 }
 
-AnyPtr StructAny::operator[](int i) const throw(Exception)
+AnyPtr StructAny::operator[](int i) const
 {
   const char what[]="StructAny::operator[](int i) : Struct key are strings not integers.";
   throw Exception(what);
 }
 
-AnyPtr StructAny::operator[](const char *key) const throw(Exception)
+AnyPtr StructAny::operator[](const char *key) const
 {
   const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
   char *whereToGet=_data;
@@ -871,13 +1093,13 @@ AnyPtr StructAny::operator[](const char *key) const throw(Exception)
   return (*iter).second->getOrBuildAnyFromZippedData(whereToGet);
 }
 
-void StructAny::setEltAtRank(int i, const Any *elem) throw(Exception)
+void StructAny::setEltAtRank(int i, const Any *elem)
 {
   const char what[]="Struct key are strings not integers.";
   throw Exception(what);
 }
 
-void StructAny::setEltAtRank(const char *key, const Any *elem) throw(Exception)
+void StructAny::setEltAtRank(const char *key, const Any *elem)
 {
   const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
   unsigned offset;
@@ -948,7 +1170,7 @@ StructAny::StructAny(TypeCodeStruct *type):ComposedAny(type,false)
 {
   _data=new char[_type->getSizeInByteOfAnyReprInSeq()];
   for(unsigned int i=0;i<_type->getSizeInByteOfAnyReprInSeq();i++)
-    _data[i]='\0';
+    _data[i]=SeqAlloc::DFT_CHAR_VAR;
 }
 
 StructAny::StructAny(const StructAny& other):ComposedAny(other)