Salome HOME
Test to check YACS capacity to deal with old XML files
[modules/yacs.git] / src / engine / Any.cxx
1 // Copyright (C) 2006-2019  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "Any.hxx"
21 #include "Runtime.hxx"
22 #include "TypeCode.hxx"
23 #include "InvalidExtractionException.hxx"
24
25 #include <boost/archive/iterators/base64_from_binary.hpp>
26 #include <boost/archive/iterators/binary_from_base64.hpp>
27 #include <boost/archive/iterators/transform_width.hpp>
28 #include <boost/archive/iterators/insert_linebreaks.hpp>
29 #include <boost/archive/iterators/remove_whitespace.hpp>
30
31 #include <algorithm>
32 #include <cstring>
33 #include <cstdlib>
34
35 using namespace YACS::ENGINE;
36 using namespace std;
37
38 // forbidden value int=-269488145 double=-1.54947e+231 bool=239
39 const char SeqAlloc::DFT_CHAR_VAR=-17;//0xEF
40
41 constexpr unsigned NB_BITS = 6;
42
43 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};
44
45 unsigned char BitAtPosSimple(char val, std::size_t bitPos)
46 {
47   return (val >> bitPos) & 0x1;
48 }
49
50 unsigned char BitAtPos(char pt0, char pt1, std::size_t bitPos)
51 {
52   if(bitPos<8)
53     return BitAtPosSimple(pt0,bitPos);
54   else
55     return BitAtPosSimple(pt1,bitPos-8);
56 }
57
58 unsigned char ChunkInternal(char pt0, char pt1, std::size_t startBitIdInByte)
59 {
60   unsigned char ret(0);
61   for(unsigned i = 0; i<NB_BITS; ++i)
62     {
63       ret |= BitAtPos(pt0,pt1,startBitIdInByte+i);
64       ret <<= 1;
65     }
66   ret >>= 1;
67   return ret;
68 }
69
70 unsigned char ChunkAtPos(const char *pt, std::size_t len, std::size_t posChunk)
71 {
72   std::size_t startByte((posChunk*NB_BITS)/8);
73   std::size_t startBitIdInByte((posChunk*NB_BITS)%8);
74   char pt1(startByte!=len-1?pt[startByte+1]:pt[startByte]);
75   return ChunkInternal(pt[startByte],pt1,startBitIdInByte);
76 }
77
78 std::size_t OnOff(std::size_t i)
79 {
80   if(i!=0)
81     return 1;
82   return 0;
83 }
84
85 std::string YACS::ENGINE::ToBase64(const std::string& bytes)
86 {//64 == 2**6
87   const char *bytesPt(bytes.c_str());
88   std::size_t input_len(bytes.size());
89   std::size_t input_len_bit(input_len*8);
90   std::size_t nb_chunks( input_len_bit/NB_BITS + OnOff((NB_BITS - input_len_bit%NB_BITS)%NB_BITS) );
91   std::string ret(nb_chunks,'\0');
92   for(std::size_t i=0;i<nb_chunks;++i)
93     {
94       unsigned char cp(ChunkAtPos(bytesPt,input_len, i));
95       ret[i] = TAB[cp];
96     }
97   return ret;
98 }
99
100 constexpr unsigned MAX_VAL_TAB2=123;
101
102 constexpr unsigned NOT_OK_VAL = 128;
103
104 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 };
105
106 unsigned char BitAtPosSimple2(char val, std::size_t bitPos)
107 {
108   return ( val >> (5-bitPos) ) & 0x1;
109 }
110
111 char BitAtPosOnChunk(char pt0, char pt1, std::size_t bitPos)
112 {
113   if(bitPos<6)
114     return BitAtPosSimple2(pt0,bitPos);
115   else
116     return BitAtPosSimple2(pt1,bitPos-6);
117 }
118
119 unsigned char CheckEntry(char c)
120 {
121   if( ((unsigned) c) < MAX_VAL_TAB2 )
122     {
123       unsigned char ret(TAB2[(unsigned char)c]);
124       if(ret != NOT_OK_VAL)
125         return ret;
126       throw YACS::Exception("Invalid character found !");
127     }
128   throw YACS::Exception("Invalid character found !");
129 }
130
131 char ByteInternal(char c0, char c1, std::size_t startBitIdInByte)
132 {
133   unsigned char ret(0);
134   char ct0(CheckEntry(c0)),ct1(CheckEntry(c1));
135   for(int i = 7; i>=0; --i)
136     {
137       ret |= BitAtPosOnChunk(ct0,ct1,startBitIdInByte+i);
138       if(i!=0)
139         ret <<= 1;
140     }
141   return ret;
142 }
143
144 char ByteAtPos(const char *chunckPt, std::size_t bytePos)
145 {
146   std::size_t startChunk((bytePos*8)/NB_BITS);
147   std::size_t startBitId((bytePos*8)%NB_BITS);
148   return ByteInternal(chunckPt[startChunk],chunckPt[startChunk+1],startBitId);
149 }
150
151 std::string YACS::ENGINE::FromBase64(const std::string& bytes)
152 {
153   std::size_t nb_chunks(bytes.size());
154   const char *chunckPt(bytes.c_str());
155   std::size_t nb_bytes_output((nb_chunks*NB_BITS)/8);
156   std::string ret(nb_bytes_output,'\0');
157   for(std::size_t i = 0; i<nb_bytes_output; ++i)
158     {
159       ret[i] = ByteAtPos(chunckPt,i);
160     }
161   return ret;
162 }
163
164 /*!
165  * Method used at load time in case of non base64 bytes in input (a throw during decoding). If so, the input bytes is returned.
166  */
167 std::string YACS::ENGINE::FromBase64Safe(const std::string& bytes)
168 {
169   try
170     {
171       return FromBase64(bytes);
172     }
173   catch(const YACS::Exception& e)
174     {
175       return bytes;
176     }
177 }
178
179 StringOnHeap::StringOnHeap(const char *val):_str(strdup(val)),_len(strlen(val)),_dealloc(0)
180 {
181 }
182
183 StringOnHeap::StringOnHeap(const char *val, std::size_t len):_dealloc(0),_len(len)
184 {
185   _str=(char *)malloc(len+1);
186   std::copy(val,val+len,_str);
187   _str[len]='\0';
188 }
189
190 StringOnHeap::StringOnHeap(const std::string& val):_dealloc(0),_len(val.size()),_str(nullptr)
191 {
192   _str=(char *)malloc(val.size()+1);
193   std::copy(val.cbegin(),val.cend(),_str);
194   _str[val.size()]='\0';
195 }
196
197 /*! 
198  * \note : no copy is performed if a deallocator is given.
199  * \param val     : String in C format that is NOT copied if
200  *                  deAlloc != 0
201  * \param deAlloc : pointer on function to deallocate val after
202  *                  last use.
203  */
204 StringOnHeap::StringOnHeap(char *val, Deallocator deAlloc):_len(0),_dealloc(deAlloc)
205 {
206   if(deAlloc)
207     _str=val;
208   else
209     _str=strdup(val);
210 }
211
212 bool StringOnHeap::operator ==(const StringOnHeap& other) const
213 {
214   return strcmp(_str, other._str)==0;
215 }
216
217 StringOnHeap *StringOnHeap::deepCopy() const
218 {
219   if(_len==0)
220     return new StringOnHeap(_str);
221   else
222     return new StringOnHeap(_str,_len);
223 }
224
225 StringOnHeap::~StringOnHeap()
226 {
227   if(_dealloc)
228     _dealloc(_str);
229   else
230     free(_str);
231 }
232
233 Any::Any(TypeCode* type):_type(type)
234 {
235   _type->incrRef();
236 }
237
238 Any::Any(const Any& other):_type(other._type)
239 {
240   _type->incrRef();
241 }
242
243 Any::~Any()
244 {
245   _type->decrRef();
246 }
247
248 bool Any::IsNull(char *data)
249 {
250   if(!data)
251     return true;
252   bool isNull(true);
253   for(std::size_t i=0;i<sizeof(void *) && isNull;i++)
254     isNull=(data[i]==SeqAlloc::DFT_CHAR_VAR);
255   return isNull;
256 }
257
258 AtomAny::AtomAny(int val):Any(Runtime::_tc_int)
259 {
260   _value._i=val;
261 }
262
263 AtomAny::AtomAny(bool val):Any(Runtime::_tc_bool)
264 {
265   _value._b=val;
266 }
267
268 AtomAny::AtomAny(double val):Any(Runtime::_tc_double)
269 {
270   _value._d=val;
271 }
272
273 AtomAny::AtomAny(const char *val):Any(Runtime::_tc_string)
274 {
275   _value._s=new StringOnHeap(val);
276 }
277
278 AtomAny::AtomAny(const std::string& val):Any(Runtime::_tc_string)
279 {
280   _value._s=new StringOnHeap(val);
281 }
282
283 AtomAny::AtomAny(const AtomAny& other):Any(other)
284 {
285   if(_type->isA(Runtime::_tc_string))
286     {
287       StringOnHeap *cpy=(other._value._s)->deepCopy();
288       memcpy(&_value._s,&cpy,_type->getSizeInByteOfAnyReprInSeq());
289     }
290   else if(_type->isA(Runtime::_tc_double))
291     memcpy(&_value._d,&other._value._d,_type->getSizeInByteOfAnyReprInSeq());
292   else if(_type->isA(Runtime::_tc_int))
293     memcpy(&_value._i,&other._value._i,_type->getSizeInByteOfAnyReprInSeq());
294   else if(_type->isA(Runtime::_tc_bool))
295     memcpy(&_value._b,&other._value._b,_type->getSizeInByteOfAnyReprInSeq());
296 }
297
298 AtomAny::AtomAny(char *val, Deallocator deAlloc):Any(Runtime::_tc_string)
299 {
300   _value._s=new StringOnHeap(val,deAlloc);
301 }
302
303 AtomAny::AtomAny(char *data, TypeCode* type):Any(type)
304 {
305   if(type->isA(Runtime::_tc_string))
306     {
307       void **tmp=(void **)data;
308       StringOnHeap *cpy=((StringOnHeap *)(*tmp))->deepCopy();
309       memcpy(&_value._s,&cpy,type->getSizeInByteOfAnyReprInSeq());
310     }
311   else if(type->isA(Runtime::_tc_double))
312     memcpy(&_value._d,data,type->getSizeInByteOfAnyReprInSeq());
313   else if(type->isA(Runtime::_tc_int))
314     memcpy(&_value._i,data,type->getSizeInByteOfAnyReprInSeq());
315   else if(type->isA(Runtime::_tc_bool))
316     memcpy(&_value._b,data,type->getSizeInByteOfAnyReprInSeq());
317 }
318
319 Any *AtomAny::clone() const
320 {
321   return new AtomAny(*this);
322 }
323
324 AtomAny *AtomAny::New(char *val,Deallocator dealloc)
325 {
326   return new AtomAny(val,dealloc);
327 }
328
329 AnyPtr AtomAny::operator[](int i) const throw(YACS::Exception)
330 {
331   throw InvalidExtractionException(_type->kind(),Sequence);
332 }
333
334 AnyPtr AtomAny::operator[](const char *key) const throw(YACS::Exception)
335 {
336   throw Exception("AtomAny::operator[] : try to get a part of a partitionned data whereas atomical.");
337 }
338
339 bool AtomAny::operator ==(const Any& other) const
340 {
341   if(!_type->isA(other.getType()))
342     return false;
343   const AtomAny& otherC=(const AtomAny&) other;//cast granted due to previous lines
344   if(_type->isA(Runtime::_tc_double))
345     return _value._d==otherC._value._d;
346   else if(_type->isA(Runtime::_tc_int))
347     return _value._i==otherC._value._i;
348   else if(_type->isA(Runtime::_tc_bool))
349     return _value._b==otherC._value._b;
350   else if(_type->isA(Runtime::_tc_string))
351     return (*_value._s)==*(otherC._value._s);
352   else
353     return false;
354 }
355
356 int AtomAny::getIntValue() const throw(YACS::Exception)
357 {
358   if(_type->isA(Runtime::_tc_int))
359     return _value._i;
360   else
361     throw Exception("Value is not an int");
362 }
363
364 bool AtomAny::getBoolValue() const throw(YACS::Exception)
365 {
366   if(_type->isA(Runtime::_tc_bool))
367     return _value._b;
368   else
369     throw Exception("Value is not a bool");
370 }
371
372 double AtomAny::getDoubleValue() const throw(YACS::Exception)
373 {
374   if(_type->isA(Runtime::_tc_double))
375     return _value._d;
376   else
377     throw Exception("Value is not a double");
378 }
379
380 std::string AtomAny::getStringValue() const throw(YACS::Exception)
381 {
382   if(_type->isA(Runtime::_tc_string))
383     {
384       std::size_t sz(_value._s->size());
385       if(sz==0)
386         return string(_value._s->cStr());
387       else
388         return string(_value._s->cStr(),sz);
389     }
390   else
391     throw Exception("Value is not a string");
392 }
393
394 const char *AtomAny::getBytesValue(std::size_t& len) const
395 {
396   if(_type->isA(Runtime::_tc_string))
397     {
398       len=_value._s->size();
399       return _value._s->cStr();
400     }
401   else
402     throw Exception("Value is not a string");
403 }
404
405 /*!
406  * \note : This method put in data its zipped recursive content in data.
407  *         The ownership of the recursive content is tranfered to data.
408  *         So this owns nothing and its counter fall by 1.
409  *         For memory space minimal use, not all of '*this' is pushed at data location. 
410  * \param data : already allocated memory zone where to put compressed content of 'this'
411  */
412 void AtomAny::putMyReprAtPlace(char *data) const
413 {
414   if(_type->isA(Runtime::_tc_string))
415     {
416       StringOnHeap *tmp=_value._s->deepCopy();
417       memcpy(data,&tmp,_type->getSizeInByteOfAnyReprInSeq());
418     }
419   else if(_type->isA(Runtime::_tc_double))
420     memcpy(data,&_value._d,_type->getSizeInByteOfAnyReprInSeq());
421   else if(_type->isA(Runtime::_tc_int))
422     memcpy(data,&_value._i,_type->getSizeInByteOfAnyReprInSeq());
423   else if(_type->isA(Runtime::_tc_bool))
424     memcpy(data,&_value._b,_type->getSizeInByteOfAnyReprInSeq());
425 }
426
427 /*!
428  * \note : This method put in data its zipped recursive content in data.
429  *         The ownership of the recursive content is tranfered to data.
430  *         So this owns nothing and its counter fall by 1.
431  *         For memory space minimal use, not all of '*this' is pushed at data location.
432  *         'deepCpy' param is not used here because by definition of AtomAny deep copy is performed.
433  * \param data : already allocated memory zone where to put compressed content of 'this'
434  * \param src :
435  * \param type :
436  * \param deepCpy :
437  */
438 void AtomAny::putReprAtPlace(char *data, const char *src, const TypeCode *type, bool deepCpy)
439 {
440   if(type->isA(Runtime::_tc_string))
441     {
442       void **tmp1=(void **)src;
443       StringOnHeap *tmp=((const StringOnHeap *)(*tmp1))->deepCopy();
444       memcpy(data,&tmp,type->getSizeInByteOfAnyReprInSeq());
445     }
446   else if(type->isA(Runtime::_tc_double))
447     memcpy(data,src,type->getSizeInByteOfAnyReprInSeq());
448   else if(type->isA(Runtime::_tc_int))
449     memcpy(data,src,type->getSizeInByteOfAnyReprInSeq());
450   else if(type->isA(Runtime::_tc_bool))
451     memcpy(data,src,type->getSizeInByteOfAnyReprInSeq());
452 }
453
454 /*!
455  * \note : Opposite method of putMyReprAtPlace. But static because due to data compression
456  *         instance is lost.
457  */
458 void AtomAny::destroyReprAtPlace(char *data, const TypeCode *type)
459 {
460   DynType typ=type->kind();
461   if(typ==String)
462     {
463       if(!Any::IsNull(data))
464         {
465           void **tmp=(void **)data;
466           delete ((StringOnHeap *)(*tmp));
467         }
468     }
469 }
470
471 AnyPtr AtomAny::getOrBuildFromData(char *data, const TypeCode *type)
472 {
473   Any *ret;
474   ret=new AtomAny(data,(TypeCode *)type);
475   return AnyPtr(ret);
476 }
477
478 bool AtomAny::takeInChargeStorageOf(TypeCode *type)
479 {
480   DynType typ=type->kind();
481   return (typ==Double || typ==Int || typ==Bool || typ==String);
482 }
483
484 AtomAny::~AtomAny()
485 {
486   if(_type->kind() == String)
487     delete _value._s;
488 }
489
490 ComposedAny::ComposedAny(const ComposedAny& other):Any(other)
491 {
492 }
493
494 ComposedAny::ComposedAny(TypeCode* type, bool isNew):Any(type)
495 {
496   if(isNew)
497     _type->decrRef();
498 }
499
500 AnyPtr ComposedAny::operator[](const char *key) const throw(YACS::Exception)
501 {
502   throw Exception("AtomAny::operator[] : try to get a part of a partitionned data not localizable by a string.");
503 }
504
505 void ComposedAny::checkTypeOf(const Any *elem) const throw(YACS::Exception)
506 {
507   if(!elem->getType()->isA(_type->contentType()))
508     throw Exception("ComposedAny::checkTypeOf : invalid type.");
509 }
510
511 int ComposedAny::getIntValue() const throw(YACS::Exception)
512 {
513  throw InvalidExtractionException(_type->kind(),Runtime::_tc_int->kind());
514 }
515
516 bool ComposedAny::getBoolValue() const throw(YACS::Exception)
517 {
518   throw InvalidExtractionException(_type->kind(),Runtime::_tc_bool->kind());
519 }
520
521 double ComposedAny::getDoubleValue() const throw(YACS::Exception)
522 {
523   throw InvalidExtractionException(_type->kind(),Runtime::_tc_double->kind());
524 }
525
526 std::string ComposedAny::getStringValue() const throw(YACS::Exception)
527 {
528   throw InvalidExtractionException(_type->kind(),Runtime::_tc_string->kind());
529 }
530
531 SeqAlloc::SeqAlloc(const SeqAlloc& other):_sizeOf1Elm(other._sizeOf1Elm),_notStdDeAlloc(0),
532  _start(0),_finish(0),_endOfStorage(0)
533 {
534   _start=allocate(other._finish-other._start);
535   _finish=_start+(other._finish-other._start);
536   _endOfStorage=_finish;
537 }
538
539 SeqAlloc::SeqAlloc(unsigned int sizeOf1Elm):_sizeOf1Elm(sizeOf1Elm),_notStdDeAlloc(0),
540                                             _start(0),_finish(0),_endOfStorage(0)
541 {
542 }
543
544 SeqAlloc::~SeqAlloc()
545 {
546   deallocate(_start);
547 }
548
549 void SeqAlloc::clear()
550 {
551   deallocate(_start);
552   _start=0;
553   _finish=0;
554   _endOfStorage=0;
555 }
556
557 /*!
558  * \note : This method is exclusively reserved for arrays of C++ built-in types because no
559  *         constructor is applied atomically.
560  */
561 void SeqAlloc::initCoarseMemory(char *mem, unsigned int size, Deallocator dealloc)
562 {
563   unsigned sizeInByte=size*_sizeOf1Elm;
564   if(dealloc)
565     {
566       _notStdDeAlloc=dealloc;
567       _start=mem;
568     }
569   else
570     {
571       _start=allocate(sizeInByte);
572       if(mem)
573         memcpy(_start,mem,sizeInByte);
574       else
575         {
576           for(unsigned int i=0;i<sizeInByte;i++) _start[i]=DFT_CHAR_VAR;// see getSetItems
577         }
578     }
579   _finish=_start+sizeInByte;
580   _endOfStorage=_finish;
581 }
582
583 void SeqAlloc::construct(char *pt, const Any *val)
584 {
585   val->putMyReprAtPlace(pt);
586 }
587
588 /*!
589  * \note: This performs the placement new or zip info into pt.
590  * \param pt :
591  * \param val     : the source from which the construction will be performed.
592  * \param tc  :
593  * \param deepCpy : If true in pt place a deep copy pointed by val will be put.
594  */
595 void SeqAlloc::construct(char *pt, const char *val, const TypeCode *tc, bool deepCpy)
596 {
597   tc->putReprAtPlace(pt,val,deepCpy);
598 }
599
600 char *SeqAlloc::allocate(unsigned int nbOfByte)
601
602   if(nbOfByte>0)
603     return (char *)::operator new(nbOfByte);
604   else
605     return 0;
606 }
607
608 // pt is not permitted to be a null pointer.
609 void SeqAlloc::deallocate(char *pt)
610
611   if(pt)
612     {
613       if(!_notStdDeAlloc)
614         ::operator delete(pt); 
615       else
616         {
617           _notStdDeAlloc(pt);
618           _notStdDeAlloc=0;
619         }
620     }
621 }
622
623 void SeqAlloc::destroy(char *pt, const TypeCode *tc) 
624
625   tc->destroyZippedAny(pt);
626 }
627
628 unsigned int SeqAlloc::size() const
629 {
630   return (_finish-_start)/_sizeOf1Elm;
631 }
632
633 std::vector<unsigned int> SeqAlloc::getSetItems() const
634 {
635   std::vector<unsigned int> ret;
636   unsigned int sz(size());
637   for(unsigned int i=0;i<sz;i++)
638     {
639       const char *pt(_start+i*_sizeOf1Elm);
640       for(unsigned j=0;j<_sizeOf1Elm && *pt==DFT_CHAR_VAR;j++,pt++); //see initCoarseMemory
641       if(pt!=_start+(i+1)*_sizeOf1Elm)
642         ret.push_back(i);
643     }
644   return ret;
645 }
646
647 void SequenceAny::clear()
648 {
649   for (char *cur=_alloc._start;cur!=_alloc._finish;cur+=_alloc._sizeOf1Elm)
650     _alloc.destroy(cur,_type->contentType());
651   _alloc.clear();
652 }
653
654 void SequenceAny::popBack()
655 {
656   _alloc._finish-=_alloc._sizeOf1Elm;
657   _alloc.destroy(_alloc._finish,_type->contentType());
658 }
659
660 void SequenceAny::pushBack(const Any* elem)
661 {
662   if(!elem->_type->isA(_type->contentType()))
663     throw InvalidExtractionException(elem->_type->kind(),_type->contentType()->kind());
664   if(_alloc._finish != _alloc._endOfStorage)
665     {
666       _alloc.construct(_alloc._finish, elem);
667       _alloc._finish+=_alloc._sizeOf1Elm;
668     }
669   else
670     realloc(_alloc._finish, elem);
671 }
672
673 bool SequenceAny::operator ==(const Any& other) const
674 {
675   if(!_type->isA(other.getType()))
676     return false;
677   const SequenceAny& otherC=(const SequenceAny&) other;//cast granted due to previous lines
678   if(size()!=otherC.size())
679     return false;
680   for(unsigned i=0;i<size();i++)
681     if(!((*(*this)[i])==(*otherC[i])))
682       return false;
683   return true;
684 }
685
686 void SequenceAny::setEltAtRank(int i, const Any *elem) throw(YACS::Exception)
687 {
688   checkTypeOf(elem);
689   _alloc.destroy(_alloc._start+i*_alloc._sizeOf1Elm,_type->contentType());
690   _alloc.construct(_alloc._start+i*_alloc._sizeOf1Elm,elem);
691 }
692
693 AnyPtr SequenceAny::operator[](int i) const throw(YACS::Exception)
694 {
695   return _type->contentType()->getOrBuildAnyFromZippedData(_alloc._start+i*_alloc._sizeOf1Elm);
696 }
697
698 /*!
699  * \note : Contrary to AtomAny 'this' (ref) is put in data NOT a deep copy.
700  * \param data : already allocated memory zone where to put address of 'this'
701  */
702 void SequenceAny::putMyReprAtPlace(char *data) const
703 {
704   const void *tmp=(const void *)this;
705   memcpy(data,&tmp,_type->getSizeInByteOfAnyReprInSeq());
706   const void **tmp2=(const void **) data;
707   ((SequenceAny *)(*tmp2))->incrRef();
708   //::new((SequenceAny *)data) SequenceAny((SequenceAny&) (*this));
709 }
710
711 void SequenceAny::putReprAtPlace(char *data, const char *src, const TypeCode *type, bool deepCpy)
712 {
713   void **tmp2=(void **) src;
714   if(!deepCpy)
715     {
716       ((SequenceAny *)(*tmp2))->incrRef();
717       memcpy(data,src,type->getSizeInByteOfAnyReprInSeq());
718     }
719   else
720     {
721       SequenceAny *cpy=new SequenceAny(*((SequenceAny *)(*tmp2)));
722       memcpy(data,&cpy,type->getSizeInByteOfAnyReprInSeq());
723     }
724   //::new((SequenceAny *)data) SequenceAny((SequenceAny&) (*this));
725 }
726
727 void SequenceAny::destroyReprAtPlace(char *data, const TypeCode *type)
728 {
729   void **tmp=(void **) data;
730   if(!Any::IsNull(data))
731     ((SequenceAny *)(*tmp))->decrRef();
732   //((SequenceAny *)data)->~SequenceAny();
733 }
734
735 AnyPtr SequenceAny::getOrBuildFromData(char *data, const TypeCode *type)
736 {
737   void **tmp=(void **) data;
738   ((SequenceAny *) (*tmp))->incrRef();
739   return AnyPtr((SequenceAny *)(*tmp));
740 }
741
742 Any *SequenceAny::clone() const
743 {
744   return new SequenceAny(*this);
745 }
746
747 SequenceAny *SequenceAny::removeUnsetItemsFromThis() const
748 {
749   std::vector<unsigned int> its(getSetItems());
750   std::size_t sz(its.size());
751   SequenceAny *ret(SequenceAny::New(getType()->contentType(),sz));
752   for(std::size_t i=0;i<sz;i++)
753     {
754       AnyPtr obj((*this)[its[i]]);
755       ret->setEltAtRank(i,obj);
756     }
757   return ret;
758 }
759
760 SequenceAny *SequenceAny::New(const TypeCode *typeOfContent)
761 {
762   if(typeOfContent->kind() == Objref)
763     {
764       //In case of Objref, use a sequence of string
765       return new SequenceAny(Runtime::_tc_string);
766     }
767   else
768     return new SequenceAny(typeOfContent);
769 }
770
771 SequenceAny *SequenceAny::New(const TypeCode *typeOfContent, unsigned lgth)
772 {
773   if(typeOfContent->kind() == Objref)
774     {
775       //In case of Objref, use a sequence of string
776       return new SequenceAny(Runtime::_tc_string,lgth);
777     }
778   else
779     return new SequenceAny(typeOfContent,lgth);
780 }
781
782 bool SequenceAny::takeInChargeStorageOf(TypeCode *type)
783 {
784   DynType typ=type->kind();
785   return (typ==Sequence);
786 }
787
788 SequenceAny::SequenceAny(const SequenceAny& other):ComposedAny(other),_alloc(other._alloc)
789 {
790   const char *srcCur=other._alloc._start;
791   for(char *cur=_alloc._start;srcCur != other._alloc._finish; srcCur+=_alloc._sizeOf1Elm, cur+=_alloc._sizeOf1Elm)
792     _alloc.construct(cur, srcCur, _type->contentType(),true);
793 }
794
795 SequenceAny::~SequenceAny()
796 {
797   for (char *cur=_alloc._start;cur!=_alloc._finish;cur+=_alloc._sizeOf1Elm)
798     _alloc.destroy(cur,_type->contentType());
799 }
800
801 /*!
802  * \param typeOfContent : typeCode of the type of elements stored in sequence.
803  */
804 SequenceAny::SequenceAny(const TypeCode *typeOfContent):ComposedAny(new TypeCodeSeq("","",typeOfContent)),
805                                                         _alloc(typeOfContent->getSizeInByteOfAnyReprInSeq())
806 {
807 }
808
809 SequenceAny::SequenceAny(const TypeCode *typeOfContent, unsigned lgth):ComposedAny(new TypeCodeSeq("","",typeOfContent)),
810                                                                        _alloc(typeOfContent->getSizeInByteOfAnyReprInSeq())
811 {
812   _alloc.initCoarseMemory(0,lgth,0);
813 }
814
815 SequenceAny::SequenceAny(int *val, unsigned int lgth, Deallocator deAlloc):ComposedAny(new TypeCodeSeq("","",Runtime::_tc_int)),
816                                                                            _alloc(Runtime::_tc_int->getSizeInByteOfAnyReprInSeq())
817 {
818   _alloc.initCoarseMemory((char *)val,lgth,deAlloc);
819 }
820
821 SequenceAny::SequenceAny(bool *val, unsigned int lgth, Deallocator deAlloc):ComposedAny(new TypeCodeSeq("","",Runtime::_tc_bool)),
822                                                                             _alloc(Runtime::_tc_bool->getSizeInByteOfAnyReprInSeq())
823 {
824   _alloc.initCoarseMemory((char *)val,lgth,deAlloc);
825 }
826
827 SequenceAny::SequenceAny(double *val, unsigned int lgth, Deallocator deAlloc):ComposedAny(new TypeCodeSeq("","",Runtime::_tc_double)),
828                                                                               _alloc(Runtime::_tc_double->getSizeInByteOfAnyReprInSeq())
829 {
830   _alloc.initCoarseMemory((char *)val,lgth,deAlloc);
831 }
832
833 SequenceAny::SequenceAny(const std::vector<int>& val):ComposedAny(new TypeCodeSeq("","",Runtime::_tc_int)),
834                                                       _alloc(Runtime::_tc_int->getSizeInByteOfAnyReprInSeq())
835 {
836   _alloc.initCoarseMemory((char *)&val[0],val.size(),0);
837 }
838
839 SequenceAny::SequenceAny(const std::vector<bool>& val):ComposedAny(new TypeCodeSeq("","",Runtime::_tc_bool)),
840                                                        _alloc(Runtime::_tc_bool->getSizeInByteOfAnyReprInSeq())
841 {
842   for(vector<bool>::const_iterator iter=val.begin();iter!=val.end();iter++)
843     {
844       AtomAnyPtr tmp=AtomAny::New(*iter);
845       pushBack(tmp);
846     }
847 }
848
849 SequenceAny::SequenceAny(const std::vector<double>& val):ComposedAny(new TypeCodeSeq("","",Runtime::_tc_double)),
850                                                          _alloc(Runtime::_tc_double->getSizeInByteOfAnyReprInSeq())
851 {
852   _alloc.initCoarseMemory((char *)&val[0],val.size(),0);
853 }
854
855 SequenceAny::SequenceAny(const std::vector<std::string>& val):ComposedAny(new TypeCodeSeq("","",Runtime::_tc_string)),
856                                                               _alloc(Runtime::_tc_string->getSizeInByteOfAnyReprInSeq())
857 {
858   for(vector<string>::const_iterator iter=val.begin();iter!=val.end();iter++)
859     {
860       AtomAnyPtr tmp=AtomAny::New(*iter);
861       pushBack(tmp);
862     }
863 }
864
865 void SequenceAny::realloc(char *endOfCurrentAllocated, const Any *elem)
866 {
867   unsigned int oldSize=_alloc._finish-_alloc._start;
868   unsigned int newSize = oldSize != 0 ? 2 * oldSize : _alloc._sizeOf1Elm;
869   char *newStart=_alloc.allocate(newSize);
870   //
871   char *newFinish=performCpy(_alloc._start, endOfCurrentAllocated,newStart);
872   _alloc.construct(newFinish, elem);
873   newFinish+=_alloc._sizeOf1Elm;
874   newFinish=performCpy(endOfCurrentAllocated, _alloc._finish, newFinish);
875   //
876   for (char *cur=_alloc._start;cur!=_alloc._finish;cur+=_alloc._sizeOf1Elm)
877     _alloc.destroy(cur,_type->contentType());
878   _alloc.deallocate(_alloc._start);
879   _alloc._start = newStart;
880   _alloc._finish = newFinish;
881   _alloc._endOfStorage=newStart+newSize;
882 }
883
884 char *SequenceAny::performCpy(char *srcStart, char *srcFinish, char *destStart)
885 {
886   char *cur=destStart;
887   for (;srcStart != srcFinish; srcStart+=_alloc._sizeOf1Elm, cur+=_alloc._sizeOf1Elm)
888     _alloc.construct(cur, srcStart, _type->contentType(),false);
889   return cur;
890 }
891
892 ArrayAny::~ArrayAny()
893 {
894   const TypeCode *subType=_type->contentType();
895   unsigned sizePerContent=subType->getSizeInByteOfAnyReprInSeq();
896   unsigned int size=((TypeCodeArray *)_type)->getStaticLgth();
897   char *tmp=_data;
898   for(unsigned i=0;i<size;i++,tmp+=sizePerContent)
899     subType->destroyZippedAny(tmp);
900   delete [] _data;
901 }
902
903 ArrayAny::ArrayAny(const TypeCode *typeOfContent, unsigned int lgth):ComposedAny(new TypeCodeArray("","",typeOfContent,lgth))
904 {
905   _data=new char[_type->getSizeInByteOfAnyReprInSeq()];
906   for(unsigned int i=0;i<_type->getSizeInByteOfAnyReprInSeq();i++)
907     _data[i]=SeqAlloc::DFT_CHAR_VAR;
908 }
909
910 ArrayAny::ArrayAny(char *data, TypeCodeArray * type):ComposedAny(type,false),_data(0)
911 {
912   _data=new char[_type->getSizeInByteOfAnyReprInSeq()];
913   const TypeCode *subType=_type->contentType();
914   unsigned sizePerContent=subType->getSizeInByteOfAnyReprInSeq();
915   for(unsigned i=0;i<type->getStaticLgth();i++)
916     subType->putReprAtPlace(_data+i*sizePerContent,data+i*sizePerContent,false);
917 }
918
919 ArrayAny::ArrayAny(const ArrayAny& other):ComposedAny(other)
920 {
921   _data=new char[_type->getSizeInByteOfAnyReprInSeq()];
922   const TypeCode *subType=_type->contentType();
923   unsigned sizePerContent=subType->getSizeInByteOfAnyReprInSeq();
924   for(unsigned i=0;i<((TypeCodeArray *)_type)->getStaticLgth();i++)
925     subType->putReprAtPlace(_data+i*sizePerContent,other._data+i*sizePerContent,true);
926 }
927
928 ArrayAny::ArrayAny(const int *val, unsigned int lgth):ComposedAny(new TypeCodeArray("","",Runtime::_tc_int,lgth)),
929                                                       _data(0)
930 {
931   _data=new char[_type->getSizeInByteOfAnyReprInSeq()];
932   memcpy(_data,val,_type->getSizeInByteOfAnyReprInSeq());
933 }
934
935 ArrayAny::ArrayAny(const bool *val, unsigned int lgth):ComposedAny(new TypeCodeArray("","",Runtime::_tc_bool,lgth)),
936                                                        _data(0)
937 {
938   _data=new char[_type->getSizeInByteOfAnyReprInSeq()];
939   memcpy(_data,val,_type->getSizeInByteOfAnyReprInSeq());
940 }
941
942 ArrayAny::ArrayAny(const double *val, unsigned int lgth):ComposedAny(new TypeCodeArray("","",Runtime::_tc_double,lgth)),
943                                                          _data(0)
944 {
945   _data=new char[_type->getSizeInByteOfAnyReprInSeq()];
946   memcpy(_data,val,_type->getSizeInByteOfAnyReprInSeq());
947 }
948
949 ArrayAny::ArrayAny(const std::vector<int>& val):ComposedAny(new TypeCodeArray("","",Runtime::_tc_int,val.size())),
950                                                 _data(0)
951 {
952   _data=new char[_type->getSizeInByteOfAnyReprInSeq()];
953   memcpy(_data,&val[0],_type->getSizeInByteOfAnyReprInSeq());
954 }
955
956 ArrayAny::ArrayAny(const std::vector<double>& val):ComposedAny(new TypeCodeArray("","",Runtime::_tc_double,val.size())),
957                                                 _data(0)
958 {
959   _data=new char[_type->getSizeInByteOfAnyReprInSeq()];
960   memcpy(_data,&val[0],_type->getSizeInByteOfAnyReprInSeq());
961 }
962
963 ArrayAny::ArrayAny(const std::vector<std::string>& val):ComposedAny(new TypeCodeArray("","",Runtime::_tc_string,val.size())),
964                                                         _data(0)
965 {
966   _data=new char[_type->getSizeInByteOfAnyReprInSeq()];
967   unsigned i=0;
968   const TypeCode *subType=_type->contentType();
969   unsigned sizePerContent=subType->getSizeInByteOfAnyReprInSeq();
970   for(vector<std::string>::const_iterator iter=val.begin();iter!=val.end();iter++,i++)
971     {
972       StringOnHeap *st=new StringOnHeap(*iter);
973       memcpy(_data+i*sizePerContent,&st,sizePerContent);
974     }
975 }
976
977 void ArrayAny::setEltAtRank(int i, const Any *elem) throw(YACS::Exception)
978 {
979   checkTypeOf(elem);
980   const TypeCode *subType=_type->contentType();
981   subType->destroyZippedAny(_data+i*subType->getSizeInByteOfAnyReprInSeq());
982   elem->putMyReprAtPlace(_data+i*subType->getSizeInByteOfAnyReprInSeq());
983 }
984
985 bool ArrayAny::operator ==(const Any& other) const
986 {
987   if(!_type->isA(other.getType()))
988     return false;
989   const ArrayAny& otherC=(const ArrayAny&) other;//cast granted due to previous lines
990   for(unsigned i=0;i<((const TypeCodeArray *)_type)->getStaticLgth();i++)
991     if(!((*(*this)[i])==(*otherC[i])))
992       return false;
993   return true;
994 }
995
996 AnyPtr ArrayAny::operator[](int i) const throw(YACS::Exception)
997 {
998   const TypeCode *subType=_type->contentType();
999   unsigned sizePerContent=subType->getSizeInByteOfAnyReprInSeq();
1000   if(i<0 || i>=((TypeCodeArray *)_type)->getStaticLgth())
1001     throw Exception("Trying to access to an invalid index in an Any Tuple");
1002   return _type->contentType()->getOrBuildAnyFromZippedData(_data+i*sizePerContent);
1003 }
1004
1005 unsigned int ArrayAny::size() const
1006 {
1007   return ((TypeCodeArray *)_type)->getStaticLgth();
1008 }
1009
1010 Any *ArrayAny::clone() const
1011 {
1012   return new ArrayAny(*this);
1013 }
1014
1015 ArrayAny *ArrayAny::New(const TypeCode *typeOfContent, unsigned int lgth)
1016 {
1017   return new ArrayAny(typeOfContent,lgth);
1018 }
1019
1020 void ArrayAny::putMyReprAtPlace(char *data) const
1021 {
1022   const TypeCode *subType=_type->contentType();
1023   unsigned sizePerContent=subType->getSizeInByteOfAnyReprInSeq();
1024   for(unsigned i=0;i<((const TypeCodeArray *)_type)->getStaticLgth();i++)
1025     subType->putReprAtPlace(data+i*sizePerContent,_data+i*sizePerContent,false);
1026 }
1027
1028 void ArrayAny::putReprAtPlace(char *data, const char *src, const TypeCodeArray *type, bool deepCpy)
1029 {
1030   const TypeCode *subType=type->contentType();
1031   unsigned sizePerContent=subType->getSizeInByteOfAnyReprInSeq();
1032   for(unsigned i=0;i<type->getStaticLgth();i++)
1033     subType->putReprAtPlace(data+i*sizePerContent,src+i*sizePerContent,deepCpy);
1034 }
1035
1036 void ArrayAny::destroyReprAtPlace(char *data, const TypeCodeArray *type)
1037 {
1038   const TypeCode *subType=type->contentType();
1039   unsigned sizePerContent=subType->getSizeInByteOfAnyReprInSeq();
1040   for(unsigned i=0;i<type->getStaticLgth();i++)
1041     subType->destroyZippedAny(data+i*sizePerContent);
1042 }
1043
1044 AnyPtr ArrayAny::getOrBuildFromData(char *data, const TypeCodeArray *type)
1045 {
1046   Any *ret;
1047   ret=new ArrayAny(data,(TypeCodeArray *)type);
1048   return AnyPtr(ret);
1049 }
1050
1051 bool ArrayAny::takeInChargeStorageOf(TypeCode *type)
1052 {
1053   DynType typ=type->kind();
1054   return (typ==Array);
1055 }
1056
1057 Any *StructAny::clone() const
1058 {
1059   return new StructAny(*this);
1060 }
1061
1062 bool StructAny::operator ==(const Any& other) const
1063 {
1064   if(!_type->isA(other.getType()))
1065     return false;
1066   const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
1067   vector< pair<string,TypeCode*> >::const_iterator iter;
1068   for(iter=typeC->_members.begin();iter!=typeC->_members.end();iter++)
1069     if(!((*(*this)[(*iter).first.c_str()]==(*other[(*iter).first.c_str()]))))
1070       return false;
1071   return true;
1072 }
1073
1074 AnyPtr StructAny::operator[](int i) const throw(YACS::Exception)
1075 {
1076   const char what[]="StructAny::operator[](int i) : Struct key are strings not integers.";
1077   throw Exception(what);
1078 }
1079
1080 AnyPtr StructAny::operator[](const char *key) const throw(YACS::Exception)
1081 {
1082   const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
1083   char *whereToGet=_data;
1084   vector< pair<string,TypeCode*> >::const_iterator iter;
1085   for(iter=typeC->_members.begin();iter!=typeC->_members.end();iter++)
1086     if((*iter).first!=key)
1087       whereToGet+=(*iter).second->getSizeInByteOfAnyReprInSeq();
1088     else
1089       break;
1090   if(iter==typeC->_members.end())
1091     {
1092       string what("Unexisting key \""); what+=key; what+="\" for struct extraction.";
1093       throw Exception(what);
1094     }
1095   return (*iter).second->getOrBuildAnyFromZippedData(whereToGet);
1096 }
1097
1098 void StructAny::setEltAtRank(int i, const Any *elem) throw(YACS::Exception)
1099 {
1100   const char what[]="Struct key are strings not integers.";
1101   throw Exception(what);
1102 }
1103
1104 void StructAny::setEltAtRank(const char *key, const Any *elem) throw(YACS::Exception)
1105 {
1106   const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
1107   unsigned offset;
1108   const TypeCode *tcOnKey=typeC->getMember(key,offset);
1109   if(!tcOnKey)
1110     throw Exception("StructAny::setEltAtRank : invalid key given.");
1111   if(!elem->getType()->isA(tcOnKey))
1112     throw Exception("StructAny::setEltAtRank : invalid data type on the specified given key.");
1113   tcOnKey->destroyZippedAny(_data+offset);
1114   elem->putMyReprAtPlace(_data+offset);
1115 }
1116
1117 void StructAny::putMyReprAtPlace(char *data) const
1118 {
1119   const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
1120   unsigned offset=0;
1121   vector< pair<string,TypeCode*> >::const_iterator iter;
1122   for(iter=typeC->_members.begin();iter!=typeC->_members.end();iter++)
1123     {
1124       (*iter).second->putReprAtPlace(data+offset,_data+offset,false);
1125       offset+=(*iter).second->getSizeInByteOfAnyReprInSeq();
1126     }
1127 }
1128
1129 void StructAny::putReprAtPlace(char *data, const char *src, const TypeCodeStruct *type, bool deepCpy)
1130 {
1131   unsigned offset=0;
1132   vector< pair<string,TypeCode*> >::const_iterator iter;
1133   for(iter=type->_members.begin();iter!=type->_members.end();iter++)
1134     {
1135       (*iter).second->putReprAtPlace(data+offset,src+offset,deepCpy);
1136       offset+=(*iter).second->getSizeInByteOfAnyReprInSeq();
1137     }
1138 }
1139
1140 void StructAny::destroyReprAtPlace(char *data, const TypeCodeStruct *type)
1141 {
1142   char *whereToGet=data;
1143   vector< pair<string,TypeCode*> >::const_iterator iter;
1144   for(iter=type->_members.begin();iter!=type->_members.end();iter++)
1145     {
1146       (*iter).second->destroyZippedAny(whereToGet);
1147       whereToGet+=(*iter).second->getSizeInByteOfAnyReprInSeq();
1148     }
1149 }
1150
1151 AnyPtr StructAny::getOrBuildFromData(char *data, const TypeCodeStruct *type)
1152 {
1153   Any *ret;
1154   ret=new StructAny(data,(TypeCodeStruct *)type);
1155   return AnyPtr(ret);
1156 }
1157
1158 StructAny::~StructAny()
1159 {
1160   const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
1161   vector< pair<string,TypeCode*> >::const_iterator iter;
1162   char *whereToGet=_data;
1163   for(iter=typeC->_members.begin();iter!=typeC->_members.end();iter++)
1164     {
1165       (*iter).second->destroyZippedAny(whereToGet);
1166       whereToGet+=(*iter).second->getSizeInByteOfAnyReprInSeq();
1167     }
1168   delete [] _data;
1169 }
1170
1171 StructAny::StructAny(TypeCodeStruct *type):ComposedAny(type,false)
1172 {
1173   _data=new char[_type->getSizeInByteOfAnyReprInSeq()];
1174   for(unsigned int i=0;i<_type->getSizeInByteOfAnyReprInSeq();i++)
1175     _data[i]=SeqAlloc::DFT_CHAR_VAR;
1176 }
1177
1178 StructAny::StructAny(const StructAny& other):ComposedAny(other)
1179 {
1180   _data=new char[_type->getSizeInByteOfAnyReprInSeq()];
1181   const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
1182   vector< pair<string,TypeCode*> >::const_iterator iter;
1183   unsigned offset=0;
1184   for(iter=typeC->_members.begin();iter!=typeC->_members.end();iter++)
1185     {
1186      (*iter).second->putReprAtPlace(_data+offset,other._data+offset,true);
1187      offset+=(*iter).second->getSizeInByteOfAnyReprInSeq();
1188     }
1189 }
1190
1191 StructAny::StructAny(char *data, TypeCodeStruct * type):ComposedAny(type,false),_data(0)
1192 {
1193   _data=new char[_type->getSizeInByteOfAnyReprInSeq()];
1194   vector< pair<string,TypeCode*> >::const_iterator iter;
1195   unsigned offset=0;
1196   for(iter=type->_members.begin();iter!=type->_members.end();iter++)
1197     {
1198       (*iter).second->putReprAtPlace(_data+offset,data+offset,false);
1199       offset+=(*iter).second->getSizeInByteOfAnyReprInSeq();
1200     }
1201 }
1202
1203 StructAny *StructAny::New(TypeCodeStruct *type)
1204 {
1205   return new StructAny(type);
1206 }